tx · 7SFcvNmEnFfgXSjKzVnLpNidZTNTvse3jUYUqnKC2EtA

3N5rCvMqUUd5CLJYp2j3Re3aBc5YBPyVMBr:  -0.03400000 Waves

2023.03.06 22:39 [2478657] smart account 3N5rCvMqUUd5CLJYp2j3Re3aBc5YBPyVMBr > SELF 0.00000000 Waves

{ "type": 13, "id": "7SFcvNmEnFfgXSjKzVnLpNidZTNTvse3jUYUqnKC2EtA", "fee": 3400000, "feeAssetId": null, "timestamp": 1678131559934, "version": 2, "chainId": 84, "sender": "3N5rCvMqUUd5CLJYp2j3Re3aBc5YBPyVMBr", "senderPublicKey": "2PX9krmZHqS45gsg4CsHWcbcNSYqQa6oJCFo6rMu4rBz", "proofs": [ "2s2hWneXSw9VvgiB8fUdzxKMVLwzzjnVwvcKSPz7pEBU72fqnQpZahtuTViU9kx6Hzfmm17DucvCpFUiA7vymJ1a" ], "script": "base64:BgIZCAISAwoBCBIECgIIARIAEgMKAQgSAwoBCA0AB2tfZnVuZHMCB2tfZnVuZHMAFGtfY29vcmRpbmF0b3JBZGRyZXNzAhRrX2Nvb3JkaW5hdG9yQWRkcmVzcwARa19tYW5hZ2VyX2FkZHJlc3MCEWtfbWFuYWdlcl9hZGRyZXNzAA9rX2FkbWluX2FkZHJlc3MCD2tfYWRtaW5fYWRkcmVzcwANa19pbml0aWFsaXplZAINa19pbml0aWFsaXplZAEOdG9Db21wb3NpdGVLZXkCBF9rZXkIX2FkZHJlc3MJAKwCAgkArAICBQRfa2V5AgFfBQhfYWRkcmVzcwEJYmFsYW5jZU9mAQhfYXNzZXRJZAkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzCQEOdG9Db21wb3NpdGVLZXkCBQdrX2Z1bmRzBQhfYXNzZXRJZAAAAQtjb29yZGluYXRvcgAJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkApggBCQERQGV4dHJOYXRpdmUoMTA1MykCBQR0aGlzBRRrX2Nvb3JkaW5hdG9yQWRkcmVzcwIoQ29vcmRp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sZSBhc3NldCBtYW5hZ2VyKQkAlAoCCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgAACQDZBAEFCF9hc3NldElkBQNuaWwAAAFpARB2aWV3X2NsYWltUHJvZml0AQhfYXNzZXRJZAMJAQEhAQkBC2luaXRpYWxpemVkAAkAAgECNkludmFsaWQgdmlld19jbGFpbVByb2ZpdCBwYXJhbXMgKHNpbXBsZSBhc3NldCBtYW5hZ2VyKQQGcHJvZml0AAAJAAIBCQCsAgIJAKwCAgkArAICCQCsAgIJAKQDAQkBCWJhbGFuY2VPZgEFCF9hc3NldElkAgEsCQCkAwEJAQliYWxhbmNlT2YBBQhfYXNzZXRJZAIBLAkApAMBBQZwcm9maXQBAnR4AQZ2ZXJpZnkABA5jb29yZGluYXRvclN0cgkAnQgCBQR0aGlzBRRrX2Nvb3JkaW5hdG9yQWRkcmVzcwMJAQlpc0RlZmluZWQBBQ5jb29yZGluYXRvclN0cgQFYWRtaW4JAJ0IAgkBEUBleHRyTmF0aXZlKDEwNjIpAQkBBXZhbHVlAQUOY29vcmRpbmF0b3JTdHIFD2tfYWRtaW5fYWRkcmVzcwMJAQlpc0RlZmluZWQBBQVhZG1pbgkBC3ZhbHVlT3JFbHNlAgkAmwgCCQERQGV4dHJOYXRpdmUoMTA2MikBCQEFdmFsdWUBBQVhZG1pbgkArAICCQCsAgIJAKwCAgIHc3RhdHVzXwkApQgBBQR0aGlzAgFfCQDYBAEIBQJ0eAJpZAcJAAIBAi51bmFibGUgdG8gdmVyaWZ5OiBhZG1pbiBub3Qgc2V0IGluIGNvb3JkaW5hdG9yCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5tpasdw==", "height": 2478657, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let k_funds = "k_funds"
5+
6+let k_coordinatorAddress = "k_coordinatorAddress"
7+
8+let k_manager_address = "k_manager_address"
9+
10+let k_admin_address = "k_admin_address"
11+
12+let k_initialized = "k_initialized"
13+
14+func toCompositeKey (_key,_address) = ((_key + "_") + _address)
15+
16+
17+func balanceOf (_assetId) = valueOrElse(getInteger(this, toCompositeKey(k_funds, _assetId)), 0)
18+
19+
20+func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set Simple Asset Manager")
21+
22+
23+func managerAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_manager_address), "Manager not set")), "Manager not set")
24+
25+
26+func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
27+
28+
29+func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
30+
31+
32+func isWhitelist (_address) = (_address == toString(managerAddress()))
33+
34+
35+func updateFunds (_assetId,_value) = [IntegerEntry(toCompositeKey(k_funds, _assetId), _value)]
36+
37+
38+@Callable(i)
39+func initialize (_coordinator) = if (if (initialized())
40+ then true
41+ else (i.caller != this))
42+ then throw("Unable to initialize")
43+ else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), BooleanEntry(k_initialized, true)]
44+
45+
46+
47+@Callable(i)
48+func withdraw (_assetId,_amount) = if (if (if (!(isWhitelist(toString(i.caller))))
49+ then true
50+ else !(initialized()))
51+ then true
52+ else (_amount > balanceOf(_assetId)))
53+ then throw(((("Invalid withdraw params (simple asset manager) " + toString(_amount)) + " > ") + toString(balanceOf(_assetId))))
54+ else {
55+ let currentAssetBalance = (balanceOf(_assetId) - _amount)
56+ (updateFunds(_assetId, currentAssetBalance) ++ [ScriptTransfer(i.caller, _amount, fromBase58String(_assetId))])
57+ }
58+
59+
60+
61+@Callable(i)
62+func deposit () = {
63+ let _amount = i.payments[0].amount
64+ let _assetId = toBase58String(valueOrErrorMessage(i.payments[0].assetId, "No assetId"))
65+ if (if (!(initialized()))
66+ then true
67+ else if (!(isWhitelist(toString(i.caller))))
68+ then (i.caller != adminAddress())
69+ else false)
70+ then throw("Invalid deposit params (simple asset manager)")
71+ else {
72+ let currentAssetBalance = (balanceOf(_assetId) + _amount)
73+ updateFunds(_assetId, currentAssetBalance)
74+ }
75+ }
76+
77+
78+
79+@Callable(i)
80+func claimProfit (_assetId) = if (if (!(initialized()))
81+ then true
82+ else (i.caller != managerAddress()))
83+ then throw("Invalid claimProfit params (simple asset manager)")
84+ else $Tuple2([ScriptTransfer(i.caller, 0, fromBase58String(_assetId))], 0)
85+
86+
87+
88+@Callable(i)
89+func view_claimProfit (_assetId) = if (!(initialized()))
90+ then throw("Invalid view_claimProfit params (simple asset manager)")
91+ else {
92+ let profit = 0
93+ throw(((((toString(balanceOf(_assetId)) + ",") + toString(balanceOf(_assetId))) + ",") + toString(profit)))
94+ }
95+
96+
97+@Verifier(tx)
98+func verify () = {
99+ let coordinatorStr = getString(this, k_coordinatorAddress)
100+ if (isDefined(coordinatorStr))
101+ then {
102+ let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
103+ if (isDefined(admin))
104+ then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
105+ else throw("unable to verify: admin not set in coordinator")
106+ }
107+ else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
108+ }
109+

github/deemru/w8io/169f3d6 
18.20 ms