tx · EjmR64ZPXm8eHGmWYqr2BP4G7A4DoujZBkqdkQF1xQ3e

3N5Z4dAWzfkEp4kNJZKQk6zf3uTVFFz5MFF:  -0.01800000 Waves

2024.06.14 18:32 [3150602] smart account 3N5Z4dAWzfkEp4kNJZKQk6zf3uTVFFz5MFF > SELF 0.00000000 Waves

{ "type": 13, "id": "EjmR64ZPXm8eHGmWYqr2BP4G7A4DoujZBkqdkQF1xQ3e", "fee": 1800000, "feeAssetId": null, "timestamp": 1718378578965, "version": 2, "chainId": 84, "sender": "3N5Z4dAWzfkEp4kNJZKQk6zf3uTVFFz5MFF", "senderPublicKey": "8Vp8fmB3ZGVRre7Cw5j9z6qXo3yD8ohPQ6agZ9mtVY5E", "proofs": [ "2C42j6HgiaNmG3qJrczLuhLF61uVf6ZKMngS3xk2Tc6WJxRrC6zhCJhNdiWwtJxhiYmPN3XFLCdSRfWqX8tLr4d3" ], "script": "base64:BwJCCAISBgoEAQgICBIAEgMKAQgSBQoDAQgIEgMKAQESBQoDCAgIEgMKAQgSBAoCCAgSAwoBCBIAEgASAwoBCBIDCgEIRQAJU0VQQVJBVE9SAgJfXwAMS0VZX01VTFRJU0lHAghNVUxUSVNJRwAKS0VZX1NUQVRVUwIGU1RBVFVTAAhLRVlfSU5JVAIESU5JVAAKS0VZX1BBVVNFRAIGUEFVU0VEAApLRVlfUEFVU0VSAgZQQVVTRVIACUtFWV9DSEFJTgIFQ0hBSU4AFEtFWV9HQVRFV0FZX0NPTlRSQUNUAhBHQVRFV0FZX0NPTlRSQUNUABNLRVlfU1dBVkVTX0NPTlRSQUNUAg9TV0FWRVNfQ09OVFJBQ1QAEEtFWV9TV0FWRVNfQVNTRVQCBUFTU0VUAAxLRVlfUkVTRVJWRVMCCFJFU0VSVkVTABJLRVlfU1RBS0lOR19BU1NFVFMCDlNUQUtJTkdfQVNTRVRTABRLRVlfU1RBS0lOR19DT05UUkFDVAIQU1RBS0lOR19DT05UUkFDVAAMRlVOQ19ERVBPU0lUAgdk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AggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5cgk9Ng==", "height": 3150602, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EzydaTK6rzUmknGewLy9YWPQxjW3yL3SAZFYnmsB9YE9 Next: none Diff:
OldNewDifferences
2323
2424 let KEY_RESERVES = "RESERVES"
2525
26+let KEY_STAKING_ASSETS = "STAKING_ASSETS"
27+
28+let KEY_STAKING_CONTRACT = "STAKING_CONTRACT"
29+
2630 let FUNC_DEPOSIT = "deposit"
2731
2832 let FUNC_REQUEST_WITHDRAWAL = "requestWithdrawal"
3236 let FUNC_GET_RATE = "getRate"
3337
3438 let FUNC_WITHDRAW = "withdraw"
39+
40+let FUNC_STAKE = "stake"
41+
42+let FUNC_UNSTAKE = "unstake"
43+
44+let FUNC_CLAIM_ALL = "claimAll"
45+
46+let FUNC_DEPOSIT_STAKING_REWARD = "depositStakingReward"
3547
3648 let WAVES = "WAVES"
3749
213225 func _saveReserves (asset_,reserves_) = [IntegerEntry(makeString([KEY_RESERVES, asset_], SEPARATOR), reserves_)]
214226
215227
228+func _loadStakingAssets () = match getString(KEY_STAKING_ASSETS) {
229+ case a: String =>
230+ if ((size(a) > 0))
231+ then split_51C(a, SEPARATOR)
232+ else nil
233+ case _ =>
234+ nil
235+}
236+
237+
238+func _saveStakingAssets (assets_) = [StringEntry(KEY_STAKING_ASSETS, makeString(assets_, SEPARATOR))]
239+
240+
241+func _loadStakingContract (asset_) = match getString(makeString([KEY_STAKING_CONTRACT, asset_], SEPARATOR)) {
242+ case a: String =>
243+ addressFromStringValue(a)
244+ case _ =>
245+ Address(base58'')
246+}
247+
248+
249+func _saveStakingContract (asset_,contract_) = [StringEntry(makeString([KEY_STAKING_CONTRACT, asset_], SEPARATOR), toString(contract_))]
250+
251+
216252 func _onlyThisContract (caller_) = if ((caller_ != this))
217253 then throw("_onlyThisContract: revert")
218254 else true
253289 else true
254290
255291
292+func _deposit (from_,to_,asset_,amount_) = {
293+ let assetDecimals = _getDecimals(asset_)
294+ let amount = _normalizeDecimals(amount_, assetDecimals, DEX_DECIMALS)
295+ let err = _validateInt(amount, 1, MAX_INT, "_deposit: invalid payment amount")
296+ if ((err == err))
297+ then {
298+ let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), from_, to_, toString(_loadChainId()), asset_, toString(amount)], nil)
299+ if ((gatewayInvocation == gatewayInvocation))
300+ then {
301+ let stakingAssets = _loadStakingAssets()
302+ let stakingInvocation = if ((asset_ == WAVES))
303+ then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, amount_)])
304+ else if (containsElement(stakingAssets, asset_))
305+ then invoke(_loadStakingContract(asset_), FUNC_STAKE, nil, [AttachedPayment(_strToAsset(asset_), amount_)])
306+ else unit
307+ if ((stakingInvocation == stakingInvocation))
308+ then _saveReserves(asset_, (_loadReserves(asset_) + amount))
309+ else throw("Strict value is not equal to itself.")
310+ }
311+ else throw("Strict value is not equal to itself.")
312+ }
313+ else throw("Strict value is not equal to itself.")
314+ }
315+
316+
256317 @Callable(i)
257318 func init (chainId_,pauser_,gatewayContract_,sWavesContract_) = {
258319 let err = if (if (if (if (if (if (_onlyThisContract(i.caller))
285346 then _validateInt(i.payments[0].amount, 0, MAX_INT, "deposit: negative payment")
286347 else false
287348 if ((err == err))
288- then {
289- let caller = toString(i.caller)
290- let asset = _assetToStr(i.payments[0].assetId)
291- let assetDecimals = _getDecimals(asset)
292- let amount = _normalizeDecimals(i.payments[0].amount, assetDecimals, DEX_DECIMALS)
293- let err1 = _validateInt(amount, 1, MAX_INT, "deposit: invalid payment amount")
294- if ((err1 == err1))
295- then {
296- let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), caller, caller, toString(_loadChainId()), asset, toString(amount)], nil)
297- if ((gatewayInvocation == gatewayInvocation))
298- then {
299- let stakingInvocation = if ((asset == WAVES))
300- then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, i.payments[0].amount)])
301- else unit
302- if ((stakingInvocation == stakingInvocation))
303- then $Tuple2(_saveReserves(asset, (_loadReserves(asset) + amount)), unit)
304- else throw("Strict value is not equal to itself.")
305- }
306- else throw("Strict value is not equal to itself.")
307- }
308- else throw("Strict value is not equal to itself.")
309- }
349+ then $Tuple2(_deposit(toString(i.caller), toString(i.caller), _assetToStr(i.payments[0].assetId), i.payments[0].amount), unit)
310350 else throw("Strict value is not equal to itself.")
311351 }
312352
324364 then _validateString(to_, "depositTo: invalid to")
325365 else false
326366 if ((err == err))
327- then {
328- let caller = toString(i.caller)
329- let asset = _assetToStr(i.payments[0].assetId)
330- let assetDecimals = _getDecimals(asset)
331- let amount = _normalizeDecimals(i.payments[0].amount, assetDecimals, DEX_DECIMALS)
332- let err1 = _validateInt(amount, 1, MAX_INT, "depositTo: invalid payment amount")
333- if ((err1 == err1))
334- then {
335- let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), caller, to_, toString(_loadChainId()), asset, toString(amount)], nil)
336- if ((gatewayInvocation == gatewayInvocation))
337- then {
338- let stakingInvocation = if ((asset == WAVES))
339- then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, i.payments[0].amount)])
340- else unit
341- if ((stakingInvocation == stakingInvocation))
342- then $Tuple2(_saveReserves(asset, (_loadReserves(asset) + amount)), unit)
343- else throw("Strict value is not equal to itself.")
344- }
345- else throw("Strict value is not equal to itself.")
346- }
347- else throw("Strict value is not equal to itself.")
348- }
367+ then $Tuple2(_deposit(toString(i.caller), to_, _assetToStr(i.payments[0].assetId), i.payments[0].amount), unit)
349368 else throw("Strict value is not equal to itself.")
350369 }
351370
418437 else false
419438 if ((err1 == err1))
420439 then {
440+ let stakingAssets = _loadStakingAssets()
421441 let unstakingInvocation = if ((asset_ == WAVES))
422442 then {
423443 let sWavesContract = _loadSWavesContract()
432452 let sWavesToWithdraw = toInt(fraction(toBigInt(amountNormalized), SWAVES_RATE_FACTOR, rate, CEILING))
433453 invoke(sWavesContract, FUNC_WITHDRAW, nil, [AttachedPayment(sWavesAsset, sWavesToWithdraw)])
434454 }
435- else unit
455+ else if (containsElement(stakingAssets, asset_))
456+ then invoke(_loadStakingContract(asset_), FUNC_UNSTAKE, [amountNormalized], nil)
457+ else unit
436458 if ((unstakingInvocation == unstakingInvocation))
437459 then $Tuple2(([ScriptTransfer(addressFromStringValue(to_), amountNormalized, _strToAsset(asset_))] ++ _saveReserves(asset_, newReserves)), unit)
438460 else throw("Strict value is not equal to itself.")
461+ }
462+ else throw("Strict value is not equal to itself.")
463+ }
464+ else throw("Strict value is not equal to itself.")
465+ }
466+
467+
468+
469+@Callable(i)
470+func depositStakingReward (asset_) = {
471+ let err = if (_whenInitialized())
472+ then _validateAsset(asset_, "depositStakingReward: invalid asset")
473+ else false
474+ if ((err == err))
475+ then {
476+ let stakingAssets = _loadStakingAssets()
477+ let updatedReserves = if ((asset_ == WAVES))
478+ then {
479+ let sWavesContract = _loadSWavesContract()
480+ let sWavesAsset = _loadSWavesAsset(sWavesContract)
481+ let invocation = invoke(sWavesContract, FUNC_GET_RATE, nil, nil)
482+ let rate = match invocation {
483+ case a: String =>
484+ parseBigIntValue(a)
485+ case _ =>
486+ throw("depositStakingReward: sWaves getRate() revert")
487+ }
488+ let swavesAmount = assetBalance(this, sWavesAsset)
489+ toInt(fraction(toBigInt(swavesAmount), rate, SWAVES_RATE_FACTOR, DOWN))
490+ }
491+ else if (containsElement(stakingAssets, asset_))
492+ then {
493+ let invocation = invoke(_loadStakingContract(asset_), FUNC_CLAIM_ALL, [toString(this)], nil)
494+ if ((invocation == invocation))
495+ then assetBalance(this, fromBase58String(asset_))
496+ else throw("Strict value is not equal to itself.")
497+ }
498+ else throw("depositStakingReward: no staking for asset")
499+ let assetDecimals = _getDecimals(asset_)
500+ let updatedReservesNormalized = _normalizeDecimals(updatedReserves, assetDecimals, DEX_DECIMALS)
501+ let stakingProfit = (updatedReservesNormalized - _loadReserves(asset_))
502+ let err1 = _validateInt(stakingProfit, 1, MAX_INT, "depositStakingReward: no reward")
503+ if ((err1 == err1))
504+ then {
505+ let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT_STAKING_REWARD, [toString(this), toString(_loadChainId()), asset_, toString(stakingProfit)], nil)
506+ if ((gatewayInvocation == gatewayInvocation))
507+ then $Tuple2(_saveReserves(asset_, updatedReservesNormalized), unit)
508+ else throw("Strict value is not equal to itself.")
509+ }
510+ else throw("Strict value is not equal to itself.")
511+ }
512+ else throw("Strict value is not equal to itself.")
513+ }
514+
515+
516+
517+@Callable(i)
518+func addStakingAsset (asset_,contract_) = {
519+ let err = if (if (_onlyThisContract(i.caller))
520+ then _validateAsset(asset_, "addStakingAsset: invalid asset")
521+ else false)
522+ then _validateAddress(contract_, "addStakingAsset: invalid contract")
523+ else false
524+ if ((err == err))
525+ then {
526+ let assets = _loadStakingAssets()
527+ let err1 = if (containsElement(assets, asset_))
528+ then throw("addStakingAsset: duplicate asset")
529+ else unit
530+ if ((err1 == err1))
531+ then $Tuple2((_saveStakingAssets((assets :+ asset_)) ++ _saveStakingContract(asset_, addressFromStringValue(contract_))), unit)
532+ else throw("Strict value is not equal to itself.")
533+ }
534+ else throw("Strict value is not equal to itself.")
535+ }
536+
537+
538+
539+@Callable(i)
540+func rmStakingAsset (asset_) = {
541+ let err = if (_onlyThisContract(i.caller))
542+ then _validateAsset(asset_, "rmStakingAsset: invalid asset")
543+ else false
544+ if ((err == err))
545+ then {
546+ let assets = _loadStakingAssets()
547+ let err1 = if (!(containsElement(assets, asset_)))
548+ then throw("rmStakingAsset: no asset")
549+ else unit
550+ if ((err1 == err1))
551+ then {
552+ let index = value(indexOf(assets, asset_))
553+ $Tuple2(_saveStakingAssets(removeByIndex(assets, index)), unit)
439554 }
440555 else throw("Strict value is not equal to itself.")
441556 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 7 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEPARATOR = "__"
55
66 let KEY_MULTISIG = "MULTISIG"
77
88 let KEY_STATUS = "STATUS"
99
1010 let KEY_INIT = "INIT"
1111
1212 let KEY_PAUSED = "PAUSED"
1313
1414 let KEY_PAUSER = "PAUSER"
1515
1616 let KEY_CHAIN = "CHAIN"
1717
1818 let KEY_GATEWAY_CONTRACT = "GATEWAY_CONTRACT"
1919
2020 let KEY_SWAVES_CONTRACT = "SWAVES_CONTRACT"
2121
2222 let KEY_SWAVES_ASSET = "ASSET"
2323
2424 let KEY_RESERVES = "RESERVES"
2525
26+let KEY_STAKING_ASSETS = "STAKING_ASSETS"
27+
28+let KEY_STAKING_CONTRACT = "STAKING_CONTRACT"
29+
2630 let FUNC_DEPOSIT = "deposit"
2731
2832 let FUNC_REQUEST_WITHDRAWAL = "requestWithdrawal"
2933
3034 let FUNC_EXECUTE_WITHDRAWAL = "executeWithdrawal"
3135
3236 let FUNC_GET_RATE = "getRate"
3337
3438 let FUNC_WITHDRAW = "withdraw"
39+
40+let FUNC_STAKE = "stake"
41+
42+let FUNC_UNSTAKE = "unstake"
43+
44+let FUNC_CLAIM_ALL = "claimAll"
45+
46+let FUNC_DEPOSIT_STAKING_REWARD = "depositStakingReward"
3547
3648 let WAVES = "WAVES"
3749
3850 let WAVES_DECIMALS = 8
3951
4052 let DEX_DECIMALS = 8
4153
4254 let MAX_INT = 9223372036854775807
4355
4456 let ZERO_BIGINT = toBigInt(0)
4557
4658 let ONE_BIGINT = toBigInt(1)
4759
4860 let SWAVES_RATE_FACTOR = toBigInt(1000000000000)
4961
5062 func _validateAddress (address_,err_) = match addressFromString(address_) {
5163 case a: Address =>
5264 true
5365 case _ =>
5466 throw(err_)
5567 }
5668
5769
5870 func _validateAsset (assetId_,err_) = if ((assetId_ == WAVES))
5971 then true
6072 else match assetInfo(fromBase58String(assetId_)) {
6173 case a: Asset =>
6274 true
6375 case _ =>
6476 throw(err_)
6577 }
6678
6779
6880 func _validateInt (val_,lowerBoundary_,upperBoundary_,err_) = if (if ((lowerBoundary_ > val_))
6981 then true
7082 else (val_ > upperBoundary_))
7183 then throw(err_)
7284 else true
7385
7486
7587 func _validateBigInt (val_,lowerBoundary_,err_) = if ((lowerBoundary_ > val_))
7688 then throw(err_)
7789 else true
7890
7991
8092 func _validateString (val_,err_) = if (if ((0 >= size(val_)))
8193 then true
8294 else contains(val_, SEPARATOR))
8395 then throw(err_)
8496 else true
8597
8698
8799 func _validatePaymentsSize (payments_,target_,err_) = if ((size(payments_) != target_))
88100 then throw(err_)
89101 else true
90102
91103
92104 func _assetToStr (asset_) = match asset_ {
93105 case a: ByteVector =>
94106 toBase58String(a)
95107 case _ =>
96108 WAVES
97109 }
98110
99111
100112 func _strToAsset (asset_) = if ((asset_ == WAVES))
101113 then unit
102114 else fromBase58String(asset_)
103115
104116
105117 func _getDecimals (assetId_) = if ((assetId_ == WAVES))
106118 then WAVES_DECIMALS
107119 else match assetInfo(fromBase58String(assetId_)) {
108120 case a: Asset =>
109121 a.decimals
110122 case _ =>
111123 throw(("_getDecimals: no asset=" + assetId_))
112124 }
113125
114126
115127 func _normalizeDecimals (amount_,sourceDecimals_,targetDecimals_) = if ((sourceDecimals_ >= targetDecimals_))
116128 then (amount_ / pow(10, 0, (sourceDecimals_ - targetDecimals_), 0, 0, DOWN))
117129 else (amount_ * pow(10, 0, (targetDecimals_ - sourceDecimals_), 0, 0, DOWN))
118130
119131
120132 func _loadInit () = match getBoolean(KEY_INIT) {
121133 case a: Boolean =>
122134 a
123135 case _ =>
124136 false
125137 }
126138
127139
128140 func _saveInit (isInit_) = [BooleanEntry(KEY_INIT, isInit_)]
129141
130142
131143 func _loadPause () = match getBoolean(KEY_PAUSED) {
132144 case a: Boolean =>
133145 a
134146 case _ =>
135147 false
136148 }
137149
138150
139151 func _savePause (isPaused_) = [BooleanEntry(KEY_PAUSED, isPaused_)]
140152
141153
142154 func _loadPauser () = match getString(KEY_PAUSER) {
143155 case a: String =>
144156 addressFromStringValue(a)
145157 case _ =>
146158 Address(base58'')
147159 }
148160
149161
150162 func _savePauser (pauser_) = [StringEntry(KEY_PAUSER, toString(pauser_))]
151163
152164
153165 func _loadMultisig () = match getString(KEY_MULTISIG) {
154166 case a: String =>
155167 addressFromStringValue(a)
156168 case _ =>
157169 Address(base58'')
158170 }
159171
160172
161173 func _saveMultisig (multisig_) = [StringEntry(KEY_MULTISIG, toString(multisig_))]
162174
163175
164176 func _loadChainId () = match getInteger(KEY_CHAIN) {
165177 case a: Int =>
166178 a
167179 case _ =>
168180 0
169181 }
170182
171183
172184 func _saveChainId (chainId_) = [IntegerEntry(KEY_CHAIN, chainId_)]
173185
174186
175187 func _loadGatewayContract () = match getString(KEY_GATEWAY_CONTRACT) {
176188 case a: String =>
177189 addressFromStringValue(a)
178190 case _ =>
179191 Address(base58'')
180192 }
181193
182194
183195 func _saveGatewayContract (gatewayContract_) = [StringEntry(KEY_GATEWAY_CONTRACT, toString(gatewayContract_))]
184196
185197
186198 func _loadSWavesContract () = match getString(KEY_SWAVES_CONTRACT) {
187199 case a: String =>
188200 addressFromStringValue(a)
189201 case _ =>
190202 Address(base58'')
191203 }
192204
193205
194206 func _saveSWavesContract (sWavesContract_) = [StringEntry(KEY_SWAVES_CONTRACT, toString(sWavesContract_))]
195207
196208
197209 func _loadSWavesAsset (contract_) = match getString(contract_, KEY_SWAVES_ASSET) {
198210 case a: String =>
199211 fromBase58String(a)
200212 case _ =>
201213 throw("_loadSWavesAsset: revert")
202214 }
203215
204216
205217 func _loadReserves (asset_) = match getInteger(makeString([KEY_RESERVES, asset_], SEPARATOR)) {
206218 case a: Int =>
207219 a
208220 case _ =>
209221 0
210222 }
211223
212224
213225 func _saveReserves (asset_,reserves_) = [IntegerEntry(makeString([KEY_RESERVES, asset_], SEPARATOR), reserves_)]
214226
215227
228+func _loadStakingAssets () = match getString(KEY_STAKING_ASSETS) {
229+ case a: String =>
230+ if ((size(a) > 0))
231+ then split_51C(a, SEPARATOR)
232+ else nil
233+ case _ =>
234+ nil
235+}
236+
237+
238+func _saveStakingAssets (assets_) = [StringEntry(KEY_STAKING_ASSETS, makeString(assets_, SEPARATOR))]
239+
240+
241+func _loadStakingContract (asset_) = match getString(makeString([KEY_STAKING_CONTRACT, asset_], SEPARATOR)) {
242+ case a: String =>
243+ addressFromStringValue(a)
244+ case _ =>
245+ Address(base58'')
246+}
247+
248+
249+func _saveStakingContract (asset_,contract_) = [StringEntry(makeString([KEY_STAKING_CONTRACT, asset_], SEPARATOR), toString(contract_))]
250+
251+
216252 func _onlyThisContract (caller_) = if ((caller_ != this))
217253 then throw("_onlyThisContract: revert")
218254 else true
219255
220256
221257 func _whenMultisigSet () = if ((_loadMultisig() == Address(base58'')))
222258 then throw("_whenMultisigSet: revert")
223259 else true
224260
225261
226262 func _whenNotInitialized () = if (_loadInit())
227263 then throw("_whenNotInitialized: revert")
228264 else true
229265
230266
231267 func _whenInitialized () = if (!(_loadInit()))
232268 then throw("_whenInitialized: revert")
233269 else true
234270
235271
236272 func _whenNotPaused () = if (_loadPause())
237273 then throw("_whenNotPaused: revert")
238274 else true
239275
240276
241277 func _whenPaused () = if (!(_loadPause()))
242278 then throw("_whenPaused: revert")
243279 else true
244280
245281
246282 func _onlyPauser (caller_) = if ((caller_ != _loadPauser()))
247283 then throw("_onlyPauser: revert")
248284 else true
249285
250286
251287 func _validateGateway (caller,err_) = if ((_loadGatewayContract() != caller))
252288 then throw(err_)
253289 else true
254290
255291
292+func _deposit (from_,to_,asset_,amount_) = {
293+ let assetDecimals = _getDecimals(asset_)
294+ let amount = _normalizeDecimals(amount_, assetDecimals, DEX_DECIMALS)
295+ let err = _validateInt(amount, 1, MAX_INT, "_deposit: invalid payment amount")
296+ if ((err == err))
297+ then {
298+ let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), from_, to_, toString(_loadChainId()), asset_, toString(amount)], nil)
299+ if ((gatewayInvocation == gatewayInvocation))
300+ then {
301+ let stakingAssets = _loadStakingAssets()
302+ let stakingInvocation = if ((asset_ == WAVES))
303+ then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, amount_)])
304+ else if (containsElement(stakingAssets, asset_))
305+ then invoke(_loadStakingContract(asset_), FUNC_STAKE, nil, [AttachedPayment(_strToAsset(asset_), amount_)])
306+ else unit
307+ if ((stakingInvocation == stakingInvocation))
308+ then _saveReserves(asset_, (_loadReserves(asset_) + amount))
309+ else throw("Strict value is not equal to itself.")
310+ }
311+ else throw("Strict value is not equal to itself.")
312+ }
313+ else throw("Strict value is not equal to itself.")
314+ }
315+
316+
256317 @Callable(i)
257318 func init (chainId_,pauser_,gatewayContract_,sWavesContract_) = {
258319 let err = if (if (if (if (if (if (_onlyThisContract(i.caller))
259320 then _whenNotInitialized()
260321 else false)
261322 then _whenMultisigSet()
262323 else false)
263324 then _validateInt(chainId_, 0, MAX_INT, "init: invalid chainId")
264325 else false)
265326 then _validateAddress(pauser_, "init: invalid pauser")
266327 else false)
267328 then _validateAddress(gatewayContract_, "init: invalid gatewayContract")
268329 else false)
269330 then _validateAddress(sWavesContract_, "init: invalid sWavesContract")
270331 else false
271332 if ((err == err))
272333 then $Tuple2(((((_saveInit(true) ++ _saveChainId(chainId_)) ++ _savePauser(addressFromStringValue(pauser_))) ++ _saveGatewayContract(addressFromStringValue(gatewayContract_))) ++ _saveSWavesContract(addressFromStringValue(sWavesContract_))), unit)
273334 else throw("Strict value is not equal to itself.")
274335 }
275336
276337
277338
278339 @Callable(i)
279340 func deposit () = {
280341 let err = if (if (if (_whenInitialized())
281342 then _whenNotPaused()
282343 else false)
283344 then _validatePaymentsSize(i.payments, 1, "deposit: no payment")
284345 else false)
285346 then _validateInt(i.payments[0].amount, 0, MAX_INT, "deposit: negative payment")
286347 else false
287348 if ((err == err))
288- then {
289- let caller = toString(i.caller)
290- let asset = _assetToStr(i.payments[0].assetId)
291- let assetDecimals = _getDecimals(asset)
292- let amount = _normalizeDecimals(i.payments[0].amount, assetDecimals, DEX_DECIMALS)
293- let err1 = _validateInt(amount, 1, MAX_INT, "deposit: invalid payment amount")
294- if ((err1 == err1))
295- then {
296- let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), caller, caller, toString(_loadChainId()), asset, toString(amount)], nil)
297- if ((gatewayInvocation == gatewayInvocation))
298- then {
299- let stakingInvocation = if ((asset == WAVES))
300- then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, i.payments[0].amount)])
301- else unit
302- if ((stakingInvocation == stakingInvocation))
303- then $Tuple2(_saveReserves(asset, (_loadReserves(asset) + amount)), unit)
304- else throw("Strict value is not equal to itself.")
305- }
306- else throw("Strict value is not equal to itself.")
307- }
308- else throw("Strict value is not equal to itself.")
309- }
349+ then $Tuple2(_deposit(toString(i.caller), toString(i.caller), _assetToStr(i.payments[0].assetId), i.payments[0].amount), unit)
310350 else throw("Strict value is not equal to itself.")
311351 }
312352
313353
314354
315355 @Callable(i)
316356 func depositTo (to_) = {
317357 let err = if (if (if (if (_whenInitialized())
318358 then _whenNotPaused()
319359 else false)
320360 then _validatePaymentsSize(i.payments, 1, "depositTo: no payment")
321361 else false)
322362 then _validateInt(i.payments[0].amount, 0, MAX_INT, "depositTo: negative payment")
323363 else false)
324364 then _validateString(to_, "depositTo: invalid to")
325365 else false
326366 if ((err == err))
327- then {
328- let caller = toString(i.caller)
329- let asset = _assetToStr(i.payments[0].assetId)
330- let assetDecimals = _getDecimals(asset)
331- let amount = _normalizeDecimals(i.payments[0].amount, assetDecimals, DEX_DECIMALS)
332- let err1 = _validateInt(amount, 1, MAX_INT, "depositTo: invalid payment amount")
333- if ((err1 == err1))
334- then {
335- let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT, [toString(this), caller, to_, toString(_loadChainId()), asset, toString(amount)], nil)
336- if ((gatewayInvocation == gatewayInvocation))
337- then {
338- let stakingInvocation = if ((asset == WAVES))
339- then invoke(_loadSWavesContract(), FUNC_DEPOSIT, nil, [AttachedPayment(unit, i.payments[0].amount)])
340- else unit
341- if ((stakingInvocation == stakingInvocation))
342- then $Tuple2(_saveReserves(asset, (_loadReserves(asset) + amount)), unit)
343- else throw("Strict value is not equal to itself.")
344- }
345- else throw("Strict value is not equal to itself.")
346- }
347- else throw("Strict value is not equal to itself.")
348- }
367+ then $Tuple2(_deposit(toString(i.caller), to_, _assetToStr(i.payments[0].assetId), i.payments[0].amount), unit)
349368 else throw("Strict value is not equal to itself.")
350369 }
351370
352371
353372
354373 @Callable(i)
355374 func requestWithdrawal (toChainId_,asset_,amount_) = {
356375 let amount = valueOrErrorMessage(parseBigInt(amount_), "requestWithdrawal: amount not int")
357376 let err = if (if (if (_whenInitialized())
358377 then _validateInt(toChainId_, 0, MAX_INT, "requestWithdrawal: invalid toChainId")
359378 else false)
360379 then _validateString(asset_, "requestWithdrawal: invalid asset")
361380 else false)
362381 then _validateBigInt(amount, ONE_BIGINT, "requestWithdrawal: negative amount")
363382 else false
364383 if ((err == err))
365384 then {
366385 let caller = toString(i.caller)
367386 let requestWithdrawalId = match invoke(_loadGatewayContract(), FUNC_REQUEST_WITHDRAWAL, [toString(this), caller, caller, toString(_loadChainId()), toString(toChainId_), asset_, amount_], nil) {
368387 case a: Int =>
369388 a
370389 case _ =>
371390 throw("requestWithdrawal: call reverted from gw")
372391 }
373392 if ((requestWithdrawalId == requestWithdrawalId))
374393 then $Tuple2(nil, requestWithdrawalId)
375394 else throw("Strict value is not equal to itself.")
376395 }
377396 else throw("Strict value is not equal to itself.")
378397 }
379398
380399
381400
382401 @Callable(i)
383402 func executeWithdrawal (requestWithdrawalId_) = {
384403 let err = if (_whenInitialized())
385404 then _validateInt(requestWithdrawalId_, 0, MAX_INT, "executeWithdrawal: invalid requestId")
386405 else false
387406 if ((err == err))
388407 then {
389408 let gatewayInvocation = reentrantInvoke(_loadGatewayContract(), FUNC_EXECUTE_WITHDRAWAL, [toString(this), toString(_loadChainId()), toString(requestWithdrawalId_)], nil)
390409 if ((gatewayInvocation == gatewayInvocation))
391410 then $Tuple2(nil, unit)
392411 else throw("Strict value is not equal to itself.")
393412 }
394413 else throw("Strict value is not equal to itself.")
395414 }
396415
397416
398417
399418 @Callable(i)
400419 func withdraw (to_,asset_,amount_) = {
401420 let amount = valueOrErrorMessage(parseInt(amount_), "withdraw: amount not int")
402421 let err = if (if (if (if (_whenInitialized())
403422 then _validateGateway(i.caller, "withdraw: invalid gateway")
404423 else false)
405424 then _validateAddress(to_, "withdraw: invalid address")
406425 else false)
407426 then _validateAsset(asset_, "withdraw: invalid asset")
408427 else false)
409428 then _validateInt(amount, 0, MAX_INT, "withdraw: negative amount")
410429 else false
411430 if ((err == err))
412431 then {
413432 let assetDecimals = _getDecimals(asset_)
414433 let amountNormalized = _normalizeDecimals(amount, DEX_DECIMALS, assetDecimals)
415434 let newReserves = (_loadReserves(asset_) - amount)
416435 let err1 = if (_validateInt(amountNormalized, 1, MAX_INT, "withdraw: invalid amount"))
417436 then _validateInt(newReserves, 0, MAX_INT, "withdraw: negative newReserves")
418437 else false
419438 if ((err1 == err1))
420439 then {
440+ let stakingAssets = _loadStakingAssets()
421441 let unstakingInvocation = if ((asset_ == WAVES))
422442 then {
423443 let sWavesContract = _loadSWavesContract()
424444 let sWavesAsset = _loadSWavesAsset(sWavesContract)
425445 let invocation = invoke(sWavesContract, FUNC_GET_RATE, nil, nil)
426446 let rate = match invocation {
427447 case a: String =>
428448 parseBigIntValue(a)
429449 case _ =>
430450 throw("withdraw: sWaves getRate() revert")
431451 }
432452 let sWavesToWithdraw = toInt(fraction(toBigInt(amountNormalized), SWAVES_RATE_FACTOR, rate, CEILING))
433453 invoke(sWavesContract, FUNC_WITHDRAW, nil, [AttachedPayment(sWavesAsset, sWavesToWithdraw)])
434454 }
435- else unit
455+ else if (containsElement(stakingAssets, asset_))
456+ then invoke(_loadStakingContract(asset_), FUNC_UNSTAKE, [amountNormalized], nil)
457+ else unit
436458 if ((unstakingInvocation == unstakingInvocation))
437459 then $Tuple2(([ScriptTransfer(addressFromStringValue(to_), amountNormalized, _strToAsset(asset_))] ++ _saveReserves(asset_, newReserves)), unit)
438460 else throw("Strict value is not equal to itself.")
461+ }
462+ else throw("Strict value is not equal to itself.")
463+ }
464+ else throw("Strict value is not equal to itself.")
465+ }
466+
467+
468+
469+@Callable(i)
470+func depositStakingReward (asset_) = {
471+ let err = if (_whenInitialized())
472+ then _validateAsset(asset_, "depositStakingReward: invalid asset")
473+ else false
474+ if ((err == err))
475+ then {
476+ let stakingAssets = _loadStakingAssets()
477+ let updatedReserves = if ((asset_ == WAVES))
478+ then {
479+ let sWavesContract = _loadSWavesContract()
480+ let sWavesAsset = _loadSWavesAsset(sWavesContract)
481+ let invocation = invoke(sWavesContract, FUNC_GET_RATE, nil, nil)
482+ let rate = match invocation {
483+ case a: String =>
484+ parseBigIntValue(a)
485+ case _ =>
486+ throw("depositStakingReward: sWaves getRate() revert")
487+ }
488+ let swavesAmount = assetBalance(this, sWavesAsset)
489+ toInt(fraction(toBigInt(swavesAmount), rate, SWAVES_RATE_FACTOR, DOWN))
490+ }
491+ else if (containsElement(stakingAssets, asset_))
492+ then {
493+ let invocation = invoke(_loadStakingContract(asset_), FUNC_CLAIM_ALL, [toString(this)], nil)
494+ if ((invocation == invocation))
495+ then assetBalance(this, fromBase58String(asset_))
496+ else throw("Strict value is not equal to itself.")
497+ }
498+ else throw("depositStakingReward: no staking for asset")
499+ let assetDecimals = _getDecimals(asset_)
500+ let updatedReservesNormalized = _normalizeDecimals(updatedReserves, assetDecimals, DEX_DECIMALS)
501+ let stakingProfit = (updatedReservesNormalized - _loadReserves(asset_))
502+ let err1 = _validateInt(stakingProfit, 1, MAX_INT, "depositStakingReward: no reward")
503+ if ((err1 == err1))
504+ then {
505+ let gatewayInvocation = invoke(_loadGatewayContract(), FUNC_DEPOSIT_STAKING_REWARD, [toString(this), toString(_loadChainId()), asset_, toString(stakingProfit)], nil)
506+ if ((gatewayInvocation == gatewayInvocation))
507+ then $Tuple2(_saveReserves(asset_, updatedReservesNormalized), unit)
508+ else throw("Strict value is not equal to itself.")
509+ }
510+ else throw("Strict value is not equal to itself.")
511+ }
512+ else throw("Strict value is not equal to itself.")
513+ }
514+
515+
516+
517+@Callable(i)
518+func addStakingAsset (asset_,contract_) = {
519+ let err = if (if (_onlyThisContract(i.caller))
520+ then _validateAsset(asset_, "addStakingAsset: invalid asset")
521+ else false)
522+ then _validateAddress(contract_, "addStakingAsset: invalid contract")
523+ else false
524+ if ((err == err))
525+ then {
526+ let assets = _loadStakingAssets()
527+ let err1 = if (containsElement(assets, asset_))
528+ then throw("addStakingAsset: duplicate asset")
529+ else unit
530+ if ((err1 == err1))
531+ then $Tuple2((_saveStakingAssets((assets :+ asset_)) ++ _saveStakingContract(asset_, addressFromStringValue(contract_))), unit)
532+ else throw("Strict value is not equal to itself.")
533+ }
534+ else throw("Strict value is not equal to itself.")
535+ }
536+
537+
538+
539+@Callable(i)
540+func rmStakingAsset (asset_) = {
541+ let err = if (_onlyThisContract(i.caller))
542+ then _validateAsset(asset_, "rmStakingAsset: invalid asset")
543+ else false
544+ if ((err == err))
545+ then {
546+ let assets = _loadStakingAssets()
547+ let err1 = if (!(containsElement(assets, asset_)))
548+ then throw("rmStakingAsset: no asset")
549+ else unit
550+ if ((err1 == err1))
551+ then {
552+ let index = value(indexOf(assets, asset_))
553+ $Tuple2(_saveStakingAssets(removeByIndex(assets, index)), unit)
439554 }
440555 else throw("Strict value is not equal to itself.")
441556 }
442557 else throw("Strict value is not equal to itself.")
443558 }
444559
445560
446561
447562 @Callable(i)
448563 func pause () = {
449564 let err = if (if (_onlyPauser(i.caller))
450565 then _whenInitialized()
451566 else false)
452567 then _whenNotPaused()
453568 else false
454569 if ((err == err))
455570 then $Tuple2(_savePause(true), unit)
456571 else throw("Strict value is not equal to itself.")
457572 }
458573
459574
460575
461576 @Callable(i)
462577 func unpause () = {
463578 let err = if (if (_onlyPauser(i.caller))
464579 then _whenInitialized()
465580 else false)
466581 then _whenPaused()
467582 else false
468583 if ((err == err))
469584 then $Tuple2(_savePause(false), unit)
470585 else throw("Strict value is not equal to itself.")
471586 }
472587
473588
474589
475590 @Callable(i)
476591 func updatePauser (pauser_) = {
477592 let err = if (if (_onlyThisContract(i.caller))
478593 then _whenInitialized()
479594 else false)
480595 then _validateAddress(pauser_, "updatePauser: invalid pauser")
481596 else false
482597 if ((err == err))
483598 then $Tuple2(_savePauser(addressFromStringValue(pauser_)), unit)
484599 else throw("Strict value is not equal to itself.")
485600 }
486601
487602
488603
489604 @Callable(i)
490605 func setMultisig (multisig_) = {
491606 let err = if (_onlyThisContract(i.caller))
492607 then _validateAddress(multisig_, "setMultisig: invalid multisig")
493608 else false
494609 if ((err == err))
495610 then $Tuple2(_saveMultisig(addressFromStringValue(multisig_)), unit)
496611 else throw("Strict value is not equal to itself.")
497612 }
498613
499614
500615 @Verifier(tx)
501616 func verify () = match getString(KEY_MULTISIG) {
502617 case multisig: String =>
503618 valueOrElse(getBoolean(addressFromStringValue(multisig), makeString([KEY_STATUS, toString(this), toBase58String(tx.id)], SEPARATOR)), false)
504619 case _ =>
505620 sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
506621 }
507622

github/deemru/w8io/026f985 
61.84 ms