tx · 9ecKwtM6oUtrNgrTgpfSHkPFAFMnmSVBxbn9yWxhNngW 3N4revPn12feiSAyC78tAZEJfsyprVYPzsL: -0.05000000 Waves 2022.02.18 16:43 [1929138] smart account 3N4revPn12feiSAyC78tAZEJfsyprVYPzsL > SELF 0.00000000 Waves
{ "type": 13, "id": "9ecKwtM6oUtrNgrTgpfSHkPFAFMnmSVBxbn9yWxhNngW", "fee": 5000000, "feeAssetId": null, "timestamp": 1645191790638, "version": 2, "chainId": 84, "sender": "3N4revPn12feiSAyC78tAZEJfsyprVYPzsL", "senderPublicKey": "5smGxL7bfeRokaN53Z31Y72dF2Lkr5Cg1kuWRV3gniNe", "proofs": [ "5NBewrAqss8FEjQJBj4RMTqky8ypQXfawLLb48EEngEXEaSSFPeDcuh8jQiUHYnXj8uuSydPhv1JuMCsszzTwdC6" ], "script": "base64:AAIFAAAAAAAAABgIAhIECgIBARIECgIBARIICgYBAQEIAQEAAAAZAAAAAAtzdHJBc3NldElkQQIAAAAsMzROOVljRUVUTFduOTNxWVE2NEVzUDF4ODl0U3J1SlU0NFJyRU1TWFhFUEoAAAAAC3N0ckFzc2V0SWRCAgAAACxERzJ4RmtQZER3S1VvQmt6R0FoUXRMcFNHemZYTGlDWVBFemVLSDJBZDI0cAAAAAAIYXNzZXRJZEEDCQAAAAAAAAIFAAAAC3N0ckFzc2V0SWRBAgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAtzdHJBc3NldElkQQAAAAAIYXNzZXRJZEIDCQAAAAAAAAIFAAAAC3N0ckFzc2V0SWRCAgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAtzdHJBc3NldElkQgAAAAADZmVlAAAAAAAAAAH0AAAAAA1mZWVHb3Zlcm5hbmNlAAAAAAAAAADIAAAAAAlmZWVTY2FsZTYAAAAAAAAPQkAAAAAABnNjYWxlMwAAAAAAAAAD6AAAAAAGc2NhbGU4AAAAAAAF9eEAAAAAAAdzY2FsZTEyAAAAAO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QUAAAAGYW1vdW50CQAAZAAAAAIFAAAACGJhbGFuY2VCBQAAAAlwbXRBbW91bnQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5EJ9hGg==", "height": 1929138, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: J5b4bNh5jk7ZntukHhZyMEX3rug9fYDwyucLH2Lqhy8p Next: HfZupzK9Mcy2Lv4p4Vpqo2uKoQP6nLSCJ4AQJUEJhJL7 Diff:
Old | New | Differences | |
---|---|---|---|
50 | 50 | func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000) | |
51 | 51 | ||
52 | 52 | ||
53 | - | func skewnessBigInt (x,y) = ((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) | |
53 | + | func skewnessBigInt (x,y) = { | |
54 | + | let skfirst = fraction(scale12, x, y) | |
55 | + | let skseconsd = fraction(scale12, y, x) | |
56 | + | ((skfirst + skseconsd) / 2) | |
57 | + | } | |
54 | 58 | ||
55 | 59 | ||
56 | 60 | func invariantCalc (x,y) = { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let strAssetIdA = "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" | |
5 | 5 | ||
6 | 6 | let strAssetIdB = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" | |
7 | 7 | ||
8 | 8 | let assetIdA = if ((strAssetIdA == "WAVES")) | |
9 | 9 | then unit | |
10 | 10 | else fromBase58String(strAssetIdA) | |
11 | 11 | ||
12 | 12 | let assetIdB = if ((strAssetIdB == "WAVES")) | |
13 | 13 | then unit | |
14 | 14 | else fromBase58String(strAssetIdB) | |
15 | 15 | ||
16 | 16 | let fee = 500 | |
17 | 17 | ||
18 | 18 | let feeGovernance = 200 | |
19 | 19 | ||
20 | 20 | let feeScale6 = 1000000 | |
21 | 21 | ||
22 | 22 | let scale3 = 1000 | |
23 | 23 | ||
24 | 24 | let scale8 = 100000000 | |
25 | 25 | ||
26 | 26 | let scale12 = 1000000000000 | |
27 | 27 | ||
28 | 28 | let slippageScale3 = 1000 | |
29 | 29 | ||
30 | 30 | let digits8 = 8 | |
31 | 31 | ||
32 | 32 | let digits12 = 12 | |
33 | 33 | ||
34 | 34 | let dAppThreshold = 50 | |
35 | 35 | ||
36 | 36 | let dAppThresholdScale2 = 100 | |
37 | 37 | ||
38 | 38 | let exchangeRatioLimitMin = 90000000 | |
39 | 39 | ||
40 | 40 | let exchangeRatioLimitMax = 110000000 | |
41 | 41 | ||
42 | 42 | let alpha = 50 | |
43 | 43 | ||
44 | 44 | let alphaDigits = 2 | |
45 | 45 | ||
46 | 46 | let beta = 46000000 | |
47 | 47 | ||
48 | 48 | let betaBigInt = 460000000000 | |
49 | 49 | ||
50 | 50 | func skewness (x,y) = (((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) / 10000) | |
51 | 51 | ||
52 | 52 | ||
53 | - | func skewnessBigInt (x,y) = ((fraction(scale12, x, y) + fraction(scale12, y, x)) / 2) | |
53 | + | func skewnessBigInt (x,y) = { | |
54 | + | let skfirst = fraction(scale12, x, y) | |
55 | + | let skseconsd = fraction(scale12, y, x) | |
56 | + | ((skfirst + skseconsd) / 2) | |
57 | + | } | |
54 | 58 | ||
55 | 59 | ||
56 | 60 | func invariantCalc (x,y) = { | |
57 | 61 | let sk = skewness(x, y) | |
58 | 62 | let xy = (x + y) | |
59 | 63 | let firstpow = pow(sk, digits8, alpha, alphaDigits, digits8, CEILING) | |
60 | 64 | let secondpow = pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN) | |
61 | 65 | let thirdpow = pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN) | |
62 | 66 | let firstsum = fraction(xy, scale8, firstpow) | |
63 | 67 | let secondsum = (2 * fraction(secondpow, thirdpow, scale8)) | |
64 | 68 | (firstsum + secondsum) | |
65 | 69 | } | |
66 | 70 | ||
67 | 71 | ||
68 | 72 | func calculateSendAmount (balanceA,balanceB,amountToSendEstimated,minTokenReceiveAmount,tokenReceiveAmount,tokenId) = { | |
69 | 73 | let slippageValue = (scale8 - ((scale8 * 1) / 10000000)) | |
70 | 74 | let deltaBetweenMaxAndMinSendValue = (amountToSendEstimated - minTokenReceiveAmount) | |
71 | 75 | let x = (balanceA + tokenReceiveAmount) | |
72 | 76 | let y = (balanceB + tokenReceiveAmount) | |
73 | 77 | let invariant = invariantCalc(balanceA, balanceB) | |
74 | 78 | let invariantNew = if ((tokenId == strAssetIdA)) | |
75 | 79 | then invariantCalc(x, (balanceB - amountToSendEstimated)) | |
76 | 80 | else if ((tokenId == strAssetIdB)) | |
77 | 81 | then invariantCalc((balanceA - amountToSendEstimated), y) | |
78 | 82 | else throw("Wrong asset in payment") | |
79 | 83 | let invariantEstimatedRatio = fraction(scale8, invariant, invariantNew) | |
80 | 84 | func getStepAmount (acc,step) = if ((acc == -1)) | |
81 | 85 | then { | |
82 | 86 | let amountToSend = (amountToSendEstimated - ((step * deltaBetweenMaxAndMinSendValue) / 5)) | |
83 | 87 | let stepInvariant = if ((tokenId == strAssetIdA)) | |
84 | 88 | then invariantCalc(x, (balanceB - amountToSend)) | |
85 | 89 | else invariantCalc((balanceA - amountToSend), y) | |
86 | 90 | if ((stepInvariant > invariant)) | |
87 | 91 | then amountToSend | |
88 | 92 | else -1 | |
89 | 93 | } | |
90 | 94 | else acc | |
91 | 95 | ||
92 | 96 | let stepAmount = { | |
93 | 97 | let $l = [1, 2, 3, 4, 5] | |
94 | 98 | let $s = size($l) | |
95 | 99 | let $acc0 = -1 | |
96 | 100 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
97 | 101 | then $a | |
98 | 102 | else getStepAmount($a, $l[$i]) | |
99 | 103 | ||
100 | 104 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
101 | 105 | then $a | |
102 | 106 | else throw("List size exceeds 5") | |
103 | 107 | ||
104 | 108 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
105 | 109 | } | |
106 | 110 | if ((0 > stepAmount)) | |
107 | 111 | then throw("something went wrong while working with amountToSend") | |
108 | 112 | else if (if ((invariantEstimatedRatio > slippageValue)) | |
109 | 113 | then (invariantNew > invariant) | |
110 | 114 | else false) | |
111 | 115 | then amountToSendEstimated | |
112 | 116 | else stepAmount | |
113 | 117 | } | |
114 | 118 | ||
115 | 119 | ||
116 | 120 | @Callable(i) | |
117 | 121 | func invariantCalcc (x,y) = { | |
118 | 122 | let sk = skewness(x, y) | |
119 | 123 | let xy = (x + y) | |
120 | 124 | let firstpow = pow(sk, digits8, alpha, alphaDigits, digits8, CEILING) | |
121 | 125 | let secondpow = pow(fraction(x, y, scale8), 0, 5, 1, (digits8 / 2), DOWN) | |
122 | 126 | let thirdpow = pow((sk - beta), digits8, alpha, alphaDigits, digits8, DOWN) | |
123 | 127 | let fractionFirst = fraction(xy, scale8, firstpow) | |
124 | 128 | let fractionSecond = fraction(secondpow, thirdpow, scale8) | |
125 | 129 | let invariant = (fractionFirst + (2 * fractionSecond)) | |
126 | 130 | [IntegerEntry("invariant", invariant)] | |
127 | 131 | } | |
128 | 132 | ||
129 | 133 | ||
130 | 134 | ||
131 | 135 | @Callable(i) | |
132 | 136 | func invariantCalccBigInt (x,y) = { | |
133 | 137 | let sk = skewnessBigInt(x, y) | |
134 | 138 | let xy = toBigInt((x + y)) | |
135 | 139 | let firstpow = pow(toBigInt(sk), digits12, toBigInt(alpha), alphaDigits, digits12, CEILING) | |
136 | 140 | let secpowfraction = fraction(toBigInt(x), toBigInt(y), toBigInt(scale8)) | |
137 | 141 | let secondpow = pow(secpowfraction, 0, toBigInt(5), 1, (digits8 / 2), DOWN) | |
138 | 142 | let thirdpow = pow(toBigInt((sk - betaBigInt)), digits12, toBigInt(alpha), alphaDigits, digits12, DOWN) | |
139 | 143 | let fractionFirst = toInt(fraction(xy, toBigInt(scale12), firstpow)) | |
140 | 144 | let fractionSecond = (2 * toInt(fraction(secondpow, thirdpow, toBigInt(scale12)))) | |
141 | 145 | let invariant = (fractionFirst + fractionSecond) | |
142 | 146 | [IntegerEntry("invariant", invariant)] | |
143 | 147 | } | |
144 | 148 | ||
145 | 149 | ||
146 | 150 | ||
147 | 151 | @Callable(i) | |
148 | 152 | func exchange (balanceA,balanceB,pmtAmount,pmtAssetId,estimatedAmountToReceive,minAmountToReceive) = { | |
149 | 153 | let amount = calculateSendAmount(balanceA, balanceB, estimatedAmountToReceive, minAmountToReceive, pmtAmount, pmtAssetId) | |
150 | 154 | let governanceReward = fraction(amount, feeGovernance, feeScale6) | |
151 | 155 | let amountMinusFee = fraction(amount, (feeScale6 - fee), feeScale6) | |
152 | 156 | ([IntegerEntry("sendAmount", amount), IntegerEntry("sendAmountWithComission", amountMinusFee), IntegerEntry("invariant", invariantCalc(balanceA, balanceB))] ++ (if ((pmtAssetId == strAssetIdA)) | |
153 | 157 | then [IntegerEntry("invariantNew", invariantCalc((balanceA + pmtAmount), (balanceB - amount)))] | |
154 | 158 | else [IntegerEntry("invariantNew", invariantCalc((balanceA - amount), (balanceB + pmtAmount)))])) | |
155 | 159 | } | |
156 | 160 | ||
157 | 161 | ||
158 | 162 | @Verifier(tx) | |
159 | 163 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
160 | 164 |
github/deemru/w8io/169f3d6 89.45 ms ◑