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:BgIJCAISABIDCgEBEgADU0VQAgJfXwAMY29udHJhY3RGaWxlAg5yZWJhbGFuY2UucmlkZQARa2V5RmFjdG9yeUFkZHJlc3MCCyVzX19mYWN0b3J5ARRrZXlBZGRpdGlvbmFsQmFsYW5jZQEHYXNzZXRJZAkAuQkCCQDMCAICBCVzJXMJAMwIAgIRYWRkaXRpb25hbEJhbGFuY2UJAMwIAgUHYXNzZXRJZAUDbmlsBQNTRVABHGtleUludGVybmFsQWRkaXRpb25hbEJhbGFuY2UBB2Fzc2V0SWQJALkJAgkAzAgCAgQlcyVzCQDMCAICGWludGVybmFsQWRkaXRpb25hbEJhbGFuY2UJAMwIAgUHYXNzZXRJZAUDbmlsBQNTRVABFmtleVN0YWtpbmdBc3NldEJhbGFuY2UBB2Fzc2V0SWQJALkJAgkAzAgCAgQlcyVzCQDMCAICE3N0YWtpbmdBc3NldEJhbGFuY2UJAMwIAgUHYXNzZXRJZAUDbmlsBQNTRVABFGdldEFkZGl0aW9uYWxCYWxhbmNlAQdhc3NldElkCQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMJARRrZXlBZGRp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YmFsYW5jZTIBBXJhdGlvCQEPcmViYWxhbmNlQXNzZXQyAgIFV0FWRVMFBXJhdGlvAE8NoKg=", "height": 2519519, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EVWMpF8k1zCAFsSpYSVSPX5GeCi5n3UCiBeuc62qepDN Next: 8RskADFKd1rom1ZhBPsKSy7n9YFc7cwcJZ3eDwcEtnbE Diff:
Old | New | Differences | |
---|---|---|---|
57 | 57 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
58 | 58 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
59 | 59 | then { | |
60 | - | let | |
61 | - | if (( | |
60 | + | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
61 | + | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
62 | 62 | then { | |
63 | - | let | |
64 | - | if (( | |
63 | + | let asset = parseAssetId(assetId) | |
64 | + | if ((amount > 0)) | |
65 | 65 | 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.") | |
85 | 77 | } | |
86 | - | else | |
78 | + | else nil | |
87 | 79 | } | |
88 | 80 | else throw("Strict value is not equal to itself.") | |
89 | 81 | } | |
167 | 159 | ||
168 | 160 | func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) { | |
169 | 161 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
170 | - | let $ | |
171 | - | let isLeasable = $ | |
172 | - | let leasedRatio = $ | |
173 | - | let minBalance = $ | |
174 | - | let proxyAddress = $ | |
175 | - | let proxyAssetId = $ | |
176 | - | let proxyRateMul = $ | |
177 | - | let stakingProfitAddress = $ | |
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 | |
178 | 170 | if (isLeasable) | |
179 | 171 | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
180 | 172 | else nil | |
185 | 177 | ||
186 | 178 | func rebalanceAsset2 (assetId,ratio) = match getLeaseProxyConfig(assetId) { | |
187 | 179 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
188 | - | let $ | |
189 | - | let isLeasable = $ | |
190 | - | let leasedRatio = $ | |
191 | - | let minBalance = $ | |
192 | - | let proxyAddress = $ | |
193 | - | let proxyAssetId = $ | |
194 | - | let proxyRateMul = $ | |
195 | - | let stakingProfitAddress = $ | |
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 | |
196 | 188 | if (isLeasable) | |
197 | 189 | then rebalanceInternal(ratio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
198 | 190 | else nil |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let contractFile = "rebalance.ride" | |
7 | 7 | ||
8 | 8 | let keyFactoryAddress = "%s__factory" | |
9 | 9 | ||
10 | 10 | func keyAdditionalBalance (assetId) = makeString(["%s%s", "additionalBalance", assetId], SEP) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func keyInternalAdditionalBalance (assetId) = makeString(["%s%s", "internalAdditionalBalance", assetId], SEP) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func keyStakingAssetBalance (assetId) = makeString(["%s%s", "stakingAssetBalance", assetId], SEP) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func getAdditionalBalance (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0) | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func getInternalAdditionalBalance (assetId) = valueOrElse(getInteger(this, keyInternalAdditionalBalance(assetId)), 0) | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func getStakingAssetBalance (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func throwError (errorMsg) = throw(((contractFile + ": ") + errorMsg)) | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func parseAssetId (input) = if ((input == "WAVES")) | |
32 | 32 | then unit | |
33 | 33 | else fromBase58String(input) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getRate (proxy) = { | |
37 | 37 | let inv = invoke(proxy, "getRate", nil, nil) | |
38 | 38 | if ((inv == inv)) | |
39 | 39 | then match inv { | |
40 | 40 | case s: String => | |
41 | 41 | parseIntValue(s) | |
42 | 42 | case _ => | |
43 | 43 | throwError("getRate() returned zero") | |
44 | 44 | } | |
45 | 45 | else throw("Strict value is not equal to itself.") | |
46 | 46 | } | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getLeaseProxyConfig (assetId) = { | |
50 | 50 | let factory = addressFromStringValue(valueOrElse(getString(keyFactoryAddress), "")) | |
51 | 51 | let myAddressString = toString(this) | |
52 | 52 | invoke(factory, "getPoolLeaseConfigREADONLY", [myAddressString, assetId], nil) | |
53 | 53 | } | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | func deposit (assetId,amount,stakingAssetId,proxy) = { | |
57 | 57 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
58 | 58 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
59 | 59 | then { | |
60 | - | let | |
61 | - | if (( | |
60 | + | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
61 | + | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
62 | 62 | then { | |
63 | - | let | |
64 | - | if (( | |
63 | + | let asset = parseAssetId(assetId) | |
64 | + | if ((amount > 0)) | |
65 | 65 | 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.") | |
85 | 77 | } | |
86 | - | else | |
78 | + | else nil | |
87 | 79 | } | |
88 | 80 | else throw("Strict value is not equal to itself.") | |
89 | 81 | } | |
90 | 82 | else throw("Strict value is not equal to itself.") | |
91 | 83 | } | |
92 | 84 | ||
93 | 85 | ||
94 | 86 | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = { | |
95 | 87 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
96 | 88 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
97 | 89 | then { | |
98 | 90 | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
99 | 91 | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
100 | 92 | then { | |
101 | 93 | let currentProxyRate = getRate(proxy) | |
102 | 94 | if ((currentProxyRate == currentProxyRate)) | |
103 | 95 | then { | |
104 | 96 | let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance) | |
105 | 97 | let stakingAsset = parseAssetId(stakingAssetId) | |
106 | 98 | let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate) | |
107 | 99 | let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate) | |
108 | 100 | let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)]) | |
109 | 101 | if ((sendStakingAssetAmount > 0)) | |
110 | 102 | then { | |
111 | 103 | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)]) | |
112 | 104 | if ((withdrawInvoke == withdrawInvoke)) | |
113 | 105 | then match withdrawInvoke { | |
114 | 106 | case receivedAssets: Int => | |
115 | 107 | let newAdditionalBalance = (currentAdditionalBalance - receivedAssets) | |
116 | 108 | let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount) | |
117 | 109 | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
118 | 110 | case _ => | |
119 | 111 | nil | |
120 | 112 | } | |
121 | 113 | else throw("Strict value is not equal to itself.") | |
122 | 114 | } | |
123 | 115 | else nil | |
124 | 116 | } | |
125 | 117 | else throw("Strict value is not equal to itself.") | |
126 | 118 | } | |
127 | 119 | else throw("Strict value is not equal to itself.") | |
128 | 120 | } | |
129 | 121 | else throw("Strict value is not equal to itself.") | |
130 | 122 | } | |
131 | 123 | ||
132 | 124 | ||
133 | 125 | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = { | |
134 | 126 | let currentAdditionalBalance = getAdditionalBalance(assetId) | |
135 | 127 | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
136 | 128 | then { | |
137 | 129 | let currentStakingAssetBalance = getStakingAssetBalance(stakingAssetId) | |
138 | 130 | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
139 | 131 | then { | |
140 | 132 | let availableBalance = if ((assetId == "WAVES")) | |
141 | 133 | then wavesBalance(this).available | |
142 | 134 | else assetBalance(this, fromBase58String(assetId)) | |
143 | 135 | if ((availableBalance == availableBalance)) | |
144 | 136 | then { | |
145 | 137 | let wholeBalance = max([0, ((availableBalance + currentAdditionalBalance) - minBalance)]) | |
146 | 138 | let targetAdditionalBalance = fraction(targetRatio, wholeBalance, 100) | |
147 | 139 | let diff = (currentAdditionalBalance - targetAdditionalBalance) | |
148 | 140 | if ((diff == 0)) | |
149 | 141 | then nil | |
150 | 142 | else if ((0 > diff)) | |
151 | 143 | then { | |
152 | 144 | let sendAssetAmount = -(diff) | |
153 | 145 | deposit(assetId, sendAssetAmount, stakingAssetId, proxy) | |
154 | 146 | } | |
155 | 147 | else { | |
156 | 148 | let getAssetAmount = diff | |
157 | 149 | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress) | |
158 | 150 | } | |
159 | 151 | } | |
160 | 152 | else throw("Strict value is not equal to itself.") | |
161 | 153 | } | |
162 | 154 | else throw("Strict value is not equal to itself.") | |
163 | 155 | } | |
164 | 156 | else throw("Strict value is not equal to itself.") | |
165 | 157 | } | |
166 | 158 | ||
167 | 159 | ||
168 | 160 | func rebalanceAsset (assetId) = match getLeaseProxyConfig(assetId) { | |
169 | 161 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
170 | - | let $ | |
171 | - | let isLeasable = $ | |
172 | - | let leasedRatio = $ | |
173 | - | let minBalance = $ | |
174 | - | let proxyAddress = $ | |
175 | - | let proxyAssetId = $ | |
176 | - | let proxyRateMul = $ | |
177 | - | let stakingProfitAddress = $ | |
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 | |
178 | 170 | if (isLeasable) | |
179 | 171 | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
180 | 172 | else nil | |
181 | 173 | case _ => | |
182 | 174 | throwError((("[" + assetId) + "] Rebalance error")) | |
183 | 175 | } | |
184 | 176 | ||
185 | 177 | ||
186 | 178 | func rebalanceAsset2 (assetId,ratio) = match getLeaseProxyConfig(assetId) { | |
187 | 179 | case a: (Boolean, Int, Int, String, String, Int, String) => | |
188 | - | let $ | |
189 | - | let isLeasable = $ | |
190 | - | let leasedRatio = $ | |
191 | - | let minBalance = $ | |
192 | - | let proxyAddress = $ | |
193 | - | let proxyAssetId = $ | |
194 | - | let proxyRateMul = $ | |
195 | - | let stakingProfitAddress = $ | |
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 | |
196 | 188 | if (isLeasable) | |
197 | 189 | then rebalanceInternal(ratio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
198 | 190 | else nil | |
199 | 191 | case _ => | |
200 | 192 | throwError((("[" + assetId) + "] Rebalance error")) | |
201 | 193 | } | |
202 | 194 | ||
203 | 195 | ||
204 | 196 | @Callable(i) | |
205 | 197 | func rebalance () = rebalanceAsset("WAVES") | |
206 | 198 | ||
207 | 199 | ||
208 | 200 | ||
209 | 201 | @Callable(i) | |
210 | 202 | func rebalance2 (ratio) = rebalanceAsset2("WAVES", ratio) | |
211 | 203 | ||
212 | 204 |
github/deemru/w8io/026f985 51.25 ms ◑