tx · iCekUQsWXTLDuGKnP1M4A59iJrmMzuqjFTEBatAjZdZ 3P8ZZY4DXiawraWhMaJLmPB1FB9sJryTuCr: -0.05400000 Waves 2024.04.23 15:32 [4141404] smart account 3P8ZZY4DXiawraWhMaJLmPB1FB9sJryTuCr > SELF 0.00000000 Waves
{ "type": 13, "id": "iCekUQsWXTLDuGKnP1M4A59iJrmMzuqjFTEBatAjZdZ", "fee": 5400000, "feeAssetId": null, "timestamp": 1713875591477, "version": 2, "chainId": 87, "sender": "3P8ZZY4DXiawraWhMaJLmPB1FB9sJryTuCr", "senderPublicKey": "BJkigEKqmZCzx9A93KpyHi6ZyJkgmRK9eB2GSrMeMhgL", "proofs": [ "hAaHzwnh9rTDtXdDpBwisgw5rKmc9CaNKnBvw3mGRJyKRiXsBgM3igCTFcHQHpBWFZcqUuBi1HBuMjqonKZ1NPJ" ], "script": "base64:BgJbCAISCAoGCAgICAgBEgASABIDCgEEEgMKAQQSABIDCgEIEgMKAQESABIDCgEIEgQKAggBEgUKAwgIARIDCgEIEgMKAQESBwoFCAgIAQESABIDCgEIEgUKAwgICFMAB1ZFUlNJT04CDVBaLTEuMi4zIFBST0QACWNvbmZpZ1N0cgkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzAg1jb25maWdBZGRyZXNzAiMzUFBFQlJnNHMyYWYyclEyWmJMdmR1MUhmZDRWbzZRVkRUbwAOQ09ORklHX0FERFJFU1MDCQAAAgUJY29uZmlnU3RyAgAFBHRoaXMJAQdBZGRyZXNzAQkA2QQBBQljb25maWdTdHIAFUFzc2V0c1dlaWdodHNEZWNpbWFscwAEAAVTY2FsZQCQTgAGU2NhbGU4AIDC1y8AB1NjYWxlMTYAgICE/qbe4REACEZlZVNjYWxlAJBOABFQb29sVG9rZW5EZWNpbWFscwAIAA5Qb29sVG9rZW5TY2FsZQkAbAYACgAABRFQb29sVG9rZW5EZWNpbWFscwAAAAAFBkhBTEZVUAAQTUlOX1NURVBTX0FNT1VOVAkBC3Z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AgkAmggCBRFjb2xkTWFzdGVyQWRkcmVzcwkArAICAgthcHByb3ZlZFR4XwkA2AQBCAUCdHgCaWQAAAAAB2vb2Ig=", "height": 4141404, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G8krBVXDg9yguDuSTFr7KQBr71uxgfb9WuucdgefK6ko Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let VERSION = "PZ-1.2.3 PROD" | |
5 | 5 | ||
6 | - | let | |
6 | + | let configStr = valueOrElse(getString(this, "configAddress"), "3PPEBRg4s2af2rQ2ZbLvdu1Hfd4Vo6QVDTo") | |
7 | 7 | ||
8 | - | let usdtAssetId = base58'34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ' | |
8 | + | let CONFIG_ADDRESS = if ((configStr == "")) | |
9 | + | then this | |
10 | + | else Address(fromBase58String(configStr)) | |
9 | 11 | ||
10 | - | let | |
12 | + | let AssetsWeightsDecimals = 4 | |
11 | 13 | ||
12 | - | let | |
14 | + | let Scale = 10000 | |
13 | 15 | ||
14 | - | let | |
16 | + | let Scale8 = 100000000 | |
15 | 17 | ||
16 | - | let | |
18 | + | let Scale16 = 10000000000000000 | |
17 | 19 | ||
18 | - | let | |
20 | + | let FeeScale = 10000 | |
19 | 21 | ||
20 | - | let | |
22 | + | let PoolTokenDecimals = 8 | |
21 | 23 | ||
22 | - | let | |
24 | + | let PoolTokenScale = pow(10, 0, PoolTokenDecimals, 0, 0, HALFUP) | |
23 | 25 | ||
24 | - | let masterPubKey = base58'4z8CKSYQBKkzx7PBb5uBP1YPa6YAHRNTApW1sQVHT5eU' | |
26 | + | let MIN_STEPS_AMOUNT = valueOrElse(getInteger(CONFIG_ADDRESS, "min_steps_amount"), 1) | |
27 | + | ||
28 | + | let MAX_STEPS_AMOUNT = valueOrElse(getInteger(CONFIG_ADDRESS, "max_steps_amount"), 500) | |
29 | + | ||
30 | + | let MIN_STEPS_INTERVAL = valueOrElse(getInteger(CONFIG_ADDRESS, "min_steps_interval"), 1) | |
31 | + | ||
32 | + | let MAX_STEPS_INTERVAL = valueOrElse(getInteger(CONFIG_ADDRESS, "max_steps_interval"), 10000) | |
33 | + | ||
34 | + | let MIN_WEIGHT = valueOrElse(getInteger(CONFIG_ADDRESS, "min_weight"), 100) | |
35 | + | ||
36 | + | let MAX_WEIGHT = valueOrElse(getInteger(CONFIG_ADDRESS, "max_weight"), 9900) | |
25 | 37 | ||
26 | 38 | func tryGetInteger (key) = match getInteger(this, key) { | |
27 | 39 | case b: Int => | |
47 | 59 | } | |
48 | 60 | ||
49 | 61 | ||
62 | + | func tryGetStringOrThrow (key) = match getString(this, key) { | |
63 | + | case b: String => | |
64 | + | b | |
65 | + | case _ => | |
66 | + | throw(("no such key in data storage: " + key)) | |
67 | + | } | |
68 | + | ||
69 | + | ||
50 | 70 | func getAssetString (assetId) = match assetId { | |
51 | 71 | case b: ByteVector => | |
52 | 72 | toBase58String(b) | |
60 | 80 | else fromBase58String(assetIdStr) | |
61 | 81 | ||
62 | 82 | ||
83 | + | func getTokenBalance (assetId) = match assetId { | |
84 | + | case t: ByteVector => | |
85 | + | assetBalance(this, t) | |
86 | + | case _ => | |
87 | + | wavesBalance(this).available | |
88 | + | } | |
89 | + | ||
90 | + | ||
63 | 91 | func addAssetBytesToList (accum,item) = (accum ++ [getAssetBytes(item)]) | |
64 | 92 | ||
65 | 93 | ||
66 | 94 | func addAssetWeightToList (accum,item) = (accum ++ [tryGetInteger((("static_" + getAssetString(item)) + "_weight"))]) | |
95 | + | ||
96 | + | ||
97 | + | func addAssetWeightToStrList (accum,item) = (accum ++ [toString(tryGetInteger((("static_" + item) + "_weight")))]) | |
67 | 98 | ||
68 | 99 | ||
69 | 100 | func addAssetDecimalsToList (accum,item) = (accum ++ [tryGetInteger((("static_" + getAssetString(item)) + "_decimals"))]) | |
74 | 105 | ||
75 | 106 | func addIntToList (accum,item) = (accum ++ [parseIntValue(item)]) | |
76 | 107 | ||
108 | + | ||
109 | + | let usdnAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdnAssetIdStr"), "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p") | |
110 | + | ||
111 | + | let puzzleAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "puzzleAssetIdStr"), "HEB8Qaw9xrWpWs8tHsiATYGBWDBtP2S7kcPALrMu43AS") | |
112 | + | ||
113 | + | let usdtAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdtAssetIdStr"), "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ") | |
114 | + | ||
115 | + | let usdtPptAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdtPptAssetIdStr"), "9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi") | |
116 | + | ||
117 | + | let romeAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "romeAssetIdStr"), "AP4Cb5xLYGH6ZigHreCZHoXpQTWDkPsG2BHqfDUx6taJ") | |
118 | + | ||
119 | + | let wavesAssetIdStr = "WAVES" | |
120 | + | ||
121 | + | let usdnAssetId = fromBase58String(usdnAssetIdStr) | |
122 | + | ||
123 | + | let puzzleAssetId = fromBase58String(puzzleAssetIdStr) | |
124 | + | ||
125 | + | let usdtAssetId = fromBase58String(usdtAssetIdStr) | |
126 | + | ||
127 | + | let usdtPptAssetId = fromBase58String(usdtPptAssetIdStr) | |
128 | + | ||
129 | + | let romeAssetId = fromBase58String(romeAssetIdStr) | |
130 | + | ||
131 | + | let wavesAssetId = unit | |
132 | + | ||
133 | + | let supportedFeeAssetsStr = [usdnAssetIdStr, puzzleAssetIdStr, usdtAssetIdStr, usdtPptAssetIdStr, wavesAssetIdStr, romeAssetIdStr] | |
134 | + | ||
135 | + | let parentPoolAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "parentPoolAddress"), "3PFDgzu1UtswAkCMxqqQjbTeHaX4cMab8Kh"))) | |
136 | + | ||
137 | + | let masterAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "masterAddress"), "3PLjwHcz9NEuaTo63NZR9B9okQiKQxZSbmf"))) | |
138 | + | ||
139 | + | let masterPubKey = fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "masterPubKey"), "4z8CKSYQBKkzx7PBb5uBP1YPa6YAHRNTApW1sQVHT5eU")) | |
140 | + | ||
141 | + | let oracleAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "oracleAddress"), "3P8d1E1BLKoD52y3bQJ1bDTd2TD1gpaLn9t"))) | |
142 | + | ||
143 | + | let stakingAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "stakingAddress"), "3PFTbywqxtFfukX3HyT881g4iW5K4QL3FAS"))) | |
144 | + | ||
145 | + | let feesAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "feesAddress"), "3PFWAVKmXjfHXyzJb12jCbhP4Uhi9t4uWiD"))) | |
146 | + | ||
147 | + | let poolsHubAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "poolsHubAddress"), "3P5YutjDNC3hABBVsveFuZTTbQ5PdtSDBgk"))) | |
148 | + | ||
149 | + | let shutdownAddressStr = valueOrElse(getString(CONFIG_ADDRESS, "shutdownAddress"), "3PEpv9hRFWEEBU22WRnLsw1bH4YGtcU728o") | |
150 | + | ||
151 | + | let layer2Addresses = valueOrElse(getString(CONFIG_ADDRESS, "layer2Addresses"), "3PR1Qvi9mHT35SwWEkLSqqE2L8thiPLdVWU,3PQoBfUKHkJAeGWhooLP7WS8ovb54av9Jp2") | |
152 | + | ||
153 | + | let govAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "govAddress"), "3P6uro9xCsE8te78QZjzqy7aq8natSzdceC"))) | |
154 | + | ||
155 | + | let coldMasterAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "coldMasterAddress"), "3PK9nhPfPbMBygB9ZgHVMHaQbSoojwrBfxj"))) | |
77 | 156 | ||
78 | 157 | let T = tryGetInteger("static_tokensAmount") | |
79 | 158 | ||
139 | 218 | ||
140 | 219 | let Fee = tryGetInteger("static_fee") | |
141 | 220 | ||
142 | - | let AssetsWeightsDecimals = 4 | |
143 | - | ||
144 | - | let Scale = 10000 | |
145 | - | ||
146 | - | let Scale8 = 100000000 | |
147 | - | ||
148 | - | let FeeScale = 10000 | |
149 | - | ||
150 | - | let PoolTokenDecimals = 8 | |
151 | - | ||
152 | - | let PoolTokenScale = pow(10, 0, PoolTokenDecimals, 0, 0, HALFUP) | |
153 | - | ||
154 | 221 | let earnedAssets = assetIds | |
155 | 222 | ||
156 | - | func isShutdown () = match getBoolean(Address(base58'3PEpv9hRFWEEBU22WRnLsw1bH4YGtcU728o'), "is_shutdown") { | |
157 | - | case x: Boolean => | |
223 | + | func isShutdown () = { | |
224 | + | let shutdownAddress = addressFromString(shutdownAddressStr) | |
225 | + | if ((shutdownAddress == unit)) | |
226 | + | then false | |
227 | + | else match getBoolean(value(shutdownAddress), "is_shutdown") { | |
228 | + | case x: Boolean => | |
229 | + | x | |
230 | + | case _ => | |
231 | + | false | |
232 | + | } | |
233 | + | } | |
234 | + | ||
235 | + | ||
236 | + | func getCurrentTokenBalance (tokenNum) = { | |
237 | + | let tokenIdStr = getAssetString(assetIds[tokenNum]) | |
238 | + | tryGetInteger((("global_" + tokenIdStr) + "_balance")) | |
239 | + | } | |
240 | + | ||
241 | + | ||
242 | + | func getKMult () = match getInteger("static_KMult") { | |
243 | + | case x: Int => | |
158 | 244 | x | |
159 | 245 | case _ => | |
160 | - | | |
246 | + | Scale16 | |
161 | 247 | } | |
162 | 248 | ||
163 | 249 | ||
164 | - | func getCurrentTokenBalance (tokenType) = { | |
165 | - | let tokenId = getAssetString(assetIds[tokenType]) | |
166 | - | tryGetInteger((("global_" + tokenId) + "_balance")) | |
250 | + | func saveCurrentWeights () = { | |
251 | + | let assetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
252 | + | func s (accum,assetId) = (accum ++ [IntegerEntry(("rebalance_startWeight_" + assetId), tryGetInteger((("static_" + assetId) + "_weight")))]) | |
253 | + | ||
254 | + | let $l = assetIdsLi | |
255 | + | let $s = size($l) | |
256 | + | let $acc0 = nil | |
257 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
258 | + | then $a | |
259 | + | else s($a, $l[$i]) | |
260 | + | ||
261 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
262 | + | then $a | |
263 | + | else throw("List size exceeds 10") | |
264 | + | ||
265 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
167 | 266 | } | |
168 | 267 | ||
169 | 268 | ||
269 | + | func getVirtualPoolTokenAmount () = fraction(tryGetInteger("global_poolToken_amount"), getKMult(), Scale16) | |
270 | + | ||
271 | + | ||
170 | 272 | func calculatePIssued (amount,tokenId) = { | |
171 | - | let Psupply = | |
273 | + | let Psupply = getVirtualPoolTokenAmount() | |
172 | 274 | let Balance = tryGetInteger((("global_" + getAssetString(tokenId)) + "_balance")) | |
173 | - | fraction(amount, Psupply, Balance, DOWN) | |
275 | + | let t1 = fraction(amount, Psupply, Balance, DOWN) | |
276 | + | t1 | |
174 | 277 | } | |
175 | 278 | ||
176 | 279 | ||
251 | 354 | } | |
252 | 355 | ||
253 | 356 | ||
357 | + | func getPriceFromOracle (assetIdStr) = match getInteger(oracleAddress, (assetIdStr + "_twap5B")) { | |
358 | + | case x: Int => | |
359 | + | x | |
360 | + | case _ => | |
361 | + | 0 | |
362 | + | } | |
363 | + | ||
364 | + | ||
365 | + | func calculateUsdValue (assetId,amount,aBalance) = { | |
366 | + | let assetWeight = tryGetInteger((("static_" + getAssetString(assetId)) + "_weight")) | |
367 | + | let feeAssetStr = tryGetString("static_feeToken") | |
368 | + | let feeAssetScale = getIntegerValue(this, (("static_" + feeAssetStr) + "_scale")) | |
369 | + | let feeAssetNum = value(indexOf(assetIds, getAssetBytes(feeAssetStr))) | |
370 | + | let feeAssetWeight = AssetsWeights[feeAssetNum] | |
371 | + | let feeAssetBalance = tryGetInteger((("global_" + feeAssetStr) + "_balance")) | |
372 | + | let valInFeeAsset = fraction(amount, (feeAssetBalance / feeAssetWeight), (aBalance / assetWeight)) | |
373 | + | let feeAssetPrice = getPriceFromOracle(feeAssetStr) | |
374 | + | fraction(valInFeeAsset, feeAssetPrice, feeAssetScale) | |
375 | + | } | |
376 | + | ||
377 | + | ||
254 | 378 | func checkTokensValidity (payments) = { | |
255 | 379 | func handler1 (accum,payment) = (accum ++ [payment.assetId]) | |
256 | 380 | ||
318 | 442 | ||
319 | 443 | func handleTokenChange (accum,tokenId) = { | |
320 | 444 | let Bk = tryGetInteger((("global_" + getAssetString(tokenId)) + "_balance")) | |
321 | - | let PSupply = | |
445 | + | let PSupply = getVirtualPoolTokenAmount() | |
322 | 446 | let tokenDecimals = tryGetInteger((("static_" + getAssetString(tokenId)) + "_scale")) | |
323 | - | let Dk = fraction((fraction((PSupply + PIssued), tokenDecimals, PSupply, CEILING) - tokenDecimals), Bk, tokenDecimals, CEILING) | |
447 | + | let a1 = fraction((toBigInt((PSupply + PIssued)) * toBigInt(Scale8)), toBigInt(tokenDecimals), toBigInt(PSupply), CEILING) | |
448 | + | let Dk = toInt(fraction((a1 - (toBigInt(tokenDecimals) * toBigInt(Scale8))), toBigInt(Bk), (toBigInt(tokenDecimals) * toBigInt(Scale8)), CEILING)) | |
324 | 449 | let paymentAmount = getTokenPaymentAmount(tokenId) | |
325 | - | let toReturn = ((if ((paymentAmount != 0)) | |
326 | - | then paymentAmount | |
327 | - | else 0) - Dk) | |
450 | + | let toReturn = (paymentAmount - Dk) | |
328 | 451 | let t = if (if (needChange) | |
329 | 452 | then (toReturn > 0) | |
330 | 453 | else false) | |
351 | 474 | func handlePoolTokensRedeem (PRedeemed,userAddress) = { | |
352 | 475 | func handleTokenRedeem (accum,tokenId) = { | |
353 | 476 | let Bk = tryGetInteger((("global_" + getAssetString(tokenId)) + "_balance")) | |
354 | - | let PSupply = | |
477 | + | let PSupply = getVirtualPoolTokenAmount() | |
355 | 478 | let tokenDecimals = tryGetInteger((("static_" + getAssetString(tokenId)) + "_scale")) | |
356 | - | let amount = toInt(fraction((toBigInt(Scale8) - fraction(toBigInt((PSupply - PRedeemed)), toBigInt(Scale8), toBigInt(PSupply), CEILING)), toBigInt(Bk), toBigInt(Scale8), DOWN)) | |
479 | + | let psuppl = fraction((toBigInt((PSupply - PRedeemed)) * toBigInt(Scale8)), toBigInt(Scale8), toBigInt(PSupply), DOWN) | |
480 | + | let amount = toInt(fraction((toBigInt(Scale16) - psuppl), toBigInt(Bk), toBigInt(Scale16), CEILING)) | |
357 | 481 | (accum ++ [IntegerEntry((("global_" + getAssetString(tokenId)) + "_balance"), (Bk - amount)), ScriptTransfer(userAddress, amount, tokenId)]) | |
358 | 482 | } | |
359 | 483 | ||
377 | 501 | let IndexOut = value(indexOf(assetIds, assetOut)) | |
378 | 502 | if ((IndexIn == IndexOut)) | |
379 | 503 | then AmountIn | |
380 | - | else fraction(BalanceOut, ((Scale8 * Scale8) - toInt(pow(fraction(toBigInt(BalanceIn), toBigInt((Scale8 * Scale8)), toBigInt((BalanceIn + AmountIn)), HALFUP), 16, toBigInt(fraction(AssetsWeights[IndexIn], | |
504 | + | else fraction(BalanceOut, ((Scale8 * Scale8) - toInt(pow(fraction((toBigInt(BalanceIn) * toBigInt(10000)), toBigInt((Scale8 * Scale8)), (toBigInt((BalanceIn + AmountIn)) * toBigInt(10000)), HALFUP), 16, toBigInt(fraction(AssetsWeights[IndexIn], 1000000000000, AssetsWeights[IndexOut])), 12, 16, CEILING))), (Scale8 * Scale8), HALFEVEN) | |
381 | 505 | } | |
382 | - | ||
383 | - | ||
384 | - | func getTokenBalance (assetId) = match assetId { | |
385 | - | case t: ByteVector => | |
386 | - | assetBalance(this, t) | |
387 | - | case _ => | |
388 | - | wavesBalance(this).available | |
389 | - | } | |
390 | 506 | ||
391 | 507 | ||
392 | 508 | func calculateCurrentAssetInterest (assetId,assetIdStr,aBalance,tokenEarningsLastCheck) = { | |
418 | 534 | let transfer = if ((rewardAmount == 0)) | |
419 | 535 | then nil | |
420 | 536 | else [ScriptTransfer(address, rewardAmount, assetId)] | |
421 | - | $Tuple2(((accum._1 ++ transfer) ++ [IntegerEntry((("global_lastCheck_" + assetIdStr) + "_earnings"), (currentTokenEarnings - rewardAmount)), IntegerEntry((("global_lastCheck_" + assetIdStr) + "_interest"), currentTokenInterest), IntegerEntry((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"), currentTokenInterest)]), (accum._2 + | |
537 | + | $Tuple2(((accum._1 ++ transfer) ++ [IntegerEntry((("global_lastCheck_" + assetIdStr) + "_earnings"), (currentTokenEarnings - rewardAmount)), IntegerEntry((("global_lastCheck_" + assetIdStr) + "_interest"), currentTokenInterest), IntegerEntry((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"), currentTokenInterest)]), (accum._2 + calculateUsdValue(assetId, rewardAmount, aBalance))) | |
422 | 538 | } | |
423 | 539 | ||
424 | 540 | let accum = { | |
435 | 551 | ||
436 | 552 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
437 | 553 | } | |
438 | - | $Tuple2((accum._1 ++ [IntegerEntry((addressStr + "_ | |
554 | + | $Tuple2((accum._1 ++ [IntegerEntry((addressStr + "_claimedRewardUSD"), (tryGetInteger((addressStr + "_claimedRewardUSD")) + accum._2)), IntegerEntry((addressStr + "_lastClaim"), lastBlock.timestamp)]), accum._2) | |
439 | 555 | } | |
440 | 556 | ||
441 | 557 | ||
448 | 564 | func sum (accum,n) = (accum + parseIntValue(n)) | |
449 | 565 | ||
450 | 566 | ||
567 | + | func checkFeeAsset (accum,next) = if (if ((indexOf(supportedFeeAssetsStr, next) != unit)) | |
568 | + | then (accum == "") | |
569 | + | else false) | |
570 | + | then next | |
571 | + | else accum | |
572 | + | ||
573 | + | ||
574 | + | func getTmpRebalanceIds (newAssetIdsLi) = { | |
575 | + | let currentAssetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
576 | + | let result = newAssetIdsLi | |
577 | + | func f (accum,assetId) = if ((indexOf(result, assetId) == unit)) | |
578 | + | then (accum ++ [assetId]) | |
579 | + | else accum | |
580 | + | ||
581 | + | let $l = currentAssetIdsLi | |
582 | + | let $s = size($l) | |
583 | + | let $acc0 = result | |
584 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
585 | + | then $a | |
586 | + | else f($a, $l[$i]) | |
587 | + | ||
588 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
589 | + | then $a | |
590 | + | else throw("List size exceeds 10") | |
591 | + | ||
592 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
593 | + | } | |
594 | + | ||
595 | + | ||
596 | + | func checkTokensChange (newAssetIdsLi) = { | |
597 | + | let currentAssetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
598 | + | func rem (accum,assetId) = if ((indexOf(newAssetIdsLi, assetId) == unit)) | |
599 | + | then (accum + 1) | |
600 | + | else accum | |
601 | + | ||
602 | + | func add (accum,assetId) = if ((indexOf(currentAssetIdsLi, assetId) == unit)) | |
603 | + | then (accum + 1) | |
604 | + | else accum | |
605 | + | ||
606 | + | let removed = { | |
607 | + | let $l = currentAssetIdsLi | |
608 | + | let $s = size($l) | |
609 | + | let $acc0 = 0 | |
610 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
611 | + | then $a | |
612 | + | else rem($a, $l[$i]) | |
613 | + | ||
614 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
615 | + | then $a | |
616 | + | else throw("List size exceeds 10") | |
617 | + | ||
618 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
619 | + | } | |
620 | + | let added = { | |
621 | + | let $l = newAssetIdsLi | |
622 | + | let $s = size($l) | |
623 | + | let $acc0 = 0 | |
624 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
625 | + | then $a | |
626 | + | else add($a, $l[$i]) | |
627 | + | ||
628 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
629 | + | then $a | |
630 | + | else throw("List size exceeds 10") | |
631 | + | ||
632 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
633 | + | } | |
634 | + | (removed + added) | |
635 | + | } | |
636 | + | ||
637 | + | ||
638 | + | func validatePayments (assetsList,payments) = { | |
639 | + | func getPaymentAssets (accum,next) = if ((0 >= next.amount)) | |
640 | + | then throw(((("Too low payment amount for " + getAssetString(next.assetId)) + ": ") + toString(next.amount))) | |
641 | + | else (accum ++ [getAssetString(next.assetId)]) | |
642 | + | ||
643 | + | let paymentList = { | |
644 | + | let $l = payments | |
645 | + | let $s = size($l) | |
646 | + | let $acc0 = nil | |
647 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
648 | + | then $a | |
649 | + | else getPaymentAssets($a, $l[$i]) | |
650 | + | ||
651 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
652 | + | then $a | |
653 | + | else throw("List size exceeds 10") | |
654 | + | ||
655 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
656 | + | } | |
657 | + | func f1 (accum,next) = if ((indexOf(assetsList, next) == unit)) | |
658 | + | then throw(((next + " asset is present in payments, but is not in new assets: ") + makeString(assetsList, ","))) | |
659 | + | else (accum + 1) | |
660 | + | ||
661 | + | func f2 (accum,next) = if ((indexOf(paymentList, next) == unit)) | |
662 | + | then throw(((next + " asset is present in new assets, but is not in payments: ") + makeString(paymentList, ","))) | |
663 | + | else (accum + 1) | |
664 | + | ||
665 | + | let a1 = { | |
666 | + | let $l = paymentList | |
667 | + | let $s = size($l) | |
668 | + | let $acc0 = 0 | |
669 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
670 | + | then $a | |
671 | + | else f1($a, $l[$i]) | |
672 | + | ||
673 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
674 | + | then $a | |
675 | + | else throw("List size exceeds 10") | |
676 | + | ||
677 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
678 | + | } | |
679 | + | let a2 = { | |
680 | + | let $l = assetsList | |
681 | + | let $s = size($l) | |
682 | + | let $acc0 = 0 | |
683 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
684 | + | then $a | |
685 | + | else f2($a, $l[$i]) | |
686 | + | ||
687 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
688 | + | then $a | |
689 | + | else throw("List size exceeds 10") | |
690 | + | ||
691 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
692 | + | } | |
693 | + | (a1 + a2) | |
694 | + | } | |
695 | + | ||
696 | + | ||
697 | + | func validateWeights (weights) = { | |
698 | + | func v (accum,w) = { | |
699 | + | let wInt = valueOrErrorMessage(parseInt(w), ("Wrong weight format: " + w)) | |
700 | + | if (if ((MIN_WEIGHT > wInt)) | |
701 | + | then true | |
702 | + | else (wInt > MAX_WEIGHT)) | |
703 | + | then throw(((((("Weight should be in range " + toString(MIN_WEIGHT)) + " - ") + toString(MAX_WEIGHT)) + ", current: ") + w)) | |
704 | + | else accum | |
705 | + | } | |
706 | + | ||
707 | + | let $l = weights | |
708 | + | let $s = size($l) | |
709 | + | let $acc0 = 0 | |
710 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
711 | + | then $a | |
712 | + | else v($a, $l[$i]) | |
713 | + | ||
714 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
715 | + | then $a | |
716 | + | else throw("List size exceeds 10") | |
717 | + | ||
718 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
719 | + | } | |
720 | + | ||
721 | + | ||
451 | 722 | @Callable(i) | |
452 | 723 | func preInit (assetIdsStr,assetWeightsStr,baseTokenIdStr,poolDomain,poolOwner,fee) = { | |
453 | 724 | let poolOwnerAddress = Address(fromBase58String(poolOwner)) | |
725 | + | let assetIdsStrLi = split(assetIdsStr, ",") | |
726 | + | let assetIdsLi = { | |
727 | + | let $l = assetIdsStrLi | |
728 | + | let $s = size($l) | |
729 | + | let $acc0 = nil | |
730 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
731 | + | then $a | |
732 | + | else addAssetBytesToList($a, $l[$i]) | |
733 | + | ||
734 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
735 | + | then $a | |
736 | + | else throw("List size exceeds 10") | |
737 | + | ||
738 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
739 | + | } | |
740 | + | let feeAssetStr = { | |
741 | + | let $l = assetIdsStrLi | |
742 | + | let $s = size($l) | |
743 | + | let $acc0 = "" | |
744 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
745 | + | then $a | |
746 | + | else checkFeeAsset($a, $l[$i]) | |
747 | + | ||
748 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
749 | + | then $a | |
750 | + | else throw("List size exceeds 10") | |
751 | + | ||
752 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
753 | + | } | |
454 | 754 | if (isShutdown()) | |
455 | 755 | then throw("contract is on stop") | |
456 | 756 | else if ((this != i.caller)) | |
457 | 757 | then throw("admin only") | |
458 | - | else if ((size(poolDomain) > 13)) | |
459 | - | then throw("too large pool domain") | |
460 | - | else if (if ((fee > 500)) | |
461 | - | then true | |
462 | - | else (50 > fee)) | |
463 | - | then throw("fee value must be between 50 and 500 (0.5-5%)") | |
464 | - | else if (if (if (if (if ((indexOf(assetIdsStr, puzzleAssetIdStr) == unit)) | |
465 | - | then (indexOf(assetIdsStr, usdnAssetIdStr) == unit) | |
466 | - | else false) | |
467 | - | then (indexOf(assetIdsStr, usdtAssetIdStr) == unit) | |
468 | - | else false) | |
469 | - | then (indexOf(assetIdsStr, "WAVES") == unit) | |
470 | - | else false) | |
471 | - | then (indexOf(assetIdsStr, usdtPptAssetIdStr) == unit) | |
472 | - | else false) | |
473 | - | then throw("pool must have USDT-WXG, USDT-PPT, USDN, WAVES or PUZZLE in the composition") | |
758 | + | else if ((feeAssetStr == "")) | |
759 | + | then throw("pool must have one of the supported fee assets in the composition") | |
760 | + | else if ((size(poolDomain) > 13)) | |
761 | + | then throw("too large pool domain") | |
762 | + | else if (if ((fee > 500)) | |
763 | + | then true | |
764 | + | else (0 > fee)) | |
765 | + | then throw("fee value must be between 50 and 500 (0.5-5%)") | |
474 | 766 | else { | |
475 | - | let assetIdsStrLi = split(assetIdsStr, ",") | |
476 | - | let assetIdsLi = { | |
477 | - | let $l = assetIdsStrLi | |
478 | - | let $s = size($l) | |
479 | - | let $acc0 = nil | |
480 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
481 | - | then $a | |
482 | - | else addAssetBytesToList($a, $l[$i]) | |
483 | - | ||
484 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
485 | - | then $a | |
486 | - | else throw("List size exceeds 10") | |
487 | - | ||
488 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
489 | - | } | |
490 | 767 | let assetWeightsStrLi = split(assetWeightsStr, ",") | |
491 | 768 | let assetWeightsSum = { | |
492 | 769 | let $l = assetWeightsStrLi | |
493 | 770 | let $s = size($l) | |
494 | 771 | let $acc0 = 0 | |
495 | - | func $ | |
772 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
496 | 773 | then $a | |
497 | 774 | else sum($a, $l[$i]) | |
498 | 775 | ||
499 | - | func $ | |
776 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
500 | 777 | then $a | |
501 | 778 | else throw("List size exceeds 10") | |
502 | 779 | ||
503 | - | $ | |
780 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
504 | 781 | } | |
505 | - | let feeAssetStr = if ((indexOf(assetIdsStr, usdnAssetIdStr) != unit)) | |
506 | - | then usdnAssetIdStr | |
507 | - | else if ((indexOf(assetIdsStr, "WAVES") != unit)) | |
508 | - | then "WAVES" | |
509 | - | else if ((indexOf(assetIdsStr, usdtAssetIdStr) != unit)) | |
510 | - | then usdtAssetIdStr | |
511 | - | else if ((indexOf(assetIdsStr, puzzleAssetIdStr) != unit)) | |
512 | - | then puzzleAssetIdStr | |
513 | - | else usdtPptAssetIdStr | |
514 | 782 | func addTokenDataEntries (accum,assetNum) = if ((assetNum >= size(assetIdsLi))) | |
515 | 783 | then accum | |
516 | 784 | else { | |
529 | 797 | let $l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
530 | 798 | let $s = size($l) | |
531 | 799 | let $acc0 = nil | |
532 | - | func $ | |
800 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
533 | 801 | then $a | |
534 | 802 | else addTokenDataEntries($a, $l[$i]) | |
535 | 803 | ||
536 | - | func $ | |
804 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
537 | 805 | then $a | |
538 | 806 | else throw("List size exceeds 10") | |
539 | 807 | ||
540 | - | $ | |
541 | - | } ++ [StringEntry("static_tokenIds", assetIdsStr), StringEntry("static_feeToken", feeAssetStr), StringEntry("static_tokenWeights", assetWeightsStr), IntegerEntry("static_tokensAmount", size(assetIdsLi)), StringEntry("static_poolDomain", poolDomain), StringEntry("static_baseTokenId", baseTokenIdStr), StringEntry("static_poolOwner", poolOwner), IntegerEntry("static_fee", fee)]) | |
808 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
809 | + | } ++ [StringEntry("static_tokenIds", assetIdsStr), StringEntry("static_feeToken", feeAssetStr), StringEntry("static_tokenWeights", assetWeightsStr), IntegerEntry("static_tokensAmount", size(assetIdsLi)), StringEntry("static_poolDomain", poolDomain), StringEntry("static_baseTokenId", baseTokenIdStr), StringEntry("static_poolOwner", poolOwner), IntegerEntry("static_fee", fee), IntegerEntry("static_KMult", Scale16), IntegerEntry("global_wasPreInited", 1)]) | |
542 | 810 | } | |
543 | 811 | } | |
544 | 812 | ||
634 | 902 | else if (!(checkTokensValidity(i.payments))) | |
635 | 903 | then throw("wrong assets attached") | |
636 | 904 | else { | |
637 | - | let PIssued = getMinPIssued(i.payments) | |
638 | - | let reissue = Reissue(getBinaryValue("global_poolToken_id"), PIssued, true) | |
639 | - | let result = handlePoolTokensAdd(PIssued, i.payments, i.originCaller, needChange) | |
640 | - | $Tuple2((result ++ [reissue, ScriptTransfer(i.caller, PIssued, tryGetBinary("global_poolToken_id")), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") + PIssued))]), PIssued) | |
905 | + | let PIssuedNoMult = getMinPIssued(i.payments) | |
906 | + | let result = handlePoolTokensAdd(PIssuedNoMult, i.payments, i.originCaller, needChange) | |
907 | + | let PIssuedWithMult = fraction(PIssuedNoMult, Scale16, getKMult(), DOWN) | |
908 | + | let reissue = Reissue(getBinaryValue("global_poolToken_id"), PIssuedWithMult, true) | |
909 | + | $Tuple2((result ++ [reissue, ScriptTransfer(i.caller, PIssuedWithMult, tryGetBinary("global_poolToken_id")), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") + PIssuedWithMult))]), PIssuedWithMult) | |
641 | 910 | } | |
911 | + | ||
912 | + | ||
913 | + | ||
914 | + | @Callable(i) | |
915 | + | func redeemIndex (sendToOrigin) = { | |
916 | + | let pmt = i.payments[0] | |
917 | + | if ((pmt.assetId != tryGetBinary("global_poolToken_id"))) | |
918 | + | then throw("please attach pool share token") | |
919 | + | else if (isShutdown()) | |
920 | + | then throw("contract is on stop") | |
921 | + | else { | |
922 | + | let PRedeemedWithMult = pmt.amount | |
923 | + | let PRedeemedWithNoMult = fraction(PRedeemedWithMult, getKMult(), Scale16, DOWN) | |
924 | + | let result = handlePoolTokensRedeem(PRedeemedWithNoMult, if (sendToOrigin) | |
925 | + | then i.originCaller | |
926 | + | else i.caller) | |
927 | + | (result ++ [Burn(tryGetBinary("global_poolToken_id"), PRedeemedWithMult), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") - PRedeemedWithMult))]) | |
928 | + | } | |
929 | + | } | |
642 | 930 | ||
643 | 931 | ||
644 | 932 | ||
654 | 942 | ||
655 | 943 | ||
656 | 944 | @Callable(i) | |
657 | - | func unstakeIndex (puzzleAmount) = { | |
658 | - | let addressStr = toString(i.originCaller) | |
659 | - | let puzzleAvailable = tryGetInteger((addressStr + "_indexStaked")) | |
945 | + | func stakeIndexFor (addressStr) = { | |
946 | + | let pmt = i.payments[0] | |
947 | + | if ((value(pmt.assetId) != tryGetBinary("global_poolToken_id"))) | |
948 | + | then throw("wrong asset attached") | |
949 | + | else indexStakeResult(addressStr, pmt.amount) | |
950 | + | } | |
951 | + | ||
952 | + | ||
953 | + | ||
954 | + | @Callable(i) | |
955 | + | func unstakeIndex (indexAmount) = { | |
956 | + | let addressStr = if ((indexOf(layer2Addresses, toString(i.caller)) != unit)) | |
957 | + | then toString(i.originCaller) | |
958 | + | else toString(i.caller) | |
959 | + | let indexAvailable = tryGetInteger((addressStr + "_indexStaked")) | |
660 | 960 | if (isShutdown()) | |
661 | 961 | then throw("contract is on stop") | |
662 | - | else if (( | |
962 | + | else if ((indexAmount > indexAvailable)) | |
663 | 963 | then throw("you don't have index tokens available") | |
664 | 964 | else if (isShutdown()) | |
665 | 965 | then throw("contract is on stop") | |
666 | - | else (claimResult( | |
966 | + | else (claimResult(addressFromStringValue(addressStr))._1 ++ [IntegerEntry((addressStr + "_indexStaked"), (indexAvailable - indexAmount)), IntegerEntry("global_indexStaked", (tryGetInteger("global_indexStaked") - indexAmount)), ScriptTransfer(i.caller, indexAmount, getBinaryValue("global_poolToken_id"))]) | |
667 | 967 | } | |
668 | 968 | ||
669 | 969 | ||
681 | 981 | ||
682 | 982 | ||
683 | 983 | @Callable(i) | |
684 | - | func redeemIndex (sendToOrigin) = { | |
685 | - | let pmt = i.payments[0] | |
686 | - | if ((pmt.assetId != tryGetBinary("global_poolToken_id"))) | |
687 | - | then throw("please attach pool share token") | |
688 | - | else if (isShutdown()) | |
689 | - | then throw("contract is on stop") | |
690 | - | else { | |
691 | - | let PRedeemed = pmt.amount | |
692 | - | let result = handlePoolTokensRedeem(PRedeemed, if (sendToOrigin) | |
693 | - | then i.originCaller | |
694 | - | else i.caller) | |
695 | - | (result ++ [Burn(tryGetBinary("global_poolToken_id"), PRedeemed), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") - PRedeemed))]) | |
696 | - | } | |
697 | - | } | |
698 | - | ||
699 | - | ||
700 | - | ||
701 | - | @Callable(i) | |
702 | 984 | func swap (assetOut,minimum) = { | |
703 | 985 | let pmt = if ((size(i.payments) == 1)) | |
704 | 986 | then value(i.payments[0]) | |
706 | 988 | let AmountIn = value(i.payments[0].amount) | |
707 | 989 | let AssetIn = pmt.assetId | |
708 | 990 | let AssetOut = getAssetBytes(assetOut) | |
991 | + | let assetIn = getAssetString(AssetIn) | |
992 | + | let scaleIn = (Scale8 / tryGetInteger((("static_" + assetIn) + "_scale"))) | |
993 | + | let scaleOut = (Scale8 / tryGetInteger((("static_" + assetOut) + "_scale"))) | |
709 | 994 | let feeAssetOutStr = tryGetString("static_feeToken") | |
710 | 995 | let feeAssetOut = if ((feeAssetOutStr == "")) | |
711 | 996 | then usdnAssetId | |
712 | 997 | else getAssetBytes(feeAssetOutStr) | |
713 | 998 | let AssetInBalance = tryGetInteger((("global_" + getAssetString(AssetIn)) + "_balance")) | |
714 | 999 | let AssetOutBalance = tryGetInteger((("global_" + assetOut) + "_balance")) | |
1000 | + | let AssetInBalanceScaled = (AssetInBalance * scaleIn) | |
1001 | + | let AssetOutBalanceScaled = (AssetOutBalance * scaleOut) | |
715 | 1002 | let feeAmountIn = fraction(AmountIn, Fee, FeeScale) | |
716 | 1003 | let cleanAmountIn = (AmountIn - feeAmountIn) | |
717 | - | let AmountOut = calculateOutAmount(cleanAmountIn, AssetIn, AssetOut, AssetInBalance, AssetOutBalance) | |
1004 | + | let cleanAmountInScaled = (cleanAmountIn * scaleIn) | |
1005 | + | let AmountOut1 = calculateOutAmount(cleanAmountInScaled, AssetIn, AssetOut, AssetInBalanceScaled, AssetOutBalanceScaled) | |
1006 | + | let AmountOut = fraction(AmountOut1, 1, scaleOut) | |
718 | 1007 | let AssetOutBalance2 = (AssetOutBalance - AmountOut) | |
719 | 1008 | let AssetInBalance2 = (AssetInBalance + cleanAmountIn) | |
720 | 1009 | let feeAssetOutBalance = if ((feeAssetOut == AssetIn)) | |
734 | 1023 | else { | |
735 | 1024 | let creatorFee = fraction(feeAmountOut, 1, 10) | |
736 | 1025 | let protocolFee = fraction(feeAmountOut, 4, 10) | |
737 | - | let stakingTopUp = if (if ((feeAssetOut == usdnAssetId)) | |
738 | - | then true | |
739 | - | else (feeAssetOut == puzzleAssetId)) | |
740 | - | then reentrantInvoke(Address(base58'3PFTbywqxtFfukX3HyT881g4iW5K4QL3FAS'), "topUpReward", nil, [AttachedPayment(feeAssetOut, protocolFee)]) | |
1026 | + | let newBalanceIn = AssetInBalance2 | |
1027 | + | let newBalanceOut = (AssetOutBalance2 - (if ((AssetOut == feeAssetOut)) | |
1028 | + | then feeAmountOut | |
1029 | + | else 0)) | |
1030 | + | let newBalanceFeeAsset = if (if ((feeAssetOut != AssetIn)) | |
1031 | + | then (feeAssetOut != AssetOut) | |
1032 | + | else false) | |
1033 | + | then (feeAssetOutBalance - feeAmountOut) | |
741 | 1034 | else unit | |
742 | - | if ((stakingTopUp == stakingTopUp)) | |
743 | - | then { | |
744 | - | let newBalanceIn = AssetInBalance2 | |
745 | - | let newBalanceOut = (AssetOutBalance2 - (if ((AssetOut == feeAssetOut)) | |
746 | - | then feeAmountOut | |
747 | - | else 0)) | |
748 | - | let newBalanceFeeAsset = if (if ((feeAssetOut != AssetIn)) | |
749 | - | then (feeAssetOut != AssetOut) | |
750 | - | else false) | |
751 | - | then (feeAssetOutBalance - feeAmountOut) | |
752 | - | else unit | |
753 | - | let assetInChange = IntegerEntry((("global_" + getAssetString(AssetIn)) + "_balance"), newBalanceIn) | |
754 | - | let assetOutChange = IntegerEntry((("global_" + assetOut) + "_balance"), newBalanceOut) | |
755 | - | let feeAssetOutChange = if ((newBalanceFeeAsset != unit)) | |
756 | - | then IntegerEntry((("global_" + getAssetString(feeAssetOut)) + "_balance"), value(newBalanceFeeAsset)) | |
757 | - | else StringEntry("hello", "world") | |
758 | - | let volumeUpdate = calculateUsdnValue(AssetIn, AmountIn, AssetInBalance, feeAssetOutBalance) | |
759 | - | $Tuple2(([assetOutChange, assetInChange, feeAssetOutChange, ScriptTransfer(i.caller, AmountOut, AssetOut), ScriptTransfer(addressFromStringValue(tryGetString("static_poolOwner")), creatorFee, feeAssetOut), IntegerEntry("global_earnedByOwner", (tryGetInteger("global_earnedByOwner") + creatorFee)), IntegerEntry("global_volume", (tryGetInteger("global_volume") + volumeUpdate))] ++ (if ((stakingTopUp == unit)) | |
760 | - | then [ScriptTransfer(Address(base58'3PFWAVKmXjfHXyzJb12jCbhP4Uhi9t4uWiD'), protocolFee, feeAssetOut)] | |
761 | - | else nil)), AmountOut) | |
762 | - | } | |
763 | - | else throw("Strict value is not equal to itself.") | |
1035 | + | let assetInChange = IntegerEntry((("global_" + getAssetString(AssetIn)) + "_balance"), newBalanceIn) | |
1036 | + | let assetOutChange = IntegerEntry((("global_" + assetOut) + "_balance"), newBalanceOut) | |
1037 | + | let feeAssetOutChange = if ((newBalanceFeeAsset != unit)) | |
1038 | + | then IntegerEntry((("global_" + getAssetString(feeAssetOut)) + "_balance"), value(newBalanceFeeAsset)) | |
1039 | + | else StringEntry("hello", "world") | |
1040 | + | let volumeUpdate = calculateUsdnValue(AssetIn, AmountIn, AssetInBalance, feeAssetOutBalance) | |
1041 | + | let volumeUsdUpdate = calculateUsdValue(AssetIn, AmountIn, AssetInBalance) | |
1042 | + | $Tuple2([assetOutChange, assetInChange, feeAssetOutChange, ScriptTransfer(i.caller, AmountOut, AssetOut), ScriptTransfer(addressFromStringValue(tryGetString("static_poolOwner")), creatorFee, feeAssetOut), IntegerEntry("global_earnedByOwner", (tryGetInteger("global_earnedByOwner") + creatorFee)), IntegerEntry("global_volume", (tryGetInteger("global_volume") + volumeUpdate)), IntegerEntry("global_volume_usd", (tryGetInteger("global_volume_usd") + volumeUsdUpdate)), ScriptTransfer(feesAddress, protocolFee, feeAssetOut)], AmountOut) | |
764 | 1043 | } | |
1044 | + | } | |
1045 | + | ||
1046 | + | ||
1047 | + | ||
1048 | + | @Callable(i) | |
1049 | + | func swapReadOnly (assetIn,assetOut,AmountIn) = { | |
1050 | + | let AssetIn = getAssetBytes(assetIn) | |
1051 | + | let AssetOut = getAssetBytes(assetOut) | |
1052 | + | let scaleIn = (Scale8 / tryGetInteger((("static_" + assetIn) + "_scale"))) | |
1053 | + | let scaleOut = (Scale8 / tryGetInteger((("static_" + assetOut) + "_scale"))) | |
1054 | + | let feeAssetOutStr = tryGetString("static_feeToken") | |
1055 | + | let feeAssetOut = if ((feeAssetOutStr == "")) | |
1056 | + | then usdnAssetId | |
1057 | + | else getAssetBytes(feeAssetOutStr) | |
1058 | + | let AssetInBalance = tryGetInteger((("global_" + getAssetString(AssetIn)) + "_balance")) | |
1059 | + | let AssetOutBalance = tryGetInteger((("global_" + assetOut) + "_balance")) | |
1060 | + | let AssetInBalanceScaled = (AssetInBalance * scaleIn) | |
1061 | + | let AssetOutBalanceScaled = (AssetOutBalance * scaleOut) | |
1062 | + | let feeAmountIn = fraction(AmountIn, Fee, FeeScale) | |
1063 | + | let cleanAmountIn = (AmountIn - feeAmountIn) | |
1064 | + | let cleanAmountInScaled = (cleanAmountIn * scaleIn) | |
1065 | + | let AmountOut1 = calculateOutAmount(cleanAmountInScaled, AssetIn, AssetOut, AssetInBalanceScaled, AssetOutBalanceScaled) | |
1066 | + | let AmountOut = fraction(AmountOut1, 1, scaleOut) | |
1067 | + | let AssetOutBalance2 = (AssetOutBalance - AmountOut) | |
1068 | + | let AssetInBalance2 = (AssetInBalance + cleanAmountIn) | |
1069 | + | let feeAssetOutBalance = if ((feeAssetOut == AssetIn)) | |
1070 | + | then AssetInBalance2 | |
1071 | + | else if ((feeAssetOut == AssetOut)) | |
1072 | + | then AssetOutBalance2 | |
1073 | + | else tryGetInteger((("global_" + getAssetString(feeAssetOut)) + "_balance")) | |
1074 | + | let feeAmountOut = calculateOutAmount(feeAmountIn, AssetIn, feeAssetOut, AssetInBalance, feeAssetOutBalance) | |
1075 | + | if ((AssetOut == AssetIn)) | |
1076 | + | then throw("this swap is not allowed") | |
1077 | + | else if ((0 > (AssetOutBalance - AmountOut))) | |
1078 | + | then throw("contract is out of reserves") | |
1079 | + | else if (isShutdown()) | |
1080 | + | then throw("contract is on stop") | |
1081 | + | else $Tuple2(nil, AmountOut) | |
765 | 1082 | } | |
766 | 1083 | ||
767 | 1084 | ||
772 | 1089 | else [StringEntry("static_poolOwner", newOwnerAddress)] | |
773 | 1090 | ||
774 | 1091 | ||
1092 | + | ||
1093 | + | @Callable(i) | |
1094 | + | func setFee (newFee) = if ((toString(i.caller) != tryGetString("static_poolOwner"))) | |
1095 | + | then throw("this call available only for pool owner") | |
1096 | + | else if ((1 > valueOrElse(getInteger(govAddress, ("approvedTx_" + toBase58String(i.transactionId))), 0))) | |
1097 | + | then throw("this transaction needs approval from puzzle network") | |
1098 | + | else [IntegerEntry("static_fee", newFee)] | |
1099 | + | ||
1100 | + | ||
1101 | + | ||
1102 | + | @Callable(i) | |
1103 | + | func setRebalancingPlan (assetIdsStr,assetWeightsStr,baseTokenIdStr,stepsAmount,stepsInterval) = if ((i.caller != addressFromStringValue(tryGetString("static_poolOwner")))) | |
1104 | + | then throw("this call available only for pool owner") | |
1105 | + | else if (valueOrElse(getBoolean(this, "rebalance_inProgress"), false)) | |
1106 | + | then throw("rebalancing in progress") | |
1107 | + | else { | |
1108 | + | let newAssetWeightsStrLi = split(assetWeightsStr, ",") | |
1109 | + | let newAssetIdsStrLi = split(assetIdsStr, ",") | |
1110 | + | let feeAssetStr = { | |
1111 | + | let $l = newAssetIdsStrLi | |
1112 | + | let $s = size($l) | |
1113 | + | let $acc0 = "" | |
1114 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
1115 | + | then $a | |
1116 | + | else checkFeeAsset($a, $l[$i]) | |
1117 | + | ||
1118 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
1119 | + | then $a | |
1120 | + | else throw("List size exceeds 10") | |
1121 | + | ||
1122 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1123 | + | } | |
1124 | + | let assetWeightsSum = { | |
1125 | + | let $l = newAssetWeightsStrLi | |
1126 | + | let $s = size($l) | |
1127 | + | let $acc0 = 0 | |
1128 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1129 | + | then $a | |
1130 | + | else sum($a, $l[$i]) | |
1131 | + | ||
1132 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1133 | + | then $a | |
1134 | + | else throw("List size exceeds 10") | |
1135 | + | ||
1136 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1137 | + | } | |
1138 | + | let oldAssetIds = getStringValue("static_tokenIds") | |
1139 | + | let oldAssetIdsLi = split(oldAssetIds, ",") | |
1140 | + | func findAdded (accum,next) = if ((indexOf(oldAssetIdsLi, next) == unit)) | |
1141 | + | then (accum ++ [next]) | |
1142 | + | else accum | |
1143 | + | ||
1144 | + | func findRemoved (accum,next) = if ((indexOf(newAssetIdsStrLi, next) == unit)) | |
1145 | + | then (accum ++ [next]) | |
1146 | + | else accum | |
1147 | + | ||
1148 | + | let addedAssets = { | |
1149 | + | let $l = newAssetIdsStrLi | |
1150 | + | let $s = size($l) | |
1151 | + | let $acc0 = nil | |
1152 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
1153 | + | then $a | |
1154 | + | else findAdded($a, $l[$i]) | |
1155 | + | ||
1156 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
1157 | + | then $a | |
1158 | + | else throw("List size exceeds 10") | |
1159 | + | ||
1160 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1161 | + | } | |
1162 | + | let removedAssets = { | |
1163 | + | let $l = oldAssetIdsLi | |
1164 | + | let $s = size($l) | |
1165 | + | let $acc0 = nil | |
1166 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1167 | + | then $a | |
1168 | + | else findRemoved($a, $l[$i]) | |
1169 | + | ||
1170 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1171 | + | then $a | |
1172 | + | else throw("List size exceeds 10") | |
1173 | + | ||
1174 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1175 | + | } | |
1176 | + | let validPayments = validatePayments(addedAssets, i.payments) | |
1177 | + | let validWeights = validateWeights(newAssetWeightsStrLi) | |
1178 | + | if ((validWeights == validWeights)) | |
1179 | + | then if ((validPayments != (size(addedAssets) + size(i.payments)))) | |
1180 | + | then throw("Payments not present or something wrong with them") | |
1181 | + | else if ((size(newAssetIdsStrLi) != size(newAssetWeightsStrLi))) | |
1182 | + | then throw("assetIds and assetWeights should have same length") | |
1183 | + | else if ((validPayments != (size(addedAssets) + size(i.payments)))) | |
1184 | + | then throw("Payments not present or something wrong with them") | |
1185 | + | else if ((feeAssetStr == "")) | |
1186 | + | then throw("pool must have one of the supported fee assets in the composition") | |
1187 | + | else if ((indexOf(newAssetIdsStrLi, baseTokenIdStr) == unit)) | |
1188 | + | then throw("baseTokenId should be present in assetIds") | |
1189 | + | else if (if ((MIN_STEPS_AMOUNT > stepsAmount)) | |
1190 | + | then true | |
1191 | + | else (stepsAmount > MAX_STEPS_AMOUNT)) | |
1192 | + | then throw(((((("Steps amount should be between " + toString(MIN_STEPS_AMOUNT)) + " and ") + toString(MAX_STEPS_AMOUNT)) + ", current: ") + toString(stepsAmount))) | |
1193 | + | else if (if ((MIN_STEPS_INTERVAL > stepsInterval)) | |
1194 | + | then true | |
1195 | + | else (stepsInterval > MAX_STEPS_INTERVAL)) | |
1196 | + | then throw(((((("Steps interval should be between " + toString(MIN_STEPS_INTERVAL)) + " and ") + toString(MAX_STEPS_INTERVAL)) + ", current: ") + toString(stepsInterval))) | |
1197 | + | else if ((assetWeightsSum != 10000)) | |
1198 | + | then throw(("sum of token weights must be equal to 10000, current: " + toString(assetWeightsSum))) | |
1199 | + | else { | |
1200 | + | func f (accum,assetIdStr) = { | |
1201 | + | let oldWeight = tryGetInteger((("static_" + assetIdStr) + "_weight")) | |
1202 | + | let newWeight = if ((indexOf(newAssetIdsStrLi, assetIdStr) == unit)) | |
1203 | + | then 0 | |
1204 | + | else parseIntValue(value(newAssetWeightsStrLi[value(indexOf(newAssetIdsStrLi, assetIdStr))])) | |
1205 | + | let deltaPerStep = fraction((newWeight - oldWeight), 10000, stepsAmount) | |
1206 | + | (accum ++ [toString(deltaPerStep)]) | |
1207 | + | } | |
1208 | + | ||
1209 | + | let tmpAssetIdsLi = getTmpRebalanceIds(newAssetIdsStrLi) | |
1210 | + | let assetDeltas = { | |
1211 | + | let $l = tmpAssetIdsLi | |
1212 | + | let $s = size($l) | |
1213 | + | let $acc0 = nil | |
1214 | + | func $f8_1 ($a,$i) = if (($i >= $s)) | |
1215 | + | then $a | |
1216 | + | else f($a, $l[$i]) | |
1217 | + | ||
1218 | + | func $f8_2 ($a,$i) = if (($i >= $s)) | |
1219 | + | then $a | |
1220 | + | else throw("List size exceeds 10") | |
1221 | + | ||
1222 | + | $f8_2($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1223 | + | } | |
1224 | + | let newTokensAdded = (checkTokensChange(newAssetIdsStrLi) > 0) | |
1225 | + | func recordAssetPayment (accum,next) = (accum ++ [IntegerEntry(("rebalance_attachedPayment_" + getAssetString(next.assetId)), next.amount)]) | |
1226 | + | ||
1227 | + | let paymentEntries = { | |
1228 | + | let $l = i.payments | |
1229 | + | let $s = size($l) | |
1230 | + | let $acc0 = nil | |
1231 | + | func $f9_1 ($a,$i) = if (($i >= $s)) | |
1232 | + | then $a | |
1233 | + | else recordAssetPayment($a, $l[$i]) | |
1234 | + | ||
1235 | + | func $f9_2 ($a,$i) = if (($i >= $s)) | |
1236 | + | then $a | |
1237 | + | else throw("List size exceeds 10") | |
1238 | + | ||
1239 | + | $f9_2($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1240 | + | } | |
1241 | + | let storeWeights = saveCurrentWeights() | |
1242 | + | let requestGovInvoke = invoke(govAddress, "requestRebalancing", [toBase58String(i.transactionId)], nil) | |
1243 | + | if ((requestGovInvoke == requestGovInvoke)) | |
1244 | + | then (([StringEntry("rebalance_addedAssets", makeString(addedAssets, ",")), StringEntry("rebalance_removedAssets", makeString(removedAssets, ",")), StringEntry("tmp_rebalanceAssetIds", makeString(tmpAssetIdsLi, ",")), BooleanEntry("rebalance_inProgress", true), BooleanEntry("rebalance_newTokensAdded", newTokensAdded), IntegerEntry("rebalance_stepsDone", 0), IntegerEntry("rebalance_lastStepHeight", height), IntegerEntry("rebalance_stepsAmount", stepsAmount), IntegerEntry("rebalance_stepsInterval", stepsInterval), StringEntry("rebalance_assetIds", assetIdsStr), StringEntry("rebalance_newBaseTokenId", baseTokenIdStr), StringEntry("rebalance_assetDeltas", makeString(assetDeltas, ","))] ++ paymentEntries) ++ storeWeights) | |
1245 | + | else throw("Strict value is not equal to itself.") | |
1246 | + | } | |
1247 | + | else throw("Strict value is not equal to itself.") | |
1248 | + | } | |
1249 | + | ||
1250 | + | ||
1251 | + | ||
1252 | + | @Callable(i) | |
1253 | + | func stepRebalancing () = { | |
1254 | + | let rebId = valueOrErrorMessage(getString(govAddress, ("pool_lastRebalancing_" + toString(this))), "rebalancing is not registered at gov address") | |
1255 | + | if (!(valueOrElse(getBoolean(this, "rebalance_inProgress"), false))) | |
1256 | + | then throw("no rebalancing in progress") | |
1257 | + | else if ((valueOrElse(getInteger(govAddress, ("rebalancing_status_" + rebId)), 0) != 2)) | |
1258 | + | then throw("this transaction needs approval from puzzle network") | |
1259 | + | else { | |
1260 | + | let lastStepHeight = getIntegerValue("rebalance_lastStepHeight") | |
1261 | + | let stepInterval = getIntegerValue("rebalance_stepsInterval") | |
1262 | + | let stepsDone = getIntegerValue("rebalance_stepsDone") | |
1263 | + | let nextStepHeight = (lastStepHeight + stepInterval) | |
1264 | + | if ((nextStepHeight > height)) | |
1265 | + | then throw("can't be done yet") | |
1266 | + | else { | |
1267 | + | let assetDeltas = split(getStringValue("rebalance_assetDeltas"), ",") | |
1268 | + | let newAssetIdsStr = getStringValue("tmp_rebalanceAssetIds") | |
1269 | + | let newAssetIds = split(newAssetIdsStr, ",") | |
1270 | + | func f (accum,assetIdStr) = (accum ++ [toString(fraction(((valueOrElse(getInteger(("rebalance_startWeight_" + assetIdStr)), 0) * 10000) + (parseIntValue(assetDeltas[value(indexOf(newAssetIds, assetIdStr))]) * (stepsDone + 1))), 1, 10000, HALFUP))]) | |
1271 | + | ||
1272 | + | let newShares = makeString({ | |
1273 | + | let $l = newAssetIds | |
1274 | + | let $s = size($l) | |
1275 | + | let $acc0 = nil | |
1276 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
1277 | + | then $a | |
1278 | + | else f($a, $l[$i]) | |
1279 | + | ||
1280 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
1281 | + | then $a | |
1282 | + | else throw("List size exceeds 10") | |
1283 | + | ||
1284 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1285 | + | }, ",") | |
1286 | + | let newTokensAdded = getBooleanValue("rebalance_newTokensAdded") | |
1287 | + | let inv = if (if (newTokensAdded) | |
1288 | + | then (stepsDone == 0) | |
1289 | + | else false) | |
1290 | + | then invoke(this, "doRebalancingWithNewTokens", [newAssetIdsStr, newShares, getStringValue("rebalance_newBaseTokenId")], nil) | |
1291 | + | else invoke(this, "doRebalancing", [newShares], nil) | |
1292 | + | if ((inv == inv)) | |
1293 | + | then { | |
1294 | + | let notifyInvoke = invoke(poolsHubAddress, "notifyPoolChange", nil, nil) | |
1295 | + | if ((notifyInvoke == notifyInvoke)) | |
1296 | + | then { | |
1297 | + | let isFinished = ((stepsDone + 1) >= getIntegerValue("rebalance_stepsAmount")) | |
1298 | + | let actions = [BooleanEntry("rebalance_inProgress", !(isFinished)), IntegerEntry("rebalance_stepsDone", (stepsDone + 1)), IntegerEntry("rebalance_lastStepHeight", height)] | |
1299 | + | if ((stepsDone == 0)) | |
1300 | + | then (actions ++ [StringEntry("static_tokenIds", newAssetIdsStr)]) | |
1301 | + | else if (isFinished) | |
1302 | + | then { | |
1303 | + | let removedAssetsLi = split(tryGetString("rebalance_removedAssets"), ",") | |
1304 | + | func rmData (accum,assetId) = (accum ++ [DeleteEntry((("static_" + assetId) + "_scale")), DeleteEntry((("static_" + assetId) + "_decimals")), DeleteEntry((("static_" + assetId) + "_weight")), DeleteEntry((("global_" + assetId) + "_balance")), DeleteEntry(("rebalance_attachedPayment_" + assetId))]) | |
1305 | + | ||
1306 | + | let rm = { | |
1307 | + | let $l = removedAssetsLi | |
1308 | + | let $s = size($l) | |
1309 | + | let $acc0 = nil | |
1310 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1311 | + | then $a | |
1312 | + | else rmData($a, $l[$i]) | |
1313 | + | ||
1314 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1315 | + | then $a | |
1316 | + | else throw("List size exceeds 10") | |
1317 | + | ||
1318 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1319 | + | } | |
1320 | + | let addedAssetsLi = split(tryGetString("rebalance_addedAssets"), ",") | |
1321 | + | func addRemovePayments (accum,assetId) = (accum ++ [DeleteEntry(("rebalance_attachedPayment_" + assetId))]) | |
1322 | + | ||
1323 | + | let rmPayments = { | |
1324 | + | let $l = addedAssetsLi | |
1325 | + | let $s = size($l) | |
1326 | + | let $acc0 = nil | |
1327 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
1328 | + | then $a | |
1329 | + | else addRemovePayments($a, $l[$i]) | |
1330 | + | ||
1331 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
1332 | + | then $a | |
1333 | + | else throw("List size exceeds 10") | |
1334 | + | ||
1335 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1336 | + | } | |
1337 | + | let finalAssetsIdsStr = tryGetString("rebalance_assetIds") | |
1338 | + | let AssetsWeightsStr = { | |
1339 | + | let $l = split(finalAssetsIdsStr, ",") | |
1340 | + | let $s = size($l) | |
1341 | + | let $acc0 = nil | |
1342 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1343 | + | then $a | |
1344 | + | else addAssetWeightToStrList($a, $l[$i]) | |
1345 | + | ||
1346 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1347 | + | then $a | |
1348 | + | else throw("List size exceeds 10") | |
1349 | + | ||
1350 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1351 | + | } | |
1352 | + | let notify = invoke(govAddress, "notifyRebalancingDone", [rebId], nil) | |
1353 | + | if ((notify == notify)) | |
1354 | + | then (((actions ++ rm) ++ rmPayments) ++ [StringEntry("static_tokenIds", finalAssetsIdsStr), StringEntry("static_tokenWeights", makeString(AssetsWeightsStr, ",")), IntegerEntry("static_tokensAmount", size(split(finalAssetsIdsStr, ",")))]) | |
1355 | + | else throw("Strict value is not equal to itself.") | |
1356 | + | } | |
1357 | + | else { | |
1358 | + | let finalAssetsIdsStr = tryGetString("rebalance_assetIds") | |
1359 | + | let AssetsWeightsStr = { | |
1360 | + | let $l = split(finalAssetsIdsStr, ",") | |
1361 | + | let $s = size($l) | |
1362 | + | let $acc0 = nil | |
1363 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1364 | + | then $a | |
1365 | + | else addAssetWeightToStrList($a, $l[$i]) | |
1366 | + | ||
1367 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1368 | + | then $a | |
1369 | + | else throw("List size exceeds 10") | |
1370 | + | ||
1371 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1372 | + | } | |
1373 | + | (actions ++ [StringEntry("static_tokenWeights", makeString(AssetsWeightsStr, ","))]) | |
1374 | + | } | |
1375 | + | } | |
1376 | + | else throw("Strict value is not equal to itself.") | |
1377 | + | } | |
1378 | + | else throw("Strict value is not equal to itself.") | |
1379 | + | } | |
1380 | + | } | |
1381 | + | } | |
1382 | + | ||
1383 | + | ||
1384 | + | ||
1385 | + | @Callable(i) | |
1386 | + | func doRebalancing (assetWeightsStr) = { | |
1387 | + | let assetWeightsStrLi = split(assetWeightsStr, ",") | |
1388 | + | let assetWeightsSum = { | |
1389 | + | let $l = assetWeightsStrLi | |
1390 | + | let $s = size($l) | |
1391 | + | let $acc0 = 0 | |
1392 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
1393 | + | then $a | |
1394 | + | else sum($a, $l[$i]) | |
1395 | + | ||
1396 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
1397 | + | then $a | |
1398 | + | else throw("List size exceeds 10") | |
1399 | + | ||
1400 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1401 | + | } | |
1402 | + | let assetIdsStrLi = split(tryGetString("static_tokenIds"), ",") | |
1403 | + | if ((i.caller != this)) | |
1404 | + | then throw("this call available only for admin") | |
1405 | + | else { | |
1406 | + | let oldKMult = getKMult() | |
1407 | + | func handler (pars,assetId) = { | |
1408 | + | let accum = pars._1 | |
1409 | + | let assetIdStr = getAssetString(assetId) | |
1410 | + | func handler2 (accum,n) = if ((n == assetId)) | |
1411 | + | then value(indexOf(assetIds, n)) | |
1412 | + | else accum | |
1413 | + | ||
1414 | + | let Token = { | |
1415 | + | let $l = assetIds | |
1416 | + | let $s = size($l) | |
1417 | + | let $acc0 = 1 | |
1418 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1419 | + | then $a | |
1420 | + | else handler2($a, $l[$i]) | |
1421 | + | ||
1422 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1423 | + | then $a | |
1424 | + | else throw("List size exceeds 10") | |
1425 | + | ||
1426 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1427 | + | } | |
1428 | + | let balance = tryGetInteger((("global_" + assetIdStr) + "_balance")) | |
1429 | + | let weight = if ((pars._2 == "new")) | |
1430 | + | then parseIntValue(assetWeightsStrLi[Token]) | |
1431 | + | else tryGetInteger((("static_" + assetIdStr) + "_weight")) | |
1432 | + | $Tuple2(fraction(accum, pow(balance, Decimals[Token], weight, AssetsWeightsDecimals, 8, FLOOR), Scale8), pars._2) | |
1433 | + | } | |
1434 | + | ||
1435 | + | let newK = ( let $l = assetIds | |
1436 | + | let $s = size($l) | |
1437 | + | let $acc0 = $Tuple2(PoolTokenScale, "new") | |
1438 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1439 | + | then $a | |
1440 | + | else handler($a, $l[$i]) | |
1441 | + | ||
1442 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1443 | + | then $a | |
1444 | + | else throw("List size exceeds 10") | |
1445 | + | ||
1446 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10))._1 | |
1447 | + | let oldK = ( let $l = assetIds | |
1448 | + | let $s = size($l) | |
1449 | + | let $acc0 = $Tuple2(PoolTokenScale, "old") | |
1450 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
1451 | + | then $a | |
1452 | + | else handler($a, $l[$i]) | |
1453 | + | ||
1454 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
1455 | + | then $a | |
1456 | + | else throw("List size exceeds 10") | |
1457 | + | ||
1458 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10))._1 | |
1459 | + | let newKMult = fraction(oldKMult, newK, oldK) | |
1460 | + | func addTokenDataEntries (accum,assetNum) = if ((assetNum >= size(assetWeightsStrLi))) | |
1461 | + | then accum | |
1462 | + | else (accum ++ [IntegerEntry((("static_" + assetIdsStrLi[assetNum]) + "_weight"), value(parseInt(assetWeightsStrLi[assetNum])))]) | |
1463 | + | ||
1464 | + | ({ | |
1465 | + | let $l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
1466 | + | let $s = size($l) | |
1467 | + | let $acc0 = nil | |
1468 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1469 | + | then $a | |
1470 | + | else addTokenDataEntries($a, $l[$i]) | |
1471 | + | ||
1472 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1473 | + | then $a | |
1474 | + | else throw("List size exceeds 10") | |
1475 | + | ||
1476 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1477 | + | } ++ [IntegerEntry("static_KMult", newKMult)]) | |
1478 | + | } | |
1479 | + | } | |
1480 | + | ||
1481 | + | ||
1482 | + | ||
1483 | + | @Callable(i) | |
1484 | + | func doRebalancingWithNewTokens (assetIdsStr,assetWeightsStr,baseTokenIdStr) = { | |
1485 | + | let newAssetWeightsStrLi = split(assetWeightsStr, ",") | |
1486 | + | let prevAssetIdsStrLi = split(tryGetString("static_tokenIds"), ",") | |
1487 | + | let newAssetIdsStrLi = split(assetIdsStr, ",") | |
1488 | + | let newAssetIds = { | |
1489 | + | let $l = newAssetIdsStrLi | |
1490 | + | let $s = size($l) | |
1491 | + | let $acc0 = nil | |
1492 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
1493 | + | then $a | |
1494 | + | else addAssetBytesToList($a, $l[$i]) | |
1495 | + | ||
1496 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
1497 | + | then $a | |
1498 | + | else throw("List size exceeds 10") | |
1499 | + | ||
1500 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1501 | + | } | |
1502 | + | let feeAssetStr = { | |
1503 | + | let $l = newAssetIdsStrLi | |
1504 | + | let $s = size($l) | |
1505 | + | let $acc0 = "" | |
1506 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1507 | + | then $a | |
1508 | + | else checkFeeAsset($a, $l[$i]) | |
1509 | + | ||
1510 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1511 | + | then $a | |
1512 | + | else throw("List size exceeds 10") | |
1513 | + | ||
1514 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1515 | + | } | |
1516 | + | let addedAssets = split(tryGetString("rebalance_addedAssets"), ",") | |
1517 | + | func findAssetPayment (assetId) = valueOrElse(getInteger(("rebalance_attachedPayment_" + getAssetString(assetId))), 0) | |
1518 | + | ||
1519 | + | func addAssetBalanceToLi (li,assetId) = (li ++ [findAssetPayment(assetId)]) | |
1520 | + | ||
1521 | + | let attachedBalances = { | |
1522 | + | let $l = newAssetIds | |
1523 | + | let $s = size($l) | |
1524 | + | let $acc0 = nil | |
1525 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
1526 | + | then $a | |
1527 | + | else addAssetBalanceToLi($a, $l[$i]) | |
1528 | + | ||
1529 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
1530 | + | then $a | |
1531 | + | else throw("List size exceeds 10") | |
1532 | + | ||
1533 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1534 | + | } | |
1535 | + | if ((i.caller != this)) | |
1536 | + | then throw(("this call available only for admin, " + toString(i.caller))) | |
1537 | + | else { | |
1538 | + | let oldKMult = getKMult() | |
1539 | + | let oldK = getVirtualPoolTokenAmount() | |
1540 | + | func myltiplyAssetsForK (pars,assetId) = { | |
1541 | + | func findAssetNum (accum,n) = if ((n == assetId)) | |
1542 | + | then value(indexOf(newAssetIds, n)) | |
1543 | + | else accum | |
1544 | + | ||
1545 | + | let currentK = pars | |
1546 | + | let assetIdStr = getAssetString(assetId) | |
1547 | + | let TokenNum = { | |
1548 | + | let $l = newAssetIds | |
1549 | + | let $s = size($l) | |
1550 | + | let $acc0 = 1 | |
1551 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1552 | + | then $a | |
1553 | + | else findAssetNum($a, $l[$i]) | |
1554 | + | ||
1555 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1556 | + | then $a | |
1557 | + | else throw("List size exceeds 10") | |
1558 | + | ||
1559 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1560 | + | } | |
1561 | + | let weight = parseIntValue(newAssetWeightsStrLi[TokenNum]) | |
1562 | + | let balanceInState = tryGetInteger((("global_" + assetIdStr) + "_balance")) | |
1563 | + | let balanceInPayment = attachedBalances[TokenNum] | |
1564 | + | let balance = (balanceInState + balanceInPayment) | |
1565 | + | let assetDecimals = if ((assetId == unit)) | |
1566 | + | then 8 | |
1567 | + | else value(assetInfo(value(assetId))).decimals | |
1568 | + | if ((0 >= balance)) | |
1569 | + | then throw(("you need to attach all new assets in payment. this asset is missed: " + assetIdStr)) | |
1570 | + | else fraction(currentK, pow(balance, assetDecimals, weight, AssetsWeightsDecimals, 8, FLOOR), Scale8) | |
1571 | + | } | |
1572 | + | ||
1573 | + | let newK = { | |
1574 | + | let $l = newAssetIds | |
1575 | + | let $s = size($l) | |
1576 | + | let $acc0 = PoolTokenScale | |
1577 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1578 | + | then $a | |
1579 | + | else myltiplyAssetsForK($a, $l[$i]) | |
1580 | + | ||
1581 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1582 | + | then $a | |
1583 | + | else throw("List size exceeds 10") | |
1584 | + | ||
1585 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1586 | + | } | |
1587 | + | let newKMult = fraction(oldKMult, newK, oldK) | |
1588 | + | func addTokenDataEntries (accum,assetNum) = { | |
1589 | + | let assetIdStr = newAssetIdsStrLi[assetNum] | |
1590 | + | let assetId = newAssetIds[assetNum] | |
1591 | + | let assetDecimals = if ((assetId == unit)) | |
1592 | + | then 8 | |
1593 | + | else value(assetInfo(value(assetId))).decimals | |
1594 | + | let newAssetData = if ((indexOf(addedAssets, assetIdStr) != unit)) | |
1595 | + | then [IntegerEntry((("global_" + assetIdStr) + "_balance"), attachedBalances[assetNum]), IntegerEntry((("static_" + assetIdStr) + "_scale"), pow(10, 0, assetDecimals, 0, 0, DOWN)), IntegerEntry((("static_" + assetIdStr) + "_decimals"), assetDecimals)] | |
1596 | + | else nil | |
1597 | + | if ((assetNum >= size(newAssetWeightsStrLi))) | |
1598 | + | then accum | |
1599 | + | else ((accum ++ [IntegerEntry((("static_" + assetIdStr) + "_weight"), value(parseInt(newAssetWeightsStrLi[assetNum])))]) ++ newAssetData) | |
1600 | + | } | |
1601 | + | ||
1602 | + | ({ | |
1603 | + | let $l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
1604 | + | let $s = size($l) | |
1605 | + | let $acc0 = nil | |
1606 | + | func $f8_1 ($a,$i) = if (($i >= $s)) | |
1607 | + | then $a | |
1608 | + | else addTokenDataEntries($a, $l[$i]) | |
1609 | + | ||
1610 | + | func $f8_2 ($a,$i) = if (($i >= $s)) | |
1611 | + | then $a | |
1612 | + | else throw("List size exceeds 10") | |
1613 | + | ||
1614 | + | $f8_2($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1615 | + | } ++ [StringEntry("static_tokenIds", assetIdsStr), StringEntry("static_feeToken", feeAssetStr), StringEntry("static_tokenWeights", assetWeightsStr), IntegerEntry("static_tokensAmount", size(newAssetIds)), IntegerEntry("static_KMult", newKMult)]) | |
1616 | + | } | |
1617 | + | } | |
1618 | + | ||
1619 | + | ||
775 | 1620 | @Verifier(tx) | |
776 | - | func verify () = if (isShutdown()) | |
777 | - | then false | |
778 | - | else if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
1621 | + | func verify () = if (if ((valueOrElse(getInteger("global_wasPreInited"), 0) == 0)) | |
1622 | + | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
779 | 1623 | then true | |
780 | 1624 | else sigVerify(tx.bodyBytes, tx.proofs[0], masterPubKey) | |
1625 | + | else false) | |
1626 | + | then true | |
1627 | + | else match tx { | |
1628 | + | case tx: SetScriptTransaction => | |
1629 | + | let scriptFull = value(tx.script) | |
1630 | + | let hash = toBase58String(sha256(scriptFull)) | |
1631 | + | if (sigVerify(tx.bodyBytes, tx.proofs[0], masterPubKey)) | |
1632 | + | then (valueOrElse(getInteger(coldMasterAddress, ("approvedScript_" + hash)), 0) > height) | |
1633 | + | else false | |
1634 | + | case _ => | |
1635 | + | if (sigVerify(tx.bodyBytes, tx.proofs[0], masterPubKey)) | |
1636 | + | then (valueOrElse(getInteger(coldMasterAddress, ("approvedTx_" + toBase58String(tx.id))), 0) > 0) | |
1637 | + | else false | |
1638 | + | } | |
781 | 1639 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let VERSION = "PZ-1.2.3 PROD" | |
5 | 5 | ||
6 | - | let | |
6 | + | let configStr = valueOrElse(getString(this, "configAddress"), "3PPEBRg4s2af2rQ2ZbLvdu1Hfd4Vo6QVDTo") | |
7 | 7 | ||
8 | - | let usdtAssetId = base58'34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ' | |
8 | + | let CONFIG_ADDRESS = if ((configStr == "")) | |
9 | + | then this | |
10 | + | else Address(fromBase58String(configStr)) | |
9 | 11 | ||
10 | - | let | |
12 | + | let AssetsWeightsDecimals = 4 | |
11 | 13 | ||
12 | - | let | |
14 | + | let Scale = 10000 | |
13 | 15 | ||
14 | - | let | |
16 | + | let Scale8 = 100000000 | |
15 | 17 | ||
16 | - | let | |
18 | + | let Scale16 = 10000000000000000 | |
17 | 19 | ||
18 | - | let | |
20 | + | let FeeScale = 10000 | |
19 | 21 | ||
20 | - | let | |
22 | + | let PoolTokenDecimals = 8 | |
21 | 23 | ||
22 | - | let | |
24 | + | let PoolTokenScale = pow(10, 0, PoolTokenDecimals, 0, 0, HALFUP) | |
23 | 25 | ||
24 | - | let masterPubKey = base58'4z8CKSYQBKkzx7PBb5uBP1YPa6YAHRNTApW1sQVHT5eU' | |
26 | + | let MIN_STEPS_AMOUNT = valueOrElse(getInteger(CONFIG_ADDRESS, "min_steps_amount"), 1) | |
27 | + | ||
28 | + | let MAX_STEPS_AMOUNT = valueOrElse(getInteger(CONFIG_ADDRESS, "max_steps_amount"), 500) | |
29 | + | ||
30 | + | let MIN_STEPS_INTERVAL = valueOrElse(getInteger(CONFIG_ADDRESS, "min_steps_interval"), 1) | |
31 | + | ||
32 | + | let MAX_STEPS_INTERVAL = valueOrElse(getInteger(CONFIG_ADDRESS, "max_steps_interval"), 10000) | |
33 | + | ||
34 | + | let MIN_WEIGHT = valueOrElse(getInteger(CONFIG_ADDRESS, "min_weight"), 100) | |
35 | + | ||
36 | + | let MAX_WEIGHT = valueOrElse(getInteger(CONFIG_ADDRESS, "max_weight"), 9900) | |
25 | 37 | ||
26 | 38 | func tryGetInteger (key) = match getInteger(this, key) { | |
27 | 39 | case b: Int => | |
28 | 40 | b | |
29 | 41 | case _ => | |
30 | 42 | 0 | |
31 | 43 | } | |
32 | 44 | ||
33 | 45 | ||
34 | 46 | func tryGetBinary (key) = match getBinary(this, key) { | |
35 | 47 | case b: ByteVector => | |
36 | 48 | b | |
37 | 49 | case _ => | |
38 | 50 | base58'' | |
39 | 51 | } | |
40 | 52 | ||
41 | 53 | ||
42 | 54 | func tryGetString (key) = match getString(this, key) { | |
43 | 55 | case b: String => | |
44 | 56 | b | |
45 | 57 | case _ => | |
46 | 58 | "" | |
47 | 59 | } | |
48 | 60 | ||
49 | 61 | ||
62 | + | func tryGetStringOrThrow (key) = match getString(this, key) { | |
63 | + | case b: String => | |
64 | + | b | |
65 | + | case _ => | |
66 | + | throw(("no such key in data storage: " + key)) | |
67 | + | } | |
68 | + | ||
69 | + | ||
50 | 70 | func getAssetString (assetId) = match assetId { | |
51 | 71 | case b: ByteVector => | |
52 | 72 | toBase58String(b) | |
53 | 73 | case _ => | |
54 | 74 | "WAVES" | |
55 | 75 | } | |
56 | 76 | ||
57 | 77 | ||
58 | 78 | func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES")) | |
59 | 79 | then unit | |
60 | 80 | else fromBase58String(assetIdStr) | |
61 | 81 | ||
62 | 82 | ||
83 | + | func getTokenBalance (assetId) = match assetId { | |
84 | + | case t: ByteVector => | |
85 | + | assetBalance(this, t) | |
86 | + | case _ => | |
87 | + | wavesBalance(this).available | |
88 | + | } | |
89 | + | ||
90 | + | ||
63 | 91 | func addAssetBytesToList (accum,item) = (accum ++ [getAssetBytes(item)]) | |
64 | 92 | ||
65 | 93 | ||
66 | 94 | func addAssetWeightToList (accum,item) = (accum ++ [tryGetInteger((("static_" + getAssetString(item)) + "_weight"))]) | |
95 | + | ||
96 | + | ||
97 | + | func addAssetWeightToStrList (accum,item) = (accum ++ [toString(tryGetInteger((("static_" + item) + "_weight")))]) | |
67 | 98 | ||
68 | 99 | ||
69 | 100 | func addAssetDecimalsToList (accum,item) = (accum ++ [tryGetInteger((("static_" + getAssetString(item)) + "_decimals"))]) | |
70 | 101 | ||
71 | 102 | ||
72 | 103 | func addAssetScaleToList (accum,item) = (accum ++ [tryGetInteger((("static_" + getAssetString(item)) + "_scale"))]) | |
73 | 104 | ||
74 | 105 | ||
75 | 106 | func addIntToList (accum,item) = (accum ++ [parseIntValue(item)]) | |
76 | 107 | ||
108 | + | ||
109 | + | let usdnAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdnAssetIdStr"), "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p") | |
110 | + | ||
111 | + | let puzzleAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "puzzleAssetIdStr"), "HEB8Qaw9xrWpWs8tHsiATYGBWDBtP2S7kcPALrMu43AS") | |
112 | + | ||
113 | + | let usdtAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdtAssetIdStr"), "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ") | |
114 | + | ||
115 | + | let usdtPptAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdtPptAssetIdStr"), "9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi") | |
116 | + | ||
117 | + | let romeAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "romeAssetIdStr"), "AP4Cb5xLYGH6ZigHreCZHoXpQTWDkPsG2BHqfDUx6taJ") | |
118 | + | ||
119 | + | let wavesAssetIdStr = "WAVES" | |
120 | + | ||
121 | + | let usdnAssetId = fromBase58String(usdnAssetIdStr) | |
122 | + | ||
123 | + | let puzzleAssetId = fromBase58String(puzzleAssetIdStr) | |
124 | + | ||
125 | + | let usdtAssetId = fromBase58String(usdtAssetIdStr) | |
126 | + | ||
127 | + | let usdtPptAssetId = fromBase58String(usdtPptAssetIdStr) | |
128 | + | ||
129 | + | let romeAssetId = fromBase58String(romeAssetIdStr) | |
130 | + | ||
131 | + | let wavesAssetId = unit | |
132 | + | ||
133 | + | let supportedFeeAssetsStr = [usdnAssetIdStr, puzzleAssetIdStr, usdtAssetIdStr, usdtPptAssetIdStr, wavesAssetIdStr, romeAssetIdStr] | |
134 | + | ||
135 | + | let parentPoolAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "parentPoolAddress"), "3PFDgzu1UtswAkCMxqqQjbTeHaX4cMab8Kh"))) | |
136 | + | ||
137 | + | let masterAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "masterAddress"), "3PLjwHcz9NEuaTo63NZR9B9okQiKQxZSbmf"))) | |
138 | + | ||
139 | + | let masterPubKey = fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "masterPubKey"), "4z8CKSYQBKkzx7PBb5uBP1YPa6YAHRNTApW1sQVHT5eU")) | |
140 | + | ||
141 | + | let oracleAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "oracleAddress"), "3P8d1E1BLKoD52y3bQJ1bDTd2TD1gpaLn9t"))) | |
142 | + | ||
143 | + | let stakingAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "stakingAddress"), "3PFTbywqxtFfukX3HyT881g4iW5K4QL3FAS"))) | |
144 | + | ||
145 | + | let feesAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "feesAddress"), "3PFWAVKmXjfHXyzJb12jCbhP4Uhi9t4uWiD"))) | |
146 | + | ||
147 | + | let poolsHubAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "poolsHubAddress"), "3P5YutjDNC3hABBVsveFuZTTbQ5PdtSDBgk"))) | |
148 | + | ||
149 | + | let shutdownAddressStr = valueOrElse(getString(CONFIG_ADDRESS, "shutdownAddress"), "3PEpv9hRFWEEBU22WRnLsw1bH4YGtcU728o") | |
150 | + | ||
151 | + | let layer2Addresses = valueOrElse(getString(CONFIG_ADDRESS, "layer2Addresses"), "3PR1Qvi9mHT35SwWEkLSqqE2L8thiPLdVWU,3PQoBfUKHkJAeGWhooLP7WS8ovb54av9Jp2") | |
152 | + | ||
153 | + | let govAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "govAddress"), "3P6uro9xCsE8te78QZjzqy7aq8natSzdceC"))) | |
154 | + | ||
155 | + | let coldMasterAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "coldMasterAddress"), "3PK9nhPfPbMBygB9ZgHVMHaQbSoojwrBfxj"))) | |
77 | 156 | ||
78 | 157 | let T = tryGetInteger("static_tokensAmount") | |
79 | 158 | ||
80 | 159 | let assetIds = { | |
81 | 160 | let $l = split(tryGetString("static_tokenIds"), ",") | |
82 | 161 | let $s = size($l) | |
83 | 162 | let $acc0 = nil | |
84 | 163 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
85 | 164 | then $a | |
86 | 165 | else addAssetBytesToList($a, $l[$i]) | |
87 | 166 | ||
88 | 167 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
89 | 168 | then $a | |
90 | 169 | else throw("List size exceeds 10") | |
91 | 170 | ||
92 | 171 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
93 | 172 | } | |
94 | 173 | ||
95 | 174 | let AssetsWeights = { | |
96 | 175 | let $l = assetIds | |
97 | 176 | let $s = size($l) | |
98 | 177 | let $acc0 = nil | |
99 | 178 | func $f1_1 ($a,$i) = if (($i >= $s)) | |
100 | 179 | then $a | |
101 | 180 | else addAssetWeightToList($a, $l[$i]) | |
102 | 181 | ||
103 | 182 | func $f1_2 ($a,$i) = if (($i >= $s)) | |
104 | 183 | then $a | |
105 | 184 | else throw("List size exceeds 10") | |
106 | 185 | ||
107 | 186 | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
108 | 187 | } | |
109 | 188 | ||
110 | 189 | let Decimals = { | |
111 | 190 | let $l = assetIds | |
112 | 191 | let $s = size($l) | |
113 | 192 | let $acc0 = nil | |
114 | 193 | func $f2_1 ($a,$i) = if (($i >= $s)) | |
115 | 194 | then $a | |
116 | 195 | else addAssetDecimalsToList($a, $l[$i]) | |
117 | 196 | ||
118 | 197 | func $f2_2 ($a,$i) = if (($i >= $s)) | |
119 | 198 | then $a | |
120 | 199 | else throw("List size exceeds 10") | |
121 | 200 | ||
122 | 201 | $f2_2($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
123 | 202 | } | |
124 | 203 | ||
125 | 204 | let Scales = { | |
126 | 205 | let $l = assetIds | |
127 | 206 | let $s = size($l) | |
128 | 207 | let $acc0 = nil | |
129 | 208 | func $f3_1 ($a,$i) = if (($i >= $s)) | |
130 | 209 | then $a | |
131 | 210 | else addAssetScaleToList($a, $l[$i]) | |
132 | 211 | ||
133 | 212 | func $f3_2 ($a,$i) = if (($i >= $s)) | |
134 | 213 | then $a | |
135 | 214 | else throw("List size exceeds 10") | |
136 | 215 | ||
137 | 216 | $f3_2($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
138 | 217 | } | |
139 | 218 | ||
140 | 219 | let Fee = tryGetInteger("static_fee") | |
141 | 220 | ||
142 | - | let AssetsWeightsDecimals = 4 | |
143 | - | ||
144 | - | let Scale = 10000 | |
145 | - | ||
146 | - | let Scale8 = 100000000 | |
147 | - | ||
148 | - | let FeeScale = 10000 | |
149 | - | ||
150 | - | let PoolTokenDecimals = 8 | |
151 | - | ||
152 | - | let PoolTokenScale = pow(10, 0, PoolTokenDecimals, 0, 0, HALFUP) | |
153 | - | ||
154 | 221 | let earnedAssets = assetIds | |
155 | 222 | ||
156 | - | func isShutdown () = match getBoolean(Address(base58'3PEpv9hRFWEEBU22WRnLsw1bH4YGtcU728o'), "is_shutdown") { | |
157 | - | case x: Boolean => | |
223 | + | func isShutdown () = { | |
224 | + | let shutdownAddress = addressFromString(shutdownAddressStr) | |
225 | + | if ((shutdownAddress == unit)) | |
226 | + | then false | |
227 | + | else match getBoolean(value(shutdownAddress), "is_shutdown") { | |
228 | + | case x: Boolean => | |
229 | + | x | |
230 | + | case _ => | |
231 | + | false | |
232 | + | } | |
233 | + | } | |
234 | + | ||
235 | + | ||
236 | + | func getCurrentTokenBalance (tokenNum) = { | |
237 | + | let tokenIdStr = getAssetString(assetIds[tokenNum]) | |
238 | + | tryGetInteger((("global_" + tokenIdStr) + "_balance")) | |
239 | + | } | |
240 | + | ||
241 | + | ||
242 | + | func getKMult () = match getInteger("static_KMult") { | |
243 | + | case x: Int => | |
158 | 244 | x | |
159 | 245 | case _ => | |
160 | - | | |
246 | + | Scale16 | |
161 | 247 | } | |
162 | 248 | ||
163 | 249 | ||
164 | - | func getCurrentTokenBalance (tokenType) = { | |
165 | - | let tokenId = getAssetString(assetIds[tokenType]) | |
166 | - | tryGetInteger((("global_" + tokenId) + "_balance")) | |
250 | + | func saveCurrentWeights () = { | |
251 | + | let assetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
252 | + | func s (accum,assetId) = (accum ++ [IntegerEntry(("rebalance_startWeight_" + assetId), tryGetInteger((("static_" + assetId) + "_weight")))]) | |
253 | + | ||
254 | + | let $l = assetIdsLi | |
255 | + | let $s = size($l) | |
256 | + | let $acc0 = nil | |
257 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
258 | + | then $a | |
259 | + | else s($a, $l[$i]) | |
260 | + | ||
261 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
262 | + | then $a | |
263 | + | else throw("List size exceeds 10") | |
264 | + | ||
265 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
167 | 266 | } | |
168 | 267 | ||
169 | 268 | ||
269 | + | func getVirtualPoolTokenAmount () = fraction(tryGetInteger("global_poolToken_amount"), getKMult(), Scale16) | |
270 | + | ||
271 | + | ||
170 | 272 | func calculatePIssued (amount,tokenId) = { | |
171 | - | let Psupply = | |
273 | + | let Psupply = getVirtualPoolTokenAmount() | |
172 | 274 | let Balance = tryGetInteger((("global_" + getAssetString(tokenId)) + "_balance")) | |
173 | - | fraction(amount, Psupply, Balance, DOWN) | |
275 | + | let t1 = fraction(amount, Psupply, Balance, DOWN) | |
276 | + | t1 | |
174 | 277 | } | |
175 | 278 | ||
176 | 279 | ||
177 | 280 | func getMinPIssued (payments) = { | |
178 | 281 | func handler (accum,current) = { | |
179 | 282 | let PIssued = calculatePIssued(current.amount, current.assetId) | |
180 | 283 | if ((PIssued == 0)) | |
181 | 284 | then throw("one of the tokens amounts is too low") | |
182 | 285 | else if (if ((accum == 0)) | |
183 | 286 | then true | |
184 | 287 | else (accum > PIssued)) | |
185 | 288 | then PIssued | |
186 | 289 | else accum | |
187 | 290 | } | |
188 | 291 | ||
189 | 292 | let minPIssed = { | |
190 | 293 | let $l = payments | |
191 | 294 | let $s = size($l) | |
192 | 295 | let $acc0 = 0 | |
193 | 296 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
194 | 297 | then $a | |
195 | 298 | else handler($a, $l[$i]) | |
196 | 299 | ||
197 | 300 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
198 | 301 | then $a | |
199 | 302 | else throw("List size exceeds 10") | |
200 | 303 | ||
201 | 304 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
202 | 305 | } | |
203 | 306 | minPIssed | |
204 | 307 | } | |
205 | 308 | ||
206 | 309 | ||
207 | 310 | func calculateUsdnValue (assetId,amount,aBalance,givenUsdnBalance) = { | |
208 | 311 | let usdnInPool = indexOf(assetIds, usdnAssetId) | |
209 | 312 | let puzzleInPool = indexOf(assetIds, puzzleAssetId) | |
210 | 313 | let usdtInPool = indexOf(assetIds, usdtAssetId) | |
211 | 314 | let usdtPptInPool = indexOf(assetIds, usdtPptAssetId) | |
212 | 315 | let wavesInPool = indexOf(assetIds, unit) | |
213 | 316 | let assetWeight = tryGetInteger((("static_" + getAssetString(assetId)) + "_weight")) | |
214 | 317 | let feeAssetStr = tryGetString("static_feeToken") | |
215 | 318 | if ((feeAssetStr == puzzleAssetIdStr)) | |
216 | 319 | then { | |
217 | 320 | let puzzleWeight = AssetsWeights[value(indexOf(assetIds, puzzleAssetId))] | |
218 | 321 | let puzzleBalance = tryGetInteger((("global_" + puzzleAssetIdStr) + "_balance")) | |
219 | 322 | let amountInPuzzle = fraction(amount, (puzzleBalance / puzzleWeight), (aBalance / assetWeight)) | |
220 | 323 | let puzzlePrice = getIntegerValue(parentPoolAddress, "global_lastPuzzlePrice") | |
221 | 324 | fraction((amountInPuzzle * puzzlePrice), 1, Scale8) | |
222 | 325 | } | |
223 | 326 | else if ((feeAssetStr == usdtAssetIdStr)) | |
224 | 327 | then { | |
225 | 328 | let usdtWeight = AssetsWeights[value(usdtInPool)] | |
226 | 329 | let usdtBalance = tryGetInteger((("global_" + usdtAssetIdStr) + "_balance")) | |
227 | 330 | fraction(amount, (usdtBalance / usdtWeight), (aBalance / assetWeight)) | |
228 | 331 | } | |
229 | 332 | else if ((feeAssetStr == usdtPptAssetIdStr)) | |
230 | 333 | then { | |
231 | 334 | let usdtWeight = AssetsWeights[value(usdtPptInPool)] | |
232 | 335 | let usdtBalance = tryGetInteger((("global_" + usdtPptAssetIdStr) + "_balance")) | |
233 | 336 | fraction(amount, (usdtBalance / usdtWeight), (aBalance / assetWeight)) | |
234 | 337 | } | |
235 | 338 | else if ((feeAssetStr == usdnAssetIdStr)) | |
236 | 339 | then { | |
237 | 340 | let usdnWeight = AssetsWeights[value(indexOf(assetIds, usdnAssetId))] | |
238 | 341 | let usdnBalance = match givenUsdnBalance { | |
239 | 342 | case x: Int => | |
240 | 343 | givenUsdnBalance | |
241 | 344 | case _ => | |
242 | 345 | tryGetInteger((("global_" + getAssetString(usdnAssetId)) + "_balance")) | |
243 | 346 | } | |
244 | 347 | fraction(amount, (value(usdnBalance) / usdnWeight), (aBalance / assetWeight)) | |
245 | 348 | } | |
246 | 349 | else { | |
247 | 350 | let wavesWeight = 3000 | |
248 | 351 | let wBalance = (tryGetInteger("global_WAVES_balance") / 50) | |
249 | 352 | fraction(amount, (wBalance / wavesWeight), (aBalance / assetWeight)) | |
250 | 353 | } | |
251 | 354 | } | |
252 | 355 | ||
253 | 356 | ||
357 | + | func getPriceFromOracle (assetIdStr) = match getInteger(oracleAddress, (assetIdStr + "_twap5B")) { | |
358 | + | case x: Int => | |
359 | + | x | |
360 | + | case _ => | |
361 | + | 0 | |
362 | + | } | |
363 | + | ||
364 | + | ||
365 | + | func calculateUsdValue (assetId,amount,aBalance) = { | |
366 | + | let assetWeight = tryGetInteger((("static_" + getAssetString(assetId)) + "_weight")) | |
367 | + | let feeAssetStr = tryGetString("static_feeToken") | |
368 | + | let feeAssetScale = getIntegerValue(this, (("static_" + feeAssetStr) + "_scale")) | |
369 | + | let feeAssetNum = value(indexOf(assetIds, getAssetBytes(feeAssetStr))) | |
370 | + | let feeAssetWeight = AssetsWeights[feeAssetNum] | |
371 | + | let feeAssetBalance = tryGetInteger((("global_" + feeAssetStr) + "_balance")) | |
372 | + | let valInFeeAsset = fraction(amount, (feeAssetBalance / feeAssetWeight), (aBalance / assetWeight)) | |
373 | + | let feeAssetPrice = getPriceFromOracle(feeAssetStr) | |
374 | + | fraction(valInFeeAsset, feeAssetPrice, feeAssetScale) | |
375 | + | } | |
376 | + | ||
377 | + | ||
254 | 378 | func checkTokensValidity (payments) = { | |
255 | 379 | func handler1 (accum,payment) = (accum ++ [payment.assetId]) | |
256 | 380 | ||
257 | 381 | let ids = { | |
258 | 382 | let $l = payments | |
259 | 383 | let $s = size($l) | |
260 | 384 | let $acc0 = nil | |
261 | 385 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
262 | 386 | then $a | |
263 | 387 | else handler1($a, $l[$i]) | |
264 | 388 | ||
265 | 389 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
266 | 390 | then $a | |
267 | 391 | else throw("List size exceeds 10") | |
268 | 392 | ||
269 | 393 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
270 | 394 | } | |
271 | 395 | if ((ids == ids)) | |
272 | 396 | then { | |
273 | 397 | func handler2 (accum,assetId) = if ((indexOf(ids, assetId) != unit)) | |
274 | 398 | then (accum + 1) | |
275 | 399 | else throw(("asset not attached: " + getAssetString(assetId))) | |
276 | 400 | ||
277 | 401 | let checks = { | |
278 | 402 | let $l = assetIds | |
279 | 403 | let $s = size($l) | |
280 | 404 | let $acc0 = 0 | |
281 | 405 | func $f5_1 ($a,$i) = if (($i >= $s)) | |
282 | 406 | then $a | |
283 | 407 | else handler2($a, $l[$i]) | |
284 | 408 | ||
285 | 409 | func $f5_2 ($a,$i) = if (($i >= $s)) | |
286 | 410 | then $a | |
287 | 411 | else throw("List size exceeds 10") | |
288 | 412 | ||
289 | 413 | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
290 | 414 | } | |
291 | 415 | if ((checks == checks)) | |
292 | 416 | then true | |
293 | 417 | else throw("Strict value is not equal to itself.") | |
294 | 418 | } | |
295 | 419 | else throw("Strict value is not equal to itself.") | |
296 | 420 | } | |
297 | 421 | ||
298 | 422 | ||
299 | 423 | func handlePoolTokensAdd (PIssued,payments,userAddress,needChange) = { | |
300 | 424 | func getTokenPaymentAmount (tokenId) = { | |
301 | 425 | func handler (accum,payment) = if ((payment.assetId == tokenId)) | |
302 | 426 | then payment.amount | |
303 | 427 | else accum | |
304 | 428 | ||
305 | 429 | let $l = payments | |
306 | 430 | let $s = size($l) | |
307 | 431 | let $acc0 = 0 | |
308 | 432 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
309 | 433 | then $a | |
310 | 434 | else handler($a, $l[$i]) | |
311 | 435 | ||
312 | 436 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
313 | 437 | then $a | |
314 | 438 | else throw("List size exceeds 10") | |
315 | 439 | ||
316 | 440 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
317 | 441 | } | |
318 | 442 | ||
319 | 443 | func handleTokenChange (accum,tokenId) = { | |
320 | 444 | let Bk = tryGetInteger((("global_" + getAssetString(tokenId)) + "_balance")) | |
321 | - | let PSupply = | |
445 | + | let PSupply = getVirtualPoolTokenAmount() | |
322 | 446 | let tokenDecimals = tryGetInteger((("static_" + getAssetString(tokenId)) + "_scale")) | |
323 | - | let Dk = fraction((fraction((PSupply + PIssued), tokenDecimals, PSupply, CEILING) - tokenDecimals), Bk, tokenDecimals, CEILING) | |
447 | + | let a1 = fraction((toBigInt((PSupply + PIssued)) * toBigInt(Scale8)), toBigInt(tokenDecimals), toBigInt(PSupply), CEILING) | |
448 | + | let Dk = toInt(fraction((a1 - (toBigInt(tokenDecimals) * toBigInt(Scale8))), toBigInt(Bk), (toBigInt(tokenDecimals) * toBigInt(Scale8)), CEILING)) | |
324 | 449 | let paymentAmount = getTokenPaymentAmount(tokenId) | |
325 | - | let toReturn = ((if ((paymentAmount != 0)) | |
326 | - | then paymentAmount | |
327 | - | else 0) - Dk) | |
450 | + | let toReturn = (paymentAmount - Dk) | |
328 | 451 | let t = if (if (needChange) | |
329 | 452 | then (toReturn > 0) | |
330 | 453 | else false) | |
331 | 454 | then [ScriptTransfer(userAddress, toReturn, tokenId)] | |
332 | 455 | else nil | |
333 | 456 | ((accum ++ t) ++ [IntegerEntry((("global_" + getAssetString(tokenId)) + "_balance"), (Bk + Dk))]) | |
334 | 457 | } | |
335 | 458 | ||
336 | 459 | let $l = assetIds | |
337 | 460 | let $s = size($l) | |
338 | 461 | let $acc0 = nil | |
339 | 462 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
340 | 463 | then $a | |
341 | 464 | else handleTokenChange($a, $l[$i]) | |
342 | 465 | ||
343 | 466 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
344 | 467 | then $a | |
345 | 468 | else throw("List size exceeds 10") | |
346 | 469 | ||
347 | 470 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
348 | 471 | } | |
349 | 472 | ||
350 | 473 | ||
351 | 474 | func handlePoolTokensRedeem (PRedeemed,userAddress) = { | |
352 | 475 | func handleTokenRedeem (accum,tokenId) = { | |
353 | 476 | let Bk = tryGetInteger((("global_" + getAssetString(tokenId)) + "_balance")) | |
354 | - | let PSupply = | |
477 | + | let PSupply = getVirtualPoolTokenAmount() | |
355 | 478 | let tokenDecimals = tryGetInteger((("static_" + getAssetString(tokenId)) + "_scale")) | |
356 | - | let amount = toInt(fraction((toBigInt(Scale8) - fraction(toBigInt((PSupply - PRedeemed)), toBigInt(Scale8), toBigInt(PSupply), CEILING)), toBigInt(Bk), toBigInt(Scale8), DOWN)) | |
479 | + | let psuppl = fraction((toBigInt((PSupply - PRedeemed)) * toBigInt(Scale8)), toBigInt(Scale8), toBigInt(PSupply), DOWN) | |
480 | + | let amount = toInt(fraction((toBigInt(Scale16) - psuppl), toBigInt(Bk), toBigInt(Scale16), CEILING)) | |
357 | 481 | (accum ++ [IntegerEntry((("global_" + getAssetString(tokenId)) + "_balance"), (Bk - amount)), ScriptTransfer(userAddress, amount, tokenId)]) | |
358 | 482 | } | |
359 | 483 | ||
360 | 484 | let $l = assetIds | |
361 | 485 | let $s = size($l) | |
362 | 486 | let $acc0 = nil | |
363 | 487 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
364 | 488 | then $a | |
365 | 489 | else handleTokenRedeem($a, $l[$i]) | |
366 | 490 | ||
367 | 491 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
368 | 492 | then $a | |
369 | 493 | else throw("List size exceeds 10") | |
370 | 494 | ||
371 | 495 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
372 | 496 | } | |
373 | 497 | ||
374 | 498 | ||
375 | 499 | func calculateOutAmount (AmountIn,assetIn,assetOut,BalanceIn,BalanceOut) = { | |
376 | 500 | let IndexIn = value(indexOf(assetIds, assetIn)) | |
377 | 501 | let IndexOut = value(indexOf(assetIds, assetOut)) | |
378 | 502 | if ((IndexIn == IndexOut)) | |
379 | 503 | then AmountIn | |
380 | - | else fraction(BalanceOut, ((Scale8 * Scale8) - toInt(pow(fraction(toBigInt(BalanceIn), toBigInt((Scale8 * Scale8)), toBigInt((BalanceIn + AmountIn)), HALFUP), 16, toBigInt(fraction(AssetsWeights[IndexIn], | |
504 | + | else fraction(BalanceOut, ((Scale8 * Scale8) - toInt(pow(fraction((toBigInt(BalanceIn) * toBigInt(10000)), toBigInt((Scale8 * Scale8)), (toBigInt((BalanceIn + AmountIn)) * toBigInt(10000)), HALFUP), 16, toBigInt(fraction(AssetsWeights[IndexIn], 1000000000000, AssetsWeights[IndexOut])), 12, 16, CEILING))), (Scale8 * Scale8), HALFEVEN) | |
381 | 505 | } | |
382 | - | ||
383 | - | ||
384 | - | func getTokenBalance (assetId) = match assetId { | |
385 | - | case t: ByteVector => | |
386 | - | assetBalance(this, t) | |
387 | - | case _ => | |
388 | - | wavesBalance(this).available | |
389 | - | } | |
390 | 506 | ||
391 | 507 | ||
392 | 508 | func calculateCurrentAssetInterest (assetId,assetIdStr,aBalance,tokenEarningsLastCheck) = { | |
393 | 509 | let totalStaked = tryGetInteger("global_indexStaked") | |
394 | 510 | let tokenBalanceLastCheck = tokenEarningsLastCheck | |
395 | 511 | let currentBalanceDelta = (getTokenBalance(assetId) - aBalance) | |
396 | 512 | let currentTokenEarnings = if ((currentBalanceDelta > tokenBalanceLastCheck)) | |
397 | 513 | then currentBalanceDelta | |
398 | 514 | else tokenBalanceLastCheck | |
399 | 515 | let newEarnings = (currentTokenEarnings - tokenBalanceLastCheck) | |
400 | 516 | let newInterest = if ((totalStaked == 0)) | |
401 | 517 | then 0 | |
402 | 518 | else fraction(newEarnings, Scale8, totalStaked) | |
403 | 519 | let lastCheckInterest = tryGetInteger((("global_lastCheck_" + assetIdStr) + "_interest")) | |
404 | 520 | (lastCheckInterest + newInterest) | |
405 | 521 | } | |
406 | 522 | ||
407 | 523 | ||
408 | 524 | func claimResult (address) = { | |
409 | 525 | let addressStr = toString(address) | |
410 | 526 | let puzzleAmount = tryGetInteger((addressStr + "_indexStaked")) | |
411 | 527 | func handler (accum,assetId) = { | |
412 | 528 | let assetIdStr = getAssetString(assetId) | |
413 | 529 | let aBalance = tryGetInteger((("global_" + getAssetString(assetId)) + "_balance")) | |
414 | 530 | let tokenEarningsLastCheck = tryGetInteger((("global_lastCheck_" + assetIdStr) + "_earnings")) | |
415 | 531 | let currentTokenInterest = calculateCurrentAssetInterest(assetId, assetIdStr, aBalance, tokenEarningsLastCheck) | |
416 | 532 | let currentTokenEarnings = max([tokenEarningsLastCheck, (getTokenBalance(assetId) - aBalance)]) | |
417 | 533 | let rewardAmount = fraction(puzzleAmount, (currentTokenInterest - tryGetInteger((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"))), Scale8) | |
418 | 534 | let transfer = if ((rewardAmount == 0)) | |
419 | 535 | then nil | |
420 | 536 | else [ScriptTransfer(address, rewardAmount, assetId)] | |
421 | - | $Tuple2(((accum._1 ++ transfer) ++ [IntegerEntry((("global_lastCheck_" + assetIdStr) + "_earnings"), (currentTokenEarnings - rewardAmount)), IntegerEntry((("global_lastCheck_" + assetIdStr) + "_interest"), currentTokenInterest), IntegerEntry((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"), currentTokenInterest)]), (accum._2 + | |
537 | + | $Tuple2(((accum._1 ++ transfer) ++ [IntegerEntry((("global_lastCheck_" + assetIdStr) + "_earnings"), (currentTokenEarnings - rewardAmount)), IntegerEntry((("global_lastCheck_" + assetIdStr) + "_interest"), currentTokenInterest), IntegerEntry((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"), currentTokenInterest)]), (accum._2 + calculateUsdValue(assetId, rewardAmount, aBalance))) | |
422 | 538 | } | |
423 | 539 | ||
424 | 540 | let accum = { | |
425 | 541 | let $l = earnedAssets | |
426 | 542 | let $s = size($l) | |
427 | 543 | let $acc0 = $Tuple2(nil, 0) | |
428 | 544 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
429 | 545 | then $a | |
430 | 546 | else handler($a, $l[$i]) | |
431 | 547 | ||
432 | 548 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
433 | 549 | then $a | |
434 | 550 | else throw("List size exceeds 10") | |
435 | 551 | ||
436 | 552 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
437 | 553 | } | |
438 | - | $Tuple2((accum._1 ++ [IntegerEntry((addressStr + "_ | |
554 | + | $Tuple2((accum._1 ++ [IntegerEntry((addressStr + "_claimedRewardUSD"), (tryGetInteger((addressStr + "_claimedRewardUSD")) + accum._2)), IntegerEntry((addressStr + "_lastClaim"), lastBlock.timestamp)]), accum._2) | |
439 | 555 | } | |
440 | 556 | ||
441 | 557 | ||
442 | 558 | func indexStakeResult (addressStr,amount) = { | |
443 | 559 | let li = claimResult(addressFromStringValue(addressStr))._1 | |
444 | 560 | (li ++ [IntegerEntry((addressStr + "_indexStaked"), (tryGetInteger((addressStr + "_indexStaked")) + amount)), IntegerEntry("global_indexStaked", (tryGetInteger("global_indexStaked") + amount))]) | |
445 | 561 | } | |
446 | 562 | ||
447 | 563 | ||
448 | 564 | func sum (accum,n) = (accum + parseIntValue(n)) | |
449 | 565 | ||
450 | 566 | ||
567 | + | func checkFeeAsset (accum,next) = if (if ((indexOf(supportedFeeAssetsStr, next) != unit)) | |
568 | + | then (accum == "") | |
569 | + | else false) | |
570 | + | then next | |
571 | + | else accum | |
572 | + | ||
573 | + | ||
574 | + | func getTmpRebalanceIds (newAssetIdsLi) = { | |
575 | + | let currentAssetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
576 | + | let result = newAssetIdsLi | |
577 | + | func f (accum,assetId) = if ((indexOf(result, assetId) == unit)) | |
578 | + | then (accum ++ [assetId]) | |
579 | + | else accum | |
580 | + | ||
581 | + | let $l = currentAssetIdsLi | |
582 | + | let $s = size($l) | |
583 | + | let $acc0 = result | |
584 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
585 | + | then $a | |
586 | + | else f($a, $l[$i]) | |
587 | + | ||
588 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
589 | + | then $a | |
590 | + | else throw("List size exceeds 10") | |
591 | + | ||
592 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
593 | + | } | |
594 | + | ||
595 | + | ||
596 | + | func checkTokensChange (newAssetIdsLi) = { | |
597 | + | let currentAssetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
598 | + | func rem (accum,assetId) = if ((indexOf(newAssetIdsLi, assetId) == unit)) | |
599 | + | then (accum + 1) | |
600 | + | else accum | |
601 | + | ||
602 | + | func add (accum,assetId) = if ((indexOf(currentAssetIdsLi, assetId) == unit)) | |
603 | + | then (accum + 1) | |
604 | + | else accum | |
605 | + | ||
606 | + | let removed = { | |
607 | + | let $l = currentAssetIdsLi | |
608 | + | let $s = size($l) | |
609 | + | let $acc0 = 0 | |
610 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
611 | + | then $a | |
612 | + | else rem($a, $l[$i]) | |
613 | + | ||
614 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
615 | + | then $a | |
616 | + | else throw("List size exceeds 10") | |
617 | + | ||
618 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
619 | + | } | |
620 | + | let added = { | |
621 | + | let $l = newAssetIdsLi | |
622 | + | let $s = size($l) | |
623 | + | let $acc0 = 0 | |
624 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
625 | + | then $a | |
626 | + | else add($a, $l[$i]) | |
627 | + | ||
628 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
629 | + | then $a | |
630 | + | else throw("List size exceeds 10") | |
631 | + | ||
632 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
633 | + | } | |
634 | + | (removed + added) | |
635 | + | } | |
636 | + | ||
637 | + | ||
638 | + | func validatePayments (assetsList,payments) = { | |
639 | + | func getPaymentAssets (accum,next) = if ((0 >= next.amount)) | |
640 | + | then throw(((("Too low payment amount for " + getAssetString(next.assetId)) + ": ") + toString(next.amount))) | |
641 | + | else (accum ++ [getAssetString(next.assetId)]) | |
642 | + | ||
643 | + | let paymentList = { | |
644 | + | let $l = payments | |
645 | + | let $s = size($l) | |
646 | + | let $acc0 = nil | |
647 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
648 | + | then $a | |
649 | + | else getPaymentAssets($a, $l[$i]) | |
650 | + | ||
651 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
652 | + | then $a | |
653 | + | else throw("List size exceeds 10") | |
654 | + | ||
655 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
656 | + | } | |
657 | + | func f1 (accum,next) = if ((indexOf(assetsList, next) == unit)) | |
658 | + | then throw(((next + " asset is present in payments, but is not in new assets: ") + makeString(assetsList, ","))) | |
659 | + | else (accum + 1) | |
660 | + | ||
661 | + | func f2 (accum,next) = if ((indexOf(paymentList, next) == unit)) | |
662 | + | then throw(((next + " asset is present in new assets, but is not in payments: ") + makeString(paymentList, ","))) | |
663 | + | else (accum + 1) | |
664 | + | ||
665 | + | let a1 = { | |
666 | + | let $l = paymentList | |
667 | + | let $s = size($l) | |
668 | + | let $acc0 = 0 | |
669 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
670 | + | then $a | |
671 | + | else f1($a, $l[$i]) | |
672 | + | ||
673 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
674 | + | then $a | |
675 | + | else throw("List size exceeds 10") | |
676 | + | ||
677 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
678 | + | } | |
679 | + | let a2 = { | |
680 | + | let $l = assetsList | |
681 | + | let $s = size($l) | |
682 | + | let $acc0 = 0 | |
683 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
684 | + | then $a | |
685 | + | else f2($a, $l[$i]) | |
686 | + | ||
687 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
688 | + | then $a | |
689 | + | else throw("List size exceeds 10") | |
690 | + | ||
691 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
692 | + | } | |
693 | + | (a1 + a2) | |
694 | + | } | |
695 | + | ||
696 | + | ||
697 | + | func validateWeights (weights) = { | |
698 | + | func v (accum,w) = { | |
699 | + | let wInt = valueOrErrorMessage(parseInt(w), ("Wrong weight format: " + w)) | |
700 | + | if (if ((MIN_WEIGHT > wInt)) | |
701 | + | then true | |
702 | + | else (wInt > MAX_WEIGHT)) | |
703 | + | then throw(((((("Weight should be in range " + toString(MIN_WEIGHT)) + " - ") + toString(MAX_WEIGHT)) + ", current: ") + w)) | |
704 | + | else accum | |
705 | + | } | |
706 | + | ||
707 | + | let $l = weights | |
708 | + | let $s = size($l) | |
709 | + | let $acc0 = 0 | |
710 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
711 | + | then $a | |
712 | + | else v($a, $l[$i]) | |
713 | + | ||
714 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
715 | + | then $a | |
716 | + | else throw("List size exceeds 10") | |
717 | + | ||
718 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
719 | + | } | |
720 | + | ||
721 | + | ||
451 | 722 | @Callable(i) | |
452 | 723 | func preInit (assetIdsStr,assetWeightsStr,baseTokenIdStr,poolDomain,poolOwner,fee) = { | |
453 | 724 | let poolOwnerAddress = Address(fromBase58String(poolOwner)) | |
725 | + | let assetIdsStrLi = split(assetIdsStr, ",") | |
726 | + | let assetIdsLi = { | |
727 | + | let $l = assetIdsStrLi | |
728 | + | let $s = size($l) | |
729 | + | let $acc0 = nil | |
730 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
731 | + | then $a | |
732 | + | else addAssetBytesToList($a, $l[$i]) | |
733 | + | ||
734 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
735 | + | then $a | |
736 | + | else throw("List size exceeds 10") | |
737 | + | ||
738 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
739 | + | } | |
740 | + | let feeAssetStr = { | |
741 | + | let $l = assetIdsStrLi | |
742 | + | let $s = size($l) | |
743 | + | let $acc0 = "" | |
744 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
745 | + | then $a | |
746 | + | else checkFeeAsset($a, $l[$i]) | |
747 | + | ||
748 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
749 | + | then $a | |
750 | + | else throw("List size exceeds 10") | |
751 | + | ||
752 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
753 | + | } | |
454 | 754 | if (isShutdown()) | |
455 | 755 | then throw("contract is on stop") | |
456 | 756 | else if ((this != i.caller)) | |
457 | 757 | then throw("admin only") | |
458 | - | else if ((size(poolDomain) > 13)) | |
459 | - | then throw("too large pool domain") | |
460 | - | else if (if ((fee > 500)) | |
461 | - | then true | |
462 | - | else (50 > fee)) | |
463 | - | then throw("fee value must be between 50 and 500 (0.5-5%)") | |
464 | - | else if (if (if (if (if ((indexOf(assetIdsStr, puzzleAssetIdStr) == unit)) | |
465 | - | then (indexOf(assetIdsStr, usdnAssetIdStr) == unit) | |
466 | - | else false) | |
467 | - | then (indexOf(assetIdsStr, usdtAssetIdStr) == unit) | |
468 | - | else false) | |
469 | - | then (indexOf(assetIdsStr, "WAVES") == unit) | |
470 | - | else false) | |
471 | - | then (indexOf(assetIdsStr, usdtPptAssetIdStr) == unit) | |
472 | - | else false) | |
473 | - | then throw("pool must have USDT-WXG, USDT-PPT, USDN, WAVES or PUZZLE in the composition") | |
758 | + | else if ((feeAssetStr == "")) | |
759 | + | then throw("pool must have one of the supported fee assets in the composition") | |
760 | + | else if ((size(poolDomain) > 13)) | |
761 | + | then throw("too large pool domain") | |
762 | + | else if (if ((fee > 500)) | |
763 | + | then true | |
764 | + | else (0 > fee)) | |
765 | + | then throw("fee value must be between 50 and 500 (0.5-5%)") | |
474 | 766 | else { | |
475 | - | let assetIdsStrLi = split(assetIdsStr, ",") | |
476 | - | let assetIdsLi = { | |
477 | - | let $l = assetIdsStrLi | |
478 | - | let $s = size($l) | |
479 | - | let $acc0 = nil | |
480 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
481 | - | then $a | |
482 | - | else addAssetBytesToList($a, $l[$i]) | |
483 | - | ||
484 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
485 | - | then $a | |
486 | - | else throw("List size exceeds 10") | |
487 | - | ||
488 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
489 | - | } | |
490 | 767 | let assetWeightsStrLi = split(assetWeightsStr, ",") | |
491 | 768 | let assetWeightsSum = { | |
492 | 769 | let $l = assetWeightsStrLi | |
493 | 770 | let $s = size($l) | |
494 | 771 | let $acc0 = 0 | |
495 | - | func $ | |
772 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
496 | 773 | then $a | |
497 | 774 | else sum($a, $l[$i]) | |
498 | 775 | ||
499 | - | func $ | |
776 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
500 | 777 | then $a | |
501 | 778 | else throw("List size exceeds 10") | |
502 | 779 | ||
503 | - | $ | |
780 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
504 | 781 | } | |
505 | - | let feeAssetStr = if ((indexOf(assetIdsStr, usdnAssetIdStr) != unit)) | |
506 | - | then usdnAssetIdStr | |
507 | - | else if ((indexOf(assetIdsStr, "WAVES") != unit)) | |
508 | - | then "WAVES" | |
509 | - | else if ((indexOf(assetIdsStr, usdtAssetIdStr) != unit)) | |
510 | - | then usdtAssetIdStr | |
511 | - | else if ((indexOf(assetIdsStr, puzzleAssetIdStr) != unit)) | |
512 | - | then puzzleAssetIdStr | |
513 | - | else usdtPptAssetIdStr | |
514 | 782 | func addTokenDataEntries (accum,assetNum) = if ((assetNum >= size(assetIdsLi))) | |
515 | 783 | then accum | |
516 | 784 | else { | |
517 | 785 | let assetDecimals = match assetIdsLi[assetNum] { | |
518 | 786 | case x: ByteVector => | |
519 | 787 | value(assetInfo(x)).decimals | |
520 | 788 | case _ => | |
521 | 789 | 8 | |
522 | 790 | } | |
523 | 791 | (accum ++ [IntegerEntry((("static_" + assetIdsStrLi[assetNum]) + "_scale"), pow(10, 0, assetDecimals, 0, 0, DOWN)), IntegerEntry((("static_" + assetIdsStrLi[assetNum]) + "_decimals"), assetDecimals), IntegerEntry((("static_" + assetIdsStrLi[assetNum]) + "_weight"), value(parseInt(assetWeightsStrLi[assetNum])))]) | |
524 | 792 | } | |
525 | 793 | ||
526 | 794 | if ((assetWeightsSum != 10000)) | |
527 | 795 | then throw("sum of token weights must be equal to 10000") | |
528 | 796 | else ({ | |
529 | 797 | let $l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
530 | 798 | let $s = size($l) | |
531 | 799 | let $acc0 = nil | |
532 | - | func $ | |
800 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
533 | 801 | then $a | |
534 | 802 | else addTokenDataEntries($a, $l[$i]) | |
535 | 803 | ||
536 | - | func $ | |
804 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
537 | 805 | then $a | |
538 | 806 | else throw("List size exceeds 10") | |
539 | 807 | ||
540 | - | $ | |
541 | - | } ++ [StringEntry("static_tokenIds", assetIdsStr), StringEntry("static_feeToken", feeAssetStr), StringEntry("static_tokenWeights", assetWeightsStr), IntegerEntry("static_tokensAmount", size(assetIdsLi)), StringEntry("static_poolDomain", poolDomain), StringEntry("static_baseTokenId", baseTokenIdStr), StringEntry("static_poolOwner", poolOwner), IntegerEntry("static_fee", fee)]) | |
808 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
809 | + | } ++ [StringEntry("static_tokenIds", assetIdsStr), StringEntry("static_feeToken", feeAssetStr), StringEntry("static_tokenWeights", assetWeightsStr), IntegerEntry("static_tokensAmount", size(assetIdsLi)), StringEntry("static_poolDomain", poolDomain), StringEntry("static_baseTokenId", baseTokenIdStr), StringEntry("static_poolOwner", poolOwner), IntegerEntry("static_fee", fee), IntegerEntry("static_KMult", Scale16), IntegerEntry("global_wasPreInited", 1)]) | |
542 | 810 | } | |
543 | 811 | } | |
544 | 812 | ||
545 | 813 | ||
546 | 814 | ||
547 | 815 | @Callable(i) | |
548 | 816 | func deInit () = if (isShutdown()) | |
549 | 817 | then throw("contract is on stop") | |
550 | 818 | else if ((i.caller != this)) | |
551 | 819 | then throw("admin only") | |
552 | 820 | else [IntegerEntry("global_wasInited", 0)] | |
553 | 821 | ||
554 | 822 | ||
555 | 823 | ||
556 | 824 | @Callable(i) | |
557 | 825 | func init () = { | |
558 | 826 | func prepareList () = { | |
559 | 827 | func handler (accum,n) = (accum ++ [IntegerEntry((("global_" + getAssetString(n.assetId)) + "_balance"), n.amount)]) | |
560 | 828 | ||
561 | 829 | let $l = i.payments | |
562 | 830 | let $s = size($l) | |
563 | 831 | let $acc0 = nil | |
564 | 832 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
565 | 833 | then $a | |
566 | 834 | else handler($a, $l[$i]) | |
567 | 835 | ||
568 | 836 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
569 | 837 | then $a | |
570 | 838 | else throw("List size exceeds 10") | |
571 | 839 | ||
572 | 840 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
573 | 841 | } | |
574 | 842 | ||
575 | 843 | func calculatePoolTokensAmount (payments) = { | |
576 | 844 | func handler (accum,pmt) = { | |
577 | 845 | let assetId = pmt.assetId | |
578 | 846 | func handler2 (accum,n) = if ((n == assetId)) | |
579 | 847 | then value(indexOf(assetIds, n)) | |
580 | 848 | else accum | |
581 | 849 | ||
582 | 850 | let Token = { | |
583 | 851 | let $l = assetIds | |
584 | 852 | let $s = size($l) | |
585 | 853 | let $acc0 = 1 | |
586 | 854 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
587 | 855 | then $a | |
588 | 856 | else handler2($a, $l[$i]) | |
589 | 857 | ||
590 | 858 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
591 | 859 | then $a | |
592 | 860 | else throw("List size exceeds 10") | |
593 | 861 | ||
594 | 862 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
595 | 863 | } | |
596 | 864 | fraction(accum, pow(pmt.amount, Decimals[Token], AssetsWeights[Token], AssetsWeightsDecimals, 8, FLOOR), Scale8) | |
597 | 865 | } | |
598 | 866 | ||
599 | 867 | let $l = payments | |
600 | 868 | let $s = size($l) | |
601 | 869 | let $acc0 = PoolTokenScale | |
602 | 870 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
603 | 871 | then $a | |
604 | 872 | else handler($a, $l[$i]) | |
605 | 873 | ||
606 | 874 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
607 | 875 | then $a | |
608 | 876 | else throw("List size exceeds 10") | |
609 | 877 | ||
610 | 878 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
611 | 879 | } | |
612 | 880 | ||
613 | 881 | if (isShutdown()) | |
614 | 882 | then throw("contract is on stop") | |
615 | 883 | else if ((tryGetInteger("global_wasInited") > 0)) | |
616 | 884 | then throw("pool already inited") | |
617 | 885 | else { | |
618 | 886 | let initialPoolTokens = calculatePoolTokensAmount(i.payments) | |
619 | 887 | if ((initialPoolTokens == 0)) | |
620 | 888 | then throw("you need a bigger tokens amount to launch the pool") | |
621 | 889 | else { | |
622 | 890 | let poolTokenIssue = Issue(("PZ " + tryGetString("static_poolDomain")), "Puzzle Swap: pool index token", initialPoolTokens, PoolTokenDecimals, true, unit, 0) | |
623 | 891 | let poolTokenId = calculateAssetId(poolTokenIssue) | |
624 | 892 | (prepareList() ++ [poolTokenIssue, IntegerEntry("global_poolToken_amount", initialPoolTokens), IntegerEntry("global_wasInited", 1), BinaryEntry("global_poolToken_id", poolTokenId), StringEntry("static_poolToken_idStr", getAssetString(poolTokenId)), IntegerEntry((toString(i.caller) + "_indexStaked"), initialPoolTokens), IntegerEntry("global_indexStaked", initialPoolTokens)]) | |
625 | 893 | } | |
626 | 894 | } | |
627 | 895 | } | |
628 | 896 | ||
629 | 897 | ||
630 | 898 | ||
631 | 899 | @Callable(i) | |
632 | 900 | func generateIndex (needChange) = if ((size(i.payments) != T)) | |
633 | 901 | then throw(("you need to attach all pool tokens. amount of pool tokens: " + toString(T))) | |
634 | 902 | else if (!(checkTokensValidity(i.payments))) | |
635 | 903 | then throw("wrong assets attached") | |
636 | 904 | else { | |
637 | - | let PIssued = getMinPIssued(i.payments) | |
638 | - | let reissue = Reissue(getBinaryValue("global_poolToken_id"), PIssued, true) | |
639 | - | let result = handlePoolTokensAdd(PIssued, i.payments, i.originCaller, needChange) | |
640 | - | $Tuple2((result ++ [reissue, ScriptTransfer(i.caller, PIssued, tryGetBinary("global_poolToken_id")), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") + PIssued))]), PIssued) | |
905 | + | let PIssuedNoMult = getMinPIssued(i.payments) | |
906 | + | let result = handlePoolTokensAdd(PIssuedNoMult, i.payments, i.originCaller, needChange) | |
907 | + | let PIssuedWithMult = fraction(PIssuedNoMult, Scale16, getKMult(), DOWN) | |
908 | + | let reissue = Reissue(getBinaryValue("global_poolToken_id"), PIssuedWithMult, true) | |
909 | + | $Tuple2((result ++ [reissue, ScriptTransfer(i.caller, PIssuedWithMult, tryGetBinary("global_poolToken_id")), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") + PIssuedWithMult))]), PIssuedWithMult) | |
641 | 910 | } | |
911 | + | ||
912 | + | ||
913 | + | ||
914 | + | @Callable(i) | |
915 | + | func redeemIndex (sendToOrigin) = { | |
916 | + | let pmt = i.payments[0] | |
917 | + | if ((pmt.assetId != tryGetBinary("global_poolToken_id"))) | |
918 | + | then throw("please attach pool share token") | |
919 | + | else if (isShutdown()) | |
920 | + | then throw("contract is on stop") | |
921 | + | else { | |
922 | + | let PRedeemedWithMult = pmt.amount | |
923 | + | let PRedeemedWithNoMult = fraction(PRedeemedWithMult, getKMult(), Scale16, DOWN) | |
924 | + | let result = handlePoolTokensRedeem(PRedeemedWithNoMult, if (sendToOrigin) | |
925 | + | then i.originCaller | |
926 | + | else i.caller) | |
927 | + | (result ++ [Burn(tryGetBinary("global_poolToken_id"), PRedeemedWithMult), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") - PRedeemedWithMult))]) | |
928 | + | } | |
929 | + | } | |
642 | 930 | ||
643 | 931 | ||
644 | 932 | ||
645 | 933 | @Callable(i) | |
646 | 934 | func stakeIndex () = { | |
647 | 935 | let addressStr = toString(i.originCaller) | |
648 | 936 | let pmt = i.payments[0] | |
649 | 937 | if ((value(pmt.assetId) != tryGetBinary("global_poolToken_id"))) | |
650 | 938 | then throw("wrong asset attached") | |
651 | 939 | else indexStakeResult(addressStr, pmt.amount) | |
652 | 940 | } | |
653 | 941 | ||
654 | 942 | ||
655 | 943 | ||
656 | 944 | @Callable(i) | |
657 | - | func unstakeIndex (puzzleAmount) = { | |
658 | - | let addressStr = toString(i.originCaller) | |
659 | - | let puzzleAvailable = tryGetInteger((addressStr + "_indexStaked")) | |
945 | + | func stakeIndexFor (addressStr) = { | |
946 | + | let pmt = i.payments[0] | |
947 | + | if ((value(pmt.assetId) != tryGetBinary("global_poolToken_id"))) | |
948 | + | then throw("wrong asset attached") | |
949 | + | else indexStakeResult(addressStr, pmt.amount) | |
950 | + | } | |
951 | + | ||
952 | + | ||
953 | + | ||
954 | + | @Callable(i) | |
955 | + | func unstakeIndex (indexAmount) = { | |
956 | + | let addressStr = if ((indexOf(layer2Addresses, toString(i.caller)) != unit)) | |
957 | + | then toString(i.originCaller) | |
958 | + | else toString(i.caller) | |
959 | + | let indexAvailable = tryGetInteger((addressStr + "_indexStaked")) | |
660 | 960 | if (isShutdown()) | |
661 | 961 | then throw("contract is on stop") | |
662 | - | else if (( | |
962 | + | else if ((indexAmount > indexAvailable)) | |
663 | 963 | then throw("you don't have index tokens available") | |
664 | 964 | else if (isShutdown()) | |
665 | 965 | then throw("contract is on stop") | |
666 | - | else (claimResult( | |
966 | + | else (claimResult(addressFromStringValue(addressStr))._1 ++ [IntegerEntry((addressStr + "_indexStaked"), (indexAvailable - indexAmount)), IntegerEntry("global_indexStaked", (tryGetInteger("global_indexStaked") - indexAmount)), ScriptTransfer(i.caller, indexAmount, getBinaryValue("global_poolToken_id"))]) | |
667 | 967 | } | |
668 | 968 | ||
669 | 969 | ||
670 | 970 | ||
671 | 971 | @Callable(i) | |
672 | 972 | func claimIndexRewards () = if (isShutdown()) | |
673 | 973 | then throw("contract is on stop") | |
674 | 974 | else claimResult(i.caller) | |
675 | 975 | ||
676 | 976 | ||
677 | 977 | ||
678 | 978 | @Callable(i) | |
679 | 979 | func evaluateClaim (user) = $Tuple2(nil, claimResult(addressFromStringValue(user))._2) | |
680 | 980 | ||
681 | 981 | ||
682 | 982 | ||
683 | 983 | @Callable(i) | |
684 | - | func redeemIndex (sendToOrigin) = { | |
685 | - | let pmt = i.payments[0] | |
686 | - | if ((pmt.assetId != tryGetBinary("global_poolToken_id"))) | |
687 | - | then throw("please attach pool share token") | |
688 | - | else if (isShutdown()) | |
689 | - | then throw("contract is on stop") | |
690 | - | else { | |
691 | - | let PRedeemed = pmt.amount | |
692 | - | let result = handlePoolTokensRedeem(PRedeemed, if (sendToOrigin) | |
693 | - | then i.originCaller | |
694 | - | else i.caller) | |
695 | - | (result ++ [Burn(tryGetBinary("global_poolToken_id"), PRedeemed), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") - PRedeemed))]) | |
696 | - | } | |
697 | - | } | |
698 | - | ||
699 | - | ||
700 | - | ||
701 | - | @Callable(i) | |
702 | 984 | func swap (assetOut,minimum) = { | |
703 | 985 | let pmt = if ((size(i.payments) == 1)) | |
704 | 986 | then value(i.payments[0]) | |
705 | 987 | else throw("please attach exactly one payment") | |
706 | 988 | let AmountIn = value(i.payments[0].amount) | |
707 | 989 | let AssetIn = pmt.assetId | |
708 | 990 | let AssetOut = getAssetBytes(assetOut) | |
991 | + | let assetIn = getAssetString(AssetIn) | |
992 | + | let scaleIn = (Scale8 / tryGetInteger((("static_" + assetIn) + "_scale"))) | |
993 | + | let scaleOut = (Scale8 / tryGetInteger((("static_" + assetOut) + "_scale"))) | |
709 | 994 | let feeAssetOutStr = tryGetString("static_feeToken") | |
710 | 995 | let feeAssetOut = if ((feeAssetOutStr == "")) | |
711 | 996 | then usdnAssetId | |
712 | 997 | else getAssetBytes(feeAssetOutStr) | |
713 | 998 | let AssetInBalance = tryGetInteger((("global_" + getAssetString(AssetIn)) + "_balance")) | |
714 | 999 | let AssetOutBalance = tryGetInteger((("global_" + assetOut) + "_balance")) | |
1000 | + | let AssetInBalanceScaled = (AssetInBalance * scaleIn) | |
1001 | + | let AssetOutBalanceScaled = (AssetOutBalance * scaleOut) | |
715 | 1002 | let feeAmountIn = fraction(AmountIn, Fee, FeeScale) | |
716 | 1003 | let cleanAmountIn = (AmountIn - feeAmountIn) | |
717 | - | let AmountOut = calculateOutAmount(cleanAmountIn, AssetIn, AssetOut, AssetInBalance, AssetOutBalance) | |
1004 | + | let cleanAmountInScaled = (cleanAmountIn * scaleIn) | |
1005 | + | let AmountOut1 = calculateOutAmount(cleanAmountInScaled, AssetIn, AssetOut, AssetInBalanceScaled, AssetOutBalanceScaled) | |
1006 | + | let AmountOut = fraction(AmountOut1, 1, scaleOut) | |
718 | 1007 | let AssetOutBalance2 = (AssetOutBalance - AmountOut) | |
719 | 1008 | let AssetInBalance2 = (AssetInBalance + cleanAmountIn) | |
720 | 1009 | let feeAssetOutBalance = if ((feeAssetOut == AssetIn)) | |
721 | 1010 | then AssetInBalance2 | |
722 | 1011 | else if ((feeAssetOut == AssetOut)) | |
723 | 1012 | then AssetOutBalance2 | |
724 | 1013 | else tryGetInteger((("global_" + getAssetString(feeAssetOut)) + "_balance")) | |
725 | 1014 | let feeAmountOut = calculateOutAmount(feeAmountIn, AssetIn, feeAssetOut, AssetInBalance, feeAssetOutBalance) | |
726 | 1015 | if ((minimum > AmountOut)) | |
727 | 1016 | then throw("amount to recieve is lower than given one") | |
728 | 1017 | else if ((AssetOut == AssetIn)) | |
729 | 1018 | then throw("this swap is not allowed") | |
730 | 1019 | else if ((0 > (AssetOutBalance - AmountOut))) | |
731 | 1020 | then throw("contract is out of reserves") | |
732 | 1021 | else if (isShutdown()) | |
733 | 1022 | then throw("contract is on stop") | |
734 | 1023 | else { | |
735 | 1024 | let creatorFee = fraction(feeAmountOut, 1, 10) | |
736 | 1025 | let protocolFee = fraction(feeAmountOut, 4, 10) | |
737 | - | let stakingTopUp = if (if ((feeAssetOut == usdnAssetId)) | |
738 | - | then true | |
739 | - | else (feeAssetOut == puzzleAssetId)) | |
740 | - | then reentrantInvoke(Address(base58'3PFTbywqxtFfukX3HyT881g4iW5K4QL3FAS'), "topUpReward", nil, [AttachedPayment(feeAssetOut, protocolFee)]) | |
1026 | + | let newBalanceIn = AssetInBalance2 | |
1027 | + | let newBalanceOut = (AssetOutBalance2 - (if ((AssetOut == feeAssetOut)) | |
1028 | + | then feeAmountOut | |
1029 | + | else 0)) | |
1030 | + | let newBalanceFeeAsset = if (if ((feeAssetOut != AssetIn)) | |
1031 | + | then (feeAssetOut != AssetOut) | |
1032 | + | else false) | |
1033 | + | then (feeAssetOutBalance - feeAmountOut) | |
741 | 1034 | else unit | |
742 | - | if ((stakingTopUp == stakingTopUp)) | |
743 | - | then { | |
744 | - | let newBalanceIn = AssetInBalance2 | |
745 | - | let newBalanceOut = (AssetOutBalance2 - (if ((AssetOut == feeAssetOut)) | |
746 | - | then feeAmountOut | |
747 | - | else 0)) | |
748 | - | let newBalanceFeeAsset = if (if ((feeAssetOut != AssetIn)) | |
749 | - | then (feeAssetOut != AssetOut) | |
750 | - | else false) | |
751 | - | then (feeAssetOutBalance - feeAmountOut) | |
752 | - | else unit | |
753 | - | let assetInChange = IntegerEntry((("global_" + getAssetString(AssetIn)) + "_balance"), newBalanceIn) | |
754 | - | let assetOutChange = IntegerEntry((("global_" + assetOut) + "_balance"), newBalanceOut) | |
755 | - | let feeAssetOutChange = if ((newBalanceFeeAsset != unit)) | |
756 | - | then IntegerEntry((("global_" + getAssetString(feeAssetOut)) + "_balance"), value(newBalanceFeeAsset)) | |
757 | - | else StringEntry("hello", "world") | |
758 | - | let volumeUpdate = calculateUsdnValue(AssetIn, AmountIn, AssetInBalance, feeAssetOutBalance) | |
759 | - | $Tuple2(([assetOutChange, assetInChange, feeAssetOutChange, ScriptTransfer(i.caller, AmountOut, AssetOut), ScriptTransfer(addressFromStringValue(tryGetString("static_poolOwner")), creatorFee, feeAssetOut), IntegerEntry("global_earnedByOwner", (tryGetInteger("global_earnedByOwner") + creatorFee)), IntegerEntry("global_volume", (tryGetInteger("global_volume") + volumeUpdate))] ++ (if ((stakingTopUp == unit)) | |
760 | - | then [ScriptTransfer(Address(base58'3PFWAVKmXjfHXyzJb12jCbhP4Uhi9t4uWiD'), protocolFee, feeAssetOut)] | |
761 | - | else nil)), AmountOut) | |
762 | - | } | |
763 | - | else throw("Strict value is not equal to itself.") | |
1035 | + | let assetInChange = IntegerEntry((("global_" + getAssetString(AssetIn)) + "_balance"), newBalanceIn) | |
1036 | + | let assetOutChange = IntegerEntry((("global_" + assetOut) + "_balance"), newBalanceOut) | |
1037 | + | let feeAssetOutChange = if ((newBalanceFeeAsset != unit)) | |
1038 | + | then IntegerEntry((("global_" + getAssetString(feeAssetOut)) + "_balance"), value(newBalanceFeeAsset)) | |
1039 | + | else StringEntry("hello", "world") | |
1040 | + | let volumeUpdate = calculateUsdnValue(AssetIn, AmountIn, AssetInBalance, feeAssetOutBalance) | |
1041 | + | let volumeUsdUpdate = calculateUsdValue(AssetIn, AmountIn, AssetInBalance) | |
1042 | + | $Tuple2([assetOutChange, assetInChange, feeAssetOutChange, ScriptTransfer(i.caller, AmountOut, AssetOut), ScriptTransfer(addressFromStringValue(tryGetString("static_poolOwner")), creatorFee, feeAssetOut), IntegerEntry("global_earnedByOwner", (tryGetInteger("global_earnedByOwner") + creatorFee)), IntegerEntry("global_volume", (tryGetInteger("global_volume") + volumeUpdate)), IntegerEntry("global_volume_usd", (tryGetInteger("global_volume_usd") + volumeUsdUpdate)), ScriptTransfer(feesAddress, protocolFee, feeAssetOut)], AmountOut) | |
764 | 1043 | } | |
1044 | + | } | |
1045 | + | ||
1046 | + | ||
1047 | + | ||
1048 | + | @Callable(i) | |
1049 | + | func swapReadOnly (assetIn,assetOut,AmountIn) = { | |
1050 | + | let AssetIn = getAssetBytes(assetIn) | |
1051 | + | let AssetOut = getAssetBytes(assetOut) | |
1052 | + | let scaleIn = (Scale8 / tryGetInteger((("static_" + assetIn) + "_scale"))) | |
1053 | + | let scaleOut = (Scale8 / tryGetInteger((("static_" + assetOut) + "_scale"))) | |
1054 | + | let feeAssetOutStr = tryGetString("static_feeToken") | |
1055 | + | let feeAssetOut = if ((feeAssetOutStr == "")) | |
1056 | + | then usdnAssetId | |
1057 | + | else getAssetBytes(feeAssetOutStr) | |
1058 | + | let AssetInBalance = tryGetInteger((("global_" + getAssetString(AssetIn)) + "_balance")) | |
1059 | + | let AssetOutBalance = tryGetInteger((("global_" + assetOut) + "_balance")) | |
1060 | + | let AssetInBalanceScaled = (AssetInBalance * scaleIn) | |
1061 | + | let AssetOutBalanceScaled = (AssetOutBalance * scaleOut) | |
1062 | + | let feeAmountIn = fraction(AmountIn, Fee, FeeScale) | |
1063 | + | let cleanAmountIn = (AmountIn - feeAmountIn) | |
1064 | + | let cleanAmountInScaled = (cleanAmountIn * scaleIn) | |
1065 | + | let AmountOut1 = calculateOutAmount(cleanAmountInScaled, AssetIn, AssetOut, AssetInBalanceScaled, AssetOutBalanceScaled) | |
1066 | + | let AmountOut = fraction(AmountOut1, 1, scaleOut) | |
1067 | + | let AssetOutBalance2 = (AssetOutBalance - AmountOut) | |
1068 | + | let AssetInBalance2 = (AssetInBalance + cleanAmountIn) | |
1069 | + | let feeAssetOutBalance = if ((feeAssetOut == AssetIn)) | |
1070 | + | then AssetInBalance2 | |
1071 | + | else if ((feeAssetOut == AssetOut)) | |
1072 | + | then AssetOutBalance2 | |
1073 | + | else tryGetInteger((("global_" + getAssetString(feeAssetOut)) + "_balance")) | |
1074 | + | let feeAmountOut = calculateOutAmount(feeAmountIn, AssetIn, feeAssetOut, AssetInBalance, feeAssetOutBalance) | |
1075 | + | if ((AssetOut == AssetIn)) | |
1076 | + | then throw("this swap is not allowed") | |
1077 | + | else if ((0 > (AssetOutBalance - AmountOut))) | |
1078 | + | then throw("contract is out of reserves") | |
1079 | + | else if (isShutdown()) | |
1080 | + | then throw("contract is on stop") | |
1081 | + | else $Tuple2(nil, AmountOut) | |
765 | 1082 | } | |
766 | 1083 | ||
767 | 1084 | ||
768 | 1085 | ||
769 | 1086 | @Callable(i) | |
770 | 1087 | func transferOwnership (newOwnerAddress) = if ((toString(i.caller) != tryGetString("static_poolOwner"))) | |
771 | 1088 | then throw("this call available only for pool owner") | |
772 | 1089 | else [StringEntry("static_poolOwner", newOwnerAddress)] | |
773 | 1090 | ||
774 | 1091 | ||
1092 | + | ||
1093 | + | @Callable(i) | |
1094 | + | func setFee (newFee) = if ((toString(i.caller) != tryGetString("static_poolOwner"))) | |
1095 | + | then throw("this call available only for pool owner") | |
1096 | + | else if ((1 > valueOrElse(getInteger(govAddress, ("approvedTx_" + toBase58String(i.transactionId))), 0))) | |
1097 | + | then throw("this transaction needs approval from puzzle network") | |
1098 | + | else [IntegerEntry("static_fee", newFee)] | |
1099 | + | ||
1100 | + | ||
1101 | + | ||
1102 | + | @Callable(i) | |
1103 | + | func setRebalancingPlan (assetIdsStr,assetWeightsStr,baseTokenIdStr,stepsAmount,stepsInterval) = if ((i.caller != addressFromStringValue(tryGetString("static_poolOwner")))) | |
1104 | + | then throw("this call available only for pool owner") | |
1105 | + | else if (valueOrElse(getBoolean(this, "rebalance_inProgress"), false)) | |
1106 | + | then throw("rebalancing in progress") | |
1107 | + | else { | |
1108 | + | let newAssetWeightsStrLi = split(assetWeightsStr, ",") | |
1109 | + | let newAssetIdsStrLi = split(assetIdsStr, ",") | |
1110 | + | let feeAssetStr = { | |
1111 | + | let $l = newAssetIdsStrLi | |
1112 | + | let $s = size($l) | |
1113 | + | let $acc0 = "" | |
1114 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
1115 | + | then $a | |
1116 | + | else checkFeeAsset($a, $l[$i]) | |
1117 | + | ||
1118 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
1119 | + | then $a | |
1120 | + | else throw("List size exceeds 10") | |
1121 | + | ||
1122 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1123 | + | } | |
1124 | + | let assetWeightsSum = { | |
1125 | + | let $l = newAssetWeightsStrLi | |
1126 | + | let $s = size($l) | |
1127 | + | let $acc0 = 0 | |
1128 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1129 | + | then $a | |
1130 | + | else sum($a, $l[$i]) | |
1131 | + | ||
1132 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1133 | + | then $a | |
1134 | + | else throw("List size exceeds 10") | |
1135 | + | ||
1136 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1137 | + | } | |
1138 | + | let oldAssetIds = getStringValue("static_tokenIds") | |
1139 | + | let oldAssetIdsLi = split(oldAssetIds, ",") | |
1140 | + | func findAdded (accum,next) = if ((indexOf(oldAssetIdsLi, next) == unit)) | |
1141 | + | then (accum ++ [next]) | |
1142 | + | else accum | |
1143 | + | ||
1144 | + | func findRemoved (accum,next) = if ((indexOf(newAssetIdsStrLi, next) == unit)) | |
1145 | + | then (accum ++ [next]) | |
1146 | + | else accum | |
1147 | + | ||
1148 | + | let addedAssets = { | |
1149 | + | let $l = newAssetIdsStrLi | |
1150 | + | let $s = size($l) | |
1151 | + | let $acc0 = nil | |
1152 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
1153 | + | then $a | |
1154 | + | else findAdded($a, $l[$i]) | |
1155 | + | ||
1156 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
1157 | + | then $a | |
1158 | + | else throw("List size exceeds 10") | |
1159 | + | ||
1160 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1161 | + | } | |
1162 | + | let removedAssets = { | |
1163 | + | let $l = oldAssetIdsLi | |
1164 | + | let $s = size($l) | |
1165 | + | let $acc0 = nil | |
1166 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1167 | + | then $a | |
1168 | + | else findRemoved($a, $l[$i]) | |
1169 | + | ||
1170 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1171 | + | then $a | |
1172 | + | else throw("List size exceeds 10") | |
1173 | + | ||
1174 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1175 | + | } | |
1176 | + | let validPayments = validatePayments(addedAssets, i.payments) | |
1177 | + | let validWeights = validateWeights(newAssetWeightsStrLi) | |
1178 | + | if ((validWeights == validWeights)) | |
1179 | + | then if ((validPayments != (size(addedAssets) + size(i.payments)))) | |
1180 | + | then throw("Payments not present or something wrong with them") | |
1181 | + | else if ((size(newAssetIdsStrLi) != size(newAssetWeightsStrLi))) | |
1182 | + | then throw("assetIds and assetWeights should have same length") | |
1183 | + | else if ((validPayments != (size(addedAssets) + size(i.payments)))) | |
1184 | + | then throw("Payments not present or something wrong with them") | |
1185 | + | else if ((feeAssetStr == "")) | |
1186 | + | then throw("pool must have one of the supported fee assets in the composition") | |
1187 | + | else if ((indexOf(newAssetIdsStrLi, baseTokenIdStr) == unit)) | |
1188 | + | then throw("baseTokenId should be present in assetIds") | |
1189 | + | else if (if ((MIN_STEPS_AMOUNT > stepsAmount)) | |
1190 | + | then true | |
1191 | + | else (stepsAmount > MAX_STEPS_AMOUNT)) | |
1192 | + | then throw(((((("Steps amount should be between " + toString(MIN_STEPS_AMOUNT)) + " and ") + toString(MAX_STEPS_AMOUNT)) + ", current: ") + toString(stepsAmount))) | |
1193 | + | else if (if ((MIN_STEPS_INTERVAL > stepsInterval)) | |
1194 | + | then true | |
1195 | + | else (stepsInterval > MAX_STEPS_INTERVAL)) | |
1196 | + | then throw(((((("Steps interval should be between " + toString(MIN_STEPS_INTERVAL)) + " and ") + toString(MAX_STEPS_INTERVAL)) + ", current: ") + toString(stepsInterval))) | |
1197 | + | else if ((assetWeightsSum != 10000)) | |
1198 | + | then throw(("sum of token weights must be equal to 10000, current: " + toString(assetWeightsSum))) | |
1199 | + | else { | |
1200 | + | func f (accum,assetIdStr) = { | |
1201 | + | let oldWeight = tryGetInteger((("static_" + assetIdStr) + "_weight")) | |
1202 | + | let newWeight = if ((indexOf(newAssetIdsStrLi, assetIdStr) == unit)) | |
1203 | + | then 0 | |
1204 | + | else parseIntValue(value(newAssetWeightsStrLi[value(indexOf(newAssetIdsStrLi, assetIdStr))])) | |
1205 | + | let deltaPerStep = fraction((newWeight - oldWeight), 10000, stepsAmount) | |
1206 | + | (accum ++ [toString(deltaPerStep)]) | |
1207 | + | } | |
1208 | + | ||
1209 | + | let tmpAssetIdsLi = getTmpRebalanceIds(newAssetIdsStrLi) | |
1210 | + | let assetDeltas = { | |
1211 | + | let $l = tmpAssetIdsLi | |
1212 | + | let $s = size($l) | |
1213 | + | let $acc0 = nil | |
1214 | + | func $f8_1 ($a,$i) = if (($i >= $s)) | |
1215 | + | then $a | |
1216 | + | else f($a, $l[$i]) | |
1217 | + | ||
1218 | + | func $f8_2 ($a,$i) = if (($i >= $s)) | |
1219 | + | then $a | |
1220 | + | else throw("List size exceeds 10") | |
1221 | + | ||
1222 | + | $f8_2($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1223 | + | } | |
1224 | + | let newTokensAdded = (checkTokensChange(newAssetIdsStrLi) > 0) | |
1225 | + | func recordAssetPayment (accum,next) = (accum ++ [IntegerEntry(("rebalance_attachedPayment_" + getAssetString(next.assetId)), next.amount)]) | |
1226 | + | ||
1227 | + | let paymentEntries = { | |
1228 | + | let $l = i.payments | |
1229 | + | let $s = size($l) | |
1230 | + | let $acc0 = nil | |
1231 | + | func $f9_1 ($a,$i) = if (($i >= $s)) | |
1232 | + | then $a | |
1233 | + | else recordAssetPayment($a, $l[$i]) | |
1234 | + | ||
1235 | + | func $f9_2 ($a,$i) = if (($i >= $s)) | |
1236 | + | then $a | |
1237 | + | else throw("List size exceeds 10") | |
1238 | + | ||
1239 | + | $f9_2($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($f9_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1240 | + | } | |
1241 | + | let storeWeights = saveCurrentWeights() | |
1242 | + | let requestGovInvoke = invoke(govAddress, "requestRebalancing", [toBase58String(i.transactionId)], nil) | |
1243 | + | if ((requestGovInvoke == requestGovInvoke)) | |
1244 | + | then (([StringEntry("rebalance_addedAssets", makeString(addedAssets, ",")), StringEntry("rebalance_removedAssets", makeString(removedAssets, ",")), StringEntry("tmp_rebalanceAssetIds", makeString(tmpAssetIdsLi, ",")), BooleanEntry("rebalance_inProgress", true), BooleanEntry("rebalance_newTokensAdded", newTokensAdded), IntegerEntry("rebalance_stepsDone", 0), IntegerEntry("rebalance_lastStepHeight", height), IntegerEntry("rebalance_stepsAmount", stepsAmount), IntegerEntry("rebalance_stepsInterval", stepsInterval), StringEntry("rebalance_assetIds", assetIdsStr), StringEntry("rebalance_newBaseTokenId", baseTokenIdStr), StringEntry("rebalance_assetDeltas", makeString(assetDeltas, ","))] ++ paymentEntries) ++ storeWeights) | |
1245 | + | else throw("Strict value is not equal to itself.") | |
1246 | + | } | |
1247 | + | else throw("Strict value is not equal to itself.") | |
1248 | + | } | |
1249 | + | ||
1250 | + | ||
1251 | + | ||
1252 | + | @Callable(i) | |
1253 | + | func stepRebalancing () = { | |
1254 | + | let rebId = valueOrErrorMessage(getString(govAddress, ("pool_lastRebalancing_" + toString(this))), "rebalancing is not registered at gov address") | |
1255 | + | if (!(valueOrElse(getBoolean(this, "rebalance_inProgress"), false))) | |
1256 | + | then throw("no rebalancing in progress") | |
1257 | + | else if ((valueOrElse(getInteger(govAddress, ("rebalancing_status_" + rebId)), 0) != 2)) | |
1258 | + | then throw("this transaction needs approval from puzzle network") | |
1259 | + | else { | |
1260 | + | let lastStepHeight = getIntegerValue("rebalance_lastStepHeight") | |
1261 | + | let stepInterval = getIntegerValue("rebalance_stepsInterval") | |
1262 | + | let stepsDone = getIntegerValue("rebalance_stepsDone") | |
1263 | + | let nextStepHeight = (lastStepHeight + stepInterval) | |
1264 | + | if ((nextStepHeight > height)) | |
1265 | + | then throw("can't be done yet") | |
1266 | + | else { | |
1267 | + | let assetDeltas = split(getStringValue("rebalance_assetDeltas"), ",") | |
1268 | + | let newAssetIdsStr = getStringValue("tmp_rebalanceAssetIds") | |
1269 | + | let newAssetIds = split(newAssetIdsStr, ",") | |
1270 | + | func f (accum,assetIdStr) = (accum ++ [toString(fraction(((valueOrElse(getInteger(("rebalance_startWeight_" + assetIdStr)), 0) * 10000) + (parseIntValue(assetDeltas[value(indexOf(newAssetIds, assetIdStr))]) * (stepsDone + 1))), 1, 10000, HALFUP))]) | |
1271 | + | ||
1272 | + | let newShares = makeString({ | |
1273 | + | let $l = newAssetIds | |
1274 | + | let $s = size($l) | |
1275 | + | let $acc0 = nil | |
1276 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
1277 | + | then $a | |
1278 | + | else f($a, $l[$i]) | |
1279 | + | ||
1280 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
1281 | + | then $a | |
1282 | + | else throw("List size exceeds 10") | |
1283 | + | ||
1284 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1285 | + | }, ",") | |
1286 | + | let newTokensAdded = getBooleanValue("rebalance_newTokensAdded") | |
1287 | + | let inv = if (if (newTokensAdded) | |
1288 | + | then (stepsDone == 0) | |
1289 | + | else false) | |
1290 | + | then invoke(this, "doRebalancingWithNewTokens", [newAssetIdsStr, newShares, getStringValue("rebalance_newBaseTokenId")], nil) | |
1291 | + | else invoke(this, "doRebalancing", [newShares], nil) | |
1292 | + | if ((inv == inv)) | |
1293 | + | then { | |
1294 | + | let notifyInvoke = invoke(poolsHubAddress, "notifyPoolChange", nil, nil) | |
1295 | + | if ((notifyInvoke == notifyInvoke)) | |
1296 | + | then { | |
1297 | + | let isFinished = ((stepsDone + 1) >= getIntegerValue("rebalance_stepsAmount")) | |
1298 | + | let actions = [BooleanEntry("rebalance_inProgress", !(isFinished)), IntegerEntry("rebalance_stepsDone", (stepsDone + 1)), IntegerEntry("rebalance_lastStepHeight", height)] | |
1299 | + | if ((stepsDone == 0)) | |
1300 | + | then (actions ++ [StringEntry("static_tokenIds", newAssetIdsStr)]) | |
1301 | + | else if (isFinished) | |
1302 | + | then { | |
1303 | + | let removedAssetsLi = split(tryGetString("rebalance_removedAssets"), ",") | |
1304 | + | func rmData (accum,assetId) = (accum ++ [DeleteEntry((("static_" + assetId) + "_scale")), DeleteEntry((("static_" + assetId) + "_decimals")), DeleteEntry((("static_" + assetId) + "_weight")), DeleteEntry((("global_" + assetId) + "_balance")), DeleteEntry(("rebalance_attachedPayment_" + assetId))]) | |
1305 | + | ||
1306 | + | let rm = { | |
1307 | + | let $l = removedAssetsLi | |
1308 | + | let $s = size($l) | |
1309 | + | let $acc0 = nil | |
1310 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1311 | + | then $a | |
1312 | + | else rmData($a, $l[$i]) | |
1313 | + | ||
1314 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1315 | + | then $a | |
1316 | + | else throw("List size exceeds 10") | |
1317 | + | ||
1318 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1319 | + | } | |
1320 | + | let addedAssetsLi = split(tryGetString("rebalance_addedAssets"), ",") | |
1321 | + | func addRemovePayments (accum,assetId) = (accum ++ [DeleteEntry(("rebalance_attachedPayment_" + assetId))]) | |
1322 | + | ||
1323 | + | let rmPayments = { | |
1324 | + | let $l = addedAssetsLi | |
1325 | + | let $s = size($l) | |
1326 | + | let $acc0 = nil | |
1327 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
1328 | + | then $a | |
1329 | + | else addRemovePayments($a, $l[$i]) | |
1330 | + | ||
1331 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
1332 | + | then $a | |
1333 | + | else throw("List size exceeds 10") | |
1334 | + | ||
1335 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1336 | + | } | |
1337 | + | let finalAssetsIdsStr = tryGetString("rebalance_assetIds") | |
1338 | + | let AssetsWeightsStr = { | |
1339 | + | let $l = split(finalAssetsIdsStr, ",") | |
1340 | + | let $s = size($l) | |
1341 | + | let $acc0 = nil | |
1342 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1343 | + | then $a | |
1344 | + | else addAssetWeightToStrList($a, $l[$i]) | |
1345 | + | ||
1346 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1347 | + | then $a | |
1348 | + | else throw("List size exceeds 10") | |
1349 | + | ||
1350 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1351 | + | } | |
1352 | + | let notify = invoke(govAddress, "notifyRebalancingDone", [rebId], nil) | |
1353 | + | if ((notify == notify)) | |
1354 | + | then (((actions ++ rm) ++ rmPayments) ++ [StringEntry("static_tokenIds", finalAssetsIdsStr), StringEntry("static_tokenWeights", makeString(AssetsWeightsStr, ",")), IntegerEntry("static_tokensAmount", size(split(finalAssetsIdsStr, ",")))]) | |
1355 | + | else throw("Strict value is not equal to itself.") | |
1356 | + | } | |
1357 | + | else { | |
1358 | + | let finalAssetsIdsStr = tryGetString("rebalance_assetIds") | |
1359 | + | let AssetsWeightsStr = { | |
1360 | + | let $l = split(finalAssetsIdsStr, ",") | |
1361 | + | let $s = size($l) | |
1362 | + | let $acc0 = nil | |
1363 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1364 | + | then $a | |
1365 | + | else addAssetWeightToStrList($a, $l[$i]) | |
1366 | + | ||
1367 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1368 | + | then $a | |
1369 | + | else throw("List size exceeds 10") | |
1370 | + | ||
1371 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1372 | + | } | |
1373 | + | (actions ++ [StringEntry("static_tokenWeights", makeString(AssetsWeightsStr, ","))]) | |
1374 | + | } | |
1375 | + | } | |
1376 | + | else throw("Strict value is not equal to itself.") | |
1377 | + | } | |
1378 | + | else throw("Strict value is not equal to itself.") | |
1379 | + | } | |
1380 | + | } | |
1381 | + | } | |
1382 | + | ||
1383 | + | ||
1384 | + | ||
1385 | + | @Callable(i) | |
1386 | + | func doRebalancing (assetWeightsStr) = { | |
1387 | + | let assetWeightsStrLi = split(assetWeightsStr, ",") | |
1388 | + | let assetWeightsSum = { | |
1389 | + | let $l = assetWeightsStrLi | |
1390 | + | let $s = size($l) | |
1391 | + | let $acc0 = 0 | |
1392 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
1393 | + | then $a | |
1394 | + | else sum($a, $l[$i]) | |
1395 | + | ||
1396 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
1397 | + | then $a | |
1398 | + | else throw("List size exceeds 10") | |
1399 | + | ||
1400 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1401 | + | } | |
1402 | + | let assetIdsStrLi = split(tryGetString("static_tokenIds"), ",") | |
1403 | + | if ((i.caller != this)) | |
1404 | + | then throw("this call available only for admin") | |
1405 | + | else { | |
1406 | + | let oldKMult = getKMult() | |
1407 | + | func handler (pars,assetId) = { | |
1408 | + | let accum = pars._1 | |
1409 | + | let assetIdStr = getAssetString(assetId) | |
1410 | + | func handler2 (accum,n) = if ((n == assetId)) | |
1411 | + | then value(indexOf(assetIds, n)) | |
1412 | + | else accum | |
1413 | + | ||
1414 | + | let Token = { | |
1415 | + | let $l = assetIds | |
1416 | + | let $s = size($l) | |
1417 | + | let $acc0 = 1 | |
1418 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1419 | + | then $a | |
1420 | + | else handler2($a, $l[$i]) | |
1421 | + | ||
1422 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1423 | + | then $a | |
1424 | + | else throw("List size exceeds 10") | |
1425 | + | ||
1426 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1427 | + | } | |
1428 | + | let balance = tryGetInteger((("global_" + assetIdStr) + "_balance")) | |
1429 | + | let weight = if ((pars._2 == "new")) | |
1430 | + | then parseIntValue(assetWeightsStrLi[Token]) | |
1431 | + | else tryGetInteger((("static_" + assetIdStr) + "_weight")) | |
1432 | + | $Tuple2(fraction(accum, pow(balance, Decimals[Token], weight, AssetsWeightsDecimals, 8, FLOOR), Scale8), pars._2) | |
1433 | + | } | |
1434 | + | ||
1435 | + | let newK = ( let $l = assetIds | |
1436 | + | let $s = size($l) | |
1437 | + | let $acc0 = $Tuple2(PoolTokenScale, "new") | |
1438 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1439 | + | then $a | |
1440 | + | else handler($a, $l[$i]) | |
1441 | + | ||
1442 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1443 | + | then $a | |
1444 | + | else throw("List size exceeds 10") | |
1445 | + | ||
1446 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10))._1 | |
1447 | + | let oldK = ( let $l = assetIds | |
1448 | + | let $s = size($l) | |
1449 | + | let $acc0 = $Tuple2(PoolTokenScale, "old") | |
1450 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
1451 | + | then $a | |
1452 | + | else handler($a, $l[$i]) | |
1453 | + | ||
1454 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
1455 | + | then $a | |
1456 | + | else throw("List size exceeds 10") | |
1457 | + | ||
1458 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10))._1 | |
1459 | + | let newKMult = fraction(oldKMult, newK, oldK) | |
1460 | + | func addTokenDataEntries (accum,assetNum) = if ((assetNum >= size(assetWeightsStrLi))) | |
1461 | + | then accum | |
1462 | + | else (accum ++ [IntegerEntry((("static_" + assetIdsStrLi[assetNum]) + "_weight"), value(parseInt(assetWeightsStrLi[assetNum])))]) | |
1463 | + | ||
1464 | + | ({ | |
1465 | + | let $l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
1466 | + | let $s = size($l) | |
1467 | + | let $acc0 = nil | |
1468 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1469 | + | then $a | |
1470 | + | else addTokenDataEntries($a, $l[$i]) | |
1471 | + | ||
1472 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1473 | + | then $a | |
1474 | + | else throw("List size exceeds 10") | |
1475 | + | ||
1476 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1477 | + | } ++ [IntegerEntry("static_KMult", newKMult)]) | |
1478 | + | } | |
1479 | + | } | |
1480 | + | ||
1481 | + | ||
1482 | + | ||
1483 | + | @Callable(i) | |
1484 | + | func doRebalancingWithNewTokens (assetIdsStr,assetWeightsStr,baseTokenIdStr) = { | |
1485 | + | let newAssetWeightsStrLi = split(assetWeightsStr, ",") | |
1486 | + | let prevAssetIdsStrLi = split(tryGetString("static_tokenIds"), ",") | |
1487 | + | let newAssetIdsStrLi = split(assetIdsStr, ",") | |
1488 | + | let newAssetIds = { | |
1489 | + | let $l = newAssetIdsStrLi | |
1490 | + | let $s = size($l) | |
1491 | + | let $acc0 = nil | |
1492 | + | func $f4_1 ($a,$i) = if (($i >= $s)) | |
1493 | + | then $a | |
1494 | + | else addAssetBytesToList($a, $l[$i]) | |
1495 | + | ||
1496 | + | func $f4_2 ($a,$i) = if (($i >= $s)) | |
1497 | + | then $a | |
1498 | + | else throw("List size exceeds 10") | |
1499 | + | ||
1500 | + | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1501 | + | } | |
1502 | + | let feeAssetStr = { | |
1503 | + | let $l = newAssetIdsStrLi | |
1504 | + | let $s = size($l) | |
1505 | + | let $acc0 = "" | |
1506 | + | func $f5_1 ($a,$i) = if (($i >= $s)) | |
1507 | + | then $a | |
1508 | + | else checkFeeAsset($a, $l[$i]) | |
1509 | + | ||
1510 | + | func $f5_2 ($a,$i) = if (($i >= $s)) | |
1511 | + | then $a | |
1512 | + | else throw("List size exceeds 10") | |
1513 | + | ||
1514 | + | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1515 | + | } | |
1516 | + | let addedAssets = split(tryGetString("rebalance_addedAssets"), ",") | |
1517 | + | func findAssetPayment (assetId) = valueOrElse(getInteger(("rebalance_attachedPayment_" + getAssetString(assetId))), 0) | |
1518 | + | ||
1519 | + | func addAssetBalanceToLi (li,assetId) = (li ++ [findAssetPayment(assetId)]) | |
1520 | + | ||
1521 | + | let attachedBalances = { | |
1522 | + | let $l = newAssetIds | |
1523 | + | let $s = size($l) | |
1524 | + | let $acc0 = nil | |
1525 | + | func $f6_1 ($a,$i) = if (($i >= $s)) | |
1526 | + | then $a | |
1527 | + | else addAssetBalanceToLi($a, $l[$i]) | |
1528 | + | ||
1529 | + | func $f6_2 ($a,$i) = if (($i >= $s)) | |
1530 | + | then $a | |
1531 | + | else throw("List size exceeds 10") | |
1532 | + | ||
1533 | + | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1534 | + | } | |
1535 | + | if ((i.caller != this)) | |
1536 | + | then throw(("this call available only for admin, " + toString(i.caller))) | |
1537 | + | else { | |
1538 | + | let oldKMult = getKMult() | |
1539 | + | let oldK = getVirtualPoolTokenAmount() | |
1540 | + | func myltiplyAssetsForK (pars,assetId) = { | |
1541 | + | func findAssetNum (accum,n) = if ((n == assetId)) | |
1542 | + | then value(indexOf(newAssetIds, n)) | |
1543 | + | else accum | |
1544 | + | ||
1545 | + | let currentK = pars | |
1546 | + | let assetIdStr = getAssetString(assetId) | |
1547 | + | let TokenNum = { | |
1548 | + | let $l = newAssetIds | |
1549 | + | let $s = size($l) | |
1550 | + | let $acc0 = 1 | |
1551 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1552 | + | then $a | |
1553 | + | else findAssetNum($a, $l[$i]) | |
1554 | + | ||
1555 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1556 | + | then $a | |
1557 | + | else throw("List size exceeds 10") | |
1558 | + | ||
1559 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1560 | + | } | |
1561 | + | let weight = parseIntValue(newAssetWeightsStrLi[TokenNum]) | |
1562 | + | let balanceInState = tryGetInteger((("global_" + assetIdStr) + "_balance")) | |
1563 | + | let balanceInPayment = attachedBalances[TokenNum] | |
1564 | + | let balance = (balanceInState + balanceInPayment) | |
1565 | + | let assetDecimals = if ((assetId == unit)) | |
1566 | + | then 8 | |
1567 | + | else value(assetInfo(value(assetId))).decimals | |
1568 | + | if ((0 >= balance)) | |
1569 | + | then throw(("you need to attach all new assets in payment. this asset is missed: " + assetIdStr)) | |
1570 | + | else fraction(currentK, pow(balance, assetDecimals, weight, AssetsWeightsDecimals, 8, FLOOR), Scale8) | |
1571 | + | } | |
1572 | + | ||
1573 | + | let newK = { | |
1574 | + | let $l = newAssetIds | |
1575 | + | let $s = size($l) | |
1576 | + | let $acc0 = PoolTokenScale | |
1577 | + | func $f7_1 ($a,$i) = if (($i >= $s)) | |
1578 | + | then $a | |
1579 | + | else myltiplyAssetsForK($a, $l[$i]) | |
1580 | + | ||
1581 | + | func $f7_2 ($a,$i) = if (($i >= $s)) | |
1582 | + | then $a | |
1583 | + | else throw("List size exceeds 10") | |
1584 | + | ||
1585 | + | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1586 | + | } | |
1587 | + | let newKMult = fraction(oldKMult, newK, oldK) | |
1588 | + | func addTokenDataEntries (accum,assetNum) = { | |
1589 | + | let assetIdStr = newAssetIdsStrLi[assetNum] | |
1590 | + | let assetId = newAssetIds[assetNum] | |
1591 | + | let assetDecimals = if ((assetId == unit)) | |
1592 | + | then 8 | |
1593 | + | else value(assetInfo(value(assetId))).decimals | |
1594 | + | let newAssetData = if ((indexOf(addedAssets, assetIdStr) != unit)) | |
1595 | + | then [IntegerEntry((("global_" + assetIdStr) + "_balance"), attachedBalances[assetNum]), IntegerEntry((("static_" + assetIdStr) + "_scale"), pow(10, 0, assetDecimals, 0, 0, DOWN)), IntegerEntry((("static_" + assetIdStr) + "_decimals"), assetDecimals)] | |
1596 | + | else nil | |
1597 | + | if ((assetNum >= size(newAssetWeightsStrLi))) | |
1598 | + | then accum | |
1599 | + | else ((accum ++ [IntegerEntry((("static_" + assetIdStr) + "_weight"), value(parseInt(newAssetWeightsStrLi[assetNum])))]) ++ newAssetData) | |
1600 | + | } | |
1601 | + | ||
1602 | + | ({ | |
1603 | + | let $l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
1604 | + | let $s = size($l) | |
1605 | + | let $acc0 = nil | |
1606 | + | func $f8_1 ($a,$i) = if (($i >= $s)) | |
1607 | + | then $a | |
1608 | + | else addTokenDataEntries($a, $l[$i]) | |
1609 | + | ||
1610 | + | func $f8_2 ($a,$i) = if (($i >= $s)) | |
1611 | + | then $a | |
1612 | + | else throw("List size exceeds 10") | |
1613 | + | ||
1614 | + | $f8_2($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($f8_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
1615 | + | } ++ [StringEntry("static_tokenIds", assetIdsStr), StringEntry("static_feeToken", feeAssetStr), StringEntry("static_tokenWeights", assetWeightsStr), IntegerEntry("static_tokensAmount", size(newAssetIds)), IntegerEntry("static_KMult", newKMult)]) | |
1616 | + | } | |
1617 | + | } | |
1618 | + | ||
1619 | + | ||
775 | 1620 | @Verifier(tx) | |
776 | - | func verify () = if (isShutdown()) | |
777 | - | then false | |
778 | - | else if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
1621 | + | func verify () = if (if ((valueOrElse(getInteger("global_wasPreInited"), 0) == 0)) | |
1622 | + | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
779 | 1623 | then true | |
780 | 1624 | else sigVerify(tx.bodyBytes, tx.proofs[0], masterPubKey) | |
1625 | + | else false) | |
1626 | + | then true | |
1627 | + | else match tx { | |
1628 | + | case tx: SetScriptTransaction => | |
1629 | + | let scriptFull = value(tx.script) | |
1630 | + | let hash = toBase58String(sha256(scriptFull)) | |
1631 | + | if (sigVerify(tx.bodyBytes, tx.proofs[0], masterPubKey)) | |
1632 | + | then (valueOrElse(getInteger(coldMasterAddress, ("approvedScript_" + hash)), 0) > height) | |
1633 | + | else false | |
1634 | + | case _ => | |
1635 | + | if (sigVerify(tx.bodyBytes, tx.proofs[0], masterPubKey)) | |
1636 | + | then (valueOrElse(getInteger(coldMasterAddress, ("approvedTx_" + toBase58String(tx.id))), 0) > 0) | |
1637 | + | else false | |
1638 | + | } | |
781 | 1639 |
github/deemru/w8io/3ef1775 195.14 ms ◑![]()