tx · EmFAdqGTeWgjZeHADrqHSnbFrH5NKEYdgC6XyGTfdaNK 3N5HkfGrou8T5NyAuZVncnAdVuGmSHuMQ5d: -0.01000000 Waves 2023.03.21 18:16 [2499942] smart account 3N5HkfGrou8T5NyAuZVncnAdVuGmSHuMQ5d > SELF 0.00000000 Waves
{ "type": 13, "id": "EmFAdqGTeWgjZeHADrqHSnbFrH5NKEYdgC6XyGTfdaNK", "fee": 1000000, "feeAssetId": null, "timestamp": 1679411836164, "version": 2, "chainId": 84, "sender": "3N5HkfGrou8T5NyAuZVncnAdVuGmSHuMQ5d", "senderPublicKey": "AZLzseQJi9XUNNp7cN6jwqDdSmQvDPNNqu7aQ6ujbsnJ", "proofs": [ "3w34vbFNg1ffNJMjFHs3tcLcUS7ZDM24d2aVNpLvaR5Kq4k1JPJj3UodRY393D6UMwH8YjErnpUo8aogfryao76H" ], "script": "base64:BgIJCAISBQoDAQEBDgAGc2NhbGU4AIDC1y8ADHNjYWxlOEJpZ0ludAkAtgIBAIDC1y8AB3NjYWxlMTgJALYCAQCAgJC7utat8A0ACnplcm9CaWdJbnQJALYCAQAAAARiaWcwCQC2AgEAAAAEYmlnMQkAtgIBAAEABGJpZzIJALYCAQACAARiaWczCQC2AgEAAwAEYmlnNAkAtgIBAAQABUFtdWx0AgMxMDAAAUECBDEwMDABBGdldEQBAnhwBAN4cDAJAJEDAgUCeHAAAAQDeHAxCQCRAwIFAnhwAAEEAXMJALcCAgUDeHAwBQN4cDEDCQAAAgUBcwUEYmlnMAUEYmlnMAQBYQkBDXBhcnNlSW50VmFsdWUBBQFBBANhbm4JAGgCBQFhAAIEAXAJALwCAwUDeHAwBQN4cDEFBGJpZzEEC3hwMF94cDFfbl9uCQC8AgMFAXAFBGJpZzQFBGJpZzEEBWFubl9zCQC8AgMJALYCAQUDYW5uBQFzBQRiaWcxBAVhbm5fMQkAtgIBCQBlAgUDYW5uAAEKAQljYWxjRE5leHQBAWQEAmRkCQC8AgMFAWQFAWQFBGJpZzE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lbGV0ZUVudHJ5AQIINTkyNDc0MDgFA25pbAECdHgBBnZlcmlmeQAG8QZFPw==", "height": 2499942, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5Q6qqdaEJ38XAZpqoR7ZfhwBnjT7Wo3R1HLqFCVHjhv8 Next: E9PtSWcUaH7eXXSwQ8Ep2niUusuRBoB1AbNmHkTpekSj Diff:
Old | New | Differences | |
---|---|---|---|
138 | 138 | func calc (aIn,balA,balB) = { | |
139 | 139 | let D = getD([toBigInt(balA), toBigInt(balB)]) | |
140 | 140 | let Y = getY(D, toBigInt(aIn), toBigInt(balA), toBigInt(balB)) | |
141 | - | [IntegerEntry("D", toInt(D)), IntegerEntry("Y", toInt( | |
141 | + | [IntegerEntry("D", toInt(D)), IntegerEntry("Y", toInt(Y)), DeleteEntry("p"), DeleteEntry("59247408")] | |
142 | 142 | } | |
143 | 143 | ||
144 | 144 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let scale8 = 100000000 | |
5 | 5 | ||
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | 9 | ||
10 | 10 | let zeroBigInt = toBigInt(0) | |
11 | 11 | ||
12 | 12 | let big0 = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big1 = toBigInt(1) | |
15 | 15 | ||
16 | 16 | let big2 = toBigInt(2) | |
17 | 17 | ||
18 | 18 | let big3 = toBigInt(3) | |
19 | 19 | ||
20 | 20 | let big4 = toBigInt(4) | |
21 | 21 | ||
22 | 22 | let Amult = "100" | |
23 | 23 | ||
24 | 24 | let A = "1000" | |
25 | 25 | ||
26 | 26 | func getD (xp) = { | |
27 | 27 | let xp0 = xp[0] | |
28 | 28 | let xp1 = xp[1] | |
29 | 29 | let s = (xp0 + xp1) | |
30 | 30 | if ((s == big0)) | |
31 | 31 | then big0 | |
32 | 32 | else { | |
33 | 33 | let a = parseIntValue(A) | |
34 | 34 | let ann = (a * 2) | |
35 | 35 | let p = fraction(xp0, xp1, big1) | |
36 | 36 | let xp0_xp1_n_n = fraction(p, big4, big1) | |
37 | 37 | let ann_s = fraction(toBigInt(ann), s, big1) | |
38 | 38 | let ann_1 = toBigInt((ann - 1)) | |
39 | 39 | func calcDNext (d) = { | |
40 | 40 | let dd = fraction(d, d, big1) | |
41 | 41 | let ddd = fraction(dd, d, big1) | |
42 | 42 | let dp = fraction(ddd, big1, xp0_xp1_n_n) | |
43 | 43 | fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1))) | |
44 | 44 | } | |
45 | 45 | ||
46 | 46 | func calc (acc,i) = if (acc._2) | |
47 | 47 | then acc | |
48 | 48 | else { | |
49 | 49 | let d = acc._1 | |
50 | 50 | let dNext = calcDNext(d) | |
51 | 51 | let dDiffRaw = (dNext - value(d)) | |
52 | 52 | let dDiff = if ((big0 > dDiffRaw)) | |
53 | 53 | then -(dDiffRaw) | |
54 | 54 | else dDiffRaw | |
55 | 55 | if ((big1 >= dDiff)) | |
56 | 56 | then $Tuple2(dNext, true) | |
57 | 57 | else $Tuple2(dNext, false) | |
58 | 58 | } | |
59 | 59 | ||
60 | 60 | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] | |
61 | 61 | let $t014801528 = { | |
62 | 62 | let $l = arr | |
63 | 63 | let $s = size($l) | |
64 | 64 | let $acc0 = $Tuple2(s, false) | |
65 | 65 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
66 | 66 | then $a | |
67 | 67 | else calc($a, $l[$i]) | |
68 | 68 | ||
69 | 69 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
70 | 70 | then $a | |
71 | 71 | else throw("List size exceeds 18") | |
72 | 72 | ||
73 | 73 | $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($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18) | |
74 | 74 | } | |
75 | 75 | let d = $t014801528._1 | |
76 | 76 | let found = $t014801528._2 | |
77 | 77 | if (found) | |
78 | 78 | then d | |
79 | 79 | else throw(("D calculation error, D = " + toString(d))) | |
80 | 80 | } | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func absBigInt (val) = if ((zeroBigInt > val)) | |
85 | 85 | then -(val) | |
86 | 86 | else val | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | func getY (D,poolAmountInBalance,balanceA,balanceB) = { | |
90 | 90 | let n = big2 | |
91 | 91 | let aPrecision = parseBigIntValue(Amult) | |
92 | 92 | let a = (parseBigIntValue(A) * aPrecision) | |
93 | 93 | let xp = [(balanceA + poolAmountInBalance), balanceB] | |
94 | 94 | let x = xp[0] | |
95 | 95 | let s = x | |
96 | 96 | let ann = (a * n) | |
97 | 97 | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
98 | 98 | let b = ((s + ((D * aPrecision) / ann)) - D) | |
99 | 99 | func calc (acc,cur) = { | |
100 | 100 | let $t021662186 = acc | |
101 | 101 | let y = $t021662186._1 | |
102 | 102 | let found = $t021662186._2 | |
103 | 103 | if ((found != unit)) | |
104 | 104 | then acc | |
105 | 105 | else { | |
106 | 106 | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
107 | 107 | let yDiff = absBigInt((yNext - value(y))) | |
108 | 108 | if ((big1 >= yDiff)) | |
109 | 109 | then $Tuple2(yNext, cur) | |
110 | 110 | else $Tuple2(yNext, unit) | |
111 | 111 | } | |
112 | 112 | } | |
113 | 113 | ||
114 | 114 | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
115 | 115 | let $t025172564 = { | |
116 | 116 | let $l = arr | |
117 | 117 | let $s = size($l) | |
118 | 118 | let $acc0 = $Tuple2(D, unit) | |
119 | 119 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
120 | 120 | then $a | |
121 | 121 | else calc($a, $l[$i]) | |
122 | 122 | ||
123 | 123 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
124 | 124 | then $a | |
125 | 125 | else throw("List size exceeds 15") | |
126 | 126 | ||
127 | 127 | $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($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15) | |
128 | 128 | } | |
129 | 129 | let y = $t025172564._1 | |
130 | 130 | let found = $t025172564._2 | |
131 | 131 | if ((found != unit)) | |
132 | 132 | then y | |
133 | 133 | else throw(("Y calculation error, Y = " + toString(y))) | |
134 | 134 | } | |
135 | 135 | ||
136 | 136 | ||
137 | 137 | @Callable(i) | |
138 | 138 | func calc (aIn,balA,balB) = { | |
139 | 139 | let D = getD([toBigInt(balA), toBigInt(balB)]) | |
140 | 140 | let Y = getY(D, toBigInt(aIn), toBigInt(balA), toBigInt(balB)) | |
141 | - | [IntegerEntry("D", toInt(D)), IntegerEntry("Y", toInt( | |
141 | + | [IntegerEntry("D", toInt(D)), IntegerEntry("Y", toInt(Y)), DeleteEntry("p"), DeleteEntry("59247408")] | |
142 | 142 | } | |
143 | 143 | ||
144 | 144 | ||
145 | 145 | @Verifier(tx) | |
146 | 146 | func verify () = true | |
147 | 147 |
github/deemru/w8io/169f3d6 37.79 ms ◑