tx · ATWBUALNB8NX7CB4WWbq32im7GoaRPNNJPrsrXm78aHG

3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h:  -0.01000000 Waves

2023.04.04 10:19 [2519519] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves

{ "type": 13, "id": "ATWBUALNB8NX7CB4WWbq32im7GoaRPNNJPrsrXm78aHG", "fee": 1000000, "feeAssetId": null, "timestamp": 1680592796467, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "4tU13cR7HDokiCyiQ2ogGBf3XDumNmyo87cEWEsmPXsVn8pbQk7daw4DtWtTPp7ujxHi2xT5TxBbxNb61wrfAVxx" ], "script": "base64:BgIJCAISABIDCgEBEgADU0VQAgJfXwAMY29udHJhY3RGaWxlAg5yZWJhbGFuY2UucmlkZQARa2V5RmFjdG9yeUFkZHJlc3MCCyVzX19mYWN0b3J5ARRrZXlBZGRpdGlvbmFsQmFsYW5jZQEHYXNzZXRJZAkAuQkCCQDMCAICBCVzJXMJAMwIAgIRYWRkaXRpb25hbEJhbGFuY2UJAMwIAgUHYXNzZXRJZAUDbmlsBQNTRVABHGtleUludGVybmFsQWRkaXRpb25hbEJhbGFuY2UBB2Fzc2V0SWQJALkJAgkAzAgCAgQlcyVzCQDMCAICGWludGVybmFsQWRkaXRpb25hbEJhbGFuY2UJAMwIAgUHYXNzZXRJZAUDbmlsBQNTRVABFmtleVN0YWtpbmdBc3NldEJhbGFuY2UBB2Fzc2V0SWQJALkJAgkAzAgCAgQlcyVzCQDMCAICE3N0YWtpbmdBc3NldEJhbGFuY2UJAMwIAgUHYXNzZXRJZAUDbmlsBQNTRVABFGdldEFkZGl0aW9uYWxCYWxhbmNlAQdhc3NldElkCQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMJARRrZXlBZGR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lYmFsYW5jZTIBBXJhdGlvCQEPcmViYWxhbmNlQXNzZXQyAgIFV0FWRVMFBXJhdGlvAE8NoKg=", "height": 2519519, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EVWMpF8k1zCAFsSpYSVSPX5GeCi5n3UCiBeuc62qepDN Next: 8RskADFKd1rom1ZhBPsKSy7n9YFc7cwcJZ3eDwcEtnbE Diff:
OldNewDifferences
5757 let currentAdditionalBalance = getAdditionalBalance(assetId)
5858 if ((currentAdditionalBalance == currentAdditionalBalance))
5959 then {
60- let currentInternalAdditionalBalance = getInternalAdditionalBalance(assetId)
61- if ((currentInternalAdditionalBalance == currentInternalAdditionalBalance))
60+ let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId)
61+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
6262 then {
63- let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId)
64- if ((currentStakingAssetBalance == currentStakingAssetBalance))
63+ let asset = parseAssetId(assetId)
64+ if ((amount > 0))
6565 then {
66- let asset = if ((assetId == "WAVES"))
67- then unit
68- else fromBase58String(assetId)
69- if ((amount > 0))
70- then {
71- let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)])
72- if ((depositInvoke == depositInvoke))
73- then match depositInvoke {
74- case receivedStakingAsset: Int =>
75- let newInternalAdditionalBalance = (currentInternalAdditionalBalance + amount)
76- let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset)
77- let additionalBalance = (newInternalAdditionalBalance - getStakingAssetBalance(assetId))
78-[IntegerEntry(keyInternalAdditionalBalance(assetId), newInternalAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), IntegerEntry(keyAdditionalBalance(assetId), additionalBalance)]
79- case _ =>
80- nil
81- }
82- else throw("Strict value is not equal to itself.")
83- }
84- else nil
66+ let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)])
67+ if ((depositInvoke == depositInvoke))
68+ then match depositInvoke {
69+ case receivedStakingAsset: Int =>
70+ let newAdditionalBalance = (currentAdditionalBalance + amount)
71+ let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset)
72+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)]
73+ case _ =>
74+ nil
75+ }
76+ else throw("Strict value is not equal to itself.")
8577 }
86- else throw("Strict value is not equal to itself.")
78+ else nil
8779 }
8880 else throw("Strict value is not equal to itself.")
8981 }
167159
168160 func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) {
169161 case a: (Boolean, Int, Int, String, String, Int, String) =>
170- let $t052565365 = a
171- let isLeasable = $t052565365._1
172- let leasedRatio = $t052565365._2
173- let minBalance = $t052565365._3
174- let proxyAddress = $t052565365._4
175- let proxyAssetId = $t052565365._5
176- let proxyRateMul = $t052565365._6
177- let stakingProfitAddress = $t052565365._7
162+ let $t048124921 = a
163+ let isLeasable = $t048124921._1
164+ let leasedRatio = $t048124921._2
165+ let minBalance = $t048124921._3
166+ let proxyAddress = $t048124921._4
167+ let proxyAssetId = $t048124921._5
168+ let proxyRateMul = $t048124921._6
169+ let stakingProfitAddress = $t048124921._7
178170 if (isLeasable)
179171 then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
180172 else nil
185177
186178 func rebalanceAsset2 (assetId,ratio) = match getLeaseProxyConfig(assetId) {
187179 case a: (Boolean, Int, Int, String, String, Int, String) =>
188- let $t058415950 = a
189- let isLeasable = $t058415950._1
190- let leasedRatio = $t058415950._2
191- let minBalance = $t058415950._3
192- let proxyAddress = $t058415950._4
193- let proxyAssetId = $t058415950._5
194- let proxyRateMul = $t058415950._6
195- let stakingProfitAddress = $t058415950._7
180+ let $t053975506 = a
181+ let isLeasable = $t053975506._1
182+ let leasedRatio = $t053975506._2
183+ let minBalance = $t053975506._3
184+ let proxyAddress = $t053975506._4
185+ let proxyAssetId = $t053975506._5
186+ let proxyRateMul = $t053975506._6
187+ let stakingProfitAddress = $t053975506._7
196188 if (isLeasable)
197189 then rebalanceInternal(ratio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
198190 else nil
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let contractFile = "rebalance.ride"
77
88 let keyFactoryAddress = "%s__factory"
99
1010 func keyAdditionalBalance (assetId) = makeString(["%s%s", "additionalBalance", assetId], SEP)
1111
1212
1313 func keyInternalAdditionalBalance (assetId) = makeString(["%s%s", "internalAdditionalBalance", assetId], SEP)
1414
1515
1616 func keyStakingAssetBalance (assetId) = makeString(["%s%s", "stakingAssetBalance", assetId], SEP)
1717
1818
1919 func getAdditionalBalance (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0)
2020
2121
2222 func getInternalAdditionalBalance (assetId) = valueOrElse(getInteger(this, keyInternalAdditionalBalance(assetId)), 0)
2323
2424
2525 func getStakingAssetBalance (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0)
2626
2727
2828 func throwError (errorMsg) = throw(((contractFile + ": ") + errorMsg))
2929
3030
3131 func parseAssetId (input) = if ((input == "WAVES"))
3232 then unit
3333 else fromBase58String(input)
3434
3535
3636 func getRate (proxy) = {
3737 let inv = invoke(proxy, "getRate", nil, nil)
3838 if ((inv == inv))
3939 then match inv {
4040 case s: String =>
4141 parseIntValue(s)
4242 case _ =>
4343 throwError("getRate() returned zero")
4444 }
4545 else throw("Strict value is not equal to itself.")
4646 }
4747
4848
4949 func getLeaseProxyConfig (assetId) = {
5050 let factory = addressFromStringValue(valueOrElse(getString(keyFactoryAddress), ""))
5151 let myAddressString = toString(this)
5252 invoke(factory, "getPoolLeaseConfigREADONLY", [myAddressString, assetId], nil)
5353 }
5454
5555
5656 func deposit (assetId,amount,stakingAssetId,proxy) = {
5757 let currentAdditionalBalance = getAdditionalBalance(assetId)
5858 if ((currentAdditionalBalance == currentAdditionalBalance))
5959 then {
60- let currentInternalAdditionalBalance = getInternalAdditionalBalance(assetId)
61- if ((currentInternalAdditionalBalance == currentInternalAdditionalBalance))
60+ let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId)
61+ if ((currentStakingAssetBalance == currentStakingAssetBalance))
6262 then {
63- let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId)
64- if ((currentStakingAssetBalance == currentStakingAssetBalance))
63+ let asset = parseAssetId(assetId)
64+ if ((amount > 0))
6565 then {
66- let asset = if ((assetId == "WAVES"))
67- then unit
68- else fromBase58String(assetId)
69- if ((amount > 0))
70- then {
71- let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)])
72- if ((depositInvoke == depositInvoke))
73- then match depositInvoke {
74- case receivedStakingAsset: Int =>
75- let newInternalAdditionalBalance = (currentInternalAdditionalBalance + amount)
76- let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset)
77- let additionalBalance = (newInternalAdditionalBalance - getStakingAssetBalance(assetId))
78-[IntegerEntry(keyInternalAdditionalBalance(assetId), newInternalAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), IntegerEntry(keyAdditionalBalance(assetId), additionalBalance)]
79- case _ =>
80- nil
81- }
82- else throw("Strict value is not equal to itself.")
83- }
84- else nil
66+ let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)])
67+ if ((depositInvoke == depositInvoke))
68+ then match depositInvoke {
69+ case receivedStakingAsset: Int =>
70+ let newAdditionalBalance = (currentAdditionalBalance + amount)
71+ let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset)
72+[IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)]
73+ case _ =>
74+ nil
75+ }
76+ else throw("Strict value is not equal to itself.")
8577 }
86- else throw("Strict value is not equal to itself.")
78+ else nil
8779 }
8880 else throw("Strict value is not equal to itself.")
8981 }
9082 else throw("Strict value is not equal to itself.")
9183 }
9284
9385
9486 func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = {
9587 let currentAdditionalBalance = getAdditionalBalance(assetId)
9688 if ((currentAdditionalBalance == currentAdditionalBalance))
9789 then {
9890 let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId)
9991 if ((currentStakingAssetBalance == currentStakingAssetBalance))
10092 then {
10193 let currentProxyRate = getRate(proxy)
10294 if ((currentProxyRate == currentProxyRate))
10395 then {
10496 let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance)
10597 let stakingAsset = parseAssetId(stakingAssetId)
10698 let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate)
10799 let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate)
108100 let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)])
109101 if ((sendStakingAssetAmount > 0))
110102 then {
111103 let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)])
112104 if ((withdrawInvoke == withdrawInvoke))
113105 then match withdrawInvoke {
114106 case receivedAssets: Int =>
115107 let newAdditionalBalance = (currentAdditionalBalance - receivedAssets)
116108 let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount)
117109 [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)]
118110 case _ =>
119111 nil
120112 }
121113 else throw("Strict value is not equal to itself.")
122114 }
123115 else nil
124116 }
125117 else throw("Strict value is not equal to itself.")
126118 }
127119 else throw("Strict value is not equal to itself.")
128120 }
129121 else throw("Strict value is not equal to itself.")
130122 }
131123
132124
133125 func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = {
134126 let currentAdditionalBalance = getAdditionalBalance(assetId)
135127 if ((currentAdditionalBalance == currentAdditionalBalance))
136128 then {
137129 let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId)
138130 if ((currentStakingAssetBalance == currentStakingAssetBalance))
139131 then {
140132 let availableBalance = if ((assetId == "WAVES"))
141133 then wavesBalance(this).available
142134 else assetBalance(this, fromBase58String(assetId))
143135 if ((availableBalance == availableBalance))
144136 then {
145137 let wholeBalance = max([0, ((availableBalance + currentAdditionalBalance) - minBalance)])
146138 let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100)
147139 let diff = (currentAdditionalBalance - targetAdditionalBalance)
148140 if ((diff == 0))
149141 then nil
150142 else if ((0 > diff))
151143 then {
152144 let sendAssetAmount = -(diff)
153145 deposit(assetId, sendAssetAmount, stakingAssetId, proxy)
154146 }
155147 else {
156148 let getAssetAmount = diff
157149 withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress)
158150 }
159151 }
160152 else throw("Strict value is not equal to itself.")
161153 }
162154 else throw("Strict value is not equal to itself.")
163155 }
164156 else throw("Strict value is not equal to itself.")
165157 }
166158
167159
168160 func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) {
169161 case a: (Boolean, Int, Int, String, String, Int, String) =>
170- let $t052565365 = a
171- let isLeasable = $t052565365._1
172- let leasedRatio = $t052565365._2
173- let minBalance = $t052565365._3
174- let proxyAddress = $t052565365._4
175- let proxyAssetId = $t052565365._5
176- let proxyRateMul = $t052565365._6
177- let stakingProfitAddress = $t052565365._7
162+ let $t048124921 = a
163+ let isLeasable = $t048124921._1
164+ let leasedRatio = $t048124921._2
165+ let minBalance = $t048124921._3
166+ let proxyAddress = $t048124921._4
167+ let proxyAssetId = $t048124921._5
168+ let proxyRateMul = $t048124921._6
169+ let stakingProfitAddress = $t048124921._7
178170 if (isLeasable)
179171 then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
180172 else nil
181173 case _ =>
182174 throwError((("[" + assetId) + "] Rebalance error"))
183175 }
184176
185177
186178 func rebalanceAsset2 (assetId,ratio) = match getLeaseProxyConfig(assetId) {
187179 case a: (Boolean, Int, Int, String, String, Int, String) =>
188- let $t058415950 = a
189- let isLeasable = $t058415950._1
190- let leasedRatio = $t058415950._2
191- let minBalance = $t058415950._3
192- let proxyAddress = $t058415950._4
193- let proxyAssetId = $t058415950._5
194- let proxyRateMul = $t058415950._6
195- let stakingProfitAddress = $t058415950._7
180+ let $t053975506 = a
181+ let isLeasable = $t053975506._1
182+ let leasedRatio = $t053975506._2
183+ let minBalance = $t053975506._3
184+ let proxyAddress = $t053975506._4
185+ let proxyAssetId = $t053975506._5
186+ let proxyRateMul = $t053975506._6
187+ let stakingProfitAddress = $t053975506._7
196188 if (isLeasable)
197189 then rebalanceInternal(ratio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress))
198190 else nil
199191 case _ =>
200192 throwError((("[" + assetId) + "] Rebalance error"))
201193 }
202194
203195
204196 @Callable(i)
205197 func rebalance () = rebalanceAsset("WAVES")
206198
207199
208200
209201 @Callable(i)
210202 func rebalance2 (ratio) = rebalanceAsset2("WAVES", ratio)
211203
212204

github/deemru/w8io/026f985 
51.25 ms