tx · Hce4aPAvmT9eMwmJomxYJuuLHT6io955KnNVFzDv8tB

3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h:  -0.05000000 Waves

2023.03.29 09:16 [2510859] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves

{ "type": 13, "id": "Hce4aPAvmT9eMwmJomxYJuuLHT6io955KnNVFzDv8tB", "fee": 5000000, "feeAssetId": null, "timestamp": 1680070604300, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "5bTXLSEL1FCXtDEh2utmEr5JNeuhuRNa8NWUvgLkPdRhBSCfbvJmcJfNWWAg6Hg25Xw6wSTvHFALw7k5HBeWevpq" ], "script": "base64:BgIHCAISAwoBAQ8ADGNvbnRyYWN0RmlsZQIJcmViYWxhbmNlAA9rZXlzVGFyZ2V0UmF0aW8CDyVzX190YXJnZXRSYXRpbwAUa2V5QWRkaXRpb25hbEJhbGFuY2UCGiVzX19hZGRpdGlvbmFsV2F2ZXNCYWxhbmNlABprZXlTV2F2ZXNBZGRpdGlvbmFsQmFsYW5jZQIRJXNfX3NXYXZlc0JhbGFuY2UAEGtleVNXYXZlc0Fzc2V0SWQCESVzX19zV2F2ZXNBc3NldElkAA9rZXlQcm94eUFkZHJlc3MCECVzX19wcm94eUFkZHJlc3MADWtleU1pbkJhbGFuY2UCEyVzX19taW5XYXZlc0JhbGFuY2UABk1VTFQxMgCAoJSljR0BEGdldEludGVnZXJPclplcm8BCmludGVnZXJLZXkEByRtYXRjaDAJAJoIAgUEdGhpcwUKaW50ZWdlcktleQMJAAECBQckbWF0Y2gwAgNJbnQEA3ZhbAUHJG1hdGNoMAUDdmFsAAABEGdldFN0cmluZ09yVGhyb3cBCXN0cmluZ0tleQQHJG1hdGNoMAkAnQgCBQR0aGlzBQlzdHJpbmdLZXkD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V0QWRkaXRpb25hbEJhbGFuY2UDCQAAAgUGY2hhbmdlAAAFA25pbAMJAGYCAAAFBmNoYW5nZQQPc2VuZFdhdmVzQW1vdW50CQBoAgUGY2hhbmdlAP///////////wEJAQdkZXBvc2l0AQUPc2VuZFdhdmVzQW1vdW50BA5nZXRXYXZlc0Ftb3VudAUGY2hhbmdlCQEId2l0aGRyYXcBBQ5nZXRXYXZlc0Ftb3VudAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgBfJZsb", "height": 2510859, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9MZwQVHAHh1AvA8EFBRP3uYh6ZCx1UhD9yB7xCVDye2U Next: 95Qmh2UMcxgtRYrLNxj1Hhv9eJE4krhpttBxDFRi5SiR Diff:
OldNewDifferences
1313
1414 let keyProxyAddress = "%s__proxyAddress"
1515
16-let keyMinBalance = "%s__minWavesBalalnce"
16+let keyMinBalance = "%s__minWavesBalance"
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__minWavesBalance"
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 
27.75 ms