tx · Ca66mpEXSrbvRDtuvEMVGJ2SQ3GRfcrBy7rJXboDTjtS 3N11gzZic4yASFhatzjC8zvLnpNhDo2B1Rv: -0.01000000 Waves 2023.10.07 15:53 [2788236] smart account 3N11gzZic4yASFhatzjC8zvLnpNhDo2B1Rv > SELF 0.00000000 Waves
{ "type": 13, "id": "Ca66mpEXSrbvRDtuvEMVGJ2SQ3GRfcrBy7rJXboDTjtS", "fee": 1000000, "feeAssetId": null, "timestamp": 1696683191340, "version": 2, "chainId": 84, "sender": "3N11gzZic4yASFhatzjC8zvLnpNhDo2B1Rv", "senderPublicKey": "EnUXxxhBK8wUfh1FveDYv9G5HBMXop6YwZWzVrBrLo2i", "proofs": [ "5EASWq5sgkZxuhZFdCyaC4kQN5dEVu3MEzrnYNXMw2wtGFuBVQg1W9xrhd8DMRZMw5ULCTKhUZtthj37kjL8rg3X" ], "script": "base64:BgIJCAISBQoDAQEYBAELd3JpdGVTdHJpbmcCA2tleQtzdHJpbmdWYWx1ZQkBC1N0cmluZ0VudHJ5AgUDa2V5BQtzdHJpbmdWYWx1ZQENc3BsaXRDZm1tSnNvbgEFZW50cnkJALUJAgUFZW50cnkCAS8BF2NhbGNFeGNlc3NBbW91bnRQZXJDZm1tAgpkaWZmZXJlbmNlC251bWJlckNmbW1zBAhxdW90aWVudAkAaQIFCmRpZmZlcmVuY2UFC251bWJlckNmbW1zBBZ0b3RhbERpc3RyaWJ1dGVkQW1vdW50CQBoAgUIcXVvdGllbnQFC251bWJlckNmbW1zBA9yZW1haW5pbmdBbW91bnQJAGUCBQpkaWZmZXJlbmNlBRZ0b3RhbERpc3RyaWJ1dGVkQW1vdW50AwkAZgIFD3JlbWFpbmluZ0Ftb3VudAAACQCUCgIFCHF1b3RpZW50BQ9yZW1haW5pbmdBbW91bnQJAJQKAgUIcXVvdGllbnQAAAEaZGlzdHJpYnV0ZUFkZGl0aW9uYWxUb2tlbnMCBXN3YXBzBGRpZmYECnRvdGFsU3dhcHMJAJADAQUFc3d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cwkAuQkCBQ1hZGp1c3RlZFN3YXBzAgEsBQNuaWwBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5IJu4Tg==", "height": 2788236, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3KojrtqfHoJe5euPC8h4gvhNLqnDSfti6yXYZXrxvWeJ Next: GCWgDzrBFEqFBNMmL57vUrn5y7ow2tbAmFnFqcmRZJmU Diff:
Old | New | Differences | |
---|---|---|---|
7 | 7 | func splitCfmmJson (entry) = split(entry, "/") | |
8 | 8 | ||
9 | 9 | ||
10 | - | func distributeDifference (swaps,diff) = { | |
10 | + | func calcExcessAmountPerCfmm (difference,numberCfmms) = { | |
11 | + | let quotient = (difference / numberCfmms) | |
12 | + | let totalDistributedAmount = (quotient * numberCfmms) | |
13 | + | let remainingAmount = (difference - totalDistributedAmount) | |
14 | + | if ((remainingAmount > 0)) | |
15 | + | then $Tuple2(quotient, remainingAmount) | |
16 | + | else $Tuple2(quotient, 0) | |
17 | + | } | |
18 | + | ||
19 | + | ||
20 | + | func distributeAdditionalTokens (swaps,diff) = { | |
11 | 21 | let totalSwaps = size(swaps) | |
22 | + | let $t020722147 = calcExcessAmountPerCfmm(diff, totalSwaps) | |
23 | + | let quotient = $t020722147._1 | |
24 | + | let remainingAmount = $t020722147._2 | |
12 | 25 | func adjustAmounts (accum,next) = { | |
13 | - | let $ | |
14 | - | let adjustedSwaps = $ | |
15 | - | let remainingDiff = $ | |
26 | + | let $t022202262 = accum | |
27 | + | let adjustedSwaps = $t022202262._1 | |
28 | + | let remainingDiff = $t022202262._2 | |
16 | 29 | let item = splitCfmmJson(next) | |
17 | 30 | let inputAmount = parseInt(item[2]) | |
18 | 31 | match inputAmount { | |
19 | 32 | case input: Int => | |
20 | - | let amountToAdjust = { | |
21 | - | let remainDiff = (remainingDiff / ((totalSwaps - size(adjustedSwaps)) + 1)) | |
22 | - | match remainDiff { | |
23 | - | case x: Int => | |
24 | - | if ((remainingDiff > 0)) | |
25 | - | then min([input, x]) | |
26 | - | else if ((0 > remainingDiff)) | |
27 | - | then max([(-(input) + 1), x]) | |
28 | - | else 0 | |
29 | - | case _ => | |
30 | - | throw("Wrong datatype") | |
31 | - | } | |
32 | - | } | |
33 | - | let newInputAmount = max([1, (input + amountToAdjust)]) | |
34 | - | let newItem = ((((item[0] + "/") + item[1]) + "/") + toString(newInputAmount)) | |
35 | - | $Tuple2((adjustedSwaps :+ newItem), (remainingDiff - (amountToAdjust * ((totalSwaps - size(adjustedSwaps)) + 1)))) | |
33 | + | let amountToAdjust = if ((remainingDiff > 0)) | |
34 | + | then ((input + quotient) + 1) | |
35 | + | else (input + quotient) | |
36 | + | let newItem = ((((item[0] + "/") + item[1]) + "/") + toString(amountToAdjust)) | |
37 | + | let newRemainingDiff = if ((remainingDiff > 0)) | |
38 | + | then (remainingDiff - 1) | |
39 | + | else remainingDiff | |
40 | + | $Tuple2((adjustedSwaps :+ newItem), newRemainingDiff) | |
36 | 41 | case _ => | |
37 | 42 | throw("Input has wrong datatype!") | |
38 | 43 | } | |
40 | 45 | ||
41 | 46 | let $l = swaps | |
42 | 47 | let $s = size($l) | |
43 | - | let $acc0 = $Tuple2(nil, | |
48 | + | let $acc0 = $Tuple2(nil, remainingAmount) | |
44 | 49 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
45 | 50 | then $a | |
46 | 51 | else adjustAmounts($a, $l[$i]) | |
56 | 61 | @Callable(i) | |
57 | 62 | func call (predeterminedAmount,availableAmount,swaps) = { | |
58 | 63 | let diff = (availableAmount - predeterminedAmount) | |
59 | - | let adjustedSwaps = if ((diff | |
60 | - | then | |
64 | + | let adjustedSwaps = if ((diff > 0)) | |
65 | + | then distributeAdditionalTokens(swaps, diff)._1 | |
61 | 66 | else swaps | |
62 | 67 | [writeString("swaps", makeString(swaps, ",")), writeString("adjustedSwaps", makeString(adjustedSwaps, ","))] | |
63 | 68 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func writeString (key,stringValue) = StringEntry(key, stringValue) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func splitCfmmJson (entry) = split(entry, "/") | |
8 | 8 | ||
9 | 9 | ||
10 | - | func distributeDifference (swaps,diff) = { | |
10 | + | func calcExcessAmountPerCfmm (difference,numberCfmms) = { | |
11 | + | let quotient = (difference / numberCfmms) | |
12 | + | let totalDistributedAmount = (quotient * numberCfmms) | |
13 | + | let remainingAmount = (difference - totalDistributedAmount) | |
14 | + | if ((remainingAmount > 0)) | |
15 | + | then $Tuple2(quotient, remainingAmount) | |
16 | + | else $Tuple2(quotient, 0) | |
17 | + | } | |
18 | + | ||
19 | + | ||
20 | + | func distributeAdditionalTokens (swaps,diff) = { | |
11 | 21 | let totalSwaps = size(swaps) | |
22 | + | let $t020722147 = calcExcessAmountPerCfmm(diff, totalSwaps) | |
23 | + | let quotient = $t020722147._1 | |
24 | + | let remainingAmount = $t020722147._2 | |
12 | 25 | func adjustAmounts (accum,next) = { | |
13 | - | let $ | |
14 | - | let adjustedSwaps = $ | |
15 | - | let remainingDiff = $ | |
26 | + | let $t022202262 = accum | |
27 | + | let adjustedSwaps = $t022202262._1 | |
28 | + | let remainingDiff = $t022202262._2 | |
16 | 29 | let item = splitCfmmJson(next) | |
17 | 30 | let inputAmount = parseInt(item[2]) | |
18 | 31 | match inputAmount { | |
19 | 32 | case input: Int => | |
20 | - | let amountToAdjust = { | |
21 | - | let remainDiff = (remainingDiff / ((totalSwaps - size(adjustedSwaps)) + 1)) | |
22 | - | match remainDiff { | |
23 | - | case x: Int => | |
24 | - | if ((remainingDiff > 0)) | |
25 | - | then min([input, x]) | |
26 | - | else if ((0 > remainingDiff)) | |
27 | - | then max([(-(input) + 1), x]) | |
28 | - | else 0 | |
29 | - | case _ => | |
30 | - | throw("Wrong datatype") | |
31 | - | } | |
32 | - | } | |
33 | - | let newInputAmount = max([1, (input + amountToAdjust)]) | |
34 | - | let newItem = ((((item[0] + "/") + item[1]) + "/") + toString(newInputAmount)) | |
35 | - | $Tuple2((adjustedSwaps :+ newItem), (remainingDiff - (amountToAdjust * ((totalSwaps - size(adjustedSwaps)) + 1)))) | |
33 | + | let amountToAdjust = if ((remainingDiff > 0)) | |
34 | + | then ((input + quotient) + 1) | |
35 | + | else (input + quotient) | |
36 | + | let newItem = ((((item[0] + "/") + item[1]) + "/") + toString(amountToAdjust)) | |
37 | + | let newRemainingDiff = if ((remainingDiff > 0)) | |
38 | + | then (remainingDiff - 1) | |
39 | + | else remainingDiff | |
40 | + | $Tuple2((adjustedSwaps :+ newItem), newRemainingDiff) | |
36 | 41 | case _ => | |
37 | 42 | throw("Input has wrong datatype!") | |
38 | 43 | } | |
39 | 44 | } | |
40 | 45 | ||
41 | 46 | let $l = swaps | |
42 | 47 | let $s = size($l) | |
43 | - | let $acc0 = $Tuple2(nil, | |
48 | + | let $acc0 = $Tuple2(nil, remainingAmount) | |
44 | 49 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
45 | 50 | then $a | |
46 | 51 | else adjustAmounts($a, $l[$i]) | |
47 | 52 | ||
48 | 53 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
49 | 54 | then $a | |
50 | 55 | else throw("List size exceeds 40") | |
51 | 56 | ||
52 | 57 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40) | |
53 | 58 | } | |
54 | 59 | ||
55 | 60 | ||
56 | 61 | @Callable(i) | |
57 | 62 | func call (predeterminedAmount,availableAmount,swaps) = { | |
58 | 63 | let diff = (availableAmount - predeterminedAmount) | |
59 | - | let adjustedSwaps = if ((diff | |
60 | - | then | |
64 | + | let adjustedSwaps = if ((diff > 0)) | |
65 | + | then distributeAdditionalTokens(swaps, diff)._1 | |
61 | 66 | else swaps | |
62 | 67 | [writeString("swaps", makeString(swaps, ",")), writeString("adjustedSwaps", makeString(adjustedSwaps, ","))] | |
63 | 68 | } | |
64 | 69 | ||
65 | 70 | ||
66 | 71 | @Verifier(tx) | |
67 | 72 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
68 | 73 |
github/deemru/w8io/169f3d6 28.98 ms ◑