tx · 7o4ECizmamiZnBnbUaktDZPwXgp9KJ9DUkeT5ZMVc3o6 3MyUL72drqr1VTxcMbUbqBqYid9Fwdhme51: -0.04500000 Waves 2023.08.04 17:35 [2695966] smart account 3MyUL72drqr1VTxcMbUbqBqYid9Fwdhme51 > SELF 0.00000000 Waves
{ "type": 13, "id": "7o4ECizmamiZnBnbUaktDZPwXgp9KJ9DUkeT5ZMVc3o6", "fee": 4500000, "feeAssetId": null, "timestamp": 1691159748754, "version": 2, "chainId": 84, "sender": "3MyUL72drqr1VTxcMbUbqBqYid9Fwdhme51", "senderPublicKey": "Eydan6KHeiTQYEQsVDrwqjDsAczhuvyYhFqMQEDcph4C", "proofs": [ "nRupeYoiK5PHc8izPD2SLcufAQnRtYUm9J5V9J3PPu1EWG4N55X45KTftUYHMCZ33jfvJv9v6i4BKCsprpF27aB" ], "script": "base64:BgI1CAISABIAEgMKAQESBQoDAQEBEgkKBwEBCAgBAQESBAoCAQESBAoCAQESABIAEgASABIAEgA+AAxrX2Jhc2VPcmFjbGUCDGtfYmFzZU9yYWNsZQANa19pbml0aWFsaXplZAINa19pbml0aWFsaXplZAAIa19wYXVzZWQCCGtfcGF1c2VkAAVrX2ZlZQIFa19mZWUAEGtfbWF4UHJpY2VJbXBhY3QCEGtfbWF4UHJpY2VJbXBhY3QAEGtfbWF4UHJpY2VTcHJlYWQCEGtfbWF4UHJpY2VTcHJlYWQAEGtfbWF4T3JhY2xlRGVsYXkCEGtfbWF4T3JhY2xlRGVsYXkAE2tfcXVvdGVBc3NldFJlc2VydmUCCGtfcXRBc3RSABJrX2Jhc2VBc3NldFJlc2VydmUCCGtfYnNBc3RSABJrX3F1b3RlQXNzZXRXZWlnaHQCCGtfcXRBc3RXABFrX2Jhc2VBc3NldFdlaWdodAIIa19ic0FzdFcAE2tfdG90YWxQb3NpdGlvblNpemUCE2tfdG90YWxQb3NpdGlvblNpemUACGtfbGFzdFR4AghrX2xhc3RUeAAUa19jb29yZGluYXRvckFkZHJlc3M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ZQIJAJsIAgkBEUBleHRyTmF0aXZlKDEwNjIpAQkBBXZhbHVlAQUFYWRtaW4JAKwCAgkArAICCQCsAgICB3N0YXR1c18JAKUIAQUEdGhpcwIBXwkA2AQBCAUCdHgCaWQHCQACAQIudW5hYmxlIHRvIHZlcmlmeTogYWRtaW4gbm90IHNldCBpbiBjb29yZGluYXRvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleXsQ6z8=", "height": 2695966, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6K5F1jJzrX1y5fPrEC2AcqcTMT4HBQnqPius5iXNGuEQ Next: none Diff:
Old | New | Differences | |
---|---|---|---|
189 | 189 | let maxPriceImpactValue = maxPriceImpact() | |
190 | 190 | if ((priceImpact > maxPriceImpactValue)) | |
191 | 191 | then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_qtAstR)) + " before base asset: ") + toString(_bsAstR)) + " quote asset amount to exchange: ") + toString(_quoteAssetAmount)) + " price before: ") + toString(priceBefore)) + " marketPrice: ") + toString(marketPrice))) | |
192 | - | else $ | |
192 | + | else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, priceImpact) | |
193 | 193 | } | |
194 | 194 | ||
195 | 195 | ||
206 | 206 | let quoteAssetDelta = abs((quoteAssetAfter - _quoteAssetReserve)) | |
207 | 207 | let quoteAssetSold = muld(quoteAssetDelta, _quoteAssetWeight) | |
208 | 208 | let maxPriceImpactValue = maxPriceImpact() | |
209 | - | let $ | |
210 | - | let quoteAssetReserveAfter1 = $ | |
211 | - | let baseAssetReserveAfter1 = $ | |
212 | - | let totalPositionSizeAfter1 = $ | |
209 | + | let $t087078869 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount) | |
210 | + | let quoteAssetReserveAfter1 = $t087078869._1 | |
211 | + | let baseAssetReserveAfter1 = $t087078869._2 | |
212 | + | let totalPositionSizeAfter1 = $t087078869._3 | |
213 | 213 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
214 | 214 | let priceDiff = abs((priceBefore - marketPrice)) | |
215 | 215 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
262 | 262 | then $Tuple2(qtAstR(), bsAstR()) | |
263 | 263 | else { | |
264 | 264 | let direction = (_positionSize > 0) | |
265 | - | let $ | |
266 | - | let currentNetMarketValue = $ | |
267 | - | let terminalQuoteAssetReserve = $ | |
268 | - | let terminalBaseAssetReserve = $ | |
265 | + | let $t01181711996 = swapOutput(direction, abs(_positionSize), false) | |
266 | + | let currentNetMarketValue = $t01181711996._1 | |
267 | + | let terminalQuoteAssetReserve = $t01181711996._2 | |
268 | + | let terminalBaseAssetReserve = $t01181711996._3 | |
269 | 269 | $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve) | |
270 | 270 | } | |
271 | 271 | } | |
348 | 348 | let qtAstRAfter = (_qtAstR + _quoteAssetAmount) | |
349 | 349 | let baseAssetAmountToAdd = (divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR) | |
350 | 350 | let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd) | |
351 | - | let $ | |
352 | - | let newQuoteAssetWeight = $ | |
353 | - | let newBaseAssetWeight = $ | |
351 | + | let $t01538115511 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter) | |
352 | + | let newQuoteAssetWeight = $t01538115511._1 | |
353 | + | let newBaseAssetWeight = $t01538115511._2 | |
354 | 354 | (updateAmmReserves(qtAstRAfter, bsAstRAfter) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)) | |
355 | 355 | } | |
356 | 356 | ||
404 | 404 | else (i.caller != spotAddress())) | |
405 | 405 | then throw("Invalid swapToBase parameters") | |
406 | 406 | else { | |
407 | - | let $t01803918196 = swapInput(true, _amount) | |
408 | - | let amountBaseAssetBought = $t01803918196._1 | |
409 | - | let quoteAssetReserveAfter = $t01803918196._2 | |
410 | - | let baseAssetReserveAfter = $t01803918196._3 | |
411 | - | let totalPositionSizeAfter = $t01803918196._4 | |
407 | + | let $t01805818234 = swapInput(true, _amount) | |
408 | + | let amountBaseAssetBought = $t01805818234._1 | |
409 | + | let quoteAssetReserveAfter = $t01805818234._2 | |
410 | + | let baseAssetReserveAfter = $t01805818234._3 | |
411 | + | let totalPositionSizeAfter = $t01805818234._4 | |
412 | + | let priceImpact = $t01805818234._5 | |
412 | 413 | let update = updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter) | |
413 | - | $Tuple2(update, amountBaseAssetBought) | |
414 | + | $Tuple2(update, $Tuple2(amountBaseAssetBought, priceImpact)) | |
414 | 415 | } | |
415 | 416 | else throw("Strict value is not equal to itself.") | |
416 | 417 | } | |
433 | 434 | else (i.caller != spotAddress())) | |
434 | 435 | then throw("Invalid swapToQuote parameters") | |
435 | 436 | else { | |
436 | - | let $t01874118899 = swapOutput(true, _amount, true) | |
437 | - | let amountQuoteAssetBought = $t01874118899._1 | |
438 | - | let quoteAssetReserveAfter = $t01874118899._2 | |
439 | - | let baseAssetReserveAfter = $t01874118899._3 | |
437 | + | let $t01879418981 = swapOutput(true, _amount, true) | |
438 | + | let amountQuoteAssetBought = $t01879418981._1 | |
439 | + | let quoteAssetReserveAfter = $t01879418981._2 | |
440 | + | let baseAssetReserveAfter = $t01879418981._3 | |
441 | + | let x1 = $t01879418981._4 | |
442 | + | let priceImpact = $t01879418981._5 | |
440 | 443 | let totalPositionSizeAfter = (totalPositionSize() - _amount) | |
441 | 444 | let update = updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter) | |
442 | - | $Tuple2(update, amountQuoteAssetBought) | |
445 | + | $Tuple2(update, $Tuple2(amountQuoteAssetBought, priceImpact)) | |
443 | 446 | } | |
444 | 447 | else throw("Strict value is not equal to itself.") | |
445 | 448 | } | |
452 | 455 | func syncTerminalPriceToOracle () = { | |
453 | 456 | let _qtAstR = qtAstR() | |
454 | 457 | let _bsAstR = bsAstR() | |
455 | - | let $ | |
456 | - | let newQuoteAssetWeight = $ | |
457 | - | let newBaseAssetWeight = $ | |
458 | + | let $t01964219758 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR) | |
459 | + | let newQuoteAssetWeight = $t01964219758._1 | |
460 | + | let newBaseAssetWeight = $t01964219758._2 | |
458 | 461 | updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight) | |
459 | 462 | } | |
460 | 463 | ||
475 | 478 | ||
476 | 479 | @Callable(i) | |
477 | 480 | func view_getTerminalAmmPrice () = { | |
478 | - | let $ | |
479 | - | let terminalQuoteAssetReserve = $ | |
480 | - | let terminalBaseAssetReserve = $ | |
481 | + | let $t02051220593 = getTerminalAmmState() | |
482 | + | let terminalQuoteAssetReserve = $t02051220593._1 | |
483 | + | let terminalBaseAssetReserve = $t02051220593._2 | |
481 | 484 | let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW())) | |
482 | 485 | throw(toString(price)) | |
483 | 486 | } | |
489 | 492 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
490 | 493 | if ((sync == sync)) | |
491 | 494 | then { | |
492 | - | let $ | |
493 | - | let terminalQuoteAssetReserve = $ | |
494 | - | let terminalBaseAssetReserve = $ | |
495 | + | let $t02091320994 = getTerminalAmmState() | |
496 | + | let terminalQuoteAssetReserve = $t02091320994._1 | |
497 | + | let terminalBaseAssetReserve = $t02091320994._2 | |
495 | 498 | let terminalPrice = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW())) | |
496 | 499 | let spotPrice = getSpotPrice() | |
497 | 500 | throw(((toString(terminalPrice) + ",") + toString(spotPrice))) | |
516 | 519 | ||
517 | 520 | @Callable(i) | |
518 | 521 | func computeTerminalAmmPrice () = { | |
519 | - | let $ | |
520 | - | let terminalQuoteAssetReserve = $ | |
521 | - | let terminalBaseAssetReserve = $ | |
522 | + | let $t02174521826 = getTerminalAmmState() | |
523 | + | let terminalQuoteAssetReserve = $t02174521826._1 | |
524 | + | let terminalBaseAssetReserve = $t02174521826._2 | |
522 | 525 | let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW())) | |
523 | 526 | $Tuple2(nil, price) | |
524 | 527 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_baseOracle = "k_baseOracle" | |
5 | 5 | ||
6 | 6 | let k_initialized = "k_initialized" | |
7 | 7 | ||
8 | 8 | let k_paused = "k_paused" | |
9 | 9 | ||
10 | 10 | let k_fee = "k_fee" | |
11 | 11 | ||
12 | 12 | let k_maxPriceImpact = "k_maxPriceImpact" | |
13 | 13 | ||
14 | 14 | let k_maxPriceSpread = "k_maxPriceSpread" | |
15 | 15 | ||
16 | 16 | let k_maxOracleDelay = "k_maxOracleDelay" | |
17 | 17 | ||
18 | 18 | let k_quoteAssetReserve = "k_qtAstR" | |
19 | 19 | ||
20 | 20 | let k_baseAssetReserve = "k_bsAstR" | |
21 | 21 | ||
22 | 22 | let k_quoteAssetWeight = "k_qtAstW" | |
23 | 23 | ||
24 | 24 | let k_baseAssetWeight = "k_bsAstW" | |
25 | 25 | ||
26 | 26 | let k_totalPositionSize = "k_totalPositionSize" | |
27 | 27 | ||
28 | 28 | let k_lastTx = "k_lastTx" | |
29 | 29 | ||
30 | 30 | let k_coordinatorAddress = "k_coordinatorAddress" | |
31 | 31 | ||
32 | 32 | let k_vault_address = "k_vault_address" | |
33 | 33 | ||
34 | 34 | let k_admin_address = "k_admin_address" | |
35 | 35 | ||
36 | 36 | let k_quote_asset = "k_quote_asset" | |
37 | 37 | ||
38 | 38 | let k_spot_address = "k_spot_address" | |
39 | 39 | ||
40 | 40 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func spotAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_spot_address), "Spot address not set")) | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | let DECIMAL_NUMBERS = 6 | |
56 | 56 | ||
57 | 57 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
58 | 58 | ||
59 | 59 | func s (_x) = (toString(_x) + ",") | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func bdivd (_x,_y) = fraction(_x, toBigInt(DECIMAL_UNIT), _y, HALFEVEN) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func bmuld (_x,_y) = fraction(_x, _y, toBigInt(DECIMAL_UNIT), HALFEVEN) | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | func abs (_x) = if ((_x > 0)) | |
75 | 75 | then _x | |
76 | 76 | else -(_x) | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func intOr (k,def) = valueOrElse(getInteger(this, k), def) | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func intA (_address,_key) = { | |
86 | 86 | let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key)) | |
87 | 87 | val | |
88 | 88 | } | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func fee () = int(k_fee) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func qtAstR () = int(k_quoteAssetReserve) | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func bsAstR () = int(k_baseAssetReserve) | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | func qtAstW () = intOr(k_quoteAssetWeight, DECIMAL_UNIT) | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | func bsAstW () = intOr(k_baseAssetWeight, DECIMAL_UNIT) | |
104 | 104 | ||
105 | 105 | ||
106 | 106 | func totalPositionSize () = int(k_totalPositionSize) | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | func maxPriceImpact () = int(k_maxPriceImpact) | |
110 | 110 | ||
111 | 111 | ||
112 | 112 | func maxPriceSpread () = int(k_maxPriceSpread) | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | func maxOracleDelay () = int(k_maxOracleDelay) | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | func lastTimestamp () = lastBlock.timestamp | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func getOracleData (key) = { | |
122 | 122 | let oracleDataStr = getString(this, key) | |
123 | 123 | if (if (isDefined(oracleDataStr)) | |
124 | 124 | then (value(oracleDataStr) != "") | |
125 | 125 | else false) | |
126 | 126 | then { | |
127 | 127 | let oracleData = split(value(oracleDataStr), ",") | |
128 | 128 | let oracleAddress = valueOrErrorMessage(addressFromString(oracleData[0]), ("Invalid oracle address in: " + value(oracleDataStr))) | |
129 | 129 | let priceKey = oracleData[1] | |
130 | 130 | let blockKey = oracleData[2] | |
131 | 131 | let openKey = oracleData[3] | |
132 | 132 | $Tuple4(oracleAddress, priceKey, blockKey, openKey) | |
133 | 133 | } | |
134 | 134 | else unit | |
135 | 135 | } | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
139 | 139 | ||
140 | 140 | ||
141 | 141 | func paused () = valueOrElse(getBoolean(this, k_paused), false) | |
142 | 142 | ||
143 | 143 | ||
144 | 144 | func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd) | |
145 | 145 | then { | |
146 | 146 | let newBase = (bsAstR() - _baseAssetAmount) | |
147 | 147 | if ((0 >= newBase)) | |
148 | 148 | then throw("Tx lead to base asset reserve <= 0, revert") | |
149 | 149 | else $Tuple3((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount)) | |
150 | 150 | } | |
151 | 151 | else { | |
152 | 152 | let newQuote = (qtAstR() - _quoteAssetAmount) | |
153 | 153 | if ((0 >= newQuote)) | |
154 | 154 | then throw("Tx lead to base quote reserve <= 0, revert") | |
155 | 155 | else $Tuple3(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount)) | |
156 | 156 | } | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | func calcInvariant (_qtAstR,_bsAstR) = { | |
160 | 160 | let bqtAstR = toBigInt(_qtAstR) | |
161 | 161 | let bbsAstR = toBigInt(_bsAstR) | |
162 | 162 | bmuld(bqtAstR, bbsAstR) | |
163 | 163 | } | |
164 | 164 | ||
165 | 165 | ||
166 | 166 | func swapInput (_isAdd,_quoteAssetAmount) = { | |
167 | 167 | let _qtAstR = qtAstR() | |
168 | 168 | let _bsAstR = bsAstR() | |
169 | 169 | let _qtAstW = qtAstW() | |
170 | 170 | let _bsAstW = bsAstW() | |
171 | 171 | let quoteAssetAmountAdjusted = divd(_quoteAssetAmount, _qtAstW) | |
172 | 172 | let k = calcInvariant(_qtAstR, _bsAstR) | |
173 | 173 | let quoteAssetReserveAfter = if (_isAdd) | |
174 | 174 | then (_qtAstR + quoteAssetAmountAdjusted) | |
175 | 175 | else (_qtAstR - quoteAssetAmountAdjusted) | |
176 | 176 | let baseAssetReserveAfter = toInt(bdivd(k, toBigInt(quoteAssetReserveAfter))) | |
177 | 177 | let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR)) | |
178 | 178 | let amountBaseAssetBought = if (_isAdd) | |
179 | 179 | then amountBaseAssetBoughtAbs | |
180 | 180 | else -(amountBaseAssetBoughtAbs) | |
181 | 181 | let $t064036573 = updateReserve(_isAdd, quoteAssetAmountAdjusted, amountBaseAssetBoughtAbs) | |
182 | 182 | let quoteAssetReserveAfter1 = $t064036573._1 | |
183 | 183 | let baseAssetReserveAfter1 = $t064036573._2 | |
184 | 184 | let totalPositionSizeAfter1 = $t064036573._3 | |
185 | 185 | let priceBefore = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW)) | |
186 | 186 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
187 | 187 | let priceDiff = abs((priceBefore - marketPrice)) | |
188 | 188 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
189 | 189 | let maxPriceImpactValue = maxPriceImpact() | |
190 | 190 | if ((priceImpact > maxPriceImpactValue)) | |
191 | 191 | then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_qtAstR)) + " before base asset: ") + toString(_bsAstR)) + " quote asset amount to exchange: ") + toString(_quoteAssetAmount)) + " price before: ") + toString(priceBefore)) + " marketPrice: ") + toString(marketPrice))) | |
192 | - | else $ | |
192 | + | else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, priceImpact) | |
193 | 193 | } | |
194 | 194 | ||
195 | 195 | ||
196 | 196 | func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight) = { | |
197 | 197 | let priceBefore = divd(muld(_quoteAssetReserve, _quoteAssetWeight), muld(_baseAssetReserve, _baseAssetWeight)) | |
198 | 198 | if ((_baseAssetAmount == 0)) | |
199 | 199 | then throw("Invalid base asset amount") | |
200 | 200 | else { | |
201 | 201 | let k = calcInvariant(_quoteAssetReserve, _baseAssetReserve) | |
202 | 202 | let baseAssetPoolAmountAfter = if (_isAdd) | |
203 | 203 | then (_baseAssetReserve + _baseAssetAmount) | |
204 | 204 | else (_baseAssetReserve - _baseAssetAmount) | |
205 | 205 | let quoteAssetAfter = toInt(bdivd(k, toBigInt(baseAssetPoolAmountAfter))) | |
206 | 206 | let quoteAssetDelta = abs((quoteAssetAfter - _quoteAssetReserve)) | |
207 | 207 | let quoteAssetSold = muld(quoteAssetDelta, _quoteAssetWeight) | |
208 | 208 | let maxPriceImpactValue = maxPriceImpact() | |
209 | - | let $ | |
210 | - | let quoteAssetReserveAfter1 = $ | |
211 | - | let baseAssetReserveAfter1 = $ | |
212 | - | let totalPositionSizeAfter1 = $ | |
209 | + | let $t087078869 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount) | |
210 | + | let quoteAssetReserveAfter1 = $t087078869._1 | |
211 | + | let baseAssetReserveAfter1 = $t087078869._2 | |
212 | + | let totalPositionSizeAfter1 = $t087078869._3 | |
213 | 213 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
214 | 214 | let priceDiff = abs((priceBefore - marketPrice)) | |
215 | 215 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
216 | 216 | if (if ((priceImpact > maxPriceImpactValue)) | |
217 | 217 | then _checkMaxPriceImpact | |
218 | 218 | else false) | |
219 | 219 | then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_quoteAssetReserve)) + " before base asset: ") + toString(_baseAssetReserve)) + " base asset amount to exchange: ") + toString(_baseAssetAmount)) + " price before: ") + toString(priceBefore)) + " market price: ") + toString(marketPrice))) | |
220 | 220 | else $Tuple5(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, priceImpact) | |
221 | 221 | } | |
222 | 222 | } | |
223 | 223 | ||
224 | 224 | ||
225 | 225 | func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), qtAstW(), bsAstR(), bsAstW()) | |
226 | 226 | ||
227 | 227 | ||
228 | 228 | func getOraclePriceValue (oracle,priceKey,blockKey) = { | |
229 | 229 | let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey)) | |
230 | 230 | if ((blockKey != "")) | |
231 | 231 | then { | |
232 | 232 | let currentBlock = lastBlock.height | |
233 | 233 | let lastOracleBlock = valueOrErrorMessage(getInteger(oracle, blockKey), ((("Can not get oracle block. Oracle: " + toString(oracle)) + " key: ") + blockKey)) | |
234 | 234 | if (((currentBlock - lastOracleBlock) > maxOracleDelay())) | |
235 | 235 | then throw(((("Oracle stale data. Last oracle block: " + toString(lastOracleBlock)) + " current block: ") + toString(currentBlock))) | |
236 | 236 | else lastValue | |
237 | 237 | } | |
238 | 238 | else lastValue | |
239 | 239 | } | |
240 | 240 | ||
241 | 241 | ||
242 | 242 | func getOraclePrice () = { | |
243 | 243 | let baseOracle = valueOrErrorMessage(getOracleData(k_baseOracle), "No base asset oracle data") | |
244 | 244 | let baseOraclePrice = getOraclePriceValue(baseOracle._1, baseOracle._2, baseOracle._3) | |
245 | 245 | let quoteOraclePrice = DECIMAL_UNIT | |
246 | 246 | divd(baseOraclePrice, quoteOraclePrice) | |
247 | 247 | } | |
248 | 248 | ||
249 | 249 | ||
250 | 250 | func getSpotPrice () = { | |
251 | 251 | let _quoteAssetReserve = qtAstR() | |
252 | 252 | let _baseAssetReserve = bsAstR() | |
253 | 253 | let _qtAstW = qtAstW() | |
254 | 254 | let _bsAstW = bsAstW() | |
255 | 255 | divd(muld(_quoteAssetReserve, _qtAstW), muld(_baseAssetReserve, _bsAstW)) | |
256 | 256 | } | |
257 | 257 | ||
258 | 258 | ||
259 | 259 | func getTerminalAmmState () = { | |
260 | 260 | let _positionSize = totalPositionSize() | |
261 | 261 | if ((_positionSize == 0)) | |
262 | 262 | then $Tuple2(qtAstR(), bsAstR()) | |
263 | 263 | else { | |
264 | 264 | let direction = (_positionSize > 0) | |
265 | - | let $ | |
266 | - | let currentNetMarketValue = $ | |
267 | - | let terminalQuoteAssetReserve = $ | |
268 | - | let terminalBaseAssetReserve = $ | |
265 | + | let $t01181711996 = swapOutput(direction, abs(_positionSize), false) | |
266 | + | let currentNetMarketValue = $t01181711996._1 | |
267 | + | let terminalQuoteAssetReserve = $t01181711996._2 | |
268 | + | let terminalBaseAssetReserve = $t01181711996._3 | |
269 | 269 | $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve) | |
270 | 270 | } | |
271 | 271 | } | |
272 | 272 | ||
273 | 273 | ||
274 | 274 | func getQuoteAssetWeight (baseAssetReserve,totalPositionSize,quoteAssetReserve,targetPrice) = { | |
275 | 275 | let b = toBigInt(baseAssetReserve) | |
276 | 276 | let sz = toBigInt(totalPositionSize) | |
277 | 277 | let q = toBigInt(quoteAssetReserve) | |
278 | 278 | let p = toBigInt(targetPrice) | |
279 | 279 | let k = bmuld(q, b) | |
280 | 280 | let newB = (b + sz) | |
281 | 281 | let newQ = bdivd(k, newB) | |
282 | 282 | let z = bdivd(newQ, newB) | |
283 | 283 | let result = bdivd(p, z) | |
284 | 284 | toInt(result) | |
285 | 285 | } | |
286 | 286 | ||
287 | 287 | ||
288 | 288 | func getSyncTerminalPrice (_terminalPrice,_qtAstR,_bsAstR) = { | |
289 | 289 | let _positionSize = totalPositionSize() | |
290 | 290 | if ((_positionSize == 0)) | |
291 | 291 | then { | |
292 | 292 | let newQtAstW = divd(muld(_terminalPrice, _bsAstR), _qtAstR) | |
293 | 293 | $Tuple2(newQtAstW, DECIMAL_UNIT) | |
294 | 294 | } | |
295 | 295 | else { | |
296 | 296 | let newQtAstW = getQuoteAssetWeight(_bsAstR, _positionSize, _qtAstR, _terminalPrice) | |
297 | 297 | let newBsAstW = DECIMAL_UNIT | |
298 | 298 | $Tuple2(newQtAstW, newBsAstW) | |
299 | 299 | } | |
300 | 300 | } | |
301 | 301 | ||
302 | 302 | ||
303 | 303 | func updateSettings (_maxPriceImpact,_maxPriceSpread,_maxOracleDelay) = [IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOracleDelay, _maxOracleDelay)] | |
304 | 304 | ||
305 | 305 | ||
306 | 306 | func updateAmmReserves (_qtAstR,_bsAstR) = if (if ((0 >= _qtAstR)) | |
307 | 307 | then true | |
308 | 308 | else (0 >= _bsAstR)) | |
309 | 309 | then throw("Can not updateAmmReserves: _qtAstR <= 0 || _bsAstR <= 0") | |
310 | 310 | else [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)] | |
311 | 311 | ||
312 | 312 | ||
313 | 313 | func updateAmmWeights (_qtAstW,_bsAstW) = [IntegerEntry(k_quoteAssetWeight, _qtAstW), IntegerEntry(k_baseAssetWeight, _bsAstW)] | |
314 | 314 | ||
315 | 315 | ||
316 | 316 | func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter) = { | |
317 | 317 | let _qtAstW = qtAstW() | |
318 | 318 | let _bsAstW = bsAstW() | |
319 | 319 | (updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter)]) | |
320 | 320 | } | |
321 | 321 | ||
322 | 322 | ||
323 | 323 | @Callable(i) | |
324 | 324 | func pause () = if ((i.caller != adminAddress())) | |
325 | 325 | then throw("Invalid pause params") | |
326 | 326 | else [BooleanEntry(k_paused, true)] | |
327 | 327 | ||
328 | 328 | ||
329 | 329 | ||
330 | 330 | @Callable(i) | |
331 | 331 | func unpause () = if ((i.caller != adminAddress())) | |
332 | 332 | then throw("Invalid unpause params") | |
333 | 333 | else [BooleanEntry(k_paused, false)] | |
334 | 334 | ||
335 | 335 | ||
336 | 336 | ||
337 | 337 | @Callable(i) | |
338 | 338 | func changeLiquidity (_quoteAssetAmount) = if (!(if ((i.caller == spotAddress())) | |
339 | 339 | then true | |
340 | 340 | else (i.caller == adminAddress()))) | |
341 | 341 | then throw("Invalid changeLiquidity params") | |
342 | 342 | else { | |
343 | 343 | let _qtAstR = qtAstR() | |
344 | 344 | let _bsAstR = bsAstR() | |
345 | 345 | let _qtAstW = qtAstW() | |
346 | 346 | let _bsAstW = bsAstW() | |
347 | 347 | let price = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW)) | |
348 | 348 | let qtAstRAfter = (_qtAstR + _quoteAssetAmount) | |
349 | 349 | let baseAssetAmountToAdd = (divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR) | |
350 | 350 | let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd) | |
351 | - | let $ | |
352 | - | let newQuoteAssetWeight = $ | |
353 | - | let newBaseAssetWeight = $ | |
351 | + | let $t01538115511 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter) | |
352 | + | let newQuoteAssetWeight = $t01538115511._1 | |
353 | + | let newBaseAssetWeight = $t01538115511._2 | |
354 | 354 | (updateAmmReserves(qtAstRAfter, bsAstRAfter) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)) | |
355 | 355 | } | |
356 | 356 | ||
357 | 357 | ||
358 | 358 | ||
359 | 359 | @Callable(i) | |
360 | 360 | func changeSettings (_maxPriceImpact,_maxPriceSpread,_maxOracleDelay) = if (if (if (if (if ((0 >= _maxPriceImpact)) | |
361 | 361 | then true | |
362 | 362 | else (0 >= _maxPriceSpread)) | |
363 | 363 | then true | |
364 | 364 | else (0 >= _maxOracleDelay)) | |
365 | 365 | then true | |
366 | 366 | else !(initialized())) | |
367 | 367 | then true | |
368 | 368 | else (i.caller != adminAddress())) | |
369 | 369 | then throw("Invalid changeSettings params") | |
370 | 370 | else updateSettings(_maxPriceImpact, _maxPriceSpread, _maxOracleDelay) | |
371 | 371 | ||
372 | 372 | ||
373 | 373 | ||
374 | 374 | @Callable(i) | |
375 | 375 | func initialize (_qtAstR,_bsAstR,_baseOracleData,_coordinator,_maxPriceImpact,_maxPriceSpread,_maxOracleDelay) = if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
376 | 376 | then true | |
377 | 377 | else (0 >= _bsAstR)) | |
378 | 378 | then true | |
379 | 379 | else (0 >= _maxPriceImpact)) | |
380 | 380 | then true | |
381 | 381 | else (0 >= _maxPriceSpread)) | |
382 | 382 | then true | |
383 | 383 | else (0 >= _maxOracleDelay)) | |
384 | 384 | then true | |
385 | 385 | else initialized()) | |
386 | 386 | then true | |
387 | 387 | else (i.caller != this)) | |
388 | 388 | then throw("Invalid initialize parameters") | |
389 | 389 | else ((updateAmm(_qtAstR, _bsAstR, 0) ++ updateSettings(_maxPriceImpact, _maxPriceSpread, _maxOracleDelay)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))]) | |
390 | 390 | ||
391 | 391 | ||
392 | 392 | ||
393 | 393 | @Callable(i) | |
394 | 394 | func swapToBase (_amount,_minBaseAssetAmount) = { | |
395 | 395 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
396 | 396 | if ((sync == sync)) | |
397 | 397 | then { | |
398 | 398 | let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil) | |
399 | 399 | if ((ensureCalledOnce == ensureCalledOnce)) | |
400 | 400 | then if (if (if (!(initialized())) | |
401 | 401 | then true | |
402 | 402 | else paused()) | |
403 | 403 | then true | |
404 | 404 | else (i.caller != spotAddress())) | |
405 | 405 | then throw("Invalid swapToBase parameters") | |
406 | 406 | else { | |
407 | - | let $t01803918196 = swapInput(true, _amount) | |
408 | - | let amountBaseAssetBought = $t01803918196._1 | |
409 | - | let quoteAssetReserveAfter = $t01803918196._2 | |
410 | - | let baseAssetReserveAfter = $t01803918196._3 | |
411 | - | let totalPositionSizeAfter = $t01803918196._4 | |
407 | + | let $t01805818234 = swapInput(true, _amount) | |
408 | + | let amountBaseAssetBought = $t01805818234._1 | |
409 | + | let quoteAssetReserveAfter = $t01805818234._2 | |
410 | + | let baseAssetReserveAfter = $t01805818234._3 | |
411 | + | let totalPositionSizeAfter = $t01805818234._4 | |
412 | + | let priceImpact = $t01805818234._5 | |
412 | 413 | let update = updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter) | |
413 | - | $Tuple2(update, amountBaseAssetBought) | |
414 | + | $Tuple2(update, $Tuple2(amountBaseAssetBought, priceImpact)) | |
414 | 415 | } | |
415 | 416 | else throw("Strict value is not equal to itself.") | |
416 | 417 | } | |
417 | 418 | else throw("Strict value is not equal to itself.") | |
418 | 419 | } | |
419 | 420 | ||
420 | 421 | ||
421 | 422 | ||
422 | 423 | @Callable(i) | |
423 | 424 | func swapToQuote (_amount,_minQuoteAssetAmount) = { | |
424 | 425 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
425 | 426 | if ((sync == sync)) | |
426 | 427 | then { | |
427 | 428 | let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil) | |
428 | 429 | if ((ensureCalledOnce == ensureCalledOnce)) | |
429 | 430 | then if (if (if (!(initialized())) | |
430 | 431 | then true | |
431 | 432 | else paused()) | |
432 | 433 | then true | |
433 | 434 | else (i.caller != spotAddress())) | |
434 | 435 | then throw("Invalid swapToQuote parameters") | |
435 | 436 | else { | |
436 | - | let $t01874118899 = swapOutput(true, _amount, true) | |
437 | - | let amountQuoteAssetBought = $t01874118899._1 | |
438 | - | let quoteAssetReserveAfter = $t01874118899._2 | |
439 | - | let baseAssetReserveAfter = $t01874118899._3 | |
437 | + | let $t01879418981 = swapOutput(true, _amount, true) | |
438 | + | let amountQuoteAssetBought = $t01879418981._1 | |
439 | + | let quoteAssetReserveAfter = $t01879418981._2 | |
440 | + | let baseAssetReserveAfter = $t01879418981._3 | |
441 | + | let x1 = $t01879418981._4 | |
442 | + | let priceImpact = $t01879418981._5 | |
440 | 443 | let totalPositionSizeAfter = (totalPositionSize() - _amount) | |
441 | 444 | let update = updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter) | |
442 | - | $Tuple2(update, amountQuoteAssetBought) | |
445 | + | $Tuple2(update, $Tuple2(amountQuoteAssetBought, priceImpact)) | |
443 | 446 | } | |
444 | 447 | else throw("Strict value is not equal to itself.") | |
445 | 448 | } | |
446 | 449 | else throw("Strict value is not equal to itself.") | |
447 | 450 | } | |
448 | 451 | ||
449 | 452 | ||
450 | 453 | ||
451 | 454 | @Callable(i) | |
452 | 455 | func syncTerminalPriceToOracle () = { | |
453 | 456 | let _qtAstR = qtAstR() | |
454 | 457 | let _bsAstR = bsAstR() | |
455 | - | let $ | |
456 | - | let newQuoteAssetWeight = $ | |
457 | - | let newBaseAssetWeight = $ | |
458 | + | let $t01964219758 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR) | |
459 | + | let newQuoteAssetWeight = $t01964219758._1 | |
460 | + | let newBaseAssetWeight = $t01964219758._2 | |
458 | 461 | updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight) | |
459 | 462 | } | |
460 | 463 | ||
461 | 464 | ||
462 | 465 | ||
463 | 466 | @Callable(i) | |
464 | 467 | func ensureCalledOnce () = if ((i.caller != this)) | |
465 | 468 | then throw("Invalid saveCurrentTxId parameters") | |
466 | 469 | else { | |
467 | 470 | let txId = toBase58String(i.transactionId) | |
468 | 471 | let lastTx = valueOrElse(getString(this, k_lastTx), "") | |
469 | 472 | if ((lastTx != txId)) | |
470 | 473 | then [StringEntry(k_lastTx, txId)] | |
471 | 474 | else throw("Can not call vAMM methods twice in one tx") | |
472 | 475 | } | |
473 | 476 | ||
474 | 477 | ||
475 | 478 | ||
476 | 479 | @Callable(i) | |
477 | 480 | func view_getTerminalAmmPrice () = { | |
478 | - | let $ | |
479 | - | let terminalQuoteAssetReserve = $ | |
480 | - | let terminalBaseAssetReserve = $ | |
481 | + | let $t02051220593 = getTerminalAmmState() | |
482 | + | let terminalQuoteAssetReserve = $t02051220593._1 | |
483 | + | let terminalBaseAssetReserve = $t02051220593._2 | |
481 | 484 | let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW())) | |
482 | 485 | throw(toString(price)) | |
483 | 486 | } | |
484 | 487 | ||
485 | 488 | ||
486 | 489 | ||
487 | 490 | @Callable(i) | |
488 | 491 | func view_getPrices () = { | |
489 | 492 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
490 | 493 | if ((sync == sync)) | |
491 | 494 | then { | |
492 | - | let $ | |
493 | - | let terminalQuoteAssetReserve = $ | |
494 | - | let terminalBaseAssetReserve = $ | |
495 | + | let $t02091320994 = getTerminalAmmState() | |
496 | + | let terminalQuoteAssetReserve = $t02091320994._1 | |
497 | + | let terminalBaseAssetReserve = $t02091320994._2 | |
495 | 498 | let terminalPrice = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW())) | |
496 | 499 | let spotPrice = getSpotPrice() | |
497 | 500 | throw(((toString(terminalPrice) + ",") + toString(spotPrice))) | |
498 | 501 | } | |
499 | 502 | else throw("Strict value is not equal to itself.") | |
500 | 503 | } | |
501 | 504 | ||
502 | 505 | ||
503 | 506 | ||
504 | 507 | @Callable(i) | |
505 | 508 | func computeSpotPrice () = { | |
506 | 509 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
507 | 510 | if ((sync == sync)) | |
508 | 511 | then { | |
509 | 512 | let result = getSpotPrice() | |
510 | 513 | $Tuple2(nil, result) | |
511 | 514 | } | |
512 | 515 | else throw("Strict value is not equal to itself.") | |
513 | 516 | } | |
514 | 517 | ||
515 | 518 | ||
516 | 519 | ||
517 | 520 | @Callable(i) | |
518 | 521 | func computeTerminalAmmPrice () = { | |
519 | - | let $ | |
520 | - | let terminalQuoteAssetReserve = $ | |
521 | - | let terminalBaseAssetReserve = $ | |
522 | + | let $t02174521826 = getTerminalAmmState() | |
523 | + | let terminalQuoteAssetReserve = $t02174521826._1 | |
524 | + | let terminalBaseAssetReserve = $t02174521826._2 | |
522 | 525 | let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW())) | |
523 | 526 | $Tuple2(nil, price) | |
524 | 527 | } | |
525 | 528 | ||
526 | 529 | ||
527 | 530 | @Verifier(tx) | |
528 | 531 | func verify () = { | |
529 | 532 | let coordinatorStr = getString(this, k_coordinatorAddress) | |
530 | 533 | if (isDefined(coordinatorStr)) | |
531 | 534 | then { | |
532 | 535 | let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address) | |
533 | 536 | if (isDefined(admin)) | |
534 | 537 | then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false) | |
535 | 538 | else throw("unable to verify: admin not set in coordinator") | |
536 | 539 | } | |
537 | 540 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
538 | 541 | } | |
539 | 542 |
github/deemru/w8io/026f985 58.66 ms ◑