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+AAxrX2Jhc2VPcmFjbGUCDGtfYmFzZU9yYWNsZQANa19pbml0aWFsaXplZAINa19pbml0aWFsaXplZAAIa19wYXVzZWQCCGtfcGF1c2VkAAVrX2ZlZQIFa19mZWUAEGtfbWF4UHJpY2VJbXBhY3QCEGtfbWF4UHJpY2VJbXBhY3QAEGtfbWF4UHJpY2VTcHJlYWQCEGtfbWF4UHJpY2VTcHJlYWQAEGtfbWF4T3JhY2xlRGVsYXkCEGtfbWF4T3JhY2xlRGVsYXkAE2tfcXVvdGVBc3NldFJlc2VydmUCCGtfcXRBc3RSABJrX2Jhc2VBc3NldFJlc2VydmUCCGtfYnNBc3RSABJrX3F1b3RlQXNzZXRXZWlnaHQCCGtfcXRBc3RXABFrX2Jhc2VBc3NldFdlaWdodAIIa19ic0FzdFcAE2tfdG90YWxQb3NpdGlvblNpemUCE2tfdG90YWxQb3NpdGlvblNpemUACGtfbGFzdFR4AghrX2xhc3RUeAAUa19jb29yZGluYXRvckFkZHJlc3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zZQIJAJsIAgkBEUBleHRyTmF0aXZlKDEwNjIpAQkBBXZhbHVlAQUFYWRtaW4JAKwCAgkArAICCQCsAgICB3N0YXR1c18JAKUIAQUEdGhpcwIBXwkA2AQBCAUCdHgCaWQHCQACAQIudW5hYmxlIHRvIHZlcmlmeTogYWRtaW4gbm90IHNldCBpbiBjb29yZGluYXRvcgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleXsQ6z8=", "height": 2695966, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6K5F1jJzrX1y5fPrEC2AcqcTMT4HBQnqPius5iXNGuEQ Next: none Diff:
OldNewDifferences
189189 let maxPriceImpactValue = maxPriceImpact()
190190 if ((priceImpact > maxPriceImpactValue))
191191 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 $Tuple4(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1)
192+ else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, priceImpact)
193193 }
194194
195195
206206 let quoteAssetDelta = abs((quoteAssetAfter - _quoteAssetReserve))
207207 let quoteAssetSold = muld(quoteAssetDelta, _quoteAssetWeight)
208208 let maxPriceImpactValue = maxPriceImpact()
209- let $t086888850 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount)
210- let quoteAssetReserveAfter1 = $t086888850._1
211- let baseAssetReserveAfter1 = $t086888850._2
212- let totalPositionSizeAfter1 = $t086888850._3
209+ let $t087078869 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount)
210+ let quoteAssetReserveAfter1 = $t087078869._1
211+ let baseAssetReserveAfter1 = $t087078869._2
212+ let totalPositionSizeAfter1 = $t087078869._3
213213 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
214214 let priceDiff = abs((priceBefore - marketPrice))
215215 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
262262 then $Tuple2(qtAstR(), bsAstR())
263263 else {
264264 let direction = (_positionSize > 0)
265- let $t01179811977 = swapOutput(direction, abs(_positionSize), false)
266- let currentNetMarketValue = $t01179811977._1
267- let terminalQuoteAssetReserve = $t01179811977._2
268- let terminalBaseAssetReserve = $t01179811977._3
265+ let $t01181711996 = swapOutput(direction, abs(_positionSize), false)
266+ let currentNetMarketValue = $t01181711996._1
267+ let terminalQuoteAssetReserve = $t01181711996._2
268+ let terminalBaseAssetReserve = $t01181711996._3
269269 $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve)
270270 }
271271 }
348348 let qtAstRAfter = (_qtAstR + _quoteAssetAmount)
349349 let baseAssetAmountToAdd = (divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR)
350350 let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd)
351- let $t01536215492 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
352- let newQuoteAssetWeight = $t01536215492._1
353- let newBaseAssetWeight = $t01536215492._2
351+ let $t01538115511 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
352+ let newQuoteAssetWeight = $t01538115511._1
353+ let newBaseAssetWeight = $t01538115511._2
354354 (updateAmmReserves(qtAstRAfter, bsAstRAfter) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight))
355355 }
356356
404404 else (i.caller != spotAddress()))
405405 then throw("Invalid swapToBase parameters")
406406 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
412413 let update = updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter)
413- $Tuple2(update, amountBaseAssetBought)
414+ $Tuple2(update, $Tuple2(amountBaseAssetBought, priceImpact))
414415 }
415416 else throw("Strict value is not equal to itself.")
416417 }
433434 else (i.caller != spotAddress()))
434435 then throw("Invalid swapToQuote parameters")
435436 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
440443 let totalPositionSizeAfter = (totalPositionSize() - _amount)
441444 let update = updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter)
442- $Tuple2(update, amountQuoteAssetBought)
445+ $Tuple2(update, $Tuple2(amountQuoteAssetBought, priceImpact))
443446 }
444447 else throw("Strict value is not equal to itself.")
445448 }
452455 func syncTerminalPriceToOracle () = {
453456 let _qtAstR = qtAstR()
454457 let _bsAstR = bsAstR()
455- let $t01954519661 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR)
456- let newQuoteAssetWeight = $t01954519661._1
457- let newBaseAssetWeight = $t01954519661._2
458+ let $t01964219758 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR)
459+ let newQuoteAssetWeight = $t01964219758._1
460+ let newBaseAssetWeight = $t01964219758._2
458461 updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)
459462 }
460463
475478
476479 @Callable(i)
477480 func view_getTerminalAmmPrice () = {
478- let $t02041520496 = getTerminalAmmState()
479- let terminalQuoteAssetReserve = $t02041520496._1
480- let terminalBaseAssetReserve = $t02041520496._2
481+ let $t02051220593 = getTerminalAmmState()
482+ let terminalQuoteAssetReserve = $t02051220593._1
483+ let terminalBaseAssetReserve = $t02051220593._2
481484 let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
482485 throw(toString(price))
483486 }
489492 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
490493 if ((sync == sync))
491494 then {
492- let $t02081620897 = getTerminalAmmState()
493- let terminalQuoteAssetReserve = $t02081620897._1
494- let terminalBaseAssetReserve = $t02081620897._2
495+ let $t02091320994 = getTerminalAmmState()
496+ let terminalQuoteAssetReserve = $t02091320994._1
497+ let terminalBaseAssetReserve = $t02091320994._2
495498 let terminalPrice = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
496499 let spotPrice = getSpotPrice()
497500 throw(((toString(terminalPrice) + ",") + toString(spotPrice)))
516519
517520 @Callable(i)
518521 func computeTerminalAmmPrice () = {
519- let $t02164821729 = getTerminalAmmState()
520- let terminalQuoteAssetReserve = $t02164821729._1
521- let terminalBaseAssetReserve = $t02164821729._2
522+ let $t02174521826 = getTerminalAmmState()
523+ let terminalQuoteAssetReserve = $t02174521826._1
524+ let terminalBaseAssetReserve = $t02174521826._2
522525 let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
523526 $Tuple2(nil, price)
524527 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_baseOracle = "k_baseOracle"
55
66 let k_initialized = "k_initialized"
77
88 let k_paused = "k_paused"
99
1010 let k_fee = "k_fee"
1111
1212 let k_maxPriceImpact = "k_maxPriceImpact"
1313
1414 let k_maxPriceSpread = "k_maxPriceSpread"
1515
1616 let k_maxOracleDelay = "k_maxOracleDelay"
1717
1818 let k_quoteAssetReserve = "k_qtAstR"
1919
2020 let k_baseAssetReserve = "k_bsAstR"
2121
2222 let k_quoteAssetWeight = "k_qtAstW"
2323
2424 let k_baseAssetWeight = "k_bsAstW"
2525
2626 let k_totalPositionSize = "k_totalPositionSize"
2727
2828 let k_lastTx = "k_lastTx"
2929
3030 let k_coordinatorAddress = "k_coordinatorAddress"
3131
3232 let k_vault_address = "k_vault_address"
3333
3434 let k_admin_address = "k_admin_address"
3535
3636 let k_quote_asset = "k_quote_asset"
3737
3838 let k_spot_address = "k_spot_address"
3939
4040 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
4141
4242
4343 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
4444
4545
4646 func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
4747
4848
4949 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
5050
5151
5252 func spotAddress () = addressFromString(valueOrErrorMessage(getString(coordinator(), k_spot_address), "Spot address not set"))
5353
5454
5555 let DECIMAL_NUMBERS = 6
5656
5757 let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10))
5858
5959 func s (_x) = (toString(_x) + ",")
6060
6161
6262 func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
6363
6464
6565 func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
6666
6767
6868 func bdivd (_x,_y) = fraction(_x, toBigInt(DECIMAL_UNIT), _y, HALFEVEN)
6969
7070
7171 func bmuld (_x,_y) = fraction(_x, _y, toBigInt(DECIMAL_UNIT), HALFEVEN)
7272
7373
7474 func abs (_x) = if ((_x > 0))
7575 then _x
7676 else -(_x)
7777
7878
7979 func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
8080
8181
8282 func intOr (k,def) = valueOrElse(getInteger(this, k), def)
8383
8484
8585 func intA (_address,_key) = {
8686 let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key))
8787 val
8888 }
8989
9090
9191 func fee () = int(k_fee)
9292
9393
9494 func qtAstR () = int(k_quoteAssetReserve)
9595
9696
9797 func bsAstR () = int(k_baseAssetReserve)
9898
9999
100100 func qtAstW () = intOr(k_quoteAssetWeight, DECIMAL_UNIT)
101101
102102
103103 func bsAstW () = intOr(k_baseAssetWeight, DECIMAL_UNIT)
104104
105105
106106 func totalPositionSize () = int(k_totalPositionSize)
107107
108108
109109 func maxPriceImpact () = int(k_maxPriceImpact)
110110
111111
112112 func maxPriceSpread () = int(k_maxPriceSpread)
113113
114114
115115 func maxOracleDelay () = int(k_maxOracleDelay)
116116
117117
118118 func lastTimestamp () = lastBlock.timestamp
119119
120120
121121 func getOracleData (key) = {
122122 let oracleDataStr = getString(this, key)
123123 if (if (isDefined(oracleDataStr))
124124 then (value(oracleDataStr) != "")
125125 else false)
126126 then {
127127 let oracleData = split(value(oracleDataStr), ",")
128128 let oracleAddress = valueOrErrorMessage(addressFromString(oracleData[0]), ("Invalid oracle address in: " + value(oracleDataStr)))
129129 let priceKey = oracleData[1]
130130 let blockKey = oracleData[2]
131131 let openKey = oracleData[3]
132132 $Tuple4(oracleAddress, priceKey, blockKey, openKey)
133133 }
134134 else unit
135135 }
136136
137137
138138 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
139139
140140
141141 func paused () = valueOrElse(getBoolean(this, k_paused), false)
142142
143143
144144 func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd)
145145 then {
146146 let newBase = (bsAstR() - _baseAssetAmount)
147147 if ((0 >= newBase))
148148 then throw("Tx lead to base asset reserve <= 0, revert")
149149 else $Tuple3((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount))
150150 }
151151 else {
152152 let newQuote = (qtAstR() - _quoteAssetAmount)
153153 if ((0 >= newQuote))
154154 then throw("Tx lead to base quote reserve <= 0, revert")
155155 else $Tuple3(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount))
156156 }
157157
158158
159159 func calcInvariant (_qtAstR,_bsAstR) = {
160160 let bqtAstR = toBigInt(_qtAstR)
161161 let bbsAstR = toBigInt(_bsAstR)
162162 bmuld(bqtAstR, bbsAstR)
163163 }
164164
165165
166166 func swapInput (_isAdd,_quoteAssetAmount) = {
167167 let _qtAstR = qtAstR()
168168 let _bsAstR = bsAstR()
169169 let _qtAstW = qtAstW()
170170 let _bsAstW = bsAstW()
171171 let quoteAssetAmountAdjusted = divd(_quoteAssetAmount, _qtAstW)
172172 let k = calcInvariant(_qtAstR, _bsAstR)
173173 let quoteAssetReserveAfter = if (_isAdd)
174174 then (_qtAstR + quoteAssetAmountAdjusted)
175175 else (_qtAstR - quoteAssetAmountAdjusted)
176176 let baseAssetReserveAfter = toInt(bdivd(k, toBigInt(quoteAssetReserveAfter)))
177177 let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR))
178178 let amountBaseAssetBought = if (_isAdd)
179179 then amountBaseAssetBoughtAbs
180180 else -(amountBaseAssetBoughtAbs)
181181 let $t064036573 = updateReserve(_isAdd, quoteAssetAmountAdjusted, amountBaseAssetBoughtAbs)
182182 let quoteAssetReserveAfter1 = $t064036573._1
183183 let baseAssetReserveAfter1 = $t064036573._2
184184 let totalPositionSizeAfter1 = $t064036573._3
185185 let priceBefore = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
186186 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
187187 let priceDiff = abs((priceBefore - marketPrice))
188188 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
189189 let maxPriceImpactValue = maxPriceImpact()
190190 if ((priceImpact > maxPriceImpactValue))
191191 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 $Tuple4(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1)
192+ else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, priceImpact)
193193 }
194194
195195
196196 func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight) = {
197197 let priceBefore = divd(muld(_quoteAssetReserve, _quoteAssetWeight), muld(_baseAssetReserve, _baseAssetWeight))
198198 if ((_baseAssetAmount == 0))
199199 then throw("Invalid base asset amount")
200200 else {
201201 let k = calcInvariant(_quoteAssetReserve, _baseAssetReserve)
202202 let baseAssetPoolAmountAfter = if (_isAdd)
203203 then (_baseAssetReserve + _baseAssetAmount)
204204 else (_baseAssetReserve - _baseAssetAmount)
205205 let quoteAssetAfter = toInt(bdivd(k, toBigInt(baseAssetPoolAmountAfter)))
206206 let quoteAssetDelta = abs((quoteAssetAfter - _quoteAssetReserve))
207207 let quoteAssetSold = muld(quoteAssetDelta, _quoteAssetWeight)
208208 let maxPriceImpactValue = maxPriceImpact()
209- let $t086888850 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount)
210- let quoteAssetReserveAfter1 = $t086888850._1
211- let baseAssetReserveAfter1 = $t086888850._2
212- let totalPositionSizeAfter1 = $t086888850._3
209+ let $t087078869 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount)
210+ let quoteAssetReserveAfter1 = $t087078869._1
211+ let baseAssetReserveAfter1 = $t087078869._2
212+ let totalPositionSizeAfter1 = $t087078869._3
213213 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
214214 let priceDiff = abs((priceBefore - marketPrice))
215215 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
216216 if (if ((priceImpact > maxPriceImpactValue))
217217 then _checkMaxPriceImpact
218218 else false)
219219 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)))
220220 else $Tuple5(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, priceImpact)
221221 }
222222 }
223223
224224
225225 func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), qtAstW(), bsAstR(), bsAstW())
226226
227227
228228 func getOraclePriceValue (oracle,priceKey,blockKey) = {
229229 let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey))
230230 if ((blockKey != ""))
231231 then {
232232 let currentBlock = lastBlock.height
233233 let lastOracleBlock = valueOrErrorMessage(getInteger(oracle, blockKey), ((("Can not get oracle block. Oracle: " + toString(oracle)) + " key: ") + blockKey))
234234 if (((currentBlock - lastOracleBlock) > maxOracleDelay()))
235235 then throw(((("Oracle stale data. Last oracle block: " + toString(lastOracleBlock)) + " current block: ") + toString(currentBlock)))
236236 else lastValue
237237 }
238238 else lastValue
239239 }
240240
241241
242242 func getOraclePrice () = {
243243 let baseOracle = valueOrErrorMessage(getOracleData(k_baseOracle), "No base asset oracle data")
244244 let baseOraclePrice = getOraclePriceValue(baseOracle._1, baseOracle._2, baseOracle._3)
245245 let quoteOraclePrice = DECIMAL_UNIT
246246 divd(baseOraclePrice, quoteOraclePrice)
247247 }
248248
249249
250250 func getSpotPrice () = {
251251 let _quoteAssetReserve = qtAstR()
252252 let _baseAssetReserve = bsAstR()
253253 let _qtAstW = qtAstW()
254254 let _bsAstW = bsAstW()
255255 divd(muld(_quoteAssetReserve, _qtAstW), muld(_baseAssetReserve, _bsAstW))
256256 }
257257
258258
259259 func getTerminalAmmState () = {
260260 let _positionSize = totalPositionSize()
261261 if ((_positionSize == 0))
262262 then $Tuple2(qtAstR(), bsAstR())
263263 else {
264264 let direction = (_positionSize > 0)
265- let $t01179811977 = swapOutput(direction, abs(_positionSize), false)
266- let currentNetMarketValue = $t01179811977._1
267- let terminalQuoteAssetReserve = $t01179811977._2
268- let terminalBaseAssetReserve = $t01179811977._3
265+ let $t01181711996 = swapOutput(direction, abs(_positionSize), false)
266+ let currentNetMarketValue = $t01181711996._1
267+ let terminalQuoteAssetReserve = $t01181711996._2
268+ let terminalBaseAssetReserve = $t01181711996._3
269269 $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve)
270270 }
271271 }
272272
273273
274274 func getQuoteAssetWeight (baseAssetReserve,totalPositionSize,quoteAssetReserve,targetPrice) = {
275275 let b = toBigInt(baseAssetReserve)
276276 let sz = toBigInt(totalPositionSize)
277277 let q = toBigInt(quoteAssetReserve)
278278 let p = toBigInt(targetPrice)
279279 let k = bmuld(q, b)
280280 let newB = (b + sz)
281281 let newQ = bdivd(k, newB)
282282 let z = bdivd(newQ, newB)
283283 let result = bdivd(p, z)
284284 toInt(result)
285285 }
286286
287287
288288 func getSyncTerminalPrice (_terminalPrice,_qtAstR,_bsAstR) = {
289289 let _positionSize = totalPositionSize()
290290 if ((_positionSize == 0))
291291 then {
292292 let newQtAstW = divd(muld(_terminalPrice, _bsAstR), _qtAstR)
293293 $Tuple2(newQtAstW, DECIMAL_UNIT)
294294 }
295295 else {
296296 let newQtAstW = getQuoteAssetWeight(_bsAstR, _positionSize, _qtAstR, _terminalPrice)
297297 let newBsAstW = DECIMAL_UNIT
298298 $Tuple2(newQtAstW, newBsAstW)
299299 }
300300 }
301301
302302
303303 func updateSettings (_maxPriceImpact,_maxPriceSpread,_maxOracleDelay) = [IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOracleDelay, _maxOracleDelay)]
304304
305305
306306 func updateAmmReserves (_qtAstR,_bsAstR) = if (if ((0 >= _qtAstR))
307307 then true
308308 else (0 >= _bsAstR))
309309 then throw("Can not updateAmmReserves: _qtAstR <= 0 || _bsAstR <= 0")
310310 else [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)]
311311
312312
313313 func updateAmmWeights (_qtAstW,_bsAstW) = [IntegerEntry(k_quoteAssetWeight, _qtAstW), IntegerEntry(k_baseAssetWeight, _bsAstW)]
314314
315315
316316 func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter) = {
317317 let _qtAstW = qtAstW()
318318 let _bsAstW = bsAstW()
319319 (updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter)])
320320 }
321321
322322
323323 @Callable(i)
324324 func pause () = if ((i.caller != adminAddress()))
325325 then throw("Invalid pause params")
326326 else [BooleanEntry(k_paused, true)]
327327
328328
329329
330330 @Callable(i)
331331 func unpause () = if ((i.caller != adminAddress()))
332332 then throw("Invalid unpause params")
333333 else [BooleanEntry(k_paused, false)]
334334
335335
336336
337337 @Callable(i)
338338 func changeLiquidity (_quoteAssetAmount) = if (!(if ((i.caller == spotAddress()))
339339 then true
340340 else (i.caller == adminAddress())))
341341 then throw("Invalid changeLiquidity params")
342342 else {
343343 let _qtAstR = qtAstR()
344344 let _bsAstR = bsAstR()
345345 let _qtAstW = qtAstW()
346346 let _bsAstW = bsAstW()
347347 let price = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
348348 let qtAstRAfter = (_qtAstR + _quoteAssetAmount)
349349 let baseAssetAmountToAdd = (divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR)
350350 let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd)
351- let $t01536215492 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
352- let newQuoteAssetWeight = $t01536215492._1
353- let newBaseAssetWeight = $t01536215492._2
351+ let $t01538115511 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
352+ let newQuoteAssetWeight = $t01538115511._1
353+ let newBaseAssetWeight = $t01538115511._2
354354 (updateAmmReserves(qtAstRAfter, bsAstRAfter) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight))
355355 }
356356
357357
358358
359359 @Callable(i)
360360 func changeSettings (_maxPriceImpact,_maxPriceSpread,_maxOracleDelay) = if (if (if (if (if ((0 >= _maxPriceImpact))
361361 then true
362362 else (0 >= _maxPriceSpread))
363363 then true
364364 else (0 >= _maxOracleDelay))
365365 then true
366366 else !(initialized()))
367367 then true
368368 else (i.caller != adminAddress()))
369369 then throw("Invalid changeSettings params")
370370 else updateSettings(_maxPriceImpact, _maxPriceSpread, _maxOracleDelay)
371371
372372
373373
374374 @Callable(i)
375375 func initialize (_qtAstR,_bsAstR,_baseOracleData,_coordinator,_maxPriceImpact,_maxPriceSpread,_maxOracleDelay) = if (if (if (if (if (if (if ((0 >= _qtAstR))
376376 then true
377377 else (0 >= _bsAstR))
378378 then true
379379 else (0 >= _maxPriceImpact))
380380 then true
381381 else (0 >= _maxPriceSpread))
382382 then true
383383 else (0 >= _maxOracleDelay))
384384 then true
385385 else initialized())
386386 then true
387387 else (i.caller != this))
388388 then throw("Invalid initialize parameters")
389389 else ((updateAmm(_qtAstR, _bsAstR, 0) ++ updateSettings(_maxPriceImpact, _maxPriceSpread, _maxOracleDelay)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))])
390390
391391
392392
393393 @Callable(i)
394394 func swapToBase (_amount,_minBaseAssetAmount) = {
395395 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
396396 if ((sync == sync))
397397 then {
398398 let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil)
399399 if ((ensureCalledOnce == ensureCalledOnce))
400400 then if (if (if (!(initialized()))
401401 then true
402402 else paused())
403403 then true
404404 else (i.caller != spotAddress()))
405405 then throw("Invalid swapToBase parameters")
406406 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
412413 let update = updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter)
413- $Tuple2(update, amountBaseAssetBought)
414+ $Tuple2(update, $Tuple2(amountBaseAssetBought, priceImpact))
414415 }
415416 else throw("Strict value is not equal to itself.")
416417 }
417418 else throw("Strict value is not equal to itself.")
418419 }
419420
420421
421422
422423 @Callable(i)
423424 func swapToQuote (_amount,_minQuoteAssetAmount) = {
424425 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
425426 if ((sync == sync))
426427 then {
427428 let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil)
428429 if ((ensureCalledOnce == ensureCalledOnce))
429430 then if (if (if (!(initialized()))
430431 then true
431432 else paused())
432433 then true
433434 else (i.caller != spotAddress()))
434435 then throw("Invalid swapToQuote parameters")
435436 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
440443 let totalPositionSizeAfter = (totalPositionSize() - _amount)
441444 let update = updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter)
442- $Tuple2(update, amountQuoteAssetBought)
445+ $Tuple2(update, $Tuple2(amountQuoteAssetBought, priceImpact))
443446 }
444447 else throw("Strict value is not equal to itself.")
445448 }
446449 else throw("Strict value is not equal to itself.")
447450 }
448451
449452
450453
451454 @Callable(i)
452455 func syncTerminalPriceToOracle () = {
453456 let _qtAstR = qtAstR()
454457 let _bsAstR = bsAstR()
455- let $t01954519661 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR)
456- let newQuoteAssetWeight = $t01954519661._1
457- let newBaseAssetWeight = $t01954519661._2
458+ let $t01964219758 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR)
459+ let newQuoteAssetWeight = $t01964219758._1
460+ let newBaseAssetWeight = $t01964219758._2
458461 updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)
459462 }
460463
461464
462465
463466 @Callable(i)
464467 func ensureCalledOnce () = if ((i.caller != this))
465468 then throw("Invalid saveCurrentTxId parameters")
466469 else {
467470 let txId = toBase58String(i.transactionId)
468471 let lastTx = valueOrElse(getString(this, k_lastTx), "")
469472 if ((lastTx != txId))
470473 then [StringEntry(k_lastTx, txId)]
471474 else throw("Can not call vAMM methods twice in one tx")
472475 }
473476
474477
475478
476479 @Callable(i)
477480 func view_getTerminalAmmPrice () = {
478- let $t02041520496 = getTerminalAmmState()
479- let terminalQuoteAssetReserve = $t02041520496._1
480- let terminalBaseAssetReserve = $t02041520496._2
481+ let $t02051220593 = getTerminalAmmState()
482+ let terminalQuoteAssetReserve = $t02051220593._1
483+ let terminalBaseAssetReserve = $t02051220593._2
481484 let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
482485 throw(toString(price))
483486 }
484487
485488
486489
487490 @Callable(i)
488491 func view_getPrices () = {
489492 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
490493 if ((sync == sync))
491494 then {
492- let $t02081620897 = getTerminalAmmState()
493- let terminalQuoteAssetReserve = $t02081620897._1
494- let terminalBaseAssetReserve = $t02081620897._2
495+ let $t02091320994 = getTerminalAmmState()
496+ let terminalQuoteAssetReserve = $t02091320994._1
497+ let terminalBaseAssetReserve = $t02091320994._2
495498 let terminalPrice = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
496499 let spotPrice = getSpotPrice()
497500 throw(((toString(terminalPrice) + ",") + toString(spotPrice)))
498501 }
499502 else throw("Strict value is not equal to itself.")
500503 }
501504
502505
503506
504507 @Callable(i)
505508 func computeSpotPrice () = {
506509 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
507510 if ((sync == sync))
508511 then {
509512 let result = getSpotPrice()
510513 $Tuple2(nil, result)
511514 }
512515 else throw("Strict value is not equal to itself.")
513516 }
514517
515518
516519
517520 @Callable(i)
518521 func computeTerminalAmmPrice () = {
519- let $t02164821729 = getTerminalAmmState()
520- let terminalQuoteAssetReserve = $t02164821729._1
521- let terminalBaseAssetReserve = $t02164821729._2
522+ let $t02174521826 = getTerminalAmmState()
523+ let terminalQuoteAssetReserve = $t02174521826._1
524+ let terminalBaseAssetReserve = $t02174521826._2
522525 let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
523526 $Tuple2(nil, price)
524527 }
525528
526529
527530 @Verifier(tx)
528531 func verify () = {
529532 let coordinatorStr = getString(this, k_coordinatorAddress)
530533 if (isDefined(coordinatorStr))
531534 then {
532535 let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
533536 if (isDefined(admin))
534537 then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
535538 else throw("unable to verify: admin not set in coordinator")
536539 }
537540 else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
538541 }
539542

github/deemru/w8io/026f985 
76.61 ms