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