tx · CvSu5MEu2Ubiytf8BouHwABQ6DiJDUj9HjeiUSw73qEy

3MtbzcFZjxhPwaM1HoYr7sSSGDk7bjBsRNN:  -0.03700000 Waves

2023.07.19 15:53 [2672772] smart account 3MtbzcFZjxhPwaM1HoYr7sSSGDk7bjBsRNN > SELF 0.00000000 Waves

{ "type": 13, "id": "CvSu5MEu2Ubiytf8BouHwABQ6DiJDUj9HjeiUSw73qEy", "fee": 3700000, "feeAssetId": null, "timestamp": 1689771263231, "version": 2, "chainId": 84, "sender": "3MtbzcFZjxhPwaM1HoYr7sSSGDk7bjBsRNN", "senderPublicKey": "269hMEydX4R6CjK9TRgFMec4TtjsckD91Vxo2pzLVzv4", "proofs": [ "2LpSVCkLcJWwwWpTQV5GYug2BJmPo45dJwUQCGMiYcbEX5vDBPH4fDEfRu9zLUqMKfLoat2JZ7WpfUEBzR338rjh" ], "script": "base64:BgIrCAISBQoDCAgIEgASABIECgIICBIECgIICBIECgIIARIAEgMKAQgSAwoBCCMAB2tfZnVuZHMCB2tfZnVuZHMAF2tfYXNzZXRfbWFuYWdlcl9hZGRyZXNzAhdrX2Fzc2V0X21hbmFnZXJfYWRkcmVzcwAUa19jb29yZGluYXRvckFkZHJlc3MCFGtfY29vcmRpbmF0b3JBZGRyZXNzABBrX29yZGVyc19hZGRyZXNzAhBrX29yZGVyc19hZGRyZXNzAA9rX3ZhdWx0X2FkZHJlc3MCD2tfdmF1bHRfYWRkcmVzcwAFa19hbW0CBWtfYW1tAA9rX2FkbWluX2FkZHJlc3MCD2tfYWRtaW5fYWRkcmVzcwARa19zdGFraW5nX2FkZHJlc3MCEWtfc3Rha2luZ19hZGRyZXNzAA5rX3Nwb3RfYWRkcmVzcwIOa19zcG90X2FkZHJlc3MAEWtfZmFybWluZ19hZGRyZXNzAhFrX2Zhcm1pbmdfYWRkcmVzcwAOa19yZXdhcmRfYXNzZXQCDmtfcmV3YXJkX2Fzc2V0AAdrX3ZhdWx0AgdrX3ZhdWx0AA1rX2luaXR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ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAEDmNvb3JkaW5hdG9yU3RyCQCdCAIFBHRoaXMFFGtfY29vcmRpbmF0b3JBZGRyZXNzAwkBCWlzRGVmaW5lZAEFDmNvb3JkaW5hdG9yU3RyBAVhZG1pbgkAnQgCCQERQGV4dHJOYXRpdmUoMTA2MikBCQEFdmFsdWUBBQ5jb29yZGluYXRvclN0cgUPa19hZG1pbl9hZGRyZXNzAwkBCWlzRGVmaW5lZAEFBWFkbWluCQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEJAQV2YWx1ZQEFBWFkbWluCQCsAgIJAKwCAgkArAICAgdzdGF0dXNfCQClCAEFBHRoaXMCAV8JANgEAQgFAnR4AmlkBwkAAgECLnVuYWJsZSB0byB2ZXJpZnk6IGFkbWluIG5vdCBzZXQgaW4gY29vcmRpbmF0b3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXlXrUJ9", "height": 2672772, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 96AL2QmC5qpFvHrjqzcpaEVuMgfV6tDWV95jhZWrx3Tw Next: none Diff:
OldNewDifferences
1919
2020 let k_spot_address = "k_spot_address"
2121
22+let k_farming_address = "k_farming_address"
23+
24+let k_reward_asset = "k_reward_asset"
25+
2226 let k_vault = "k_vault"
2327
2428 let k_initialized = "k_initialized"
2529
2630 let k_paused = "k_paused"
31+
32+let k_profitDirection = "k_profitDirection"
33+
34+let PROFIT_LP = 1
35+
36+let PROFIT_FARM = 2
2737
2838 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
2939
4959 func spotAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_spot_address), "Spot address not set")), "Spot address invalid")
5060
5161
62+func farmingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_farming_address)), "Farming not set")
63+
64+
65+func rewardAsset () = fromBase58String(valueOrErrorMessage(getString(coordinator(), k_reward_asset), "Reward asset not set"))
66+
67+
5268 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
5369
5470
5672
5773
5874 func assetManagerAddress (_assetId) = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, toCompositeKey(k_asset_manager_address, _assetId)), ("No asset manager for token " + _assetId))), ("Invalid asset manager address for token " + _assetId))
75+
76+
77+func profitDirection () = valueOrElse(getInteger(this, k_profitDirection), PROFIT_LP)
5978
6079
6180 func isSpotVault (_address) = {
114133 else false)
115134 then throw("Invalid addTokenVault params")
116135 else [StringEntry(toCompositeKey(k_asset_manager_address, _assetId), toString(addressFromStringValue(_vaultAddress)))]
136+
137+
138+
139+@Callable(i)
140+func changeAssetManager (_assetId,_vaultAddress) = if (if (if (!(initialized()))
141+ then true
142+ else (i.caller != adminAddress()))
143+ then true
144+ else if (!(isDefined(getString(toCompositeKey(k_asset_manager_address, _assetId)))))
145+ then (balanceOf(_assetId) > 0)
146+ else false)
147+ then throw("Invalid changeAssetManager params")
148+ else {
149+ let actualBalance = balanceOf(_assetId)
150+ if ((actualBalance == actualBalance))
151+ then {
152+ let unstake = invoke(assetManagerAddress(_assetId), "withdraw", [_assetId, actualBalance], nil)
153+ if ((unstake == unstake))
154+ then {
155+ let stake = invoke(addressFromStringValue(_vaultAddress), "deposit", nil, [AttachedPayment(fromBase58String(_assetId), actualBalance)])
156+ if ((stake == stake))
157+ then [StringEntry(toCompositeKey(k_asset_manager_address, _assetId), toString(addressFromStringValue(_vaultAddress)))]
158+ else throw("Strict value is not equal to itself.")
159+ }
160+ else throw("Strict value is not equal to itself.")
161+ }
162+ else throw("Strict value is not equal to itself.")
163+ }
117164
118165
119166
184231 case _ =>
185232 throw("Invalid claimProfit result type")
186233 }
187- $Tuple2([ScriptTransfer(i.caller, profit, if ((_assetId == "WAVES"))
234+ let profitAsset = if ((_assetId == "WAVES"))
188235 then unit
189- else fromBase58String(_assetId))], profit)
236+ else fromBase58String(_assetId)
237+ let profitReceiver = if (if ((profitAsset == rewardAsset()))
238+ then (profitDirection() == PROFIT_FARM)
239+ else false)
240+ then farmingAddress()
241+ else i.caller
242+ $Tuple2([ScriptTransfer(profitReceiver, profit, profitAsset)], profit)
190243 }
191244 else throw("Strict value is not equal to itself.")
192245 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_funds = "k_funds"
55
66 let k_asset_manager_address = "k_asset_manager_address"
77
88 let k_coordinatorAddress = "k_coordinatorAddress"
99
1010 let k_orders_address = "k_orders_address"
1111
1212 let k_vault_address = "k_vault_address"
1313
1414 let k_amm = "k_amm"
1515
1616 let k_admin_address = "k_admin_address"
1717
1818 let k_staking_address = "k_staking_address"
1919
2020 let k_spot_address = "k_spot_address"
2121
22+let k_farming_address = "k_farming_address"
23+
24+let k_reward_asset = "k_reward_asset"
25+
2226 let k_vault = "k_vault"
2327
2428 let k_initialized = "k_initialized"
2529
2630 let k_paused = "k_paused"
31+
32+let k_profitDirection = "k_profitDirection"
33+
34+let PROFIT_LP = 1
35+
36+let PROFIT_FARM = 2
2737
2838 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
2939
3040
3141 func balanceOf (_assetId) = valueOrElse(getInteger(this, toCompositeKey(k_funds, _assetId)), 0)
3242
3343
3444 func coordinator () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_coordinatorAddress), "Coordinator not set Manager")), "Coordinator address invalid")
3545
3646
3747 func vaultAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_vault_address), "Vault address not set")), "Vault address invalid")
3848
3949
4050 func ordersAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_orders_address), "Orders address not set")), "Orders address invalid")
4151
4252
4353 func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set"))
4454
4555
4656 func stakingAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_staking_address), "Staking address not set")), "Staking address invalid")
4757
4858
4959 func spotAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_spot_address), "Spot address not set")), "Spot address invalid")
5060
5161
62+func farmingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_farming_address)), "Farming not set")
63+
64+
65+func rewardAsset () = fromBase58String(valueOrErrorMessage(getString(coordinator(), k_reward_asset), "Reward asset not set"))
66+
67+
5268 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
5369
5470
5571 func paused () = valueOrElse(getBoolean(this, k_paused), false)
5672
5773
5874 func assetManagerAddress (_assetId) = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, toCompositeKey(k_asset_manager_address, _assetId)), ("No asset manager for token " + _assetId))), ("Invalid asset manager address for token " + _assetId))
75+
76+
77+func profitDirection () = valueOrElse(getInteger(this, k_profitDirection), PROFIT_LP)
5978
6079
6180 func isSpotVault (_address) = {
6281 let spot = spotAddress()
6382 valueOrElse(getBoolean(spot, toCompositeKey(k_vault, _address)), false)
6483 }
6584
6685
6786 func isWhitelist (_address) = if (if (if ((_address == toString(stakingAddress())))
6887 then true
6988 else (_address == toString(vaultAddress())))
7089 then true
7190 else (_address == toString(ordersAddress())))
7291 then true
7392 else isSpotVault(_address)
7493
7594
7695 func updateFunds (_assetId,_value) = [IntegerEntry(toCompositeKey(k_funds, _assetId), _value)]
7796
7897
7998 func strAssetId (_asset) = if (isDefined(_asset))
8099 then toBase58String(value(_asset))
81100 else "WAVES"
82101
83102
84103 @Callable(i)
85104 func initialize (_coordinator,_quoteAssetId,_quoteAssetManager) = if (if (initialized())
86105 then true
87106 else (i.caller != this))
88107 then throw("Unable to initialize")
89108 else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), StringEntry(toCompositeKey(k_asset_manager_address, _quoteAssetId), toString(addressFromStringValue(_quoteAssetManager))), BooleanEntry(k_initialized, true)]
90109
91110
92111
93112 @Callable(i)
94113 func unpause () = if ((i.caller != adminAddress()))
95114 then throw("Invalid unpause params")
96115 else [BooleanEntry(k_paused, false)]
97116
98117
99118
100119 @Callable(i)
101120 func pause () = if ((i.caller != adminAddress()))
102121 then throw("Invalid pause params")
103122 else [BooleanEntry(k_paused, true)]
104123
105124
106125
107126 @Callable(i)
108127 func addAssetManager (_assetId,_vaultAddress) = if (if (if (!(initialized()))
109128 then true
110129 else (i.caller != adminAddress()))
111130 then true
112131 else if (isDefined(getString(toCompositeKey(k_asset_manager_address, _assetId))))
113132 then (balanceOf(_assetId) > 0)
114133 else false)
115134 then throw("Invalid addTokenVault params")
116135 else [StringEntry(toCompositeKey(k_asset_manager_address, _assetId), toString(addressFromStringValue(_vaultAddress)))]
136+
137+
138+
139+@Callable(i)
140+func changeAssetManager (_assetId,_vaultAddress) = if (if (if (!(initialized()))
141+ then true
142+ else (i.caller != adminAddress()))
143+ then true
144+ else if (!(isDefined(getString(toCompositeKey(k_asset_manager_address, _assetId)))))
145+ then (balanceOf(_assetId) > 0)
146+ else false)
147+ then throw("Invalid changeAssetManager params")
148+ else {
149+ let actualBalance = balanceOf(_assetId)
150+ if ((actualBalance == actualBalance))
151+ then {
152+ let unstake = invoke(assetManagerAddress(_assetId), "withdraw", [_assetId, actualBalance], nil)
153+ if ((unstake == unstake))
154+ then {
155+ let stake = invoke(addressFromStringValue(_vaultAddress), "deposit", nil, [AttachedPayment(fromBase58String(_assetId), actualBalance)])
156+ if ((stake == stake))
157+ then [StringEntry(toCompositeKey(k_asset_manager_address, _assetId), toString(addressFromStringValue(_vaultAddress)))]
158+ else throw("Strict value is not equal to itself.")
159+ }
160+ else throw("Strict value is not equal to itself.")
161+ }
162+ else throw("Strict value is not equal to itself.")
163+ }
117164
118165
119166
120167 @Callable(i)
121168 func withdraw (_assetId,_amount) = if (if (if (if (!(isWhitelist(toString(i.caller))))
122169 then true
123170 else !(initialized()))
124171 then true
125172 else paused())
126173 then true
127174 else (_amount > balanceOf(_assetId)))
128175 then throw(((("Invalid withdraw params (manager) " + toString(_amount)) + " > ") + toString(balanceOf(_assetId))))
129176 else {
130177 let unstake = invoke(assetManagerAddress(_assetId), "withdraw", [_assetId, _amount], nil)
131178 if ((unstake == unstake))
132179 then {
133180 let currentAssetBalance = (balanceOf(_assetId) - _amount)
134181 (updateFunds(_assetId, currentAssetBalance) ++ [ScriptTransfer(i.caller, _amount, if ((_assetId == "WAVES"))
135182 then unit
136183 else fromBase58String(_assetId))])
137184 }
138185 else throw("Strict value is not equal to itself.")
139186 }
140187
141188
142189
143190 @Callable(i)
144191 func deposit () = {
145192 let _amount = i.payments[0].amount
146193 let _assetId = strAssetId(i.payments[0].assetId)
147194 if (if (if (if (!(initialized()))
148195 then true
149196 else if (!(isWhitelist(toString(i.caller))))
150197 then (i.caller != adminAddress())
151198 else false)
152199 then true
153200 else paused())
154201 then true
155202 else (size(i.payments) != 1))
156203 then throw("Invalid deposit params (manager)")
157204 else {
158205 let stake = invoke(assetManagerAddress(_assetId), "deposit", nil, [AttachedPayment(i.payments[0].assetId, _amount)])
159206 if ((stake == stake))
160207 then {
161208 let currentAssetBalance = (balanceOf(_assetId) + _amount)
162209 updateFunds(_assetId, currentAssetBalance)
163210 }
164211 else throw("Strict value is not equal to itself.")
165212 }
166213 }
167214
168215
169216
170217 @Callable(i)
171218 func claimProfit (_assetId) = if (if (!(initialized()))
172219 then true
173220 else !(if ((i.caller == vaultAddress()))
174221 then true
175222 else isSpotVault(toString(i.caller))))
176223 then throw("Invalid claimProfit params (manager)")
177224 else {
178225 let doClaimProfitResult = invoke(assetManagerAddress(_assetId), "claimProfit", [_assetId], nil)
179226 if ((doClaimProfitResult == doClaimProfitResult))
180227 then {
181228 let profit = match doClaimProfitResult {
182229 case t: Int =>
183230 t
184231 case _ =>
185232 throw("Invalid claimProfit result type")
186233 }
187- $Tuple2([ScriptTransfer(i.caller, profit, if ((_assetId == "WAVES"))
234+ let profitAsset = if ((_assetId == "WAVES"))
188235 then unit
189- else fromBase58String(_assetId))], profit)
236+ else fromBase58String(_assetId)
237+ let profitReceiver = if (if ((profitAsset == rewardAsset()))
238+ then (profitDirection() == PROFIT_FARM)
239+ else false)
240+ then farmingAddress()
241+ else i.caller
242+ $Tuple2([ScriptTransfer(profitReceiver, profit, profitAsset)], profit)
190243 }
191244 else throw("Strict value is not equal to itself.")
192245 }
193246
194247
195248
196249 @Callable(i)
197250 func view_claimProfit (_assetId) = if (!(initialized()))
198251 then throw("Invalid view_claimProfit params (manager)")
199252 else {
200253 let doClaimProfitResult = invoke(assetManagerAddress(_assetId), "claimProfit", [_assetId], nil)
201254 if ((doClaimProfitResult == doClaimProfitResult))
202255 then {
203256 let profit = match doClaimProfitResult {
204257 case t: Int =>
205258 t
206259 case _ =>
207260 throw("Invalid claimProfit result type")
208261 }
209262 throw(((((toString(balanceOf(_assetId)) + ",") + toString((balanceOf(_assetId) + profit))) + ",") + toString(profit)))
210263 }
211264 else throw("Strict value is not equal to itself.")
212265 }
213266
214267
215268 @Verifier(tx)
216269 func verify () = {
217270 let coordinatorStr = getString(this, k_coordinatorAddress)
218271 if (isDefined(coordinatorStr))
219272 then {
220273 let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
221274 if (isDefined(admin))
222275 then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
223276 else throw("unable to verify: admin not set in coordinator")
224277 }
225278 else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
226279 }
227280

github/deemru/w8io/026f985 
34.62 ms