tx · GDKW3UDDBE6382rTSZo4yK5ZTPhWHDHpKEdvS7t8516c 3MvRWw2FPEimFCTGtK7qY9uAJbM7XJ4ZfJS: -0.01300000 Waves 2023.03.30 12:34 [2512505] smart account 3MvRWw2FPEimFCTGtK7qY9uAJbM7XJ4ZfJS > SELF 0.00000000 Waves
{ "type": 13, "id": "GDKW3UDDBE6382rTSZo4yK5ZTPhWHDHpKEdvS7t8516c", "fee": 1300000, "feeAssetId": null, "timestamp": 1680168870148, "version": 2, "chainId": 84, "sender": "3MvRWw2FPEimFCTGtK7qY9uAJbM7XJ4ZfJS", "senderPublicKey": "HP8sssVq1866F7CaPQJwgFrt6fsqhQjKwM84cL1wjD2a", "proofs": [ "3n9Sb5gR9PRxf1ng35EPFxjidcwKAPv5hM5tNiWx5cRYvt8T6MDR9CHK4K5E85UdqqdFAudqdoEpH7Li9vrbMwKw" ], "script": "base64:BgIcCAISBQoDCAEIEgMKAQgSAwoBCBIHCgUICAEBASkAC1NGX1BPU19UWVBFAgJTRgALV1hfUE9TX1RZUEUCAldYAAZTQ0FMRTgAgMLXLwAKRkVFX1NDQUxFNgDAhD0AFGtTRlBvb2xBQXNzZXRCYWxhbmNlAg9BX2Fzc2V0X2JhbGFuY2UAFGtTRlBvb2xCQXNzZXRCYWxhbmNlAg9CX2Fzc2V0X2JhbGFuY2UAD2tTRlBvb2xBQXNzZXRJZAIKQV9hc3NldF9pZAAPa1NGUG9vbEJBc3NldElkAgpCX2Fzc2V0X2lkAA5rU0ZQb29sU2hhcmVJZAIOc2hhcmVfYXNzZXRfaWQAEGtTRkZhcm1pbmdTdGFrZWQCFF9zaGFyZV90b2tlbnNfbG9ja2VkAA1rVXNlclBvc2l0aW9uAg5fdXNlcl9wb3NpdGlvbgARa1VzZXJQb3NpdGlvblR5cGUCE191c2VyX3Bvc2l0aW9uX3R5cGUAEGtVc2VyUG9zaXRpb25OdW0CFV91c2VyX3Bvc2l0aW9uX251bWJlcgAOa1RvdGFsUG9zaXRpb24CD190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lcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXmoGuyN", "height": 2512505, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 46drfk4cqfd98yHBmxgEe9oJDMQ4by34r7Nw4bgQoGFp Next: 7W9rSazdqpfwrYAQFrUZxSrVEtRZUeS1At15QEx6x1wd Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | let kSFPoolBAssetId = "B_asset_id" | |
19 | 19 | ||
20 | 20 | let kSFPoolShareId = "share_asset_id" | |
21 | - | ||
22 | - | let kSFPoolVersion = "version" | |
23 | 21 | ||
24 | 22 | let kSFFarmingStaked = "_share_tokens_locked" | |
25 | 23 | ||
49 | 47 | ||
50 | 48 | let kLendService = "lend_service_addr" | |
51 | 49 | ||
50 | + | let kPriceOracle = "price_oracle" | |
51 | + | ||
52 | 52 | let moneyBox = Address(fromBase58String(valueOrErrorMessage(getString(this, kMoneyBox), "No axly moneyBox address"))) | |
53 | + | ||
54 | + | let priceOracleAddr = Address(fromBase58String(valueOrErrorMessage(getString(this, kPriceOracle), "No price oracle address"))) | |
53 | 55 | ||
54 | 56 | func isSelfCall (i) = if ((i.caller == this)) | |
55 | 57 | then unit | |
69 | 71 | func getSFPoolData (poolAddr) = $Tuple5(valueOrErrorMessage(getString(poolAddr, kSFPoolAAssetId), "Can't get pool A asset id"), valueOrErrorMessage(getString(poolAddr, kSFPoolBAssetId), "Can't get pool B asset id"), valueOrErrorMessage(getInteger(poolAddr, kSFPoolAAssetBalance), "Can't get pool A asset balance"), valueOrErrorMessage(getInteger(poolAddr, kSFPoolBAssetBalance), "Can't get pool B asset balance"), valueOrErrorMessage(getString(poolAddr, kSFPoolShareId), "Can't get share asset id")) | |
70 | 72 | ||
71 | 73 | ||
72 | - | func getWXPoolData (poolAddr) = $Tuple5(valueOrErrorMessage(getString(poolAddr, kSFPoolAAssetId), "Can't get pool A asset id"), valueOrErrorMessage(getString(poolAddr, kSFPoolBAssetId), "Can't get pool B asset id"), valueOrErrorMessage(getInteger(poolAddr, kSFPoolAAssetBalance), "Can't get pool A asset balance"), valueOrErrorMessage(getInteger(poolAddr, kSFPoolBAssetBalance), "Can't get pool B asset balance"), valueOrErrorMessage(getString(poolAddr, kSFPoolShareId), "Can't get share asset id")) | |
74 | + | func getWXPoolData (poolAddr) = { | |
75 | + | let cfg = { | |
76 | + | let @ = invoke(poolAddr, "getPoolConfigWrapperREADONLY", nil, nil) | |
77 | + | if ($isInstanceOf(@, "List[Any]")) | |
78 | + | then @ | |
79 | + | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
80 | + | } | |
81 | + | if ((cfg == cfg)) | |
82 | + | then $Tuple5(valueOrErrorMessage({ | |
83 | + | let @ = cfg[4] | |
84 | + | if ($isInstanceOf(@, "String")) | |
85 | + | then @ | |
86 | + | else unit | |
87 | + | }, "Can't get pool A asset id"), valueOrErrorMessage({ | |
88 | + | let @ = cfg[5] | |
89 | + | if ($isInstanceOf(@, "String")) | |
90 | + | then @ | |
91 | + | else unit | |
92 | + | }, "Can't get pool B asset id"), 0, 0, valueOrErrorMessage({ | |
93 | + | let @ = cfg[3] | |
94 | + | if ($isInstanceOf(@, "String")) | |
95 | + | then @ | |
96 | + | else unit | |
97 | + | }, "Can't get pool LP asset id")) | |
98 | + | else throw("Strict value is not equal to itself.") | |
99 | + | } | |
73 | 100 | ||
74 | 101 | ||
75 | 102 | func getAxlyTotalPosition (pool) = valueOrElse(getInteger(this, (pool + kTotalPosition)), 0) | |
84 | 111 | ||
85 | 112 | ||
86 | 113 | func getSFFarmingAddr () = Address(fromBase58String(valueOrErrorMessage(getString(this, kSFFarmingAddr), "Can't get swopfi farming addr"))) | |
114 | + | ||
115 | + | ||
116 | + | func getWXFarmingAddr (poolAddr) = { | |
117 | + | let fContract = Address(fromBase58String(valueOrElse(getString(poolAddr, "%s__factoryContract"), "Can't get WX factory contract addr"))) | |
118 | + | let factroyCfg = split(valueOrElse(getString(fContract, "%s__factoryConfig"), "Can't get WX factory cfg"), "__") | |
119 | + | Address(fromBase58String(factroyCfg[1])) | |
120 | + | } | |
87 | 121 | ||
88 | 122 | ||
89 | 123 | func getLendSrvAddr () = Address(fromBase58String(valueOrErrorMessage(getString(this, kLendService), "Can't get lend service addr"))) | |
104 | 138 | else fromBase58String(assetId) | |
105 | 139 | ||
106 | 140 | ||
107 | - | func replanishSwopFi (user,pool,withLoan,pmtA,pmtAssetA,pmtB,pmtAssetB,balA,balB,shareId,virtualSwapTokenPay,virtualSwapTokenGet) = { | |
141 | + | func getAssetDecimals (assetId) = if ((assetId == "WAVES")) | |
142 | + | then 8 | |
143 | + | else match assetInfo(fromBase58String(assetId)) { | |
144 | + | case asset: Asset => | |
145 | + | asset.decimals | |
146 | + | case _ => | |
147 | + | throw("Can't find asset") | |
148 | + | } | |
149 | + | ||
150 | + | ||
151 | + | func replanishSwopFi (user,pool,withLoan,pmtA,pmtAssetA,pmtB,pmtAssetB,balA,balB,shareId) = { | |
108 | 152 | let shareBalanceBefore = accountBalance(fromBase58String(shareId)) | |
109 | 153 | if ((shareBalanceBefore == shareBalanceBefore)) | |
110 | 154 | then { | |
111 | 155 | let poolAddr = Address(fromBase58String(pool)) | |
112 | 156 | let ratioA = fraction(SCALE8, pmtA, balA) | |
113 | 157 | let ratioB = fraction(SCALE8, pmtB, balB) | |
114 | - | let $ | |
158 | + | let $t050435335 = if ((ratioB > ratioA)) | |
115 | 159 | then { | |
116 | 160 | let pmt = fraction(balB, ratioA, SCALE8, CEILING) | |
117 | 161 | $Tuple4(pmtA, pmt, (pmtB - pmt), pmtAssetB) | |
120 | 164 | let pmt = fraction(balA, ratioB, SCALE8, CEILING) | |
121 | 165 | $Tuple4(pmt, pmtB, (pmtA - pmt), pmtAssetA) | |
122 | 166 | } | |
123 | - | let pmtAmountA = $t045474840._1 | |
124 | - | let pmtAmountB = $t045474840._2 | |
125 | - | let change = $t045474840._3 | |
126 | - | let changeAssetId = $t045474840._4 | |
127 | - | let poolVersion = getStringValue(poolAddr, "version") | |
167 | + | let pmtAmountA = $t050435335._1 | |
168 | + | let pmtAmountB = $t050435335._2 | |
169 | + | let change = $t050435335._3 | |
170 | + | let changeAssetId = $t050435335._4 | |
128 | 171 | let inv1 = if (if ((pmtAmountA > 0)) | |
129 | 172 | then (pmtAmountB > 0) | |
130 | 173 | else false) | |
131 | 174 | then { | |
132 | 175 | let payments = [AttachedPayment(assetIdFromStr(pmtAssetA), pmtAmountA), AttachedPayment(assetIdFromStr(pmtAssetB), pmtAmountB)] | |
133 | - | if ((poolVersion == "1.0.0")) | |
134 | - | then invoke(poolAddr, "callFunction", ["replenishWithTwoTokens", ["false", "0"]], payments) | |
135 | - | else if ((poolVersion == "2.0.0")) | |
136 | - | then invoke(poolAddr, "replenishWithTwoTokensV2", [false, 0], payments) | |
137 | - | else throw("Wrong pool type") | |
176 | + | invoke(poolAddr, "callFunction", ["replenishWithTwoTokens", ["false", "0"]], payments) | |
138 | 177 | } | |
139 | 178 | else 0 | |
140 | 179 | if ((inv1 == inv1)) | |
142 | 181 | let inv2 = if ((change > 0)) | |
143 | 182 | then { | |
144 | 183 | let payments = [AttachedPayment(assetIdFromStr(changeAssetId), change)] | |
145 | - | if ((poolVersion == "1.0.0")) | |
146 | - | then { | |
147 | - | let vars = ["0", "false", "0"] | |
148 | - | invoke(poolAddr, "callFunction", ["replenishWithOneToken", vars], payments) | |
149 | - | } | |
150 | - | else if ((poolVersion == "2.0.0")) | |
151 | - | then { | |
152 | - | let vars = [virtualSwapTokenPay, virtualSwapTokenGet, false, 0] | |
153 | - | invoke(poolAddr, "replenishWithOneTokenV2", [false, 0], payments) | |
154 | - | } | |
155 | - | else throw("Wrong pool type") | |
184 | + | let vars = ["0", "false", "0"] | |
185 | + | invoke(poolAddr, "replenishWithOneTokenV2", [false, 0], payments) | |
156 | 186 | } | |
157 | 187 | else 0 | |
158 | 188 | if ((inv2 == inv2)) | |
165 | 195 | then throw("amount of staked sharetokens must be > 0") | |
166 | 196 | else { | |
167 | 197 | let inv3 = invoke(getSFFarmingAddr(), "lockShareTokens", [pool, 0], [AttachedPayment(fromBase58String(shareId), userShareForStake)]) | |
198 | + | if ((inv3 == inv3)) | |
199 | + | then { | |
200 | + | let totalAmount = getAxlyTotalPosition(pool) | |
201 | + | let newPosNum = getNewUserPositionNumber(pool, user) | |
202 | + | let baseEntry = [IntegerEntry((pool + kTotalPosition), (totalAmount + userShareForStake)), IntegerEntry((((((pool + "_") + user) + "_") + toString(newPosNum)) + kUserPosition), userShareForStake), StringEntry((((((pool + "_") + user) + "_") + toString(newPosNum)) + kUserPositionType), SF_POS_TYPE), IntegerEntry((((pool + "_") + user) + kUserPositionNum), newPosNum), ScriptTransfer(moneyBox, axlyInFee, fromBase58String(shareId))] | |
203 | + | $Tuple2(baseEntry, userShareForStake) | |
204 | + | } | |
205 | + | else throw("Strict value is not equal to itself.") | |
206 | + | } | |
207 | + | } | |
208 | + | else throw("Strict value is not equal to itself.") | |
209 | + | } | |
210 | + | else throw("Strict value is not equal to itself.") | |
211 | + | } | |
212 | + | else throw("Strict value is not equal to itself.") | |
213 | + | } | |
214 | + | ||
215 | + | ||
216 | + | func replanishWX (user,pool,withLoan,pmtA,pmtAssetA,pmtB,pmtAssetB,shareId) = { | |
217 | + | let poolAddr = Address(fromBase58String(pool)) | |
218 | + | let $t072978116 = if (if ((pmtA > 0)) | |
219 | + | then (pmtB > 0) | |
220 | + | else false) | |
221 | + | then { | |
222 | + | let evalPutInA = { | |
223 | + | let @ = invoke(poolAddr, "evaluatePutByAmountAssetREADONLY", [pmtA], nil) | |
224 | + | if ($isInstanceOf(@, "List[Any]")) | |
225 | + | then @ | |
226 | + | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
227 | + | } | |
228 | + | if ((evalPutInA == evalPutInA)) | |
229 | + | then { | |
230 | + | let evalPutInB = { | |
231 | + | let @ = invoke(poolAddr, "evaluatePutByPriceAssetREADONLY", [pmtB], nil) | |
232 | + | if ($isInstanceOf(@, "List[Any]")) | |
233 | + | then @ | |
234 | + | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
235 | + | } | |
236 | + | if ((evalPutInB == evalPutInB)) | |
237 | + | then { | |
238 | + | let lpInA = { | |
239 | + | let @ = evalPutInA[0] | |
240 | + | if ($isInstanceOf(@, "Int")) | |
241 | + | then @ | |
242 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
243 | + | } | |
244 | + | let lpInB = { | |
245 | + | let @ = evalPutInB[0] | |
246 | + | if ($isInstanceOf(@, "Int")) | |
247 | + | then @ | |
248 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
249 | + | } | |
250 | + | if ((lpInA > lpInB)) | |
251 | + | then { | |
252 | + | let pmtInB = { | |
253 | + | let @ = evalPutInB[7] | |
254 | + | if ($isInstanceOf(@, "Int")) | |
255 | + | then @ | |
256 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
257 | + | } | |
258 | + | $Tuple4(pmtA, pmtInB, (pmtB - pmtInB), pmtAssetB) | |
259 | + | } | |
260 | + | else { | |
261 | + | let pmtInA = { | |
262 | + | let @ = evalPutInB[6] | |
263 | + | if ($isInstanceOf(@, "Int")) | |
264 | + | then @ | |
265 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
266 | + | } | |
267 | + | $Tuple4(pmtInA, pmtB, (pmtA - pmtInA), pmtAssetA) | |
268 | + | } | |
269 | + | } | |
270 | + | else throw("Strict value is not equal to itself.") | |
271 | + | } | |
272 | + | else throw("Strict value is not equal to itself.") | |
273 | + | } | |
274 | + | else if ((pmtA > 0)) | |
275 | + | then $Tuple4(pmtA, pmtB, pmtA, pmtAssetA) | |
276 | + | else if ((pmtB > 0)) | |
277 | + | then $Tuple4(pmtA, pmtB, pmtB, pmtAssetB) | |
278 | + | else throw("pmts must be > 0") | |
279 | + | let pmtAmountA = $t072978116._1 | |
280 | + | let pmtAmountB = $t072978116._2 | |
281 | + | let change = $t072978116._3 | |
282 | + | let changeAssetId = $t072978116._4 | |
283 | + | let shareBalanceBefore = accountBalance(fromBase58String(shareId)) | |
284 | + | if ((shareBalanceBefore == shareBalanceBefore)) | |
285 | + | then { | |
286 | + | let inv1 = if (if ((pmtAmountA > 0)) | |
287 | + | then (pmtAmountB > 0) | |
288 | + | else false) | |
289 | + | then { | |
290 | + | let payments = [AttachedPayment(assetIdFromStr(pmtAssetA), pmtAmountA), AttachedPayment(assetIdFromStr(pmtAssetB), pmtAmountB)] | |
291 | + | invoke(poolAddr, "put", [1, false], payments) | |
292 | + | } | |
293 | + | else 0 | |
294 | + | if ((inv1 == inv1)) | |
295 | + | then { | |
296 | + | let inv2 = if ((change > 0)) | |
297 | + | then { | |
298 | + | let payments = [AttachedPayment(assetIdFromStr(changeAssetId), change)] | |
299 | + | invoke(poolAddr, "putOneTkn", [0, false], payments) | |
300 | + | } | |
301 | + | else 0 | |
302 | + | if ((inv2 == inv2)) | |
303 | + | then { | |
304 | + | let shareBalanceAfter = accountBalance(fromBase58String(shareId)) | |
305 | + | let totalShare = (shareBalanceAfter - shareBalanceBefore) | |
306 | + | let axlyInFee = fraction(totalShare, getAxlyInFee(pool, withLoan), FEE_SCALE6) | |
307 | + | let userShareForStake = (totalShare - axlyInFee) | |
308 | + | if ((0 >= userShareForStake)) | |
309 | + | then throw("amount of staked sharetokens must be > 0") | |
310 | + | else { | |
311 | + | let inv3 = invoke(getWXFarmingAddr(poolAddr), "stake", nil, [AttachedPayment(fromBase58String(shareId), userShareForStake)]) | |
168 | 312 | if ((inv3 == inv3)) | |
169 | 313 | then { | |
170 | 314 | let totalAmount = getAxlyTotalPosition(pool) | |
182 | 326 | } | |
183 | 327 | ||
184 | 328 | ||
185 | - | func replanishWX (user,pool,withLoan,pmtA,pmtAssetA,pmtB,pmtAssetB,balA,balB,shareId,virtualSwapTokenPay,virtualSwapTokenGet) = nil | |
186 | - | ||
187 | - | ||
188 | 329 | @Callable(i) | |
189 | - | func replanish (pool,borrowAmount,borrowAssetId,virtualSwapTokenPay,virtualSwapTokenGet) = { | |
190 | - | let type = valueOrErrorMessage(getString(this, (kPool + pool)), "Pool is not inited") | |
191 | - | let $t075947845 = if ((type == SF_POS_TYPE)) | |
192 | - | then getSFPoolData(Address(fromBase58String(pool))) | |
193 | - | else if ((type == WX_POS_TYPE)) | |
194 | - | then getWXPoolData(Address(fromBase58String(pool))) | |
195 | - | else throw("Wrong pool type") | |
196 | - | let AId = $t075947845._1 | |
197 | - | let BId = $t075947845._2 | |
198 | - | let balA = $t075947845._3 | |
199 | - | let balB = $t075947845._4 | |
200 | - | let shareId = $t075947845._5 | |
201 | - | let $t078498486 = if ((size(i.payments) == 2)) | |
202 | - | then if ((assetIdToStr(i.payments[0].assetId) != AId)) | |
203 | - | then throw("Wrong payment asset A") | |
204 | - | else if ((assetIdToStr(i.payments[1].assetId) != BId)) | |
205 | - | then throw("Wrong payment asset B") | |
206 | - | else $Tuple4(i.payments[0].amount, AId, i.payments[1].amount, BId) | |
207 | - | else if ((size(i.payments) == 1)) | |
208 | - | then if ((assetIdToStr(i.payments[0].assetId) == AId)) | |
209 | - | then $Tuple4(i.payments[0].amount, AId, 0, BId) | |
210 | - | else if ((assetIdToStr(i.payments[0].assetId) == BId)) | |
211 | - | then $Tuple4(0, AId, i.payments[0].amount, BId) | |
212 | - | else throw("Wrong payment") | |
213 | - | else throw("One or two payments expected") | |
214 | - | let pmtA = $t078498486._1 | |
215 | - | let pmtAssetA = $t078498486._2 | |
216 | - | let pmtB = $t078498486._3 | |
217 | - | let pmtAssetB = $t078498486._4 | |
218 | - | if ((borrowAmount > 0)) | |
219 | - | then { | |
220 | - | let request = makeString([type, toString(i.caller), pool, toString(pmtA), pmtAssetA, toString(pmtB), pmtAssetB, toString(balA), toString(balB), shareId, toString(virtualSwapTokenPay), toString(virtualSwapTokenGet), borrowAssetId, toString(borrowAmount)], ",") | |
221 | - | let newRequestId = { | |
222 | - | let @ = invoke(this, "createNewRequest", [request], nil) | |
223 | - | if ($isInstanceOf(@, "Int")) | |
224 | - | then @ | |
225 | - | else unit | |
330 | + | func replanish (pool,leverage,borrowAssetId) = if (if ((100 > leverage)) | |
331 | + | then true | |
332 | + | else (leverage > 300)) | |
333 | + | then throw("Leverage can't be <100 and >300") | |
334 | + | else { | |
335 | + | let type = valueOrErrorMessage(getString(this, (kPool + pool)), "Pool is not inited") | |
336 | + | let $t0996910220 = if ((type == SF_POS_TYPE)) | |
337 | + | then getSFPoolData(Address(fromBase58String(pool))) | |
338 | + | else if ((type == WX_POS_TYPE)) | |
339 | + | then getWXPoolData(Address(fromBase58String(pool))) | |
340 | + | else throw("Wrong pool type") | |
341 | + | let AId = $t0996910220._1 | |
342 | + | let BId = $t0996910220._2 | |
343 | + | let balA = $t0996910220._3 | |
344 | + | let balB = $t0996910220._4 | |
345 | + | let shareId = $t0996910220._5 | |
346 | + | let $t01022310860 = if ((size(i.payments) == 2)) | |
347 | + | then if ((assetIdToStr(i.payments[0].assetId) != AId)) | |
348 | + | then throw("Wrong payment asset A") | |
349 | + | else if ((assetIdToStr(i.payments[1].assetId) != BId)) | |
350 | + | then throw("Wrong payment asset B") | |
351 | + | else $Tuple4(i.payments[0].amount, AId, i.payments[1].amount, BId) | |
352 | + | else if ((size(i.payments) == 1)) | |
353 | + | then if ((assetIdToStr(i.payments[0].assetId) == AId)) | |
354 | + | then $Tuple4(i.payments[0].amount, AId, 0, BId) | |
355 | + | else if ((assetIdToStr(i.payments[0].assetId) == BId)) | |
356 | + | then $Tuple4(0, AId, i.payments[0].amount, BId) | |
357 | + | else throw("Wrong payment") | |
358 | + | else throw("One or two payments expected") | |
359 | + | let pmtA = $t01022310860._1 | |
360 | + | let pmtAssetA = $t01022310860._2 | |
361 | + | let pmtB = $t01022310860._3 | |
362 | + | let pmtAssetB = $t01022310860._4 | |
363 | + | if ((leverage > 100)) | |
364 | + | then { | |
365 | + | let dPriceA = { | |
366 | + | let @ = invoke(priceOracleAddr, "getTWAP60", [pmtAssetA, false], nil) | |
367 | + | if ($isInstanceOf(@, "Int")) | |
368 | + | then @ | |
369 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
370 | + | } | |
371 | + | let dPriceB = { | |
372 | + | let @ = invoke(priceOracleAddr, "getTWAP60", [pmtAssetB, false], nil) | |
373 | + | if ($isInstanceOf(@, "Int")) | |
374 | + | then @ | |
375 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
376 | + | } | |
377 | + | let paydInDollar = (fraction(dPriceA, pmtA, pow(10, 0, getAssetDecimals(pmtAssetA), 0, 0, DOWN)) + fraction(dPriceB, pmtB, pow(10, 0, getAssetDecimals(pmtAssetB), 0, 0, DOWN))) | |
378 | + | let borrowAmount = fraction(paydInDollar, (leverage - 100), 100) | |
379 | + | let request = makeString([type, toString(i.caller), pool, toString(pmtA), pmtAssetA, toString(pmtB), pmtAssetB, toString(balA), toString(balB), shareId, borrowAssetId, toString(borrowAmount)], ",") | |
380 | + | let newRequestId = { | |
381 | + | let @ = invoke(this, "createNewRequest", [request], nil) | |
382 | + | if ($isInstanceOf(@, "Int")) | |
383 | + | then @ | |
384 | + | else unit | |
385 | + | } | |
386 | + | if ((newRequestId == newRequestId)) | |
387 | + | then { | |
388 | + | let args = [toString(i.caller), shareId, borrowAssetId, borrowAmount, toString(this), "replanishFromLand", toString(valueOrErrorMessage(newRequestId, "Can't create new request"))] | |
389 | + | let inv = reentrantInvoke(getLendSrvAddr(), "flashPosition", args, nil) | |
390 | + | nil | |
391 | + | } | |
392 | + | else throw("Strict value is not equal to itself.") | |
226 | 393 | } | |
227 | - | if ((newRequestId == newRequestId)) | |
228 | - | then { | |
229 | - | let args = [toString(i.caller), shareId, borrowAssetId, borrowAmount, toString(this), "replanishFromLand", toString(valueOrErrorMessage(newRequestId, "Can't create new request"))] | |
230 | - | let inv = reentrantInvoke(getLendSrvAddr(), "flashPosition", args, nil) | |
231 | - | nil | |
232 | - | } | |
233 | - | else throw("Strict value is not equal to itself.") | |
234 | - | } | |
235 | - | else if ((type == SF_POS_TYPE)) | |
236 | - | then replanishSwopFi(toString(i.caller), pool, false, pmtA, pmtAssetA, pmtB, pmtAssetB, balA, balB, shareId, virtualSwapTokenPay, virtualSwapTokenGet) | |
237 | - | else throw("Cant wx") | |
238 | - | } | |
394 | + | else if ((type == SF_POS_TYPE)) | |
395 | + | then replanishSwopFi(toString(i.caller), pool, false, pmtA, pmtAssetA, pmtB, pmtAssetB, balA, balB, shareId) | |
396 | + | else replanishWX(toString(i.caller), pool, false, pmtA, pmtAssetA, pmtB, pmtAssetB, shareId) | |
397 | + | } | |
239 | 398 | ||
240 | 399 | ||
241 | 400 | ||
257 | 416 | else parseIntValue(request[3]) | |
258 | 417 | if ((request[0] == SF_POS_TYPE)) | |
259 | 418 | then { | |
260 | - | let $ | |
261 | - | let entries = $ | |
262 | - | let lpAmount = $ | |
419 | + | let $t01324313557 = replanishSwopFi(request[1], request[2], true, pmtA, request[4], pmtB, request[6], parseIntValue(request[7]), parseIntValue(request[8]), request[9]) | |
420 | + | let entries = $t01324313557._1 | |
421 | + | let lpAmount = $t01324313557._2 | |
263 | 422 | $Tuple2((entries :+ DeleteEntry((requestId + kRequestId))), lpAmount) | |
264 | 423 | } | |
265 | - | else throw("Cant wx") | |
424 | + | else if ((request[0] == SF_POS_TYPE)) | |
425 | + | then { | |
426 | + | let $t01366813898 = replanishWX(request[1], request[2], true, pmtA, request[4], pmtB, request[6], request[9]) | |
427 | + | let entries = $t01366813898._1 | |
428 | + | let lpAmount = $t01366813898._2 | |
429 | + | $Tuple2((entries :+ DeleteEntry((requestId + kRequestId))), lpAmount) | |
430 | + | } | |
431 | + | else throw("Wrong request type") | |
266 | 432 | } | |
267 | 433 | } | |
268 | 434 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SF_POS_TYPE = "SF" | |
5 | 5 | ||
6 | 6 | let WX_POS_TYPE = "WX" | |
7 | 7 | ||
8 | 8 | let SCALE8 = 100000000 | |
9 | 9 | ||
10 | 10 | let FEE_SCALE6 = 1000000 | |
11 | 11 | ||
12 | 12 | let kSFPoolAAssetBalance = "A_asset_balance" | |
13 | 13 | ||
14 | 14 | let kSFPoolBAssetBalance = "B_asset_balance" | |
15 | 15 | ||
16 | 16 | let kSFPoolAAssetId = "A_asset_id" | |
17 | 17 | ||
18 | 18 | let kSFPoolBAssetId = "B_asset_id" | |
19 | 19 | ||
20 | 20 | let kSFPoolShareId = "share_asset_id" | |
21 | - | ||
22 | - | let kSFPoolVersion = "version" | |
23 | 21 | ||
24 | 22 | let kSFFarmingStaked = "_share_tokens_locked" | |
25 | 23 | ||
26 | 24 | let kUserPosition = "_user_position" | |
27 | 25 | ||
28 | 26 | let kUserPositionType = "_user_position_type" | |
29 | 27 | ||
30 | 28 | let kUserPositionNum = "_user_position_number" | |
31 | 29 | ||
32 | 30 | let kTotalPosition = "_total_position" | |
33 | 31 | ||
34 | 32 | let kAxlyInFeeWithoutLoan = "_axly_fee_without_loan" | |
35 | 33 | ||
36 | 34 | let kAxlyInFeeWithLoan = "_axly_fee_with_loan" | |
37 | 35 | ||
38 | 36 | let kAxlyCapFee = "_axly_fee_cap" | |
39 | 37 | ||
40 | 38 | let kRequestId = "_request_id" | |
41 | 39 | ||
42 | 40 | let kRequestIter = "requests_iter" | |
43 | 41 | ||
44 | 42 | let kPool = "pool_" | |
45 | 43 | ||
46 | 44 | let kMoneyBox = "axly_money_box" | |
47 | 45 | ||
48 | 46 | let kSFFarmingAddr = "swopfi_farming_addr" | |
49 | 47 | ||
50 | 48 | let kLendService = "lend_service_addr" | |
51 | 49 | ||
50 | + | let kPriceOracle = "price_oracle" | |
51 | + | ||
52 | 52 | let moneyBox = Address(fromBase58String(valueOrErrorMessage(getString(this, kMoneyBox), "No axly moneyBox address"))) | |
53 | + | ||
54 | + | let priceOracleAddr = Address(fromBase58String(valueOrErrorMessage(getString(this, kPriceOracle), "No price oracle address"))) | |
53 | 55 | ||
54 | 56 | func isSelfCall (i) = if ((i.caller == this)) | |
55 | 57 | then unit | |
56 | 58 | else throw("Only contract itself can call this function") | |
57 | 59 | ||
58 | 60 | ||
59 | 61 | func accountBalance (assetId) = match assetId { | |
60 | 62 | case id: ByteVector => | |
61 | 63 | assetBalance(this, id) | |
62 | 64 | case waves: Unit => | |
63 | 65 | wavesBalance(this).available | |
64 | 66 | case _ => | |
65 | 67 | throw("Match error") | |
66 | 68 | } | |
67 | 69 | ||
68 | 70 | ||
69 | 71 | func getSFPoolData (poolAddr) = $Tuple5(valueOrErrorMessage(getString(poolAddr, kSFPoolAAssetId), "Can't get pool A asset id"), valueOrErrorMessage(getString(poolAddr, kSFPoolBAssetId), "Can't get pool B asset id"), valueOrErrorMessage(getInteger(poolAddr, kSFPoolAAssetBalance), "Can't get pool A asset balance"), valueOrErrorMessage(getInteger(poolAddr, kSFPoolBAssetBalance), "Can't get pool B asset balance"), valueOrErrorMessage(getString(poolAddr, kSFPoolShareId), "Can't get share asset id")) | |
70 | 72 | ||
71 | 73 | ||
72 | - | func getWXPoolData (poolAddr) = $Tuple5(valueOrErrorMessage(getString(poolAddr, kSFPoolAAssetId), "Can't get pool A asset id"), valueOrErrorMessage(getString(poolAddr, kSFPoolBAssetId), "Can't get pool B asset id"), valueOrErrorMessage(getInteger(poolAddr, kSFPoolAAssetBalance), "Can't get pool A asset balance"), valueOrErrorMessage(getInteger(poolAddr, kSFPoolBAssetBalance), "Can't get pool B asset balance"), valueOrErrorMessage(getString(poolAddr, kSFPoolShareId), "Can't get share asset id")) | |
74 | + | func getWXPoolData (poolAddr) = { | |
75 | + | let cfg = { | |
76 | + | let @ = invoke(poolAddr, "getPoolConfigWrapperREADONLY", nil, nil) | |
77 | + | if ($isInstanceOf(@, "List[Any]")) | |
78 | + | then @ | |
79 | + | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
80 | + | } | |
81 | + | if ((cfg == cfg)) | |
82 | + | then $Tuple5(valueOrErrorMessage({ | |
83 | + | let @ = cfg[4] | |
84 | + | if ($isInstanceOf(@, "String")) | |
85 | + | then @ | |
86 | + | else unit | |
87 | + | }, "Can't get pool A asset id"), valueOrErrorMessage({ | |
88 | + | let @ = cfg[5] | |
89 | + | if ($isInstanceOf(@, "String")) | |
90 | + | then @ | |
91 | + | else unit | |
92 | + | }, "Can't get pool B asset id"), 0, 0, valueOrErrorMessage({ | |
93 | + | let @ = cfg[3] | |
94 | + | if ($isInstanceOf(@, "String")) | |
95 | + | then @ | |
96 | + | else unit | |
97 | + | }, "Can't get pool LP asset id")) | |
98 | + | else throw("Strict value is not equal to itself.") | |
99 | + | } | |
73 | 100 | ||
74 | 101 | ||
75 | 102 | func getAxlyTotalPosition (pool) = valueOrElse(getInteger(this, (pool + kTotalPosition)), 0) | |
76 | 103 | ||
77 | 104 | ||
78 | 105 | func getNewUserPositionNumber (pool,user) = (valueOrElse(getInteger(this, (((pool + "_") + user) + kUserPositionNum)), 0) + 1) | |
79 | 106 | ||
80 | 107 | ||
81 | 108 | func getAxlyInFee (pool,withLoan) = if (withLoan) | |
82 | 109 | then getIntegerValue(this, (pool + kAxlyInFeeWithLoan)) | |
83 | 110 | else getIntegerValue(this, (pool + kAxlyInFeeWithoutLoan)) | |
84 | 111 | ||
85 | 112 | ||
86 | 113 | func getSFFarmingAddr () = Address(fromBase58String(valueOrErrorMessage(getString(this, kSFFarmingAddr), "Can't get swopfi farming addr"))) | |
114 | + | ||
115 | + | ||
116 | + | func getWXFarmingAddr (poolAddr) = { | |
117 | + | let fContract = Address(fromBase58String(valueOrElse(getString(poolAddr, "%s__factoryContract"), "Can't get WX factory contract addr"))) | |
118 | + | let factroyCfg = split(valueOrElse(getString(fContract, "%s__factoryConfig"), "Can't get WX factory cfg"), "__") | |
119 | + | Address(fromBase58String(factroyCfg[1])) | |
120 | + | } | |
87 | 121 | ||
88 | 122 | ||
89 | 123 | func getLendSrvAddr () = Address(fromBase58String(valueOrErrorMessage(getString(this, kLendService), "Can't get lend service addr"))) | |
90 | 124 | ||
91 | 125 | ||
92 | 126 | func assetIdToStr (assetId) = match assetId { | |
93 | 127 | case id: ByteVector => | |
94 | 128 | toBase58String(id) | |
95 | 129 | case waves: Unit => | |
96 | 130 | "WAVES" | |
97 | 131 | case _ => | |
98 | 132 | throw("Match error") | |
99 | 133 | } | |
100 | 134 | ||
101 | 135 | ||
102 | 136 | func assetIdFromStr (assetId) = if ((assetId == "WAVES")) | |
103 | 137 | then unit | |
104 | 138 | else fromBase58String(assetId) | |
105 | 139 | ||
106 | 140 | ||
107 | - | func replanishSwopFi (user,pool,withLoan,pmtA,pmtAssetA,pmtB,pmtAssetB,balA,balB,shareId,virtualSwapTokenPay,virtualSwapTokenGet) = { | |
141 | + | func getAssetDecimals (assetId) = if ((assetId == "WAVES")) | |
142 | + | then 8 | |
143 | + | else match assetInfo(fromBase58String(assetId)) { | |
144 | + | case asset: Asset => | |
145 | + | asset.decimals | |
146 | + | case _ => | |
147 | + | throw("Can't find asset") | |
148 | + | } | |
149 | + | ||
150 | + | ||
151 | + | func replanishSwopFi (user,pool,withLoan,pmtA,pmtAssetA,pmtB,pmtAssetB,balA,balB,shareId) = { | |
108 | 152 | let shareBalanceBefore = accountBalance(fromBase58String(shareId)) | |
109 | 153 | if ((shareBalanceBefore == shareBalanceBefore)) | |
110 | 154 | then { | |
111 | 155 | let poolAddr = Address(fromBase58String(pool)) | |
112 | 156 | let ratioA = fraction(SCALE8, pmtA, balA) | |
113 | 157 | let ratioB = fraction(SCALE8, pmtB, balB) | |
114 | - | let $ | |
158 | + | let $t050435335 = if ((ratioB > ratioA)) | |
115 | 159 | then { | |
116 | 160 | let pmt = fraction(balB, ratioA, SCALE8, CEILING) | |
117 | 161 | $Tuple4(pmtA, pmt, (pmtB - pmt), pmtAssetB) | |
118 | 162 | } | |
119 | 163 | else { | |
120 | 164 | let pmt = fraction(balA, ratioB, SCALE8, CEILING) | |
121 | 165 | $Tuple4(pmt, pmtB, (pmtA - pmt), pmtAssetA) | |
122 | 166 | } | |
123 | - | let pmtAmountA = $t045474840._1 | |
124 | - | let pmtAmountB = $t045474840._2 | |
125 | - | let change = $t045474840._3 | |
126 | - | let changeAssetId = $t045474840._4 | |
127 | - | let poolVersion = getStringValue(poolAddr, "version") | |
167 | + | let pmtAmountA = $t050435335._1 | |
168 | + | let pmtAmountB = $t050435335._2 | |
169 | + | let change = $t050435335._3 | |
170 | + | let changeAssetId = $t050435335._4 | |
128 | 171 | let inv1 = if (if ((pmtAmountA > 0)) | |
129 | 172 | then (pmtAmountB > 0) | |
130 | 173 | else false) | |
131 | 174 | then { | |
132 | 175 | let payments = [AttachedPayment(assetIdFromStr(pmtAssetA), pmtAmountA), AttachedPayment(assetIdFromStr(pmtAssetB), pmtAmountB)] | |
133 | - | if ((poolVersion == "1.0.0")) | |
134 | - | then invoke(poolAddr, "callFunction", ["replenishWithTwoTokens", ["false", "0"]], payments) | |
135 | - | else if ((poolVersion == "2.0.0")) | |
136 | - | then invoke(poolAddr, "replenishWithTwoTokensV2", [false, 0], payments) | |
137 | - | else throw("Wrong pool type") | |
176 | + | invoke(poolAddr, "callFunction", ["replenishWithTwoTokens", ["false", "0"]], payments) | |
138 | 177 | } | |
139 | 178 | else 0 | |
140 | 179 | if ((inv1 == inv1)) | |
141 | 180 | then { | |
142 | 181 | let inv2 = if ((change > 0)) | |
143 | 182 | then { | |
144 | 183 | let payments = [AttachedPayment(assetIdFromStr(changeAssetId), change)] | |
145 | - | if ((poolVersion == "1.0.0")) | |
146 | - | then { | |
147 | - | let vars = ["0", "false", "0"] | |
148 | - | invoke(poolAddr, "callFunction", ["replenishWithOneToken", vars], payments) | |
149 | - | } | |
150 | - | else if ((poolVersion == "2.0.0")) | |
151 | - | then { | |
152 | - | let vars = [virtualSwapTokenPay, virtualSwapTokenGet, false, 0] | |
153 | - | invoke(poolAddr, "replenishWithOneTokenV2", [false, 0], payments) | |
154 | - | } | |
155 | - | else throw("Wrong pool type") | |
184 | + | let vars = ["0", "false", "0"] | |
185 | + | invoke(poolAddr, "replenishWithOneTokenV2", [false, 0], payments) | |
156 | 186 | } | |
157 | 187 | else 0 | |
158 | 188 | if ((inv2 == inv2)) | |
159 | 189 | then { | |
160 | 190 | let shareBalanceAfter = accountBalance(fromBase58String(shareId)) | |
161 | 191 | let totalShare = (shareBalanceAfter - shareBalanceBefore) | |
162 | 192 | let axlyInFee = fraction(totalShare, getAxlyInFee(pool, withLoan), FEE_SCALE6) | |
163 | 193 | let userShareForStake = (totalShare - axlyInFee) | |
164 | 194 | if ((0 >= userShareForStake)) | |
165 | 195 | then throw("amount of staked sharetokens must be > 0") | |
166 | 196 | else { | |
167 | 197 | let inv3 = invoke(getSFFarmingAddr(), "lockShareTokens", [pool, 0], [AttachedPayment(fromBase58String(shareId), userShareForStake)]) | |
198 | + | if ((inv3 == inv3)) | |
199 | + | then { | |
200 | + | let totalAmount = getAxlyTotalPosition(pool) | |
201 | + | let newPosNum = getNewUserPositionNumber(pool, user) | |
202 | + | let baseEntry = [IntegerEntry((pool + kTotalPosition), (totalAmount + userShareForStake)), IntegerEntry((((((pool + "_") + user) + "_") + toString(newPosNum)) + kUserPosition), userShareForStake), StringEntry((((((pool + "_") + user) + "_") + toString(newPosNum)) + kUserPositionType), SF_POS_TYPE), IntegerEntry((((pool + "_") + user) + kUserPositionNum), newPosNum), ScriptTransfer(moneyBox, axlyInFee, fromBase58String(shareId))] | |
203 | + | $Tuple2(baseEntry, userShareForStake) | |
204 | + | } | |
205 | + | else throw("Strict value is not equal to itself.") | |
206 | + | } | |
207 | + | } | |
208 | + | else throw("Strict value is not equal to itself.") | |
209 | + | } | |
210 | + | else throw("Strict value is not equal to itself.") | |
211 | + | } | |
212 | + | else throw("Strict value is not equal to itself.") | |
213 | + | } | |
214 | + | ||
215 | + | ||
216 | + | func replanishWX (user,pool,withLoan,pmtA,pmtAssetA,pmtB,pmtAssetB,shareId) = { | |
217 | + | let poolAddr = Address(fromBase58String(pool)) | |
218 | + | let $t072978116 = if (if ((pmtA > 0)) | |
219 | + | then (pmtB > 0) | |
220 | + | else false) | |
221 | + | then { | |
222 | + | let evalPutInA = { | |
223 | + | let @ = invoke(poolAddr, "evaluatePutByAmountAssetREADONLY", [pmtA], nil) | |
224 | + | if ($isInstanceOf(@, "List[Any]")) | |
225 | + | then @ | |
226 | + | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
227 | + | } | |
228 | + | if ((evalPutInA == evalPutInA)) | |
229 | + | then { | |
230 | + | let evalPutInB = { | |
231 | + | let @ = invoke(poolAddr, "evaluatePutByPriceAssetREADONLY", [pmtB], nil) | |
232 | + | if ($isInstanceOf(@, "List[Any]")) | |
233 | + | then @ | |
234 | + | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
235 | + | } | |
236 | + | if ((evalPutInB == evalPutInB)) | |
237 | + | then { | |
238 | + | let lpInA = { | |
239 | + | let @ = evalPutInA[0] | |
240 | + | if ($isInstanceOf(@, "Int")) | |
241 | + | then @ | |
242 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
243 | + | } | |
244 | + | let lpInB = { | |
245 | + | let @ = evalPutInB[0] | |
246 | + | if ($isInstanceOf(@, "Int")) | |
247 | + | then @ | |
248 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
249 | + | } | |
250 | + | if ((lpInA > lpInB)) | |
251 | + | then { | |
252 | + | let pmtInB = { | |
253 | + | let @ = evalPutInB[7] | |
254 | + | if ($isInstanceOf(@, "Int")) | |
255 | + | then @ | |
256 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
257 | + | } | |
258 | + | $Tuple4(pmtA, pmtInB, (pmtB - pmtInB), pmtAssetB) | |
259 | + | } | |
260 | + | else { | |
261 | + | let pmtInA = { | |
262 | + | let @ = evalPutInB[6] | |
263 | + | if ($isInstanceOf(@, "Int")) | |
264 | + | then @ | |
265 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
266 | + | } | |
267 | + | $Tuple4(pmtInA, pmtB, (pmtA - pmtInA), pmtAssetA) | |
268 | + | } | |
269 | + | } | |
270 | + | else throw("Strict value is not equal to itself.") | |
271 | + | } | |
272 | + | else throw("Strict value is not equal to itself.") | |
273 | + | } | |
274 | + | else if ((pmtA > 0)) | |
275 | + | then $Tuple4(pmtA, pmtB, pmtA, pmtAssetA) | |
276 | + | else if ((pmtB > 0)) | |
277 | + | then $Tuple4(pmtA, pmtB, pmtB, pmtAssetB) | |
278 | + | else throw("pmts must be > 0") | |
279 | + | let pmtAmountA = $t072978116._1 | |
280 | + | let pmtAmountB = $t072978116._2 | |
281 | + | let change = $t072978116._3 | |
282 | + | let changeAssetId = $t072978116._4 | |
283 | + | let shareBalanceBefore = accountBalance(fromBase58String(shareId)) | |
284 | + | if ((shareBalanceBefore == shareBalanceBefore)) | |
285 | + | then { | |
286 | + | let inv1 = if (if ((pmtAmountA > 0)) | |
287 | + | then (pmtAmountB > 0) | |
288 | + | else false) | |
289 | + | then { | |
290 | + | let payments = [AttachedPayment(assetIdFromStr(pmtAssetA), pmtAmountA), AttachedPayment(assetIdFromStr(pmtAssetB), pmtAmountB)] | |
291 | + | invoke(poolAddr, "put", [1, false], payments) | |
292 | + | } | |
293 | + | else 0 | |
294 | + | if ((inv1 == inv1)) | |
295 | + | then { | |
296 | + | let inv2 = if ((change > 0)) | |
297 | + | then { | |
298 | + | let payments = [AttachedPayment(assetIdFromStr(changeAssetId), change)] | |
299 | + | invoke(poolAddr, "putOneTkn", [0, false], payments) | |
300 | + | } | |
301 | + | else 0 | |
302 | + | if ((inv2 == inv2)) | |
303 | + | then { | |
304 | + | let shareBalanceAfter = accountBalance(fromBase58String(shareId)) | |
305 | + | let totalShare = (shareBalanceAfter - shareBalanceBefore) | |
306 | + | let axlyInFee = fraction(totalShare, getAxlyInFee(pool, withLoan), FEE_SCALE6) | |
307 | + | let userShareForStake = (totalShare - axlyInFee) | |
308 | + | if ((0 >= userShareForStake)) | |
309 | + | then throw("amount of staked sharetokens must be > 0") | |
310 | + | else { | |
311 | + | let inv3 = invoke(getWXFarmingAddr(poolAddr), "stake", nil, [AttachedPayment(fromBase58String(shareId), userShareForStake)]) | |
168 | 312 | if ((inv3 == inv3)) | |
169 | 313 | then { | |
170 | 314 | let totalAmount = getAxlyTotalPosition(pool) | |
171 | 315 | let newPosNum = getNewUserPositionNumber(pool, user) | |
172 | 316 | $Tuple2([IntegerEntry((pool + kTotalPosition), (totalAmount + userShareForStake)), IntegerEntry((((((pool + "_") + user) + "_") + toString(newPosNum)) + kUserPosition), userShareForStake), StringEntry((((((pool + "_") + user) + "_") + toString(newPosNum)) + kUserPositionType), SF_POS_TYPE), IntegerEntry((((pool + "_") + user) + kUserPositionNum), newPosNum), ScriptTransfer(moneyBox, axlyInFee, fromBase58String(shareId))], userShareForStake) | |
173 | 317 | } | |
174 | 318 | else throw("Strict value is not equal to itself.") | |
175 | 319 | } | |
176 | 320 | } | |
177 | 321 | else throw("Strict value is not equal to itself.") | |
178 | 322 | } | |
179 | 323 | else throw("Strict value is not equal to itself.") | |
180 | 324 | } | |
181 | 325 | else throw("Strict value is not equal to itself.") | |
182 | 326 | } | |
183 | 327 | ||
184 | 328 | ||
185 | - | func replanishWX (user,pool,withLoan,pmtA,pmtAssetA,pmtB,pmtAssetB,balA,balB,shareId,virtualSwapTokenPay,virtualSwapTokenGet) = nil | |
186 | - | ||
187 | - | ||
188 | 329 | @Callable(i) | |
189 | - | func replanish (pool,borrowAmount,borrowAssetId,virtualSwapTokenPay,virtualSwapTokenGet) = { | |
190 | - | let type = valueOrErrorMessage(getString(this, (kPool + pool)), "Pool is not inited") | |
191 | - | let $t075947845 = if ((type == SF_POS_TYPE)) | |
192 | - | then getSFPoolData(Address(fromBase58String(pool))) | |
193 | - | else if ((type == WX_POS_TYPE)) | |
194 | - | then getWXPoolData(Address(fromBase58String(pool))) | |
195 | - | else throw("Wrong pool type") | |
196 | - | let AId = $t075947845._1 | |
197 | - | let BId = $t075947845._2 | |
198 | - | let balA = $t075947845._3 | |
199 | - | let balB = $t075947845._4 | |
200 | - | let shareId = $t075947845._5 | |
201 | - | let $t078498486 = if ((size(i.payments) == 2)) | |
202 | - | then if ((assetIdToStr(i.payments[0].assetId) != AId)) | |
203 | - | then throw("Wrong payment asset A") | |
204 | - | else if ((assetIdToStr(i.payments[1].assetId) != BId)) | |
205 | - | then throw("Wrong payment asset B") | |
206 | - | else $Tuple4(i.payments[0].amount, AId, i.payments[1].amount, BId) | |
207 | - | else if ((size(i.payments) == 1)) | |
208 | - | then if ((assetIdToStr(i.payments[0].assetId) == AId)) | |
209 | - | then $Tuple4(i.payments[0].amount, AId, 0, BId) | |
210 | - | else if ((assetIdToStr(i.payments[0].assetId) == BId)) | |
211 | - | then $Tuple4(0, AId, i.payments[0].amount, BId) | |
212 | - | else throw("Wrong payment") | |
213 | - | else throw("One or two payments expected") | |
214 | - | let pmtA = $t078498486._1 | |
215 | - | let pmtAssetA = $t078498486._2 | |
216 | - | let pmtB = $t078498486._3 | |
217 | - | let pmtAssetB = $t078498486._4 | |
218 | - | if ((borrowAmount > 0)) | |
219 | - | then { | |
220 | - | let request = makeString([type, toString(i.caller), pool, toString(pmtA), pmtAssetA, toString(pmtB), pmtAssetB, toString(balA), toString(balB), shareId, toString(virtualSwapTokenPay), toString(virtualSwapTokenGet), borrowAssetId, toString(borrowAmount)], ",") | |
221 | - | let newRequestId = { | |
222 | - | let @ = invoke(this, "createNewRequest", [request], nil) | |
223 | - | if ($isInstanceOf(@, "Int")) | |
224 | - | then @ | |
225 | - | else unit | |
330 | + | func replanish (pool,leverage,borrowAssetId) = if (if ((100 > leverage)) | |
331 | + | then true | |
332 | + | else (leverage > 300)) | |
333 | + | then throw("Leverage can't be <100 and >300") | |
334 | + | else { | |
335 | + | let type = valueOrErrorMessage(getString(this, (kPool + pool)), "Pool is not inited") | |
336 | + | let $t0996910220 = if ((type == SF_POS_TYPE)) | |
337 | + | then getSFPoolData(Address(fromBase58String(pool))) | |
338 | + | else if ((type == WX_POS_TYPE)) | |
339 | + | then getWXPoolData(Address(fromBase58String(pool))) | |
340 | + | else throw("Wrong pool type") | |
341 | + | let AId = $t0996910220._1 | |
342 | + | let BId = $t0996910220._2 | |
343 | + | let balA = $t0996910220._3 | |
344 | + | let balB = $t0996910220._4 | |
345 | + | let shareId = $t0996910220._5 | |
346 | + | let $t01022310860 = if ((size(i.payments) == 2)) | |
347 | + | then if ((assetIdToStr(i.payments[0].assetId) != AId)) | |
348 | + | then throw("Wrong payment asset A") | |
349 | + | else if ((assetIdToStr(i.payments[1].assetId) != BId)) | |
350 | + | then throw("Wrong payment asset B") | |
351 | + | else $Tuple4(i.payments[0].amount, AId, i.payments[1].amount, BId) | |
352 | + | else if ((size(i.payments) == 1)) | |
353 | + | then if ((assetIdToStr(i.payments[0].assetId) == AId)) | |
354 | + | then $Tuple4(i.payments[0].amount, AId, 0, BId) | |
355 | + | else if ((assetIdToStr(i.payments[0].assetId) == BId)) | |
356 | + | then $Tuple4(0, AId, i.payments[0].amount, BId) | |
357 | + | else throw("Wrong payment") | |
358 | + | else throw("One or two payments expected") | |
359 | + | let pmtA = $t01022310860._1 | |
360 | + | let pmtAssetA = $t01022310860._2 | |
361 | + | let pmtB = $t01022310860._3 | |
362 | + | let pmtAssetB = $t01022310860._4 | |
363 | + | if ((leverage > 100)) | |
364 | + | then { | |
365 | + | let dPriceA = { | |
366 | + | let @ = invoke(priceOracleAddr, "getTWAP60", [pmtAssetA, false], nil) | |
367 | + | if ($isInstanceOf(@, "Int")) | |
368 | + | then @ | |
369 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
370 | + | } | |
371 | + | let dPriceB = { | |
372 | + | let @ = invoke(priceOracleAddr, "getTWAP60", [pmtAssetB, false], nil) | |
373 | + | if ($isInstanceOf(@, "Int")) | |
374 | + | then @ | |
375 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
376 | + | } | |
377 | + | let paydInDollar = (fraction(dPriceA, pmtA, pow(10, 0, getAssetDecimals(pmtAssetA), 0, 0, DOWN)) + fraction(dPriceB, pmtB, pow(10, 0, getAssetDecimals(pmtAssetB), 0, 0, DOWN))) | |
378 | + | let borrowAmount = fraction(paydInDollar, (leverage - 100), 100) | |
379 | + | let request = makeString([type, toString(i.caller), pool, toString(pmtA), pmtAssetA, toString(pmtB), pmtAssetB, toString(balA), toString(balB), shareId, borrowAssetId, toString(borrowAmount)], ",") | |
380 | + | let newRequestId = { | |
381 | + | let @ = invoke(this, "createNewRequest", [request], nil) | |
382 | + | if ($isInstanceOf(@, "Int")) | |
383 | + | then @ | |
384 | + | else unit | |
385 | + | } | |
386 | + | if ((newRequestId == newRequestId)) | |
387 | + | then { | |
388 | + | let args = [toString(i.caller), shareId, borrowAssetId, borrowAmount, toString(this), "replanishFromLand", toString(valueOrErrorMessage(newRequestId, "Can't create new request"))] | |
389 | + | let inv = reentrantInvoke(getLendSrvAddr(), "flashPosition", args, nil) | |
390 | + | nil | |
391 | + | } | |
392 | + | else throw("Strict value is not equal to itself.") | |
226 | 393 | } | |
227 | - | if ((newRequestId == newRequestId)) | |
228 | - | then { | |
229 | - | let args = [toString(i.caller), shareId, borrowAssetId, borrowAmount, toString(this), "replanishFromLand", toString(valueOrErrorMessage(newRequestId, "Can't create new request"))] | |
230 | - | let inv = reentrantInvoke(getLendSrvAddr(), "flashPosition", args, nil) | |
231 | - | nil | |
232 | - | } | |
233 | - | else throw("Strict value is not equal to itself.") | |
234 | - | } | |
235 | - | else if ((type == SF_POS_TYPE)) | |
236 | - | then replanishSwopFi(toString(i.caller), pool, false, pmtA, pmtAssetA, pmtB, pmtAssetB, balA, balB, shareId, virtualSwapTokenPay, virtualSwapTokenGet) | |
237 | - | else throw("Cant wx") | |
238 | - | } | |
394 | + | else if ((type == SF_POS_TYPE)) | |
395 | + | then replanishSwopFi(toString(i.caller), pool, false, pmtA, pmtAssetA, pmtB, pmtAssetB, balA, balB, shareId) | |
396 | + | else replanishWX(toString(i.caller), pool, false, pmtA, pmtAssetA, pmtB, pmtAssetB, shareId) | |
397 | + | } | |
239 | 398 | ||
240 | 399 | ||
241 | 400 | ||
242 | 401 | @Callable(i) | |
243 | 402 | func replanishFromLand (requestId) = { | |
244 | 403 | let request = split(valueOrErrorMessage(getString(this, (requestId + kRequestId)), ("No request with id " + requestId)), ",") | |
245 | 404 | if ((size(i.payments) != 1)) | |
246 | 405 | then throw("Wrong payment size") | |
247 | 406 | else if (if ((assetIdToStr(i.payments[0].assetId) != request[12])) | |
248 | 407 | then true | |
249 | 408 | else (i.payments[0].amount != parseIntValue(request[13]))) | |
250 | 409 | then throw("Wrong payment") | |
251 | 410 | else { | |
252 | 411 | let pmtA = if ((request[4] == assetIdToStr(i.payments[0].assetId))) | |
253 | 412 | then (parseIntValue(request[3]) + i.payments[0].amount) | |
254 | 413 | else parseIntValue(request[3]) | |
255 | 414 | let pmtB = if ((request[6] == assetIdToStr(i.payments[0].assetId))) | |
256 | 415 | then (parseIntValue(request[5]) + i.payments[0].amount) | |
257 | 416 | else parseIntValue(request[3]) | |
258 | 417 | if ((request[0] == SF_POS_TYPE)) | |
259 | 418 | then { | |
260 | - | let $ | |
261 | - | let entries = $ | |
262 | - | let lpAmount = $ | |
419 | + | let $t01324313557 = replanishSwopFi(request[1], request[2], true, pmtA, request[4], pmtB, request[6], parseIntValue(request[7]), parseIntValue(request[8]), request[9]) | |
420 | + | let entries = $t01324313557._1 | |
421 | + | let lpAmount = $t01324313557._2 | |
263 | 422 | $Tuple2((entries :+ DeleteEntry((requestId + kRequestId))), lpAmount) | |
264 | 423 | } | |
265 | - | else throw("Cant wx") | |
424 | + | else if ((request[0] == SF_POS_TYPE)) | |
425 | + | then { | |
426 | + | let $t01366813898 = replanishWX(request[1], request[2], true, pmtA, request[4], pmtB, request[6], request[9]) | |
427 | + | let entries = $t01366813898._1 | |
428 | + | let lpAmount = $t01366813898._2 | |
429 | + | $Tuple2((entries :+ DeleteEntry((requestId + kRequestId))), lpAmount) | |
430 | + | } | |
431 | + | else throw("Wrong request type") | |
266 | 432 | } | |
267 | 433 | } | |
268 | 434 | ||
269 | 435 | ||
270 | 436 | ||
271 | 437 | @Callable(i) | |
272 | 438 | func createNewRequest (params) = valueOrElse(isSelfCall(i), { | |
273 | 439 | let newRequestId = (valueOrElse(getInteger(this, kRequestIter), 0) + 1) | |
274 | 440 | $Tuple2([StringEntry((toString(newRequestId) + kRequestId), params)], newRequestId) | |
275 | 441 | }) | |
276 | 442 | ||
277 | 443 | ||
278 | 444 | ||
279 | 445 | @Callable(i) | |
280 | 446 | func initNewPool (type,poolAddr,inFeeNoLoan,inFeeLoan,capFee) = if (if ((type != SF_POS_TYPE)) | |
281 | 447 | then (type != WX_POS_TYPE) | |
282 | 448 | else false) | |
283 | 449 | then throw("Wrong type") | |
284 | 450 | else [IntegerEntry((poolAddr + kAxlyInFeeWithoutLoan), inFeeNoLoan), IntegerEntry((poolAddr + kAxlyInFeeWithLoan), inFeeLoan), IntegerEntry((poolAddr + kAxlyCapFee), capFee), StringEntry((kPool + poolAddr), type)] | |
285 | 451 | ||
286 | 452 | ||
287 | 453 | @Verifier(tx) | |
288 | 454 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
289 | 455 |
github/deemru/w8io/169f3d6 52.77 ms ◑