tx · 3k6jZHZrFD1dioi6GjqhmQeHP4svrf2WGeqbYA6W5SwW 3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH: -0.03400000 Waves 2022.10.06 10:42 [2260170] smart account 3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH > SELF 0.00000000 Waves
{ "type": 13, "id": "3k6jZHZrFD1dioi6GjqhmQeHP4svrf2WGeqbYA6W5SwW", "fee": 3400000, "feeAssetId": null, "timestamp": 1665042153187, "version": 2, "chainId": 84, "sender": "3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH", "senderPublicKey": "3mgJJUcUNFHYP2pNkbkfB2C8D4gSEKEGisFByu2i6xoM", "proofs": [ "3DRFW4U7DRUoJxz7FToyA2UqbLjCeTuCyM3MSaDfkHq36KD1iFbcFYQM9P33snUrJfP5sVyWFgobguefbPdkNKqh" ], "script": "base64:BgIiCAISBgoECAgICBIECgIICBIECgIIARIAEgMKAQgSAwoBCBsAB2tfZnVuZHMCB2tfZnVuZHMAD2tfdmlyZXNfYWRkcmVzcwIPa192aXJlc19hZGRyZXNzAA1rX3ZpcmVzX3ZhdWx0Ag1rX3ZpcmVzX3ZhdWx0ABZrX2Fzc2V0X2NsYWltZWRfcHJvZml0AhZrX2Fzc2V0X2NsYWltZWRfcHJvZml0ABRrX2Nvb3JkaW5hdG9yQWRkcmVzcwIUa19jb29yZGluYXRvckFkZHJlc3MAE2tfaW5zdXJhbmNlX2FkZHJlc3MCE2tfaW5zdXJhbmNlX2FkZHJlc3MABWtfYW1tAgVrX2FtbQAPa19hZG1pbl9hZGRyZXNzAg9rX2FkbWluX2FkZHJlc3MAEmtfYWRtaW5fcHVibGljX2tleQISa19hZG1pbl9wdWJsaWNfa2V5AA1rX3F1b3RlX2Fzc2V0Ag1rX3F1b3RlX2Fzc2V0AA9rX3F1b3RlX3N0YWtpbmcCD2tfcXVvdGVfc3Rha2luZwARa19zdGFraW5nX2FkZHJlc3MCEWtfc3Rha2luZ19hZGRyZXNzAA1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WN1cnJlbnRBbW91bnQJAPwHBAkBCnZpcmVzVmF1bHQBBQhfYXNzZXRJZAIQZ2V0Q3VycmVudFRvdGFscwkAzAgCCQClCAEFBHRoaXMFA25pbAUDbmlsAwkAAAIFDWN1cnJlbnRBbW91bnQFDWN1cnJlbnRBbW91bnQEE2N1cnJlbnRBc3NldEJhbGFuY2UEByRtYXRjaDAFDWN1cnJlbnRBbW91bnQDCQABAgUHJG1hdGNoMAIUKEludCwgSW50LCBJbnQsIEludCkEAXQFByRtYXRjaDAIBQF0Al8zCQACAQIaSW52YWxpZCBjdXJyZW50QW1vdW50IHR5cGUEBnByb2ZpdAkAZQIFE2N1cnJlbnRBc3NldEJhbGFuY2UJAQliYWxhbmNlT2YBBQhfYXNzZXRJZAkAAgEJAKwCAgkArAICCQCsAgIJAKwCAgkApAMBCQEJYmFsYW5jZU9mAQUIX2Fzc2V0SWQCASwJAKQDAQUTY3VycmVudEFzc2V0QmFsYW5jZQIBLAkApAMBBQZwcm9maXQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACQEOYWRtaW5QdWJsaWNLZXkAGk/agQ==", "height": 2260170, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: B4bA9uX74UCSjD9ncDCNkXnUynwEX5MdnSxvExWypX1U Full:
Old | New | Differences | |
---|---|---|---|
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_vires_address = "k_vires_address" | |
7 | + | ||
8 | + | let k_vires_vault = "k_vires_vault" | |
9 | + | ||
10 | + | let k_asset_claimed_profit = "k_asset_claimed_profit" | |
11 | + | ||
12 | + | let k_coordinatorAddress = "k_coordinatorAddress" | |
13 | + | ||
14 | + | let k_insurance_address = "k_insurance_address" | |
15 | + | ||
16 | + | let k_amm = "k_amm" | |
17 | + | ||
18 | + | let k_admin_address = "k_admin_address" | |
19 | + | ||
20 | + | let k_admin_public_key = "k_admin_public_key" | |
21 | + | ||
22 | + | let k_quote_asset = "k_quote_asset" | |
23 | + | ||
24 | + | let k_quote_staking = "k_quote_staking" | |
25 | + | ||
26 | + | let k_staking_address = "k_staking_address" | |
27 | + | ||
28 | + | let k_initialized = "k_initialized" | |
29 | + | ||
30 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
31 | + | ||
32 | + | ||
33 | + | func balanceOf (_assetId) = valueOrElse(getInteger(this, toCompositeKey(k_funds, _assetId)), 0) | |
34 | + | ||
35 | + | ||
36 | + | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
37 | + | ||
38 | + | ||
39 | + | func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set") | |
40 | + | ||
41 | + | ||
42 | + | func isAmm (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
43 | + | ||
44 | + | ||
45 | + | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
46 | + | ||
47 | + | ||
48 | + | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
49 | + | ||
50 | + | ||
51 | + | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
52 | + | ||
53 | + | ||
54 | + | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
55 | + | ||
56 | + | ||
57 | + | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set") | |
58 | + | ||
59 | + | ||
60 | + | func viresAddress () = valueOrErrorMessage(addressFromString(getStringValue(this, k_vires_address)), "Vires not set") | |
61 | + | ||
62 | + | ||
63 | + | func viresVault (_assetId) = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, toCompositeKey(k_vires_vault, _assetId)), ("No vault for token " + _assetId))), ("Invalid address for token " + _assetId)) | |
64 | + | ||
65 | + | ||
66 | + | func isWhitelist (_address) = if (if (isAmm(_address)) | |
67 | + | then true | |
68 | + | else (_address == toString(insuranceAddress()))) | |
69 | + | then true | |
70 | + | else (_address == toString(stakingAddress())) | |
71 | + | ||
72 | + | ||
73 | + | func updateFunds (_assetId,_value) = [IntegerEntry(toCompositeKey(k_funds, _assetId), _value)] | |
74 | + | ||
75 | + | ||
76 | + | @Callable(i) | |
77 | + | func initialize (_coordinator,_viresAddress,_quoteAssetId,_quoteAssetVault) = if (initialized()) | |
78 | + | then throw("Already initialized") | |
79 | + | else [StringEntry(k_coordinatorAddress, _coordinator), StringEntry(k_vires_address, _viresAddress), StringEntry(toCompositeKey(k_vires_vault, _quoteAssetId), _quoteAssetVault), BooleanEntry(k_initialized, true)] | |
80 | + | ||
81 | + | ||
82 | + | ||
83 | + | @Callable(i) | |
84 | + | func addTokenVault (_assetId,_vaultAddress) = if (if (!(initialized())) | |
85 | + | then true | |
86 | + | else (i.caller != adminAddress())) | |
87 | + | then throw("Invalid addTokenVault params") | |
88 | + | else [StringEntry(toCompositeKey(k_vires_vault, _assetId), _vaultAddress)] | |
89 | + | ||
90 | + | ||
91 | + | ||
92 | + | @Callable(i) | |
93 | + | func withdraw (_assetId,_amount) = if (if (if (!(isWhitelist(toString(i.caller)))) | |
94 | + | then true | |
95 | + | else !(initialized())) | |
96 | + | then true | |
97 | + | else (_amount > balanceOf(_assetId))) | |
98 | + | then throw(((("Invalid withdraw params " + toString(_amount)) + " > ") + toString(balanceOf(_assetId)))) | |
99 | + | else { | |
100 | + | let unstake = invoke(viresAddress(), "withdraw", [_assetId, _amount], nil) | |
101 | + | if ((unstake == unstake)) | |
102 | + | then { | |
103 | + | let currentAssetBalance = (balanceOf(_assetId) - _amount) | |
104 | + | (updateFunds(_assetId, currentAssetBalance) ++ [ScriptTransfer(i.caller, _amount, fromBase58String(_assetId))]) | |
105 | + | } | |
106 | + | else throw("Strict value is not equal to itself.") | |
107 | + | } | |
108 | + | ||
109 | + | ||
110 | + | ||
111 | + | @Callable(i) | |
112 | + | func deposit () = { | |
113 | + | let _amount = i.payments[0].amount | |
114 | + | let _assetId = toBase58String(valueOrErrorMessage(i.payments[0].assetId, "No assetId")) | |
115 | + | if (if (if ((i.payments[0].assetId != quoteAsset())) | |
116 | + | then true | |
117 | + | else !(initialized())) | |
118 | + | then true | |
119 | + | else if (!(isWhitelist(toString(i.caller)))) | |
120 | + | then (i.caller != adminAddress()) | |
121 | + | else false) | |
122 | + | then throw("Invalid deposit params") | |
123 | + | else { | |
124 | + | let vault = viresVault(_assetId) | |
125 | + | let stake = invoke(viresAddress(), "deposit", [toString(vault), false], [AttachedPayment(i.payments[0].assetId, _amount)]) | |
126 | + | if ((stake == stake)) | |
127 | + | then { | |
128 | + | let currentAssetBalance = (balanceOf(_assetId) + _amount) | |
129 | + | updateFunds(_assetId, currentAssetBalance) | |
130 | + | } | |
131 | + | else throw("Strict value is not equal to itself.") | |
132 | + | } | |
133 | + | } | |
134 | + | ||
135 | + | ||
136 | + | ||
137 | + | @Callable(i) | |
138 | + | func claimProfit (_assetId) = if (if (if ((fromBase58String(_assetId) != quoteAsset())) | |
139 | + | then true | |
140 | + | else !(initialized())) | |
141 | + | then true | |
142 | + | else (i.caller != adminAddress())) | |
143 | + | then throw("Invalid claimProfit params") | |
144 | + | else { | |
145 | + | let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil) | |
146 | + | if ((currentAmount == currentAmount)) | |
147 | + | then { | |
148 | + | let currentAssetBalance = match currentAmount { | |
149 | + | case t: (Int, Int, Int, Int) => | |
150 | + | t._3 | |
151 | + | case _ => | |
152 | + | throw("Invalid currentAmount type") | |
153 | + | } | |
154 | + | let profit = (currentAssetBalance - balanceOf(_assetId)) | |
155 | + | let unstake = invoke(viresAddress(), "withdraw", [_assetId, profit], nil) | |
156 | + | if ((unstake == unstake)) | |
157 | + | then [ScriptTransfer(i.caller, profit, fromBase58String(_assetId))] | |
158 | + | else throw("Strict value is not equal to itself.") | |
159 | + | } | |
160 | + | else throw("Strict value is not equal to itself.") | |
161 | + | } | |
162 | + | ||
163 | + | ||
164 | + | ||
165 | + | @Callable(i) | |
166 | + | func view_claimProfit (_assetId) = if (if ((fromBase58String(_assetId) != quoteAsset())) | |
167 | + | then true | |
168 | + | else !(initialized())) | |
169 | + | then throw("Invalid view_claimProfit params") | |
170 | + | else { | |
171 | + | let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil) | |
172 | + | if ((currentAmount == currentAmount)) | |
173 | + | then { | |
174 | + | let currentAssetBalance = match currentAmount { | |
175 | + | case t: (Int, Int, Int, Int) => | |
176 | + | t._3 | |
177 | + | case _ => | |
178 | + | throw("Invalid currentAmount type") | |
179 | + | } | |
180 | + | let profit = (currentAssetBalance - balanceOf(_assetId)) | |
181 | + | throw(((((toString(balanceOf(_assetId)) + ",") + toString(currentAssetBalance)) + ",") + toString(profit))) | |
182 | + | } | |
183 | + | else throw("Strict value is not equal to itself.") | |
184 | + | } | |
185 | + | ||
186 | + | ||
187 | + | @Verifier(tx) | |
188 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
189 | + |
github/deemru/w8io/026f985 176.03 ms ◑