tx · 4qa9sF5Ct77GhVPnmvKGw1FueY37QqMAoFcgMEcdessd

3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH:  -0.03700000 Waves

2023.02.04 14:52 [2434846] smart account 3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH > SELF 0.00000000 Waves

{ "type": 13, "id": "4qa9sF5Ct77GhVPnmvKGw1FueY37QqMAoFcgMEcdessd", "fee": 3700000, "feeAssetId": null, "timestamp": 1675511572501, "version": 2, "chainId": 84, "sender": "3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH", "senderPublicKey": "3mgJJUcUNFHYP2pNkbkfB2C8D4gSEKEGisFByu2i6xoM", "proofs": [ "2jJJswvaViwg3ooHvAeQi2ogm1wSKZm8U28ma62W8J94VxNeHzce1wqiuAyoT992YcU1adhvzBmkmpedoQYxAAB1" ], "script": "base64:BgIiCAISBgoECAgICBIECgIICBIECgIIARIAEgMKAQgSAwoBCBoAB2tfZnVuZHMCB2tfZnVuZHMAD2tfdmlyZXNfYWRkcmVzcwIPa192aXJlc19hZGRyZXNzAA1rX3ZpcmVzX3ZhdWx0Ag1rX3ZpcmVzX3ZhdWx0ABZrX2Fzc2V0X2NsYWltZWRfcHJvZml0AhZrX2Fzc2V0X2NsYWltZWRfcHJvZml0ABRrX2Nvb3JkaW5hdG9yQWRkcmVzcwIUa19jb29yZGluYXRvckFkZHJlc3MAEGtfb3JkZXJzX2FkZHJlc3MCEGtfb3JkZXJzX2FkZHJlc3MAD2tfdmF1bHRfYWRkcmVzcwIPa192YXVsdF9hZGRyZXNzAAVrX2FtbQIFa19hbW0AD2tfYWRtaW5fYWRkcmVzcwIPa19hZG1pbl9hZGRyZXNzAA1rX3F1b3RlX2Fzc2V0Ag1rX3F1b3RlX2Fzc2V0AA9rX3F1b3RlX3N0YWtpbmcCD2tfcXVvdGVfc3Rha2luZwARa19zdGFraW5nX2FkZHJlc3MCEWtfc3Rha2luZ19hZGRyZXNzAA1rX2luaXRpYWxpemVkAg1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N0YXR1c18JAKUIAQUEdGhpcwIBXwkA2AQBCAUCdHgCaWQHCQACAQIudW5hYmxlIHRvIHZlcmlmeTogYWRtaW4gbm90IHNldCBpbiBjb29yZGluYXRvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleZaM9cQ=", "height": 2434846, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B4bA9uX74UCSjD9ncDCNkXnUynwEX5MdnSxvExWypX1U Next: CT38S7wUUk2m8hxerk8xRbP7aC5HfhfDSxKEaQMMsLPu Diff:
OldNewDifferences
1111
1212 let k_coordinatorAddress = "k_coordinatorAddress"
1313
14-let k_insurance_address = "k_insurance_address"
15-
1614 let k_orders_address = "k_orders_address"
1715
1816 let k_vault_address = "k_vault_address"
2018 let k_amm = "k_amm"
2119
2220 let k_admin_address = "k_admin_address"
23-
24-let k_admin_public_key = "k_admin_public_key"
2521
2622 let k_quote_asset = "k_quote_asset"
2723
4036 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
4137
4238
43-func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set")
44-
45-
4639 func vaultAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_vault_address)), "Vault not set")
4740
4841
4942 func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set")
5043
5144
52-func isAmm (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
53-
54-
5545 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
5646
5747
5848 func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
59-
60-
61-func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
6249
6350
6451 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
7360 func viresVault (_assetId) = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, toCompositeKey(k_vires_vault, _assetId)), ("No vault for token " + _assetId))), ("Invalid address for token " + _assetId))
7461
7562
76-func isWhitelist (_address) = if (if (if (if (isAmm(_address))
77- then true
78- else (_address == toString(insuranceAddress())))
79- then true
80- else (_address == toString(stakingAddress())))
63+func isWhitelist (_address) = if (if ((_address == toString(stakingAddress())))
8164 then true
8265 else (_address == toString(vaultAddress())))
8366 then true
8871
8972
9073 @Callable(i)
91-func initialize (_coordinator,_viresAddress,_quoteAssetId,_quoteAssetVault) = if (initialized())
92- then throw("Already initialized")
93- else [StringEntry(k_coordinatorAddress, _coordinator), StringEntry(k_vires_address, _viresAddress), StringEntry(toCompositeKey(k_vires_vault, _quoteAssetId), _quoteAssetVault), BooleanEntry(k_initialized, true)]
74+func initialize (_coordinator,_viresAddress,_quoteAssetId,_quoteAssetVault) = if (if (initialized())
75+ then true
76+ else (i.caller != this))
77+ then throw("Unable to initialize")
78+ else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), StringEntry(k_vires_address, toString(addressFromStringValue(_viresAddress))), StringEntry(toCompositeKey(k_vires_vault, _quoteAssetId), toString(addressFromStringValue(_quoteAssetVault))), BooleanEntry(k_initialized, true)]
9479
9580
9681
9984 then true
10085 else (i.caller != adminAddress()))
10186 then throw("Invalid addTokenVault params")
102- else [StringEntry(toCompositeKey(k_vires_vault, _assetId), _vaultAddress)]
87+ else [StringEntry(toCompositeKey(k_vires_vault, _assetId), toString(addressFromStringValue(_vaultAddress)))]
10388
10489
10590
153138 then true
154139 else !(initialized()))
155140 then true
156- else (i.caller != adminAddress()))
141+ else (i.caller != vaultAddress()))
157142 then throw("Invalid claimProfit params")
158143 else {
159144 let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil)
168153 let profit = (currentAssetBalance - balanceOf(_assetId))
169154 let unstake = invoke(viresAddress(), "withdraw", [_assetId, profit], nil)
170155 if ((unstake == unstake))
171- then [ScriptTransfer(i.caller, profit, fromBase58String(_assetId))]
156+ then $Tuple2([ScriptTransfer(i.caller, profit, fromBase58String(_assetId))], profit)
172157 else throw("Strict value is not equal to itself.")
173158 }
174159 else throw("Strict value is not equal to itself.")
199184
200185
201186 @Verifier(tx)
202-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
187+func verify () = {
188+ let coordinatorStr = getString(this, k_coordinatorAddress)
189+ if (isDefined(coordinatorStr))
190+ then {
191+ let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
192+ if (isDefined(admin))
193+ then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
194+ else throw("unable to verify: admin not set in coordinator")
195+ }
196+ else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
197+ }
203198
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_funds = "k_funds"
55
66 let k_vires_address = "k_vires_address"
77
88 let k_vires_vault = "k_vires_vault"
99
1010 let k_asset_claimed_profit = "k_asset_claimed_profit"
1111
1212 let k_coordinatorAddress = "k_coordinatorAddress"
1313
14-let k_insurance_address = "k_insurance_address"
15-
1614 let k_orders_address = "k_orders_address"
1715
1816 let k_vault_address = "k_vault_address"
1917
2018 let k_amm = "k_amm"
2119
2220 let k_admin_address = "k_admin_address"
23-
24-let k_admin_public_key = "k_admin_public_key"
2521
2622 let k_quote_asset = "k_quote_asset"
2723
2824 let k_quote_staking = "k_quote_staking"
2925
3026 let k_staking_address = "k_staking_address"
3127
3228 let k_initialized = "k_initialized"
3329
3430 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
3531
3632
3733 func balanceOf (_assetId) = valueOrElse(getInteger(this, toCompositeKey(k_funds, _assetId)), 0)
3834
3935
4036 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
4137
4238
43-func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set")
44-
45-
4639 func vaultAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_vault_address)), "Vault not set")
4740
4841
4942 func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set")
5043
5144
52-func isAmm (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
53-
54-
5545 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
5646
5747
5848 func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
59-
60-
61-func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
6249
6350
6451 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
6552
6653
6754 func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set")
6855
6956
7057 func viresAddress () = valueOrErrorMessage(addressFromString(getStringValue(this, k_vires_address)), "Vires not set")
7158
7259
7360 func viresVault (_assetId) = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, toCompositeKey(k_vires_vault, _assetId)), ("No vault for token " + _assetId))), ("Invalid address for token " + _assetId))
7461
7562
76-func isWhitelist (_address) = if (if (if (if (isAmm(_address))
77- then true
78- else (_address == toString(insuranceAddress())))
79- then true
80- else (_address == toString(stakingAddress())))
63+func isWhitelist (_address) = if (if ((_address == toString(stakingAddress())))
8164 then true
8265 else (_address == toString(vaultAddress())))
8366 then true
8467 else (_address == toString(ordersAddress()))
8568
8669
8770 func updateFunds (_assetId,_value) = [IntegerEntry(toCompositeKey(k_funds, _assetId), _value)]
8871
8972
9073 @Callable(i)
91-func initialize (_coordinator,_viresAddress,_quoteAssetId,_quoteAssetVault) = if (initialized())
92- then throw("Already initialized")
93- else [StringEntry(k_coordinatorAddress, _coordinator), StringEntry(k_vires_address, _viresAddress), StringEntry(toCompositeKey(k_vires_vault, _quoteAssetId), _quoteAssetVault), BooleanEntry(k_initialized, true)]
74+func initialize (_coordinator,_viresAddress,_quoteAssetId,_quoteAssetVault) = if (if (initialized())
75+ then true
76+ else (i.caller != this))
77+ then throw("Unable to initialize")
78+ else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), StringEntry(k_vires_address, toString(addressFromStringValue(_viresAddress))), StringEntry(toCompositeKey(k_vires_vault, _quoteAssetId), toString(addressFromStringValue(_quoteAssetVault))), BooleanEntry(k_initialized, true)]
9479
9580
9681
9782 @Callable(i)
9883 func addTokenVault (_assetId,_vaultAddress) = if (if (!(initialized()))
9984 then true
10085 else (i.caller != adminAddress()))
10186 then throw("Invalid addTokenVault params")
102- else [StringEntry(toCompositeKey(k_vires_vault, _assetId), _vaultAddress)]
87+ else [StringEntry(toCompositeKey(k_vires_vault, _assetId), toString(addressFromStringValue(_vaultAddress)))]
10388
10489
10590
10691 @Callable(i)
10792 func withdraw (_assetId,_amount) = if (if (if (!(isWhitelist(toString(i.caller))))
10893 then true
10994 else !(initialized()))
11095 then true
11196 else (_amount > balanceOf(_assetId)))
11297 then throw(((("Invalid withdraw params (manager) " + toString(_amount)) + " > ") + toString(balanceOf(_assetId))))
11398 else {
11499 let unstake = invoke(viresAddress(), "withdraw", [_assetId, _amount], nil)
115100 if ((unstake == unstake))
116101 then {
117102 let currentAssetBalance = (balanceOf(_assetId) - _amount)
118103 (updateFunds(_assetId, currentAssetBalance) ++ [ScriptTransfer(i.caller, _amount, fromBase58String(_assetId))])
119104 }
120105 else throw("Strict value is not equal to itself.")
121106 }
122107
123108
124109
125110 @Callable(i)
126111 func deposit () = {
127112 let _amount = i.payments[0].amount
128113 let _assetId = toBase58String(valueOrErrorMessage(i.payments[0].assetId, "No assetId"))
129114 if (if (if ((i.payments[0].assetId != quoteAsset()))
130115 then true
131116 else !(initialized()))
132117 then true
133118 else if (!(isWhitelist(toString(i.caller))))
134119 then (i.caller != adminAddress())
135120 else false)
136121 then throw("Invalid deposit params (manager)")
137122 else {
138123 let vault = viresVault(_assetId)
139124 let stake = invoke(viresAddress(), "deposit", [toString(vault), false], [AttachedPayment(i.payments[0].assetId, _amount)])
140125 if ((stake == stake))
141126 then {
142127 let currentAssetBalance = (balanceOf(_assetId) + _amount)
143128 updateFunds(_assetId, currentAssetBalance)
144129 }
145130 else throw("Strict value is not equal to itself.")
146131 }
147132 }
148133
149134
150135
151136 @Callable(i)
152137 func claimProfit (_assetId) = if (if (if ((fromBase58String(_assetId) != quoteAsset()))
153138 then true
154139 else !(initialized()))
155140 then true
156- else (i.caller != adminAddress()))
141+ else (i.caller != vaultAddress()))
157142 then throw("Invalid claimProfit params")
158143 else {
159144 let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil)
160145 if ((currentAmount == currentAmount))
161146 then {
162147 let currentAssetBalance = match currentAmount {
163148 case t: (Int, Int, Int, Int) =>
164149 t._3
165150 case _ =>
166151 throw("Invalid currentAmount type")
167152 }
168153 let profit = (currentAssetBalance - balanceOf(_assetId))
169154 let unstake = invoke(viresAddress(), "withdraw", [_assetId, profit], nil)
170155 if ((unstake == unstake))
171- then [ScriptTransfer(i.caller, profit, fromBase58String(_assetId))]
156+ then $Tuple2([ScriptTransfer(i.caller, profit, fromBase58String(_assetId))], profit)
172157 else throw("Strict value is not equal to itself.")
173158 }
174159 else throw("Strict value is not equal to itself.")
175160 }
176161
177162
178163
179164 @Callable(i)
180165 func view_claimProfit (_assetId) = if (if ((fromBase58String(_assetId) != quoteAsset()))
181166 then true
182167 else !(initialized()))
183168 then throw("Invalid view_claimProfit params")
184169 else {
185170 let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil)
186171 if ((currentAmount == currentAmount))
187172 then {
188173 let currentAssetBalance = match currentAmount {
189174 case t: (Int, Int, Int, Int) =>
190175 t._3
191176 case _ =>
192177 throw("Invalid currentAmount type")
193178 }
194179 let profit = (currentAssetBalance - balanceOf(_assetId))
195180 throw(((((toString(balanceOf(_assetId)) + ",") + toString(currentAssetBalance)) + ",") + toString(profit)))
196181 }
197182 else throw("Strict value is not equal to itself.")
198183 }
199184
200185
201186 @Verifier(tx)
202-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
187+func verify () = {
188+ let coordinatorStr = getString(this, k_coordinatorAddress)
189+ if (isDefined(coordinatorStr))
190+ then {
191+ let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
192+ if (isDefined(admin))
193+ then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
194+ else throw("unable to verify: admin not set in coordinator")
195+ }
196+ else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
197+ }
203198

github/deemru/w8io/026f985 
45.00 ms