tx · 9MZwQVHAHh1AvA8EFBRP3uYh6ZCx1UhD9yB7xCVDye2U

3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h:  -0.05000000 Waves

2023.03.29 09:15 [2510858] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves

{ "type": 13, "id": "9MZwQVHAHh1AvA8EFBRP3uYh6ZCx1UhD9yB7xCVDye2U", "fee": 5000000, "feeAssetId": null, "timestamp": 1680070550220, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "LUCx3bDi6BUrfDBiqJvYpzgNQoXgM4NGZg1i4nPYLxjXMnM64y6HJsX1E3RFw2hwV3tBwHv43U8H89gFh9pgkBt" ], "script": "base64:BgIHCAISAwoBAQ8ADGNvbnRyYWN0RmlsZQIJcmViYWxhbmNlAA9rZXlzVGFyZ2V0UmF0aW8CDyVzX190YXJnZXRSYXRpbwAUa2V5QWRkaXRpb25hbEJhbGFuY2UCGiVzX19hZGRpdGlvbmFsV2F2ZXNCYWxhbmNlABprZXlTV2F2ZXNBZGRpdGlvbmFsQmFsYW5jZQIRJXNfX3NXYXZlc0JhbGFuY2UAEGtleVNXYXZlc0Fzc2V0SWQCESVzX19zV2F2ZXNBc3NldElkAA9rZXlQcm94eUFkZHJlc3MCECVzX19wcm94eUFkZHJlc3MADWtleU1pbkJhbGFuY2UCFCVzX19taW5XYXZlc0JhbGFsbmNlAAZNVUxUMTIAgKCUpY0dARBnZXRJbnRlZ2VyT3JaZXJvAQppbnRlZ2VyS2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFCmludGVnZXJLZXkDCQABAgUHJG1hdGNoMAIDSW50BAN2YWwFByRtYXRjaDAFA3ZhbAAAARBnZXRTdHJpbmdPclRocm93AQlzdHJpbmdLZXkEByRtYXRjaDAJAJ0IAgUEdGh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uY2UFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlAwkAAAIFBmNoYW5nZQAABQNuaWwDCQBmAgAABQZjaGFuZ2UED3NlbmRXYXZlc0Ftb3VudAkAaAIFBmNoYW5nZQD///////////8BCQEHZGVwb3NpdAEFD3NlbmRXYXZlc0Ftb3VudAQOZ2V0V2F2ZXNBbW91bnQFBmNoYW5nZQkBCHdpdGhkcmF3AQUOZ2V0V2F2ZXNBbW91bnQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AJxtsiQ==", "height": 2510858, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 36UVQqSDA8X6FYQvznVGRyYbXPYZyp6AecqTJBzfp4u1 Next: Hce4aPAvmT9eMwmJomxYJuuLHT6io955KnNVFzDv8tB Diff:
OldNewDifferences
1313
1414 let keyProxyAddress = "%s__proxyAddress"
1515
16-let keyMinBalance = "%s_minWavesBalalnce"
16+let keyMinBalance = "%s__minWavesBalalnce"
1717
1818 let MULT12 = 1000000000000
1919
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
88 let keyAdditionalBalance = "%s__additionalWavesBalance"
99
1010 let keySWavesAdditionalBalance = "%s__sWavesBalance"
1111
1212 let keySWavesAssetId = "%s__sWavesAssetId"
1313
1414 let keyProxyAddress = "%s__proxyAddress"
1515
16-let keyMinBalance = "%s_minWavesBalalnce"
16+let keyMinBalance = "%s__minWavesBalalnce"
1717
1818 let MULT12 = 1000000000000
1919
2020 func getIntegerOrZero (integerKey) = match getInteger(this, integerKey) {
2121 case val: Int =>
2222 val
2323 case _ =>
2424 0
2525 }
2626
2727
2828 func getStringOrThrow (stringKey) = match getString(this, stringKey) {
2929 case s: String =>
3030 s
3131 case _ =>
3232 throw((("[" + stringKey) + "] is empty"))
3333 }
3434
3535
3636 func getTargetRatio () = match getInteger(keysTargetRatio) {
3737 case ratio: Int =>
3838 min([100, max([0, ratio])])
3939 case _ =>
4040 80
4141 }
4242
4343
4444 func getMinBalance () = match getInteger(keyMinBalance) {
4545 case i: Int =>
4646 max([0, i])
4747 case _ =>
4848 0
4949 }
5050
5151
5252 func getRate () = {
5353 let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress))
5454 let inv = invoke(proxy, "getRate", nil, nil)
5555 if ((inv == inv))
5656 then match inv {
5757 case s: String =>
5858 parseIntValue(s)
5959 case _ =>
6060 throw("ZERO rate")
6161 }
6262 else throw("Strict value is not equal to itself.")
6363 }
6464
6565
6666 func deposit (wavesAmount) = {
6767 let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress))
6868 let currentAdditionalBalance = getIntegerOrZero(keyAdditionalBalance)
6969 if ((currentAdditionalBalance == currentAdditionalBalance))
7070 then {
7171 let currentSWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
7272 if ((currentSWavesBalance == currentSWavesBalance))
7373 then if ((wavesAmount > 0))
7474 then {
7575 let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(unit, wavesAmount)])
7676 if ((depositInvoke == depositInvoke))
7777 then match depositInvoke {
7878 case receivedSWaves: Int =>
7979 let newAdditionalBalance = (currentAdditionalBalance + wavesAmount)
8080 let newSWavesBalance = (currentSWavesBalance + receivedSWaves)
8181 [IntegerEntry(keyAdditionalBalance, newAdditionalBalance), IntegerEntry(keySWavesAdditionalBalance, newSWavesBalance)]
8282 case _ =>
8383 nil
8484 }
8585 else throw("Strict value is not equal to itself.")
8686 }
8787 else nil
8888 else throw("Strict value is not equal to itself.")
8989 }
9090 else throw("Strict value is not equal to itself.")
9191 }
9292
9393
9494 func withdraw (wavesAmount) = {
9595 let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress))
9696 let sWavesId = fromBase58String(getStringOrThrow(keySWavesAssetId))
9797 if ((sWavesId == sWavesId))
9898 then {
9999 let currentAdditionalBalance = getIntegerOrZero(keyAdditionalBalance)
100100 if ((currentAdditionalBalance == currentAdditionalBalance))
101101 then {
102102 let currentSWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
103103 if ((currentSWavesBalance == currentSWavesBalance))
104104 then {
105105 let currentProxyRate = getRate()
106106 if ((currentProxyRate == currentProxyRate))
107107 then {
108108 let sendSWavesAmount = fraction(MULT12, wavesAmount, currentProxyRate)
109109 if ((sendSWavesAmount > 0))
110110 then {
111111 let depositInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(sWavesId, sendSWavesAmount)])
112112 if ((depositInvoke == depositInvoke))
113113 then match depositInvoke {
114114 case receivedWaves: Int =>
115115 let newAdditionalBalance = (currentAdditionalBalance - receivedWaves)
116116 let newSWavesBalance = (currentSWavesBalance - sendSWavesAmount)
117117 [IntegerEntry(keyAdditionalBalance, newAdditionalBalance), IntegerEntry(keySWavesAdditionalBalance, newSWavesBalance)]
118118 case _ =>
119119 nil
120120 }
121121 else throw("Strict value is not equal to itself.")
122122 }
123123 else nil
124124 }
125125 else throw("Strict value is not equal to itself.")
126126 }
127127 else throw("Strict value is not equal to itself.")
128128 }
129129 else throw("Strict value is not equal to itself.")
130130 }
131131 else throw("Strict value is not equal to itself.")
132132 }
133133
134134
135135 @Callable(i)
136136 func rebalanceRatio (targetRatio) = {
137137 let regularBalance = max([0, (wavesBalance(this).regular - getMinBalance())])
138138 if ((regularBalance == regularBalance))
139139 then {
140140 let additionalBalance = getIntegerOrZero(keyAdditionalBalance)
141141 if ((additionalBalance == additionalBalance))
142142 then {
143143 let wholeBalance = (regularBalance + additionalBalance)
144144 let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100)
145145 let change = (additionalBalance - targetAdditionalBalance)
146146 if ((change == 0))
147147 then nil
148148 else if ((0 > change))
149149 then {
150150 let sendWavesAmount = (change * -1)
151151 deposit(sendWavesAmount)
152152 }
153153 else {
154154 let getWavesAmount = change
155155 withdraw(getWavesAmount)
156156 }
157157 }
158158 else throw("Strict value is not equal to itself.")
159159 }
160160 else throw("Strict value is not equal to itself.")
161161 }
162162
163163

github/deemru/w8io/026f985 
32.40 ms