tx · CT38S7wUUk2m8hxerk8xRbP7aC5HfhfDSxKEaQMMsLPu

3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH:  -0.03700000 Waves

2023.03.03 23:06 [2474335] smart account 3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH > SELF 0.00000000 Waves

{ "type": 13, "id": "CT38S7wUUk2m8hxerk8xRbP7aC5HfhfDSxKEaQMMsLPu", "fee": 3700000, "feeAssetId": null, "timestamp": 1677874016522, "version": 2, "chainId": 84, "sender": "3NCkVR5gTgfosVUNRTsUHc6kXdhh2V3betH", "senderPublicKey": "3mgJJUcUNFHYP2pNkbkfB2C8D4gSEKEGisFByu2i6xoM", "proofs": [ "3VzgDWxxG2GubqMjLNdFuyZ3NcDtMWEgVuMMAtzKaw4HeHkRyse5DqBJn57H2uctdYo9VFTqbCFGRBwT4PKQBgQ" ], "script": "base64:BgIqCAISBQoDCAgIEgASABIECgIICBIECgIIARIAEgMKAQgSAwoBCBIDCgEIFgAHa19mdW5kcwIHa19mdW5kcwAXa19hc3NldF9tYW5hZ2VyX2FkZHJlc3MCF2tfYXNzZXRfbWFuYWdlcl9hZGRyZXNzABRrX2Nvb3JkaW5hdG9yQWRkcmVzcwIUa19jb29yZGluYXRvckFkZHJlc3MAEGtfb3JkZXJzX2FkZHJlc3MCEGtfb3JkZXJzX2FkZHJlc3MAD2tfdmF1bHRfYWRkcmVzcwIPa192YXVsdF9hZGRyZXNzAAVrX2FtbQIFa19hbW0AD2tfYWRtaW5fYWRkcmVzcwIPa19hZG1pbl9hZGRyZXNzABFrX3N0YWtpbmdfYWRkcmVzcwIRa19zdGFraW5nX2FkZHJlc3MADWtfaW5pdGlhbGl6ZWQCDWtfaW5pdGlhbGl6ZWQACGtfcGF1c2VkAghrX3BhdXNlZAEOdG9Db21wb3NpdGVLZXkCBF9rZXkIX2FkZHJlc3MJAKwCAgkArAICBQRfa2V5AgFfBQhfYWRkcmVzcwEJYmFsYW5jZU9mAQhfYXNzZXRJZAkB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Status": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4qa9sF5Ct77GhVPnmvKGw1FueY37QqMAoFcgMEcdessd Next: yUBx7abeS1ib8eAcFauLQAwhagmUwdorVgsVpeu9nKL Diff:
OldNewDifferences
33 {-# CONTENT_TYPE DAPP #-}
44 let k_funds = "k_funds"
55
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"
6+let k_asset_manager_address = "k_asset_manager_address"
117
128 let k_coordinatorAddress = "k_coordinatorAddress"
139
1915
2016 let k_admin_address = "k_admin_address"
2117
22-let k_quote_asset = "k_quote_asset"
23-
24-let k_quote_staking = "k_quote_staking"
25-
2618 let k_staking_address = "k_staking_address"
2719
2820 let k_initialized = "k_initialized"
21+
22+let k_paused = "k_paused"
2923
3024 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
3125
3327 func balanceOf (_assetId) = valueOrElse(getInteger(this, toCompositeKey(k_funds, _assetId)), 0)
3428
3529
36-func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
30+func coordinator () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_coordinatorAddress), "Coordinator not set Manager")), "Coordinator address invalid")
3731
3832
39-func vaultAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_vault_address)), "Vault not set")
33+func vaultAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_vault_address), "Vault address not set")), "Vault address invalid")
4034
4135
42-func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set")
36+func ordersAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_orders_address), "Orders address not set")), "Orders address invalid")
37+
38+
39+func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set"))
40+
41+
42+func stakingAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_staking_address), "Staking address not set")), "Staking address invalid")
4343
4444
4545 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
4646
4747
48-func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
48+func paused () = valueOrElse(getBoolean(this, k_paused), false)
4949
5050
51-func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
52-
53-
54-func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set")
55-
56-
57-func viresAddress () = valueOrErrorMessage(addressFromString(getStringValue(this, k_vires_address)), "Vires not set")
58-
59-
60-func viresVault (_assetId) = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, toCompositeKey(k_vires_vault, _assetId)), ("No vault for token " + _assetId))), ("Invalid address for token " + _assetId))
51+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))
6152
6253
6354 func isWhitelist (_address) = if (if ((_address == toString(stakingAddress())))
7162
7263
7364 @Callable(i)
74-func initialize (_coordinator,_viresAddress,_quoteAssetId,_quoteAssetVault) = if (if (initialized())
65+func initialize (_coordinator,_quoteAssetId,_quoteAssetManager) = if (if (initialized())
7566 then true
7667 else (i.caller != this))
7768 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)]
69+ else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), StringEntry(toCompositeKey(k_asset_manager_address, _quoteAssetId), toString(addressFromStringValue(_quoteAssetManager))), BooleanEntry(k_initialized, true)]
7970
8071
8172
8273 @Callable(i)
83-func addTokenVault (_assetId,_vaultAddress) = if (if (!(initialized()))
84- then true
85- else (i.caller != adminAddress()))
86- then throw("Invalid addTokenVault params")
87- else [StringEntry(toCompositeKey(k_vires_vault, _assetId), toString(addressFromStringValue(_vaultAddress)))]
74+func unpause () = if ((i.caller != adminAddress()))
75+ then throw("Invalid unpause params")
76+ else [BooleanEntry(k_paused, false)]
8877
8978
9079
9180 @Callable(i)
92-func withdraw (_assetId,_amount) = if (if (if (!(isWhitelist(toString(i.caller))))
81+func pause () = if ((i.caller != adminAddress()))
82+ then throw("Invalid pause params")
83+ else [BooleanEntry(k_paused, true)]
84+
85+
86+
87+@Callable(i)
88+func addAssetManager (_assetId,_vaultAddress) = if (if (if (!(initialized()))
89+ then true
90+ else (i.caller != adminAddress()))
91+ then true
92+ else isDefined(getString(toCompositeKey(k_asset_manager_address, _assetId))))
93+ then throw("Invalid addTokenVault params")
94+ else [StringEntry(toCompositeKey(k_asset_manager_address, _assetId), toString(addressFromStringValue(_vaultAddress)))]
95+
96+
97+
98+@Callable(i)
99+func withdraw (_assetId,_amount) = if (if (if (if (!(isWhitelist(toString(i.caller))))
93100 then true
94101 else !(initialized()))
102+ then true
103+ else paused())
95104 then true
96105 else (_amount > balanceOf(_assetId)))
97106 then throw(((("Invalid withdraw params (manager) " + toString(_amount)) + " > ") + toString(balanceOf(_assetId))))
98107 else {
99- let unstake = invoke(viresAddress(), "withdraw", [_assetId, _amount], nil)
108+ let unstake = invoke(assetManagerAddress(_assetId), "withdraw", [_assetId, _amount], nil)
100109 if ((unstake == unstake))
101110 then {
102111 let currentAssetBalance = (balanceOf(_assetId) - _amount)
111120 func deposit () = {
112121 let _amount = i.payments[0].amount
113122 let _assetId = toBase58String(valueOrErrorMessage(i.payments[0].assetId, "No assetId"))
114- if (if (if ((i.payments[0].assetId != quoteAsset()))
115- then true
116- else !(initialized()))
123+ if (if (if (if (!(initialized()))
117124 then true
118125 else if (!(isWhitelist(toString(i.caller))))
119126 then (i.caller != adminAddress())
120127 else false)
128+ then true
129+ else paused())
130+ then true
131+ else (size(i.payments) != 1))
121132 then throw("Invalid deposit params (manager)")
122133 else {
123- let vault = viresVault(_assetId)
124- let stake = invoke(viresAddress(), "deposit", [toString(vault), false], [AttachedPayment(i.payments[0].assetId, _amount)])
134+ let stake = invoke(assetManagerAddress(_assetId), "deposit", nil, [AttachedPayment(i.payments[0].assetId, _amount)])
125135 if ((stake == stake))
126136 then {
127137 let currentAssetBalance = (balanceOf(_assetId) + _amount)
134144
135145
136146 @Callable(i)
137-func claimProfit (_assetId) = if (if (if ((fromBase58String(_assetId) != quoteAsset()))
138- then true
139- else !(initialized()))
147+func claimProfit (_assetId) = if (if (!(initialized()))
140148 then true
141149 else (i.caller != vaultAddress()))
142- then throw("Invalid claimProfit params")
150+ then throw("Invalid claimProfit params (manager)")
143151 else {
144- let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil)
145- if ((currentAmount == currentAmount))
152+ let doClaimProfitResult = invoke(assetManagerAddress(_assetId), "claimProfit", [_assetId], nil)
153+ if ((doClaimProfitResult == doClaimProfitResult))
146154 then {
147- let currentAssetBalance = match currentAmount {
148- case t: (Int, Int, Int, Int) =>
149- t._3
155+ let profit = match doClaimProfitResult {
156+ case t: Int =>
157+ t
150158 case _ =>
151- throw("Invalid currentAmount type")
159+ throw("Invalid claimProfit result type")
152160 }
153- let profit = (currentAssetBalance - balanceOf(_assetId))
154- let unstake = invoke(viresAddress(), "withdraw", [_assetId, profit], nil)
155- if ((unstake == unstake))
156- then $Tuple2([ScriptTransfer(i.caller, profit, fromBase58String(_assetId))], profit)
157- else throw("Strict value is not equal to itself.")
161+ $Tuple2([ScriptTransfer(i.caller, profit, fromBase58String(_assetId))], profit)
158162 }
159163 else throw("Strict value is not equal to itself.")
160164 }
162166
163167
164168 @Callable(i)
165-func view_claimProfit (_assetId) = if (if ((fromBase58String(_assetId) != quoteAsset()))
166- then true
167- else !(initialized()))
168- then throw("Invalid view_claimProfit params")
169+func view_claimProfit (_assetId) = if (!(initialized()))
170+ then throw("Invalid view_claimProfit params (manager)")
169171 else {
170- let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil)
171- if ((currentAmount == currentAmount))
172+ let doClaimProfitResult = invoke(assetManagerAddress(_assetId), "claimProfit", [_assetId], nil)
173+ if ((doClaimProfitResult == doClaimProfitResult))
172174 then {
173- let currentAssetBalance = match currentAmount {
174- case t: (Int, Int, Int, Int) =>
175- t._3
175+ let profit = match doClaimProfitResult {
176+ case t: Int =>
177+ t
176178 case _ =>
177- throw("Invalid currentAmount type")
179+ throw("Invalid claimProfit result type")
178180 }
179- let profit = (currentAssetBalance - balanceOf(_assetId))
180- throw(((((toString(balanceOf(_assetId)) + ",") + toString(currentAssetBalance)) + ",") + toString(profit)))
181+ throw(((((toString(balanceOf(_assetId)) + ",") + toString((balanceOf(_assetId) + profit))) + ",") + toString(profit)))
181182 }
182183 else throw("Strict value is not equal to itself.")
183184 }
185+
186+
187+
188+@Callable(i)
189+func migrate (_assetId) = {
190+ let _amount = balanceOf(_assetId)
191+ if (if (if (!(initialized()))
192+ then true
193+ else (i.caller != adminAddress()))
194+ then true
195+ else !(paused()))
196+ then throw("Invalid migrate params (manager)")
197+ else {
198+ let unstake = invoke(valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, "k_vires_address"), "No legacy vires address")), "Invalid legacy vires address"), "withdraw", [_assetId, _amount], nil)
199+ if ((unstake == unstake))
200+ then {
201+ let stake = invoke(assetManagerAddress(_assetId), "deposit", nil, [AttachedPayment(fromBase58String(_assetId), _amount)])
202+ if ((stake == stake))
203+ then [DeleteEntry("k_vires_address"), DeleteEntry("k_vires_vault")]
204+ else throw("Strict value is not equal to itself.")
205+ }
206+ else throw("Strict value is not equal to itself.")
207+ }
208+ }
184209
185210
186211 @Verifier(tx)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_funds = "k_funds"
55
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"
6+let k_asset_manager_address = "k_asset_manager_address"
117
128 let k_coordinatorAddress = "k_coordinatorAddress"
139
1410 let k_orders_address = "k_orders_address"
1511
1612 let k_vault_address = "k_vault_address"
1713
1814 let k_amm = "k_amm"
1915
2016 let k_admin_address = "k_admin_address"
2117
22-let k_quote_asset = "k_quote_asset"
23-
24-let k_quote_staking = "k_quote_staking"
25-
2618 let k_staking_address = "k_staking_address"
2719
2820 let k_initialized = "k_initialized"
21+
22+let k_paused = "k_paused"
2923
3024 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
3125
3226
3327 func balanceOf (_assetId) = valueOrElse(getInteger(this, toCompositeKey(k_funds, _assetId)), 0)
3428
3529
36-func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
30+func coordinator () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, k_coordinatorAddress), "Coordinator not set Manager")), "Coordinator address invalid")
3731
3832
39-func vaultAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_vault_address)), "Vault not set")
33+func vaultAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_vault_address), "Vault address not set")), "Vault address invalid")
4034
4135
42-func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set")
36+func ordersAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_orders_address), "Orders address not set")), "Orders address invalid")
37+
38+
39+func adminAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_admin_address), "Admin address not set"))
40+
41+
42+func stakingAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_staking_address), "Staking address not set")), "Staking address invalid")
4343
4444
4545 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
4646
4747
48-func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
48+func paused () = valueOrElse(getBoolean(this, k_paused), false)
4949
5050
51-func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
52-
53-
54-func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set")
55-
56-
57-func viresAddress () = valueOrErrorMessage(addressFromString(getStringValue(this, k_vires_address)), "Vires not set")
58-
59-
60-func viresVault (_assetId) = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, toCompositeKey(k_vires_vault, _assetId)), ("No vault for token " + _assetId))), ("Invalid address for token " + _assetId))
51+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))
6152
6253
6354 func isWhitelist (_address) = if (if ((_address == toString(stakingAddress())))
6455 then true
6556 else (_address == toString(vaultAddress())))
6657 then true
6758 else (_address == toString(ordersAddress()))
6859
6960
7061 func updateFunds (_assetId,_value) = [IntegerEntry(toCompositeKey(k_funds, _assetId), _value)]
7162
7263
7364 @Callable(i)
74-func initialize (_coordinator,_viresAddress,_quoteAssetId,_quoteAssetVault) = if (if (initialized())
65+func initialize (_coordinator,_quoteAssetId,_quoteAssetManager) = if (if (initialized())
7566 then true
7667 else (i.caller != this))
7768 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)]
69+ else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), StringEntry(toCompositeKey(k_asset_manager_address, _quoteAssetId), toString(addressFromStringValue(_quoteAssetManager))), BooleanEntry(k_initialized, true)]
7970
8071
8172
8273 @Callable(i)
83-func addTokenVault (_assetId,_vaultAddress) = if (if (!(initialized()))
84- then true
85- else (i.caller != adminAddress()))
86- then throw("Invalid addTokenVault params")
87- else [StringEntry(toCompositeKey(k_vires_vault, _assetId), toString(addressFromStringValue(_vaultAddress)))]
74+func unpause () = if ((i.caller != adminAddress()))
75+ then throw("Invalid unpause params")
76+ else [BooleanEntry(k_paused, false)]
8877
8978
9079
9180 @Callable(i)
92-func withdraw (_assetId,_amount) = if (if (if (!(isWhitelist(toString(i.caller))))
81+func pause () = if ((i.caller != adminAddress()))
82+ then throw("Invalid pause params")
83+ else [BooleanEntry(k_paused, true)]
84+
85+
86+
87+@Callable(i)
88+func addAssetManager (_assetId,_vaultAddress) = if (if (if (!(initialized()))
89+ then true
90+ else (i.caller != adminAddress()))
91+ then true
92+ else isDefined(getString(toCompositeKey(k_asset_manager_address, _assetId))))
93+ then throw("Invalid addTokenVault params")
94+ else [StringEntry(toCompositeKey(k_asset_manager_address, _assetId), toString(addressFromStringValue(_vaultAddress)))]
95+
96+
97+
98+@Callable(i)
99+func withdraw (_assetId,_amount) = if (if (if (if (!(isWhitelist(toString(i.caller))))
93100 then true
94101 else !(initialized()))
102+ then true
103+ else paused())
95104 then true
96105 else (_amount > balanceOf(_assetId)))
97106 then throw(((("Invalid withdraw params (manager) " + toString(_amount)) + " > ") + toString(balanceOf(_assetId))))
98107 else {
99- let unstake = invoke(viresAddress(), "withdraw", [_assetId, _amount], nil)
108+ let unstake = invoke(assetManagerAddress(_assetId), "withdraw", [_assetId, _amount], nil)
100109 if ((unstake == unstake))
101110 then {
102111 let currentAssetBalance = (balanceOf(_assetId) - _amount)
103112 (updateFunds(_assetId, currentAssetBalance) ++ [ScriptTransfer(i.caller, _amount, fromBase58String(_assetId))])
104113 }
105114 else throw("Strict value is not equal to itself.")
106115 }
107116
108117
109118
110119 @Callable(i)
111120 func deposit () = {
112121 let _amount = i.payments[0].amount
113122 let _assetId = toBase58String(valueOrErrorMessage(i.payments[0].assetId, "No assetId"))
114- if (if (if ((i.payments[0].assetId != quoteAsset()))
115- then true
116- else !(initialized()))
123+ if (if (if (if (!(initialized()))
117124 then true
118125 else if (!(isWhitelist(toString(i.caller))))
119126 then (i.caller != adminAddress())
120127 else false)
128+ then true
129+ else paused())
130+ then true
131+ else (size(i.payments) != 1))
121132 then throw("Invalid deposit params (manager)")
122133 else {
123- let vault = viresVault(_assetId)
124- let stake = invoke(viresAddress(), "deposit", [toString(vault), false], [AttachedPayment(i.payments[0].assetId, _amount)])
134+ let stake = invoke(assetManagerAddress(_assetId), "deposit", nil, [AttachedPayment(i.payments[0].assetId, _amount)])
125135 if ((stake == stake))
126136 then {
127137 let currentAssetBalance = (balanceOf(_assetId) + _amount)
128138 updateFunds(_assetId, currentAssetBalance)
129139 }
130140 else throw("Strict value is not equal to itself.")
131141 }
132142 }
133143
134144
135145
136146 @Callable(i)
137-func claimProfit (_assetId) = if (if (if ((fromBase58String(_assetId) != quoteAsset()))
138- then true
139- else !(initialized()))
147+func claimProfit (_assetId) = if (if (!(initialized()))
140148 then true
141149 else (i.caller != vaultAddress()))
142- then throw("Invalid claimProfit params")
150+ then throw("Invalid claimProfit params (manager)")
143151 else {
144- let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil)
145- if ((currentAmount == currentAmount))
152+ let doClaimProfitResult = invoke(assetManagerAddress(_assetId), "claimProfit", [_assetId], nil)
153+ if ((doClaimProfitResult == doClaimProfitResult))
146154 then {
147- let currentAssetBalance = match currentAmount {
148- case t: (Int, Int, Int, Int) =>
149- t._3
155+ let profit = match doClaimProfitResult {
156+ case t: Int =>
157+ t
150158 case _ =>
151- throw("Invalid currentAmount type")
159+ throw("Invalid claimProfit result type")
152160 }
153- let profit = (currentAssetBalance - balanceOf(_assetId))
154- let unstake = invoke(viresAddress(), "withdraw", [_assetId, profit], nil)
155- if ((unstake == unstake))
156- then $Tuple2([ScriptTransfer(i.caller, profit, fromBase58String(_assetId))], profit)
157- else throw("Strict value is not equal to itself.")
161+ $Tuple2([ScriptTransfer(i.caller, profit, fromBase58String(_assetId))], profit)
158162 }
159163 else throw("Strict value is not equal to itself.")
160164 }
161165
162166
163167
164168 @Callable(i)
165-func view_claimProfit (_assetId) = if (if ((fromBase58String(_assetId) != quoteAsset()))
166- then true
167- else !(initialized()))
168- then throw("Invalid view_claimProfit params")
169+func view_claimProfit (_assetId) = if (!(initialized()))
170+ then throw("Invalid view_claimProfit params (manager)")
169171 else {
170- let currentAmount = invoke(viresVault(_assetId), "getCurrentTotals", [toString(this)], nil)
171- if ((currentAmount == currentAmount))
172+ let doClaimProfitResult = invoke(assetManagerAddress(_assetId), "claimProfit", [_assetId], nil)
173+ if ((doClaimProfitResult == doClaimProfitResult))
172174 then {
173- let currentAssetBalance = match currentAmount {
174- case t: (Int, Int, Int, Int) =>
175- t._3
175+ let profit = match doClaimProfitResult {
176+ case t: Int =>
177+ t
176178 case _ =>
177- throw("Invalid currentAmount type")
179+ throw("Invalid claimProfit result type")
178180 }
179- let profit = (currentAssetBalance - balanceOf(_assetId))
180- throw(((((toString(balanceOf(_assetId)) + ",") + toString(currentAssetBalance)) + ",") + toString(profit)))
181+ throw(((((toString(balanceOf(_assetId)) + ",") + toString((balanceOf(_assetId) + profit))) + ",") + toString(profit)))
181182 }
182183 else throw("Strict value is not equal to itself.")
183184 }
185+
186+
187+
188+@Callable(i)
189+func migrate (_assetId) = {
190+ let _amount = balanceOf(_assetId)
191+ if (if (if (!(initialized()))
192+ then true
193+ else (i.caller != adminAddress()))
194+ then true
195+ else !(paused()))
196+ then throw("Invalid migrate params (manager)")
197+ else {
198+ let unstake = invoke(valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, "k_vires_address"), "No legacy vires address")), "Invalid legacy vires address"), "withdraw", [_assetId, _amount], nil)
199+ if ((unstake == unstake))
200+ then {
201+ let stake = invoke(assetManagerAddress(_assetId), "deposit", nil, [AttachedPayment(fromBase58String(_assetId), _amount)])
202+ if ((stake == stake))
203+ then [DeleteEntry("k_vires_address"), DeleteEntry("k_vires_vault")]
204+ else throw("Strict value is not equal to itself.")
205+ }
206+ else throw("Strict value is not equal to itself.")
207+ }
208+ }
184209
185210
186211 @Verifier(tx)
187212 func verify () = {
188213 let coordinatorStr = getString(this, k_coordinatorAddress)
189214 if (isDefined(coordinatorStr))
190215 then {
191216 let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
192217 if (isDefined(admin))
193218 then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
194219 else throw("unable to verify: admin not set in coordinator")
195220 }
196221 else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
197222 }
198223

github/deemru/w8io/026f985 
45.21 ms