tx · 7udwsQSXbHLwcqkw8Wt1byuy3hDwZmnBPDmTp27xMMy2

3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h:  -0.05000000 Waves

2023.03.27 13:15 [2508247] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves

{ "type": 13, "id": "7udwsQSXbHLwcqkw8Wt1byuy3hDwZmnBPDmTp27xMMy2", "fee": 5000000, "feeAssetId": null, "timestamp": 1679912141071, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "3a1ou3SgDBcD4acDyhptxBgmS7oEXba7btSKigCUQcATxd4n6Riqxi1BVzSj7usNgpx2zS7tpa289CsGWzjpABN3" ], "script": "base64:BgIPCAISABIAEgASBQoDAQEBCgAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIaJXNfX2FkZGl0aW9uYWxXYXZlc0JhbGFuY2UAGmtleVNXYXZlc0FkZGl0aW9uYWxCYWxhbmNlAhElc19fc1dhdmVzQmFsYW5jZQAQa2V5U1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQAD2tleVByb3h5QWRkcmVzcwIQJXNfX3Byb3h5QWRkcmVzcwEQZ2V0SW50ZWdlck9yWmVybwEKaW50ZWdlcktleQQHJG1hdGNoMAkAmggCBQR0aGlzBQppbnRlZ2VyS2V5AwkAAQIFByRtYXRjaDACA0ludAQDdmFsBQckbWF0Y2gwBQN2YWwAAAEQZ2V0U3RyaW5nT3JUaHJvdwEJc3RyaW5nS2V5BAckbWF0Y2gwCQCdCAIFBHRoaXMFCXN0cmluZ0tleQMJAAECBQckbWF0Y2gwAgZTdHJpbmcEAXMFByRtYXRjaDAFAXMJ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kAawMFC3RhcmdldFJhdGlvBQNzdW0AZAQGY2hhbmdlCQBlAgUKYWRkaXRpb25hbAUXdGFyZ2V0QWRkaXRpb25hbEJhbGFuY2UEBm5ld1JlZwkAZAIFDnJlZ3VsYXJCYWxhbmNlBQZjaGFuZ2UDCQBmAgAABQZjaGFuZ2UECnNlbmRBbW91bnQJAGgCBQZjaGFuZ2UA////////////AQkAlAoCBQNuaWwJAMwIAgUGbmV3UmVnCQDMCAIFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlCQDMCAIFBmNoYW5nZQkAzAgCCQCsAgICCWRlcG9zaXQ6IAkApAMBBQpzZW5kQW1vdW50BQNuaWwECnNlbmRBbW91bnQFBmNoYW5nZQkAlAoCBQNuaWwJAMwIAgUGbmV3UmVnCQDMCAIFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlCQDMCAIFBmNoYW5nZQkAzAgCCQCsAgICCndpdGhkcmF3OiAJAKQDAQUKc2VuZEFtb3VudAUDbmlsACzYB8E=", "height": 2508247, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8Gf6LecFJ8qt6Q17gNyF6mhyaXVzxDXETYvbGpEyvm2X Next: ALSyjvDVKxkFhaACEuVFweozBT7CFNdrKEn7h1dDQboC Diff:
OldNewDifferences
55
66 let keysTargetRatio = "%s__targetRatio"
77
8-let keyAdditionalBalance = "%s__addittionalWavesBalance"
8+let keyAdditionalBalance = "%s__additionalWavesBalance"
99
10-let keySWavesAdditionBalance = "%s__sWavesBalance"
10+let keySWavesAdditionalBalance = "%s__sWavesBalance"
1111
1212 let keySWavesAssetId = "%s__sWavesAssetId"
1313
3232 func internalWavesBalance () = (wavesBalance(this).regular + getIntegerOrZero(keyAdditionalBalance))
3333
3434
35+func currentRate () = {
36+ let additionalBalance = getIntegerOrZero(keyAdditionalBalance)
37+ let sWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
38+ if ((additionalBalance == 0))
39+ then 0
40+ else fraction(10000000000, additionalBalance, sWavesBalance)
41+ }
42+
43+
3544 @Callable(i)
3645 func returnWavesBalance () = $Tuple2(nil, internalWavesBalance())
3746
3847
3948
4049 @Callable(i)
41-func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionBalance))
50+func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionalBalance))
4251
4352
4453
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let contractFile = "rebalance"
55
66 let keysTargetRatio = "%s__targetRatio"
77
8-let keyAdditionalBalance = "%s__addittionalWavesBalance"
8+let keyAdditionalBalance = "%s__additionalWavesBalance"
99
10-let keySWavesAdditionBalance = "%s__sWavesBalance"
10+let keySWavesAdditionalBalance = "%s__sWavesBalance"
1111
1212 let keySWavesAssetId = "%s__sWavesAssetId"
1313
1414 let keyProxyAddress = "%s__proxyAddress"
1515
1616 func getIntegerOrZero (integerKey) = match getInteger(this, integerKey) {
1717 case val: Int =>
1818 val
1919 case _ =>
2020 0
2121 }
2222
2323
2424 func getStringOrThrow (stringKey) = match getString(this, stringKey) {
2525 case s: String =>
2626 s
2727 case _ =>
2828 throw((("[" + stringKey) + "] is empty"))
2929 }
3030
3131
3232 func internalWavesBalance () = (wavesBalance(this).regular + getIntegerOrZero(keyAdditionalBalance))
3333
3434
35+func currentRate () = {
36+ let additionalBalance = getIntegerOrZero(keyAdditionalBalance)
37+ let sWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
38+ if ((additionalBalance == 0))
39+ then 0
40+ else fraction(10000000000, additionalBalance, sWavesBalance)
41+ }
42+
43+
3544 @Callable(i)
3645 func returnWavesBalance () = $Tuple2(nil, internalWavesBalance())
3746
3847
3948
4049 @Callable(i)
41-func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionBalance))
50+func returnSWavesBalance () = $Tuple2(nil, getIntegerOrZero(keySWavesAdditionalBalance))
4251
4352
4453
4554 @Callable(i)
4655 func calcRatio () = {
4756 let regularWavesBalance = wavesBalance(this).regular
4857 let additional = getIntegerOrZero(keyAdditionalBalance)
4958 let ratio = fraction(100, additional, (additional + regularWavesBalance))
5059 $Tuple2(nil, ratio)
5160 }
5261
5362
5463
5564 @Callable(i)
5665 func calcRatioTest (regularBalance,additional,targetRatio) = {
5766 let sum = (regularBalance + additional)
5867 let targetAdditionalBalance = fraction(targetRatio, sum, 100)
5968 let change = (additional - targetAdditionalBalance)
6069 let newReg = (regularBalance + change)
6170 if ((0 > change))
6271 then {
6372 let sendAmount = (change * -1)
6473 $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("deposit: " + toString(sendAmount))])
6574 }
6675 else {
6776 let sendAmount = change
6877 $Tuple2(nil, [newReg, targetAdditionalBalance, change, ("withdraw: " + toString(sendAmount))])
6978 }
7079 }
7180
7281

github/deemru/w8io/026f985 
27.77 ms