tx · GuWtKs3nYMdz2tUqzSF3Xmi9nZzLLUmXVtpq8jcdRpEn

3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h:  -0.05000000 Waves

2023.03.29 14:45 [2511188] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves

{ "type": 13, "id": "GuWtKs3nYMdz2tUqzSF3Xmi9nZzLLUmXVtpq8jcdRpEn", "fee": 5000000, "feeAssetId": null, "timestamp": 1680090396813, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "5Jxs8ZaNV1bQLe1AT1emJc6UKoacfQrVYqLRr58W5TGXF2e6oL84kMdaGjNFjofvnhJ5fK6u9VBH9kTdYwa3Cqs3" ], "script": "base64:BgIJCAISAwoBARIAFAAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIaJXNfX2FkZGl0aW9uYWxXYXZlc0JhbGFuY2UAGmtleVNXYXZlc0FkZGl0aW9uYWxCYWxhbmNlAhElc19fc1dhdmVzQmFsYW5jZQAQa2V5U1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQAD2tleVByb3h5QWRkcmVzcwIQJXNfX3Byb3h5QWRkcmVzcwANa2V5TWluQmFsYW5jZQITJXNfX21pbldhdmVzQmFsYW5jZQARa2V5RmFjdG9yeUFkZHJlc3MCCyVzX19mYWN0b3J5AAZNVUxUMTIAgKCUpY0dARBnZXRJbnRlZ2VyT3JaZXJvAQppbnRlZ2VyS2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFCmludGVnZXJLZXkDCQABAgUHJG1hdGNoMAIDSW50BAN2YWwFByRtYXRjaDAFA3ZhbAAAARBnZXRTdHJpbmdP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bGFuY2UJAJYDAQkAzAgCAAAJAMwIAgkAZQIJAGQCBRBhdmFpbGFibGVCYWxhbmNlBRFhZGRpdGlvbmFsQmFsYW5jZQkBDWdldE1pbkJhbGFuY2UABQNuaWwEF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlCQBrAwULdGFyZ2V0UmF0aW8FDHdob2xlQmFsYW5jZQBkBARkaWZmCQBlAgURYWRkaXRpb25hbEJhbGFuY2UFF3RhcmdldEFkZGl0aW9uYWxCYWxhbmNlAwkAAAIFBGRpZmYAAAUDbmlsAwkAZgIAAAUEZGlmZgQPc2VuZFdhdmVzQW1vdW50CQEBLQEFBGRpZmYJAQdkZXBvc2l0AQUPc2VuZFdhdmVzQW1vdW50BA5nZXRXYXZlc0Ftb3VudAUEZGlmZgkBCHdpdGhkcmF3AQUOZ2V0V2F2ZXNBbW91bnQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4CAWkBDnJlYmFsYW5jZVJhdGlvAQt0YXJnZXRSYXRpbwkBEXJlYmFsYW5jZUludGVybmFsAQULdGFyZ2V0UmF0aW8BaQEJcmViYWxhbmNlAAkBEXJlYmFsYW5jZUludGVybmFsAQkBDmdldFRhcmdldFJhdGlvAABOjxUe", "height": 2511188, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9B5o6xrQxZesRAhzUguYrZiAsQDiEBE8rwd8j9ahfLaN Next: AMUwG36YQv66tpSkTNkVUyUeaCsDCK5rdczmaWj9tJvc Diff:
OldNewDifferences
1414 let keyProxyAddress = "%s__proxyAddress"
1515
1616 let keyMinBalance = "%s__minWavesBalance"
17+
18+let keyFactoryAddress = "%s__factory"
1719
1820 let MULT12 = 1000000000000
1921
6769
6870
6971 func getSWavesId () = fromBase58String(getStringOrThrow(keySWavesAssetId))
72+
73+
74+func getLeaseProxyConfig () = {
75+ let factory = addressFromStringValue(valueOrElse(getString(keyFactoryAddress), ""))
76+ let myAddressString = toString(this)
77+ $Tuple2(invoke(factory, "", [myAddressString, "WAVES"], nil), myAddressString)
78+ }
7079
7180
7281 func deposit (wavesAmount) = {
134143
135144
136145 func rebalanceInternal (targetRatio) = {
137- let regularBalance = wavesBalance(this).regular
138- if ((regularBalance == regularBalance))
146+ let availableBalance = wavesBalance(this).available
147+ if ((availableBalance == availableBalance))
139148 then {
140149 let additionalBalance = getIntegerOrZero(keyAdditionalBalance)
141150 if ((additionalBalance == additionalBalance))
142151 then {
143- let wholeBalance = max([0, ((regularBalance + additionalBalance) - getMinBalance())])
152+ let wholeBalance = max([0, ((availableBalance + additionalBalance) - getMinBalance())])
144153 let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100)
145154 let diff = (additionalBalance - targetAdditionalBalance)
146155 if ((diff == 0))
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"
17+
18+let keyFactoryAddress = "%s__factory"
1719
1820 let MULT12 = 1000000000000
1921
2022 func getIntegerOrZero (integerKey) = match getInteger(this, integerKey) {
2123 case val: Int =>
2224 val
2325 case _ =>
2426 0
2527 }
2628
2729
2830 func getStringOrThrow (stringKey) = match getString(this, stringKey) {
2931 case s: String =>
3032 s
3133 case _ =>
3234 throw((("[" + stringKey) + "] is empty"))
3335 }
3436
3537
3638 func getTargetRatio () = match getInteger(keysTargetRatio) {
3739 case ratio: Int =>
3840 min([100, max([0, ratio])])
3941 case _ =>
4042 0
4143 }
4244
4345
4446 func getMinBalance () = match getInteger(keyMinBalance) {
4547 case i: Int =>
4648 max([0, i])
4749 case _ =>
4850 0
4951 }
5052
5153
5254 func getRate () = {
5355 let proxy = addressFromStringValue(getStringOrThrow(keyProxyAddress))
5456 let inv = invoke(proxy, "getRate", nil, nil)
5557 if ((inv == inv))
5658 then match inv {
5759 case s: String =>
5860 parseIntValue(s)
5961 case _ =>
6062 throw("Rate is zero (0)")
6163 }
6264 else throw("Strict value is not equal to itself.")
6365 }
6466
6567
6668 func getProxyAddress () = addressFromStringValue(getStringOrThrow(keyProxyAddress))
6769
6870
6971 func getSWavesId () = fromBase58String(getStringOrThrow(keySWavesAssetId))
72+
73+
74+func getLeaseProxyConfig () = {
75+ let factory = addressFromStringValue(valueOrElse(getString(keyFactoryAddress), ""))
76+ let myAddressString = toString(this)
77+ $Tuple2(invoke(factory, "", [myAddressString, "WAVES"], nil), myAddressString)
78+ }
7079
7180
7281 func deposit (wavesAmount) = {
7382 let proxy = getProxyAddress()
7483 let currentAdditionalBalance = getIntegerOrZero(keyAdditionalBalance)
7584 if ((currentAdditionalBalance == currentAdditionalBalance))
7685 then {
7786 let currentSWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
7887 if ((currentSWavesBalance == currentSWavesBalance))
7988 then if ((wavesAmount > 0))
8089 then {
8190 let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(unit, wavesAmount)])
8291 if ((depositInvoke == depositInvoke))
8392 then match depositInvoke {
8493 case receivedSWaves: Int =>
8594 let newAdditionalBalance = (currentAdditionalBalance + wavesAmount)
8695 let newSWavesBalance = (currentSWavesBalance + receivedSWaves)
8796 [IntegerEntry(keyAdditionalBalance, newAdditionalBalance), IntegerEntry(keySWavesAdditionalBalance, newSWavesBalance)]
8897 case _ =>
8998 nil
9099 }
91100 else throw("Strict value is not equal to itself.")
92101 }
93102 else nil
94103 else throw("Strict value is not equal to itself.")
95104 }
96105 else throw("Strict value is not equal to itself.")
97106 }
98107
99108
100109 func withdraw (wavesAmount) = {
101110 let proxy = getProxyAddress()
102111 let currentAdditionalBalance = getIntegerOrZero(keyAdditionalBalance)
103112 if ((currentAdditionalBalance == currentAdditionalBalance))
104113 then {
105114 let currentSWavesBalance = getIntegerOrZero(keySWavesAdditionalBalance)
106115 if ((currentSWavesBalance == currentSWavesBalance))
107116 then {
108117 let currentProxyRate = getRate()
109118 if ((currentProxyRate == currentProxyRate))
110119 then {
111120 let sendSWavesAmount = fraction(MULT12, wavesAmount, currentProxyRate)
112121 if ((sendSWavesAmount > 0))
113122 then {
114123 let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(getSWavesId(), sendSWavesAmount)])
115124 if ((withdrawInvoke == withdrawInvoke))
116125 then match withdrawInvoke {
117126 case receivedWaves: Int =>
118127 let newAdditionalBalance = (currentAdditionalBalance - receivedWaves)
119128 let newSWavesBalance = (currentSWavesBalance - sendSWavesAmount)
120129 [IntegerEntry(keyAdditionalBalance, newAdditionalBalance), IntegerEntry(keySWavesAdditionalBalance, newSWavesBalance)]
121130 case _ =>
122131 nil
123132 }
124133 else throw("Strict value is not equal to itself.")
125134 }
126135 else nil
127136 }
128137 else throw("Strict value is not equal to itself.")
129138 }
130139 else throw("Strict value is not equal to itself.")
131140 }
132141 else throw("Strict value is not equal to itself.")
133142 }
134143
135144
136145 func rebalanceInternal (targetRatio) = {
137- let regularBalance = wavesBalance(this).regular
138- if ((regularBalance == regularBalance))
146+ let availableBalance = wavesBalance(this).available
147+ if ((availableBalance == availableBalance))
139148 then {
140149 let additionalBalance = getIntegerOrZero(keyAdditionalBalance)
141150 if ((additionalBalance == additionalBalance))
142151 then {
143- let wholeBalance = max([0, ((regularBalance + additionalBalance) - getMinBalance())])
152+ let wholeBalance = max([0, ((availableBalance + additionalBalance) - getMinBalance())])
144153 let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100)
145154 let diff = (additionalBalance - targetAdditionalBalance)
146155 if ((diff == 0))
147156 then nil
148157 else if ((0 > diff))
149158 then {
150159 let sendWavesAmount = -(diff)
151160 deposit(sendWavesAmount)
152161 }
153162 else {
154163 let getWavesAmount = diff
155164 withdraw(getWavesAmount)
156165 }
157166 }
158167 else throw("Strict value is not equal to itself.")
159168 }
160169 else throw("Strict value is not equal to itself.")
161170 }
162171
163172
164173 @Callable(i)
165174 func rebalanceRatio (targetRatio) = rebalanceInternal(targetRatio)
166175
167176
168177
169178 @Callable(i)
170179 func rebalance () = rebalanceInternal(getTargetRatio())
171180
172181

github/deemru/w8io/026f985 
37.90 ms