tx · AMUwG36YQv66tpSkTNkVUyUeaCsDCK5rdczmaWj9tJvc

3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h:  -0.05000000 Waves

2023.03.29 14:47 [2511189] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves

{ "type": 13, "id": "AMUwG36YQv66tpSkTNkVUyUeaCsDCK5rdczmaWj9tJvc", "fee": 5000000, "feeAssetId": null, "timestamp": 1680090462618, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "5Qzfr8ZS6nBS9u2FuZSHxkmPcTTBDYDKJeFZPVi18XiM67Bk6iz5QVLhQDG3N6o5sNwz6P6xo9WtVum2NqsbCdSz" ], "script": "base64:BgIJCAISAwoBARIAFAAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIaJXNfX2FkZGl0aW9uYWxXYXZlc0JhbGFuY2UAGmtleVNXYXZlc0FkZGl0aW9uYWxCYWxhbmNlAhElc19fc1dhdmVzQmFsYW5jZQAQa2V5U1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQAD2tleVByb3h5QWRkcmVzcwIQJXNfX3Byb3h5QWRkcmVzcwANa2V5TWluQmFsYW5jZQITJXNfX21pbldhdmVzQmFsYW5jZQARa2V5RmFjdG9yeUFkZHJlc3MCCyVzX19mYWN0b3J5AAZNVUxUMTIAgKCUpY0dARBnZXRJbnRlZ2VyT3JaZXJvAQppbnRlZ2VyS2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFCmludGVnZXJLZXkDCQABAgUHJG1hdGNoMAIDSW50BAN2YWwFByRtYXRjaDAFA3ZhbAAAARBnZXRTdHJpbmdPclRocm93AQ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FsQmFsYW5jZQURYWRkaXRpb25hbEJhbGFuY2UEDHdob2xlQmFsYW5jZQkAlgMBCQDMCAIAAAkAzAgCCQBlAgkAZAIFEGF2YWlsYWJsZUJhbGFuY2UFEWFkZGl0aW9uYWxCYWxhbmNlCQENZ2V0TWluQmFsYW5jZQAFA25pbAQXdGFyZ2V0QWRkaXRpb25hbEJhbGFuY2UJAGsDBQt0YXJnZXRSYXRpbwUMd2hvbGVCYWxhbmNlAGQEBGRpZmYJAGUCBRFhZGRpdGlvbmFsQmFsYW5jZQUXdGFyZ2V0QWRkaXRpb25hbEJhbGFuY2UDCQAAAgUEZGlmZgAABQNuaWwDCQBmAgAABQRkaWZmBA9zZW5kV2F2ZXNBbW91bnQJAQEtAQUEZGlmZgkBB2RlcG9zaXQBBQ9zZW5kV2F2ZXNBbW91bnQEDmdldFdhdmVzQW1vdW50BQRkaWZmCQEId2l0aGRyYXcBBQ5nZXRXYXZlc0Ftb3VudAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgIBaQEOcmViYWxhbmNlUmF0aW8BC3RhcmdldFJhdGlvCQERcmViYWxhbmNlSW50ZXJuYWwBBQt0YXJnZXRSYXRpbwFpAQlyZWJhbGFuY2UACQERcmViYWxhbmNlSW50ZXJuYWwBCQEOZ2V0VGFyZ2V0UmF0aW8AAFQWmzM=", "height": 2511189, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GuWtKs3nYMdz2tUqzSF3Xmi9nZzLLUmXVtpq8jcdRpEn Next: 6qjiGmkGnHy9XM3BQwo6xgVdGx6go2qGNUPJvCvpBFnS Diff:
OldNewDifferences
7474 func getLeaseProxyConfig () = {
7575 let factory = addressFromStringValue(valueOrElse(getString(keyFactoryAddress), ""))
7676 let myAddressString = toString(this)
77- $Tuple2(invoke(factory, "", [myAddressString, "WAVES"], nil), myAddressString)
77+ $Tuple2(invoke(factory, "getPoolLeaseConfigREADONLY", [myAddressString, "WAVES"], nil), myAddressString)
7878 }
7979
8080
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
1616 let keyMinBalance = "%s__minWavesBalance"
1717
1818 let keyFactoryAddress = "%s__factory"
1919
2020 let MULT12 = 1000000000000
2121
2222 func getIntegerOrZero (integerKey) = match getInteger(this, integerKey) {
2323 case val: Int =>
2424 val
2525 case _ =>
2626 0
2727 }
2828
2929
3030 func getStringOrThrow (stringKey) = match getString(this, stringKey) {
3131 case s: String =>
3232 s
3333 case _ =>
3434 throw((("[" + stringKey) + "] is empty"))
3535 }
3636
3737
3838 func getTargetRatio () = match getInteger(keysTargetRatio) {
3939 case ratio: Int =>
4040 min([100, max([0, ratio])])
4141 case _ =>
4242 0
4343 }
4444
4545
4646 func getMinBalance () = match getInteger(keyMinBalance) {
4747 case i: Int =>
4848 max([0, i])
4949 case _ =>
5050 0
5151 }
5252
5353
5454 func getRate () = {
5555 let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress))
5656 let inv = invoke(proxy, "getRate", nil, nil)
5757 if ((inv == inv))
5858 then match inv {
5959 case s: String =>
6060 parseIntValue(s)
6161 case _ =>
6262 throw("Rate is zero (0)")
6363 }
6464 else throw("Strict value is not equal to itself.")
6565 }
6666
6767
6868 func getProxyAddress () = addressFromStringValue(getStringOrThrow(keyProxyAddress))
6969
7070
7171 func getSWavesId () = fromBase58String(getStringOrThrow(keySWavesAssetId))
7272
7373
7474 func getLeaseProxyConfig () = {
7575 let factory = addressFromStringValue(valueOrElse(getString(keyFactoryAddress), ""))
7676 let myAddressString = toString(this)
77- $Tuple2(invoke(factory, "", [myAddressString, "WAVES"], nil), myAddressString)
77+ $Tuple2(invoke(factory, "getPoolLeaseConfigREADONLY", [myAddressString, "WAVES"], nil), myAddressString)
7878 }
7979
8080
8181 func deposit (wavesAmount) = {
8282 let proxy = getProxyAddress()
8383 let currentAdditionalBalance = getIntegerOrZero(keyAdditionalBalance)
8484 if ((currentAdditionalBalance == currentAdditionalBalance))
8585 then {
8686 let currentSWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
8787 if ((currentSWavesBalance == currentSWavesBalance))
8888 then if ((wavesAmount > 0))
8989 then {
9090 let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(unit, wavesAmount)])
9191 if ((depositInvoke == depositInvoke))
9292 then match depositInvoke {
9393 case receivedSWaves: Int =>
9494 let newAdditionalBalance = (currentAdditionalBalance + wavesAmount)
9595 let newSWavesBalance = (currentSWavesBalance + receivedSWaves)
9696 [IntegerEntry(keyAdditionalBalance, newAdditionalBalance), IntegerEntry(keySWavesAdditionalBalance, newSWavesBalance)]
9797 case _ =>
9898 nil
9999 }
100100 else throw("Strict value is not equal to itself.")
101101 }
102102 else nil
103103 else throw("Strict value is not equal to itself.")
104104 }
105105 else throw("Strict value is not equal to itself.")
106106 }
107107
108108
109109 func withdraw (wavesAmount) = {
110110 let proxy = getProxyAddress()
111111 let currentAdditionalBalance = getIntegerOrZero(keyAdditionalBalance)
112112 if ((currentAdditionalBalance == currentAdditionalBalance))
113113 then {
114114 let currentSWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
115115 if ((currentSWavesBalance == currentSWavesBalance))
116116 then {
117117 let currentProxyRate = getRate()
118118 if ((currentProxyRate == currentProxyRate))
119119 then {
120120 let sendSWavesAmount = fraction(MULT12, wavesAmount, currentProxyRate)
121121 if ((sendSWavesAmount > 0))
122122 then {
123123 let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(getSWavesId(), sendSWavesAmount)])
124124 if ((withdrawInvoke == withdrawInvoke))
125125 then match withdrawInvoke {
126126 case receivedWaves: Int =>
127127 let newAdditionalBalance = (currentAdditionalBalance - receivedWaves)
128128 let newSWavesBalance = (currentSWavesBalance - sendSWavesAmount)
129129 [IntegerEntry(keyAdditionalBalance, newAdditionalBalance), IntegerEntry(keySWavesAdditionalBalance, newSWavesBalance)]
130130 case _ =>
131131 nil
132132 }
133133 else throw("Strict value is not equal to itself.")
134134 }
135135 else nil
136136 }
137137 else throw("Strict value is not equal to itself.")
138138 }
139139 else throw("Strict value is not equal to itself.")
140140 }
141141 else throw("Strict value is not equal to itself.")
142142 }
143143
144144
145145 func rebalanceInternal (targetRatio) = {
146146 let availableBalance = wavesBalance(this).available
147147 if ((availableBalance == availableBalance))
148148 then {
149149 let additionalBalance = getIntegerOrZero(keyAdditionalBalance)
150150 if ((additionalBalance == additionalBalance))
151151 then {
152152 let wholeBalance = max([0, ((availableBalance + additionalBalance) - getMinBalance())])
153153 let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100)
154154 let diff = (additionalBalance - targetAdditionalBalance)
155155 if ((diff == 0))
156156 then nil
157157 else if ((0 > diff))
158158 then {
159159 let sendWavesAmount = -(diff)
160160 deposit(sendWavesAmount)
161161 }
162162 else {
163163 let getWavesAmount = diff
164164 withdraw(getWavesAmount)
165165 }
166166 }
167167 else throw("Strict value is not equal to itself.")
168168 }
169169 else throw("Strict value is not equal to itself.")
170170 }
171171
172172
173173 @Callable(i)
174174 func rebalanceRatio (targetRatio) = rebalanceInternal(targetRatio)
175175
176176
177177
178178 @Callable(i)
179179 func rebalance () = rebalanceInternal(getTargetRatio())
180180
181181

github/deemru/w8io/026f985 
31.03 ms