tx · HnXK7yM16Rk9BRHepsw8RZFJsssHZR16YJs8jyvDxxxP

3N4revPn12feiSAyC78tAZEJfsyprVYPzsL:  -0.05000000 Waves

2022.02.18 10:01 [1928734] smart account 3N4revPn12feiSAyC78tAZEJfsyprVYPzsL > SELF 0.00000000 Waves

{ "type": 13, "id": "HnXK7yM16Rk9BRHepsw8RZFJsssHZR16YJs8jyvDxxxP", "fee": 5000000, "feeAssetId": null, "timestamp": 1645167695773, "version": 2, "chainId": 84, "sender": "3N4revPn12feiSAyC78tAZEJfsyprVYPzsL", "senderPublicKey": "5smGxL7bfeRokaN53Z31Y72dF2Lkr5Cg1kuWRV3gniNe", "proofs": [ "2vVuGPWaRy8EwvHU89emFLTpPrnREi99Uf59dyre5ngWZeycexBmcMwGnhJpfRfZQqfBfuWx7c7fKZhAy9Qm2GvZ" ], "script": "base64:AAIFAAAAAAAAABgIAhIECgIBARIECgIBARIICgYBAQEIAQEAAAAZAAAAAAtzdHJBc3NldElkQQIAAAAsMzROOVljRUVUTFduOTNxWVE2NEVzUDF4ODl0U3J1SlU0NFJyRU1TWFhFUEoAAAAAC3N0ckFzc2V0SWRCAgAAACxERzJ4RmtQZER3S1VvQmt6R0FoUXRMcFNHemZYTGlDWVBFemVLSDJBZDI0cAAAAAAIYXNzZXRJZEEDCQAAAAAAAAIFAAAAC3N0ckFzc2V0SWRBAgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAtzdHJBc3NldElkQQAAAAAIYXNzZXRJZEIDCQAAAAAAAAIFAAAAC3N0ckFzc2V0SWRCAgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAtzdHJBc3NldElkQgAAAAADZmVlAAAAAAAAAAH0AAAAAA1mZWVHb3Zlcm5hbmNlAAAAAAAAAADIAAAAAAlmZWVTY2FsZTYAAAAAAAAPQkAAAAAABnNjYWxlMwAAAAAAAAAD6AAAAAAGc2NhbGU4AAAAAAAF9eEAAAAAAAdzY2FsZTEyAAAAAOj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AAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5OWzrKA==", "height": 1928734, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DNUCKGaAj3jaR3uxF9q56Jsqr9SSriXCuxg3E69YjUSs Next: 47fQxWfxcvz3FfiTjtKH7HBUSyBRp4xoEW8dXaDjLjBB Diff:
OldNewDifferences
5959 let firstpow = pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)
6060 let secondpow = pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN)
6161 let thirdpow = pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN)
62- (fraction(xy, scale8, firstpow) + (2 * fraction(secondpow, thirdpow, scale8)))
62+ let firstsum = fraction(xy, scale8, firstpow)
63+ let secondsum = (2 * fraction(secondpow, thirdpow, scale8))
64+ (firstsum + secondsum)
6365 }
6466
6567
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let strAssetIdA = "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ"
55
66 let strAssetIdB = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
77
88 let assetIdA = if ((strAssetIdA == "WAVES"))
99 then unit
1010 else fromBase58String(strAssetIdA)
1111
1212 let assetIdB = if ((strAssetIdB == "WAVES"))
1313 then unit
1414 else fromBase58String(strAssetIdB)
1515
1616 let fee = 500
1717
1818 let feeGovernance = 200
1919
2020 let feeScale6 = 1000000
2121
2222 let scale3 = 1000
2323
2424 let scale8 = 100000000
2525
2626 let scale12 = 1000000000000
2727
2828 let slippageScale3 = 1000
2929
3030 let digits8 = 8
3131
3232 let digits12 = 12
3333
3434 let dAppThreshold = 50
3535
3636 let dAppThresholdScale2 = 100
3737
3838 let exchangeRatioLimitMin = 90000000
3939
4040 let exchangeRatioLimitMax = 110000000
4141
4242 let alpha = 50
4343
4444 let alphaDigits = 2
4545
4646 let beta = 46000000
4747
4848 let betaBigInt = 460000000000
4949
5050 func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000)
5151
5252
5353 func skewnessBigInt (x,y) = ((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2)
5454
5555
5656 func invariantCalc (x,y) = {
5757 let sk = skewness(x, y)
5858 let xy = (x + y)
5959 let firstpow = pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)
6060 let secondpow = pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN)
6161 let thirdpow = pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN)
62- (fraction(xy, scale8, firstpow) + (2 * fraction(secondpow, thirdpow, scale8)))
62+ let firstsum = fraction(xy, scale8, firstpow)
63+ let secondsum = (2 * fraction(secondpow, thirdpow, scale8))
64+ (firstsum + secondsum)
6365 }
6466
6567
6668 func calculateSendAmount (balanceA,balanceB,amountToSendEstimated,minTokenReceiveAmount,tokenReceiveAmount,tokenId) = {
6769 let slippageValue = (scale8 - ((scale8 * 1) / 10000000))
6870 let deltaBetweenMaxAndMinSendValue = (amountToSendEstimated - minTokenReceiveAmount)
6971 let x = (balanceA + tokenReceiveAmount)
7072 let y = (balanceB + tokenReceiveAmount)
7173 let invariant = invariantCalc(balanceA, balanceB)
7274 let invariantNew = if ((tokenId == strAssetIdA))
7375 then invariantCalc(x, (balanceB - amountToSendEstimated))
7476 else if ((tokenId == strAssetIdB))
7577 then invariantCalc((balanceA - amountToSendEstimated), y)
7678 else throw("Wrong asset in payment")
7779 let invariantEstimatedRatio = fraction(scale8, invariant, invariantNew)
7880 func getStepAmount (acc,step) = if ((acc == -1))
7981 then {
8082 let amountToSend = (amountToSendEstimated - ((step * deltaBetweenMaxAndMinSendValue) / 5))
8183 let stepInvariant = if ((tokenId == strAssetIdA))
8284 then invariantCalc(x, (balanceB - amountToSend))
8385 else invariantCalc((balanceA - amountToSend), y)
8486 if ((stepInvariant > invariant))
8587 then amountToSend
8688 else -1
8789 }
8890 else acc
8991
9092 let stepAmount = {
9193 let $l = [1, 2, 3, 4, 5]
9294 let $s = size($l)
9395 let $acc0 = -1
9496 func $f0_1 ($a,$i) = if (($i >= $s))
9597 then $a
9698 else getStepAmount($a, $l[$i])
9799
98100 func $f0_2 ($a,$i) = if (($i >= $s))
99101 then $a
100102 else throw("List size exceeds 5")
101103
102104 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
103105 }
104106 if ((0 > stepAmount))
105107 then throw("something went wrong while working with amountToSend")
106108 else if (if ((invariantEstimatedRatio > slippageValue))
107109 then (invariantNew > invariant)
108110 else false)
109111 then amountToSendEstimated
110112 else stepAmount
111113 }
112114
113115
114116 @Callable(i)
115117 func invariantCalcc (x,y) = {
116118 let sk = skewness(x, y)
117119 let xy = (x + y)
118120 let firstpow = pow(sk, digits8, alpha, alphaDigits, digits8, CEILING)
119121 let secondpow = pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN)
120122 let thirdpow = pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN)
121123 let fractionFirst = fraction(xy, scale8, firstpow)
122124 let fractionSecond = fraction(secondpow, thirdpow, scale8)
123125 let invariant = (fractionFirst + (2 * fractionSecond))
124126 [IntegerEntry("invariant", invariant)]
125127 }
126128
127129
128130
129131 @Callable(i)
130132 func invariantCalccBigInt (x,y) = {
131133 let sk = skewnessBigInt(x, y)
132134 let xy = toBigInt((x + y))
133135 let firstpow = pow(toBigInt(sk), digits12, toBigInt(alpha), alphaDigits, digits12, CEILING)
134136 let secondpow = pow(fraction(toBigInt(x), toBigInt(y), toBigInt(scale8)), 0, toBigInt(5), 1, (digits8 / 2), DOWN)
135137 let thirdpow = pow(toBigInt((sk - betaBigInt)), digits12, toBigInt(alpha), alphaDigits, digits12, DOWN)
136138 let fractionFirst = toInt(fraction(xy, toBigInt(scale12), firstpow))
137139 let fractionSecond = toInt(fraction(secondpow, thirdpow, toBigInt(scale12)))
138140 let invariant = (fractionFirst + (2 * fractionSecond))
139141 [IntegerEntry("invariant", invariant)]
140142 }
141143
142144
143145
144146 @Callable(i)
145147 func exchange (balanceA,balanceB,pmtAmount,pmtAssetId,estimatedAmountToReceive,minAmountToReceive) = {
146148 let amount = calculateSendAmount(balanceA, balanceB, estimatedAmountToReceive, minAmountToReceive, pmtAmount, pmtAssetId)
147149 let governanceReward = fraction(amount, feeGovernance, feeScale6)
148150 let amountMinusFee = fraction(amount, (feeScale6 - fee), feeScale6)
149151 ([IntegerEntry("sendAmount", amount), IntegerEntry("sendAmountWithComission", amountMinusFee), IntegerEntry("invariant", invariantCalc(balanceA, balanceB))] ++ (if ((pmtAssetId == strAssetIdA))
150152 then [IntegerEntry("invariantNew", invariantCalc((balanceA + pmtAmount), (balanceB - amount)))]
151153 else [IntegerEntry("invariantNew", invariantCalc((balanceA - amount), (balanceB + pmtAmount)))]))
152154 }
153155
154156
155157 @Verifier(tx)
156158 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
157159

github/deemru/w8io/026f985 
31.61 ms