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:BgIJCAISBQoDAQEBDgAGc2NhbGU4AIDC1y8ADHNjYWxlOEJpZ0ludAkAtgIBAIDC1y8AB3NjYWxlMTgJALYCAQCAgJC7utat8A0ACnplcm9CaWdJbnQJALYCAQAAAARiaWcwCQC2AgEAAAAEYmlnMQkAtgIBAAEABGJpZzIJALYCAQACAARiaWczCQC2AgEAAwAEYmlnNAkAtgIBAAQABUFtdWx0AgMxMDAAAUECBDEwMDABBGdldEQBAnhwBAN4cDAJAJEDAgUCeHAAAAQDeHAxCQCRAwIFAnhwAAEEAXMJALcCAgUDeHAwBQN4cDEDCQAAAgUBcwUEYmlnMAUEYmlnMAQBYQkBDXBhcnNlSW50VmFsdWUBBQFBBANhbm4JAGgCBQFhAAIEAXAJALwCAwUDeHAwBQN4cDEFBGJpZzEEC3hwMF94cDFfbl9uCQC8AgMFAXAFBGJpZzQFBGJpZzEEBWFubl9zCQC8AgMJALYCAQUDYW5uBQFzBQRiaWcxBAVhbm5fMQkAtgIBCQBlAgUDYW5uAAEKAQljYWxjRE5leHQBAWQEAmRkCQC8AgMFAWQFAWQFBGJpZz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RlbGV0ZUVudHJ5AQIINTkyNDc0MDgFA25pbAECdHgBBnZlcmlmeQAG8QZFPw==", "height": 2499942, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5Q6qqdaEJ38XAZpqoR7ZfhwBnjT7Wo3R1HLqFCVHjhv8 Next: E9PtSWcUaH7eXXSwQ8Ep2niUusuRBoB1AbNmHkTpekSj Diff:
OldNewDifferences
138138 func calc (aIn,balA,balB) = {
139139 let D = getD([toBigInt(balA), toBigInt(balB)])
140140 let Y = getY(D, toBigInt(aIn), toBigInt(balA), toBigInt(balB))
141-[IntegerEntry("D", toInt(D)), IntegerEntry("Y", toInt(D)), DeleteEntry("p"), DeleteEntry("59247408")]
141+[IntegerEntry("D", toInt(D)), IntegerEntry("Y", toInt(Y)), DeleteEntry("p"), DeleteEntry("59247408")]
142142 }
143143
144144
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let scale8 = 100000000
55
66 let scale8BigInt = toBigInt(100000000)
77
88 let scale18 = toBigInt(1000000000000000000)
99
1010 let zeroBigInt = toBigInt(0)
1111
1212 let big0 = toBigInt(0)
1313
1414 let big1 = toBigInt(1)
1515
1616 let big2 = toBigInt(2)
1717
1818 let big3 = toBigInt(3)
1919
2020 let big4 = toBigInt(4)
2121
2222 let Amult = "100"
2323
2424 let A = "1000"
2525
2626 func getD (xp) = {
2727 let xp0 = xp[0]
2828 let xp1 = xp[1]
2929 let s = (xp0 + xp1)
3030 if ((s == big0))
3131 then big0
3232 else {
3333 let a = parseIntValue(A)
3434 let ann = (a * 2)
3535 let p = fraction(xp0, xp1, big1)
3636 let xp0_xp1_n_n = fraction(p, big4, big1)
3737 let ann_s = fraction(toBigInt(ann), s, big1)
3838 let ann_1 = toBigInt((ann - 1))
3939 func calcDNext (d) = {
4040 let dd = fraction(d, d, big1)
4141 let ddd = fraction(dd, d, big1)
4242 let dp = fraction(ddd, big1, xp0_xp1_n_n)
4343 fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)))
4444 }
4545
4646 func calc (acc,i) = if (acc._2)
4747 then acc
4848 else {
4949 let d = acc._1
5050 let dNext = calcDNext(d)
5151 let dDiffRaw = (dNext - value(d))
5252 let dDiff = if ((big0 > dDiffRaw))
5353 then -(dDiffRaw)
5454 else dDiffRaw
5555 if ((big1 >= dDiff))
5656 then $Tuple2(dNext, true)
5757 else $Tuple2(dNext, false)
5858 }
5959
6060 let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
6161 let $t014801528 = {
6262 let $l = arr
6363 let $s = size($l)
6464 let $acc0 = $Tuple2(s, false)
6565 func $f0_1 ($a,$i) = if (($i >= $s))
6666 then $a
6767 else calc($a, $l[$i])
6868
6969 func $f0_2 ($a,$i) = if (($i >= $s))
7070 then $a
7171 else throw("List size exceeds 18")
7272
7373 $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)
7474 }
7575 let d = $t014801528._1
7676 let found = $t014801528._2
7777 if (found)
7878 then d
7979 else throw(("D calculation error, D = " + toString(d)))
8080 }
8181 }
8282
8383
8484 func absBigInt (val) = if ((zeroBigInt > val))
8585 then -(val)
8686 else val
8787
8888
8989 func getY (D,poolAmountInBalance,balanceA,balanceB) = {
9090 let n = big2
9191 let aPrecision = parseBigIntValue(Amult)
9292 let a = (parseBigIntValue(A) * aPrecision)
9393 let xp = [(balanceA + poolAmountInBalance), balanceB]
9494 let x = xp[0]
9595 let s = x
9696 let ann = (a * n)
9797 let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
9898 let b = ((s + ((D * aPrecision) / ann)) - D)
9999 func calc (acc,cur) = {
100100 let $t021662186 = acc
101101 let y = $t021662186._1
102102 let found = $t021662186._2
103103 if ((found != unit))
104104 then acc
105105 else {
106106 let yNext = (((y * y) + c) / ((big2 * y) + b))
107107 let yDiff = absBigInt((yNext - value(y)))
108108 if ((big1 >= yDiff))
109109 then $Tuple2(yNext, cur)
110110 else $Tuple2(yNext, unit)
111111 }
112112 }
113113
114114 let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
115115 let $t025172564 = {
116116 let $l = arr
117117 let $s = size($l)
118118 let $acc0 = $Tuple2(D, unit)
119119 func $f0_1 ($a,$i) = if (($i >= $s))
120120 then $a
121121 else calc($a, $l[$i])
122122
123123 func $f0_2 ($a,$i) = if (($i >= $s))
124124 then $a
125125 else throw("List size exceeds 15")
126126
127127 $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)
128128 }
129129 let y = $t025172564._1
130130 let found = $t025172564._2
131131 if ((found != unit))
132132 then y
133133 else throw(("Y calculation error, Y = " + toString(y)))
134134 }
135135
136136
137137 @Callable(i)
138138 func calc (aIn,balA,balB) = {
139139 let D = getD([toBigInt(balA), toBigInt(balB)])
140140 let Y = getY(D, toBigInt(aIn), toBigInt(balA), toBigInt(balB))
141-[IntegerEntry("D", toInt(D)), IntegerEntry("Y", toInt(D)), DeleteEntry("p"), DeleteEntry("59247408")]
141+[IntegerEntry("D", toInt(D)), IntegerEntry("Y", toInt(Y)), DeleteEntry("p"), DeleteEntry("59247408")]
142142 }
143143
144144
145145 @Verifier(tx)
146146 func verify () = true
147147

github/deemru/w8io/169f3d6 
31.83 ms