tx · D8kuC3QNL1qjdaTHdEtyw8LuhBLPfQFvJ1Vf1MPGmBmz

3MyBf8rGo9HC6bAB4vZ18iL9QaJYL7Q1xVM:  -0.01400000 Waves

2021.10.07 13:39 [1735703] smart account 3MyBf8rGo9HC6bAB4vZ18iL9QaJYL7Q1xVM > SELF 0.00000000 Waves

{ "type": 13, "id": "D8kuC3QNL1qjdaTHdEtyw8LuhBLPfQFvJ1Vf1MPGmBmz", "fee": 1400000, "feeAssetId": null, "timestamp": 1633603248277, "version": 1, "sender": "3MyBf8rGo9HC6bAB4vZ18iL9QaJYL7Q1xVM", "senderPublicKey": "FsSGFph7Y6SYdi3n3F5UddoKEYWyMrJAqiKV8t9qqgqB", "proofs": [ "ncKaHsoBFF82vRbGFhastmxpEyodtdWb7GvtNdXywvGY1s4zHyGiaDsijvBzLgyW2qjgzkTknF8jSbVu42vUdTh" ], "script": "base64:AAIFAAAAAAAAADUIAhIECgIICBIECgIBBBIAEgASBAoCAQESBAoCCAgSABIFCgMBAQgSBQoDAQEIEgUKAwgBCAAAADwAAAAACmxQZGVjaW1hbHMAAAAAAAAAAAgAAAAABnNjYWxlOAAAAAAABfXhAAAAAAAMc2NhbGU4QmlnSW50CQABNgAAAAEAAAAAAAX14QAAAAAAB3NjYWxlMTgJAAE2AAAAAQAN4Lazp2QAAAAAAAADU0VQAgAAAAJfXwAAAAAFRU1QVFkCAAAAAAAAAAAKUG9vbEFjdGl2ZQAAAAAAAAAAAQAAAAAPUG9vbFB1dERpc2FibGVkAAAAAAAAAAACAAAAABNQb29sTWF0Y2hlckRpc2FibGVkAAAAAAAAAAADAAAAAAxQb29sU2h1dGRvd24AAAAAAAAAAAQAAAAADmlkeFBvb2xBZGRyZXNzAAAAAAAAAAABAAAAAA1pZHhQb29sU3RhdHVzAAAAAAAAAAACAAAAABBpZHhQb29sTFBBc3NldElkAAAAAAAAAAADAAAAAA1pZHhBbXRBc3NldElkAAAAAAAAAAAEAAAAAA9pZHhQcmljZUFzc2V0SWQ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AAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkHBAAAAA1tYW5hZ2VyUHVibGljCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMJAQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAUAAAAFRU1QVFkDCQAAAAAAAAIFAAAADW1hbmFnZXJQdWJsaWMFAAAABUVNUFRZCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAJAAJZAAAAAQUAAAANbWFuYWdlclB1YmxpY8sQnDc=", "chainId": 84, "height": 1735703, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GzmJ9HYrugLQxeK98DgNvP7J5p6iJk5antqS5EXJDPNi Next: CnswSUY9aK9BFMs4cZgtmCWHqoTvY1PPHJShcNFVLxAY Diff:
OldNewDifferences
1010 let scale18 = toBigInt(1000000000000000000)
1111
1212 let SEP = "__"
13+
14+let EMPTY = ""
1315
1416 let PoolActive = 1
1517
2527
2628 let idxPoolLPAssetId = 3
2729
28-let idxAmountAssetId = 4
30+let idxAmtAssetId = 4
2931
3032 let idxPriceAssetId = 5
3133
32-let idxAmountAssetDecimals = 6
34+let idxAmtAssetDcm = 6
3335
34-let idxPriceAssetDecimals = 7
36+let idxPriceAssetDcm = 7
3537
36-let idxAmountAssetInternalId = 8
38+let idxIAmtAssetId = 8
3739
38-let idxPriceAssetInternalId = 9
40+let idxIPriceAssetId = 9
3941
40-let idxLPAssetDecimals = 10
42+let idxLPAssetDcm = 10
4143
42-let idxMatcherPublicKey = 11
43-
44-let idxPoolAmountAssetAmt = 1
44+let idxPoolAmtAssetAmt = 1
4545
4646 let idxPoolPriceAssetAmt = 2
4747
4949
5050 let idxFactoryStakingContract = 1
5151
52-let idxFactoryBoostingConfig = 2
52+let idxFactorySlippageContract = 7
53+
54+func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
55+
56+
57+func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
58+
59+
60+func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
61+
5362
5463 func keyFactoryContract () = "%s__factoryContract"
64+
65+
66+func keyManagerPublicKey () = "%s__managerPublicKey"
5567
5668
5769 func keyPriceLast () = "%s%s__price__last"
6072 func keyPriceHistory (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
6173
6274
63-func keyPoolLiquidity (internalAmountAsset,internalPriceAsset) = (((("%d%d%s__" + internalAmountAsset) + "__") + internalPriceAsset) + "__locked")
64-
65-
6675 func keyPutActionByUser (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
6776
6877
6978 func keyGetActionByUser (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
7079
7180
72-func keyAmountAsset () = "%s__amountAsset"
81+func keyAmtAsset () = "%s__amountAsset"
7382
7483
7584 func keyPriceAsset () = "%s__priceAsset"
76-
77-
78-func keyKCurrent () = "%s%s__K_current"
7985
8086
8187 func keyKHistoric (h,timestamp) = makeString(["%s%s%d%d__K_history", toString(h), toString(timestamp)], SEP)
8793 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
8894
8995
90-func keyPoolConfig (amountAssetInternal,priceAssetInternal) = (((("%d%d%s__" + amountAssetInternal) + "__") + priceAssetInternal) + "__config")
96+func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
9197
9298
9399 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
99105 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
100106
101107
102-let factoryContract = addressFromStringValue(valueOrErrorMessage(getString(this, keyFactoryContract()), "No Factory Account found."))
108+func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
109+
110+
111+func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
112+
113+
114+let factoryContract = addressFromStringValue(getStringOrFail(this, keyFactoryContract()))
103115
104116 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
105117
106118
107119 func getPoolConfig () = {
108- let poolAmountAsset = valueOrErrorMessage(getString(this, keyAmountAsset()), "No config for amount asset found")
109- let poolPriceAsset = valueOrErrorMessage(getString(this, keyPriceAsset()), "No config for price asset found")
110- let poolPriceAssetInternal = valueOrErrorMessage(getInteger(factoryContract, keyMappingsBaseAsset2internalId(poolPriceAsset)), "No config for internal price asset found")
111- let poolAmountAssetInternal = valueOrErrorMessage(getInteger(factoryContract, keyMappingsBaseAsset2internalId(poolAmountAsset)), "No config for internal amount asset found")
112- split(valueOrErrorMessage(getString(factoryContract, keyPoolConfig(toString(poolAmountAssetInternal), toString(poolPriceAssetInternal))), "No factory config found for pool assets."), SEP)
120+ let amtAsset = getStringOrFail(this, keyAmtAsset())
121+ let priceAsset = getStringOrFail(this, keyPriceAsset())
122+ let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
123+ let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
124+ split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
113125 }
114126
115127
116-func getFactoryConfig () = split(valueOrErrorMessage(getString(factoryContract, keyFactoryConfig()), "No factory config found."), SEP)
128+func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
117129
118130
119-func getPoolLiquidity (amountAssetInternalId,priceAssetInternalId) = {
120- let currentPoolLiquidityValue = getString(this, keyPoolLiquidity(amountAssetInternalId, priceAssetInternalId))
121- if (isDefined(currentPoolLiquidityValue))
122- then split(value(currentPoolLiquidityValue), SEP)
123- else ["", "0", "0", "0"]
124- }
131+func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP)
125132
126133
127-func dataPoolLiquidity (amountAssetLocked,priceAssetLocked,lpTokenLocked) = makeString(["%d%d%d", toString(amountAssetLocked), toString(priceAssetLocked), toString(lpTokenLocked)], SEP)
134+func dataGetActionInfo (outAmtAssetAmt,outPriceAssetAmt,inLpAmt,price,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d", toString(outAmtAssetAmt), toString(outPriceAssetAmt), toString(inLpAmt), toString(price), toString(txHeight), toString(txTimestamp)], SEP)
128135
129136
130-func dataPutActionInfo (inAmountAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d%d", toString(inAmountAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp)], SEP)
131-
132-
133-func dataGetActionInfo (outAmountAssetAmt,outPriceAssetAmt,inLpAmt,price,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d", toString(outAmountAssetAmt), toString(outPriceAssetAmt), toString(inLpAmt), toString(price), toString(txHeight), toString(txTimestamp)], SEP)
134-
135-
136-func privateCastToScaleOf (amount,resultScale,currentScale) = fraction(amount, resultScale, currentScale)
137-
138-
139-func privateBigIntCastToScaleOf (amount,resultScale,currentScale) = fraction(amount, resultScale, currentScale)
140-
141-
142-func calculatePrice (priceAssetLockedAmt,amountAssetlLockedAmt) = fraction(priceAssetLockedAmt, scale8, amountAssetlLockedAmt)
143-
144-
145-func calculatePriceBigInt (priceAssetLockedAmt,amountAssetlLockedAmt) = toInt(fraction(priceAssetLockedAmt, scale8BigInt, amountAssetlLockedAmt))
146-
147-
148-func privateCalculatePrice (amoutAssetDecimals,priceAssetDecimals,amountAssetAmt,priceAssetAmt) = {
149- let amountAssetAmtCasted = privateCastToScaleOf(amountAssetAmt, scale8, amoutAssetDecimals)
150- let priceAssetAmtCasted = privateCastToScaleOf(priceAssetAmt, scale8, priceAssetDecimals)
151- calculatePrice(priceAssetAmtCasted, amountAssetAmtCasted)
152- }
153-
154-
155-func privateGetAccountBalance (assetId) = if ((assetId == "WAVES"))
137+func getAccBalance (assetId) = if ((assetId == "WAVES"))
156138 then wavesBalance(this).available
157139 else assetBalance(this, fromBase58String(assetId))
158140
159141
160-func calculatePrices (amountAssetAmt,priceAssetAmt,lpAmount) = {
161- let poolConfigDataList = getPoolConfig()
162- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
163- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
164- let poolPrice = privateCalculatePrice(amoutAssetDecimals, priceAssetDecimals, amountAssetAmt, priceAssetAmt)
165- let amountAssetPoolLockedAmt = privateCastToScaleOf(amountAssetAmt, scale8, amoutAssetDecimals)
166- let priceAssetPoolLockedAmt = privateCastToScaleOf(priceAssetAmt, scale8, priceAssetDecimals)
167- let lpPriceInAmountAsset = calculatePrice(amountAssetPoolLockedAmt, lpAmount)
168- let lpPriceInPriceAsset = calculatePrice(priceAssetPoolLockedAmt, lpAmount)
169-[poolPrice, lpPriceInAmountAsset, lpPriceInPriceAsset]
142+func calcPriceBigInt (priceAssetLockedAmt,amtAssetlLockedAmt,resultScale) = fraction(priceAssetLockedAmt, resultScale, amtAssetlLockedAmt)
143+
144+
145+func privateCalcPrice (amtAssetDcm,priceAssetDcm,amtAssetAmt,priceAssetAmt) = {
146+ let amtAssetAmtX18 = toX18(amtAssetAmt, amtAssetDcm)
147+ let priceAssetAmtX18 = toX18(priceAssetAmt, priceAssetDcm)
148+ toInt(calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18, scale8BigInt))
170149 }
171150
172151
173-func privateEstimateGetOperation (paymentLpAssetId,paymentLpAmount,userAddress) = {
152+func calcPrices (amtAssetAmt,priceAssetAmt,lpAmt) = {
153+ let cfg = getPoolConfig()
154+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
155+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
156+ let poolPrice = privateCalcPrice(amtAssetDcm, priceAssetDcm, amtAssetAmt, priceAssetAmt)
157+ let amtAssetAmtX18 = toX18(amtAssetAmt, amtAssetDcm)
158+ let priceAssetAmtX18 = toX18(priceAssetAmt, priceAssetDcm)
159+ let lpAmtX18 = toX18(lpAmt, scale8)
160+ let lpPriceInAmtAsset = toInt(calcPriceBigInt(amtAssetAmtX18, lpAmtX18, scale8BigInt))
161+ let lpPriceInPriceAsset = toInt(calcPriceBigInt(priceAssetAmtX18, lpAmtX18, scale8BigInt))
162+[poolPrice, lpPriceInAmtAsset, lpPriceInPriceAsset]
163+ }
164+
165+
166+func estimateGetOperation (paymentLpAssetId,paymentLpAmt,userAddress) = {
174167 let poolConfigList = getPoolConfig()
175168 let lpAssetId = poolConfigList[idxPoolLPAssetId]
176- let amountAssetId = poolConfigList[idxAmountAssetId]
169+ let amtAssetId = poolConfigList[idxAmtAssetId]
177170 let priceAssetId = poolConfigList[idxPriceAssetId]
178- let amountAssetInternalId = poolConfigList[idxAmountAssetInternalId]
179- let priceAssetInternalId = poolConfigList[idxPriceAssetInternalId]
180- let amoutAssetDecimals = parseIntValue(poolConfigList[idxAmountAssetDecimals])
181- let priceAssetDecimals = parseIntValue(poolConfigList[idxPriceAssetDecimals])
171+ let iAmtAssetId = poolConfigList[idxIAmtAssetId]
172+ let iPriceAssetId = poolConfigList[idxIPriceAssetId]
173+ let amtAssetDcm = parseIntValue(poolConfigList[idxAmtAssetDcm])
174+ let priceAssetDcm = parseIntValue(poolConfigList[idxPriceAssetDcm])
182175 let poolStatus = poolConfigList[idxPoolStatus]
183- let poolLiquidityList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
184- let poolLPBalance = parseIntValue(poolLiquidityList[idxPoolLPAssetAmt])
185- let poolAmountAssetBalance = parseIntValue(poolLiquidityList[idxPoolAmountAssetAmt])
186- let poolPriceAssetBalance = parseIntValue(poolLiquidityList[idxPoolPriceAssetAmt])
176+ let poolLPBalance = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
187177 if ((lpAssetId != paymentLpAssetId))
188178 then throw("Invalid asset passed.")
189179 else {
190- let amountAssetPoolLockedAmt = privateBigIntCastToScaleOf(toBigInt(privateGetAccountBalance(amountAssetId)), scale18, toBigInt(amoutAssetDecimals))
191- let priceAssetPoolLockedAmt = privateBigIntCastToScaleOf(toBigInt(privateGetAccountBalance(priceAssetId)), scale18, toBigInt(priceAssetDecimals))
192- let currentPrice = calculatePriceBigInt(priceAssetPoolLockedAmt, amountAssetPoolLockedAmt)
193- let paymentLpAmountBuf = privateBigIntCastToScaleOf(toBigInt(paymentLpAmount), scale18, scale8BigInt)
194- let poolLPBalanceBuf = privateBigIntCastToScaleOf(toBigInt(poolLPBalance), scale18, scale8BigInt)
195- let outAmountAssetAmt = fraction(amountAssetPoolLockedAmt, paymentLpAmountBuf, poolLPBalanceBuf)
196- let outPriceAssetAmt = fraction(priceAssetPoolLockedAmt, paymentLpAmountBuf, poolLPBalanceBuf)
197- let outAmountAssetAmtFinal = toInt(privateBigIntCastToScaleOf(outAmountAssetAmt, toBigInt(amoutAssetDecimals), scale18))
198- let outPriceAssetAmtFinal = toInt(privateBigIntCastToScaleOf(outPriceAssetAmt, toBigInt(priceAssetDecimals), scale18))
199- $Tuple11(outAmountAssetAmtFinal, outPriceAssetAmtFinal, amountAssetInternalId, priceAssetInternalId, amountAssetId, priceAssetId, poolAmountAssetBalance, poolPriceAssetBalance, poolLPBalance, currentPrice, poolStatus)
180+ let amtAssetBalance = getAccBalance(amtAssetId)
181+ let amtAssetBalanceX18 = toX18(amtAssetBalance, amtAssetDcm)
182+ let priceAssetBalance = getAccBalance(priceAssetId)
183+ let priceAssetBalanceX18 = toX18(priceAssetBalance, priceAssetDcm)
184+ let curPrice = toInt(calcPriceBigInt(priceAssetBalanceX18, amtAssetBalanceX18, scale8BigInt))
185+ let paymentLpAmtX18 = toX18(paymentLpAmt, scale8)
186+ let poolLPBalanceX18 = toX18(poolLPBalance, scale8)
187+ let outAmtAssetAmt = fraction(amtAssetBalanceX18, paymentLpAmtX18, poolLPBalanceX18)
188+ let outPriceAssetAmt = fraction(priceAssetBalanceX18, paymentLpAmtX18, poolLPBalanceX18)
189+ let outAmtAssetAmtFinal = fromX18(outAmtAssetAmt, amtAssetDcm)
190+ let outPriceAssetAmtFinal = fromX18(outPriceAssetAmt, priceAssetDcm)
191+ $Tuple11(outAmtAssetAmtFinal, outPriceAssetAmtFinal, iAmtAssetId, iPriceAssetId, amtAssetId, priceAssetId, amtAssetBalance, priceAssetBalance, poolLPBalance, curPrice, poolStatus)
200192 }
201193 }
202194
203195
204-func privateEstimatePutOperation (slippageTolerance,inAmountAssetAmt,inAmountAssetId,inPriceAssetAmt,inPriceAssetId,userAddress,isEvaluate) = {
205- let poolConfigDataList = getPoolConfig()
206- let lpAssetId = fromBase58String(poolConfigDataList[idxPoolLPAssetId])
207- let amountAssetId = poolConfigDataList[idxAmountAssetId]
208- let priceAssetId = poolConfigDataList[idxPriceAssetId]
209- let amountAssetInternalId = poolConfigDataList[idxAmountAssetInternalId]
210- let priceAssetInternalId = poolConfigDataList[idxPriceAssetInternalId]
211- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
212- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
213- let poolStatus = poolConfigDataList[idxPoolStatus]
214- let poolLiquidityDataList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
215- let poolAmountAssetBalance = parseIntValue(poolLiquidityDataList[idxPoolAmountAssetAmt])
216- let poolPriceAssetBalance = parseIntValue(poolLiquidityDataList[idxPoolPriceAssetAmt])
217- let poolLPBalance = parseIntValue(poolLiquidityDataList[idxPoolLPAssetAmt])
218- if (if ((amountAssetId != inAmountAssetId))
196+func estimatePutOperation (slippageTolerance,inAmtAssetAmt,inAmtAssetId,inPriceAssetAmt,inPriceAssetId,userAddress,isEvaluate) = {
197+ let cfg = getPoolConfig()
198+ let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
199+ let amtAssetId = cfg[idxAmtAssetId]
200+ let priceAssetId = cfg[idxPriceAssetId]
201+ let iAmtAssetId = cfg[idxIAmtAssetId]
202+ let iPriceAssetId = cfg[idxIPriceAssetId]
203+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
204+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
205+ let poolStatus = cfg[idxPoolStatus]
206+ let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
207+ if (if ((amtAssetId != inAmtAssetId))
219208 then true
220209 else (priceAssetId != inPriceAssetId))
221- then throw("Invalid amount or price asset passed.")
210+ then throw("Invalid amt or price asset passed.")
222211 else {
223- let accountAmountAssetBalance = if (isEvaluate)
224- then privateGetAccountBalance(amountAssetId)
225- else (privateGetAccountBalance(amountAssetId) - inAmountAssetAmt)
226- let accountPriceAssetBalance = if (isEvaluate)
227- then privateGetAccountBalance(priceAssetId)
228- else (privateGetAccountBalance(priceAssetId) - inPriceAssetAmt)
229- let amoutAssetDecimalsBigInt = toBigInt(amoutAssetDecimals)
230- let priceAssetDecimalsBigInt = toBigInt(priceAssetDecimals)
231- let inAmountAssetAmtCalculated = privateBigIntCastToScaleOf(toBigInt(inAmountAssetAmt), scale18, amoutAssetDecimalsBigInt)
232- let inPriceAssetAmtCalculated = privateBigIntCastToScaleOf(toBigInt(inPriceAssetAmt), scale18, priceAssetDecimalsBigInt)
233- let userPrice = calculatePriceBigInt(inPriceAssetAmtCalculated, inAmountAssetAmtCalculated)
234- let amountAssetPoolLockedAmt = privateBigIntCastToScaleOf(toBigInt(accountAmountAssetBalance), scale18, amoutAssetDecimalsBigInt)
235- let priceAssetPoolLockedAmt = privateBigIntCastToScaleOf(toBigInt(accountPriceAssetBalance), scale18, priceAssetDecimalsBigInt)
236- let curentPrice = if ((poolLPBalance == 0))
212+ let accAmtAssetBalance = if (isEvaluate)
213+ then getAccBalance(amtAssetId)
214+ else (getAccBalance(amtAssetId) - inAmtAssetAmt)
215+ let accPriceAssetBalance = if (isEvaluate)
216+ then getAccBalance(priceAssetId)
217+ else (getAccBalance(priceAssetId) - inPriceAssetAmt)
218+ let inAmtAssetAmtX18 = toX18(inAmtAssetAmt, amtAssetDcm)
219+ let inPriceAssetAmtX18 = toX18(inPriceAssetAmt, priceAssetDcm)
220+ let userPrice = toInt(calcPriceBigInt(inPriceAssetAmtX18, inAmtAssetAmtX18, scale8BigInt))
221+ let accAmtAssetBalanceX18 = toX18(accAmtAssetBalance, amtAssetDcm)
222+ let accPriceAssetBalanceX18 = toX18(accPriceAssetBalance, priceAssetDcm)
223+ let curPrice = if ((poolLPBalance == 0))
237224 then 0
238- else calculatePriceBigInt(priceAssetPoolLockedAmt, amountAssetPoolLockedAmt)
239- let slippage = if ((curentPrice == 0))
225+ else toInt(calcPriceBigInt(accPriceAssetBalanceX18, accAmtAssetBalanceX18, scale8BigInt))
226+ let slippage = if ((curPrice == 0))
240227 then 0
241- else if ((curentPrice > userPrice))
242- then fraction((curentPrice - userPrice), 100, curentPrice)
243- else fraction((userPrice - curentPrice), 100, curentPrice)
244- if (if ((curentPrice != 0))
245- then ((slippage * scale8) > slippageTolerance)
228+ else if ((curPrice > userPrice))
229+ then fraction((curPrice - userPrice), scale8, curPrice)
230+ else fraction((userPrice - curPrice), scale8, curPrice)
231+ if (if ((curPrice != 0))
232+ then (slippage > slippageTolerance)
246233 else false)
247- then throw(((("Price slippage " + toString((slippage * scale8))) + " exceeded the passed limit of ") + toString(slippageTolerance)))
234+ then throw(((("Price slippage " + toString(slippage)) + " exceeded the passed limit of ") + toString(slippageTolerance)))
248235 else {
249- let finalPrice = calculatePriceBigInt((priceAssetPoolLockedAmt + inPriceAssetAmtCalculated), (amountAssetPoolLockedAmt + inAmountAssetAmtCalculated))
250- let outLpAmount = if ((poolLPBalance == 0))
236+ let res = if ((poolLPBalance == 0))
251237 then {
252- let lpResultBuf = pow((inAmountAssetAmtCalculated * inPriceAssetAmtCalculated), 0, toBigInt(5), 1, 0, DOWN)
253- toInt(privateBigIntCastToScaleOf(lpResultBuf, scale8BigInt, scale18))
238+ let lpResultBuf = pow((inAmtAssetAmtX18 * inPriceAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
239+ $Tuple4(fromX18(lpResultBuf, scale8), fromX18(inAmtAssetAmtX18, amtAssetDcm), fromX18(inPriceAssetAmtX18, priceAssetDcm), toInt(calcPriceBigInt((accPriceAssetBalanceX18 + inPriceAssetAmtX18), (accAmtAssetBalanceX18 + inAmtAssetAmtX18), scale8BigInt)))
254240 }
255241 else {
256- let poolLPBalanceBuf = privateBigIntCastToScaleOf(toBigInt(poolLPBalance), scale18, scale8BigInt)
257- let lpAmtByAmountAsset = toInt(privateBigIntCastToScaleOf(fraction(poolLPBalanceBuf, inAmountAssetAmtCalculated, amountAssetPoolLockedAmt), scale8BigInt, scale18))
258- let lpAmtByPriceAsset = toInt(privateBigIntCastToScaleOf(fraction(poolLPBalanceBuf, inPriceAssetAmtCalculated, priceAssetPoolLockedAmt), scale8BigInt, scale18))
259- if ((lpAmtByPriceAsset > lpAmtByAmountAsset))
260- then lpAmtByAmountAsset
261- else lpAmtByPriceAsset
242+ let poolLPBalanceX18 = toX18(poolLPBalance, scale8)
243+ let curPriceX18 = toX18(curPrice, scale8)
244+ let pEqByA = fraction(curPriceX18, inAmtAssetAmtX18, scale18)
245+ let resAssetsToPut = if ((pEqByA > inPriceAssetAmtX18))
246+ then $Tuple2(fraction(inPriceAssetAmtX18, scale18, curPriceX18), inPriceAssetAmtX18)
247+ else $Tuple2(inAmtAssetAmtX18, pEqByA)
248+ let lpResult = fromX18(fraction(poolLPBalanceX18, resAssetsToPut._2, accPriceAssetBalanceX18), scale8)
249+ $Tuple4(lpResult, fromX18(resAssetsToPut._1, amtAssetDcm), fromX18(resAssetsToPut._2, priceAssetDcm), toInt(calcPriceBigInt((accPriceAssetBalanceX18 + resAssetsToPut._2), (accAmtAssetBalanceX18 + resAssetsToPut._1), scale8BigInt)))
262250 }
263- if ((0 >= outLpAmount))
251+ if ((0 >= res._1))
264252 then throw("Invalid calculations. LP calculated is less than zero.")
265- else $Tuple10(outLpAmount, finalPrice, poolAmountAssetBalance, poolPriceAssetBalance, poolLPBalance, amountAssetInternalId, priceAssetInternalId, lpAssetId, slippage, poolStatus)
253+ else $Tuple12(res._1, res._4, accAmtAssetBalance, accPriceAssetBalance, poolLPBalance, iAmtAssetId, iPriceAssetId, lpAssetId, slippage, poolStatus, res._2, res._3)
266254 }
267255 }
268256 }
269257
270258
271259 func validateMatcherOrderAllowed (order) = {
272- let poolConfigDataList = getPoolConfig()
273- let amountAssetId = poolConfigDataList[idxAmountAssetId]
274- let priceAssetId = poolConfigDataList[idxPriceAssetId]
275- let poolStatus = parseIntValue(poolConfigDataList[idxPoolStatus])
276- let matcherPublicKeyStr = poolConfigDataList[idxMatcherPublicKey]
277- let amountAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
278- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
279- let accountAmountAssetBalance = privateGetAccountBalance(amountAssetId)
280- let accountPriceAssetBalance = privateGetAccountBalance(priceAssetId)
281- let currentPrice = if ((order.orderType == Buy))
282- then privateCalculatePrice(amountAssetDecimals, priceAssetDecimals, (accountAmountAssetBalance + order.amount), accountPriceAssetBalance)
283- else privateCalculatePrice(amountAssetDecimals, priceAssetDecimals, (accountAmountAssetBalance + order.amount), accountPriceAssetBalance)
284- let isPoolStatusValid = if (if (if (isGlobalShutdown())
260+ let cfg = getPoolConfig()
261+ let amtAssetId = cfg[idxAmtAssetId]
262+ let priceAssetId = cfg[idxPriceAssetId]
263+ let poolStatus = parseIntValue(cfg[idxPoolStatus])
264+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
265+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
266+ let accAmtAssetBalance = getAccBalance(amtAssetId)
267+ let accPriceAssetBalance = getAccBalance(priceAssetId)
268+ let curPrice = if ((order.orderType == Buy))
269+ then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
270+ else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
271+ if (if (if (isGlobalShutdown())
285272 then true
286273 else (poolStatus == PoolMatcherDisabled))
287274 then true
288275 else (poolStatus == PoolShutdown))
289- then false
290- else true
291- let isValidMatcherSign = true
292- let orderAmountAsset = order.assetPair.amountAsset
293- let orderAmountAssetStr = if ((orderAmountAsset == unit))
294- then "WAVES"
295- else toBase58String(value(orderAmountAsset))
296- let orderPriceAsset = order.assetPair.priceAsset
297- let orderPriceAssetStr = if ((orderPriceAsset == unit))
298- then "WAVES"
299- else toBase58String(value(orderPriceAsset))
300- let isValidAssetPair = if (if ((orderAmountAssetStr != amountAssetId))
301- then true
302- else (orderPriceAssetStr != priceAssetId))
303- then false
304- else true
305- let orderPrice = order.price
306- let priceDecimals = fraction(scale8, priceAssetDecimals, amountAssetDecimals)
307- let castedOrderPrice = privateCastToScaleOf(orderPrice, scale8, priceDecimals)
308- let isOrderPriceValid = if ((order.orderType == Buy))
309- then (currentPrice >= castedOrderPrice)
310- else (castedOrderPrice >= currentPrice)
311- if (if (if (isValidAssetPair)
312- then isValidMatcherSign
313- else false)
314- then isPoolStatusValid
315- else false)
316- then isOrderPriceValid
317- else false
276+ then throw("Exchange operations disabled")
277+ else {
278+ let orderAmtAsset = order.assetPair.amountAsset
279+ let orderAmtAssetStr = if ((orderAmtAsset == unit))
280+ then "WAVES"
281+ else toBase58String(value(orderAmtAsset))
282+ let orderPriceAsset = order.assetPair.priceAsset
283+ let orderPriceAssetStr = if ((orderPriceAsset == unit))
284+ then "WAVES"
285+ else toBase58String(value(orderPriceAsset))
286+ if (if ((orderAmtAssetStr != amtAssetId))
287+ then true
288+ else (orderPriceAssetStr != priceAssetId))
289+ then throw("Wrong order assets.")
290+ else {
291+ let orderPrice = order.price
292+ let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
293+ let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
294+ let isOrderPriceValid = if ((order.orderType == Buy))
295+ then (curPrice >= castedOrderPrice)
296+ else (castedOrderPrice >= curPrice)
297+ if (!(isOrderPriceValid))
298+ then throw(((("Order price leads to K decrease. castedOrderPrice=" + toString(castedOrderPrice)) + " curPrice=") + toString(curPrice)))
299+ else true
300+ }
301+ }
318302 }
319303
320304
321-@Callable(i)
322-func constructor (factoryContract) = if ((i.caller != this))
323- then throw("permissions denied")
324- else [StringEntry(keyFactoryContract(), factoryContract)]
305+func commonGet (i) = {
306+ let pmtAmtAsset = value(i.payments[0])
307+ let pmtAssetId = value(pmtAmtAsset.assetId)
308+ let pmtAssetAmt = pmtAmtAsset.amount
309+ let res = estimateGetOperation(toBase58String(pmtAssetId), pmtAssetAmt, toString(i.caller))
310+ let outAmtAssetAmt = res._1
311+ let outPriceAssetAmt = res._2
312+ let iAmtAssetId = res._3
313+ let iPriceAssetId = res._4
314+ let amtAssetId = res._5
315+ let priceAssetId = res._6
316+ let poolAmtAssetBalance = res._7
317+ let poolPriceAssetBalance = res._8
318+ let poolLPBalance = res._9
319+ let curPrice = res._10
320+ let poolStatus = parseIntValue(res._11)
321+ if (if (isGlobalShutdown())
322+ then true
323+ else (poolStatus == PoolShutdown))
324+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
325+ else $Tuple5(outAmtAssetAmt, outPriceAssetAmt, pmtAssetAmt, pmtAssetId, [ScriptTransfer(i.caller, outAmtAssetAmt, if ((amtAssetId == "WAVES"))
326+ then unit
327+ else fromBase58String(amtAssetId)), ScriptTransfer(i.caller, outPriceAssetAmt, if ((priceAssetId == "WAVES"))
328+ then unit
329+ else fromBase58String(priceAssetId)), StringEntry(keyGetActionByUser(toString(i.caller), toBase58String(i.transactionId)), dataGetActionInfo(outAmtAssetAmt, outPriceAssetAmt, pmtAssetAmt, curPrice, height, lastBlock.timestamp)), StringEntry(keyPriceLast(), ("%s__" + toString(curPrice))), StringEntry(keyPriceHistory(height, lastBlock.timestamp), ("%s__" + toString(curPrice)))])
330+ }
325331
326332
327-
328-@Callable(i)
329-func put (slippageTolerance,shouldAutoStake) = {
330- let factoryConfigList = getFactoryConfig()
331- let stakingContract = valueOrErrorMessage(addressFromString(factoryConfigList[idxFactoryStakingContract]), "Error. Incorrect staking address.")
332- let pmtAmountAsset = value(i.payments[0])
333- let inAmountAssetAmt = pmtAmountAsset.amount
334- let inAmountAssetId = if (!(isDefined(pmtAmountAsset.assetId)))
333+func commonPut (i,slippageTolerance,emitLp) = {
334+ let pmtAmtAsset = value(i.payments[0])
335+ let inAmtAssetAmt = pmtAmtAsset.amount
336+ let inAmtAssetId = if (!(isDefined(pmtAmtAsset.assetId)))
335337 then fromBase58String("WAVES")
336- else value(pmtAmountAsset.assetId)
338+ else value(pmtAmtAsset.assetId)
337339 let pmtPriceAsset = value(i.payments[1])
338340 let inPriceAssetAmt = pmtPriceAsset.amount
339341 let inPriceAssetId = if (!(isDefined(pmtPriceAsset.assetId)))
340342 then fromBase58String("WAVES")
341343 else value(pmtPriceAsset.assetId)
342- let estimatedPutResults = privateEstimatePutOperation(slippageTolerance, inAmountAssetAmt, toBase58String(inAmountAssetId), inPriceAssetAmt, toBase58String(inPriceAssetId), toString(i.caller), false)
343- let outLpAmount = estimatedPutResults._1
344- let curentPrice = estimatedPutResults._2
345- let poolAmountAssetBalance = estimatedPutResults._3
346- let poolPriceAssetBalance = estimatedPutResults._4
347- let poolLPBalance = estimatedPutResults._5
348- let amountAssetInternalId = estimatedPutResults._6
349- let priceAssetInternalId = estimatedPutResults._7
350- let lpAssetId = estimatedPutResults._8
351- let slippageCalculated = estimatedPutResults._9
352- let poolStatus = parseIntValue(estimatedPutResults._10)
344+ let estPut = estimatePutOperation(slippageTolerance, inAmtAssetAmt, toBase58String(inAmtAssetId), inPriceAssetAmt, toBase58String(inPriceAssetId), toString(i.caller), false)
345+ let outLpAmt = estPut._1
346+ let curPrice = estPut._2
347+ let poolAmtAssetBalance = estPut._3
348+ let poolPriceAssetBalance = estPut._4
349+ let poolLPBalance = estPut._5
350+ let iAmtAssetId = estPut._6
351+ let iPriceAssetId = estPut._7
352+ let lpAssetId = estPut._8
353+ let slippageCalc = estPut._9
354+ let poolStatus = parseIntValue(estPut._10)
355+ let realAmtAssetIn = estPut._11
356+ let realPriceAssetIn = estPut._12
353357 if (if (if (isGlobalShutdown())
354358 then true
355359 else (poolStatus == PoolPutDisabled))
357361 else (poolStatus == PoolShutdown))
358362 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
359363 else {
360- let emitLPAssetOnFactory = invoke(factoryContract, "emit", [outLpAmount], nil)
361- if ((emitLPAssetOnFactory == emitLPAssetOnFactory))
362- then if ((emitLPAssetOnFactory != "success"))
363- then throw("LP asset reissue failed during emit call on factory.")
364- else {
365- let results = [StringEntry(keyPriceLast(), ("%s__" + toString(curentPrice))), StringEntry(keyPriceHistory(height, lastBlock.timestamp), ("%s__" + toString(curentPrice))), StringEntry(keyPutActionByUser(toString(i.caller), toBase58String(i.transactionId)), dataPutActionInfo(inAmountAssetAmt, inPriceAssetAmt, outLpAmount, curentPrice, slippageTolerance, slippageCalculated, height, lastBlock.timestamp)), StringEntry(keyPoolLiquidity(amountAssetInternalId, priceAssetInternalId), dataPoolLiquidity((poolAmountAssetBalance + inAmountAssetAmt), (poolPriceAssetBalance + inPriceAssetAmt), (poolLPBalance + outLpAmount)))]
366- if (shouldAutoStake)
367- then {
368- let stake = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, outLpAmount)])
369- if ((stake == stake))
370- then results
371- else throw("Strict value is not equal to itself.")
372- }
373- else (results :+ ScriptTransfer(i.caller, outLpAmount, lpAssetId))
374- }
364+ let lpAmtToEmit = if (!(emitLp))
365+ then 0
366+ else outLpAmt
367+ let diffInAmtAsset = (inAmtAssetAmt - realAmtAssetIn)
368+ let diffInPriceAsset = (inPriceAssetAmt - realPriceAssetIn)
369+ let dataStateWrite = [StringEntry(keyPriceLast(), ("%s__" + toString(curPrice))), StringEntry(keyPriceHistory(height, lastBlock.timestamp), ("%s__" + toString(curPrice))), StringEntry(keyPutActionByUser(toString(i.caller), toBase58String(i.transactionId)), dataPutActionInfo(realAmtAssetIn, realPriceAssetIn, lpAmtToEmit, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, diffInAmtAsset, diffInPriceAsset))]
370+ $Tuple9(lpAmtToEmit, lpAssetId, dataStateWrite, inAmtAssetAmt, realAmtAssetIn, inPriceAssetAmt, realPriceAssetIn, pmtAmtAsset.assetId, pmtPriceAsset.assetId)
371+ }
372+ }
373+
374+
375+@Callable(i)
376+func constructor (factoryContract,managerPublicKey) = if ((i.caller != this))
377+ then throw("permissions denied")
378+ else [StringEntry(keyFactoryContract(), factoryContract), StringEntry(keyManagerPublicKey(), managerPublicKey)]
379+
380+
381+
382+@Callable(i)
383+func put (slippageTolerance,shouldAutoStake) = {
384+ let factoryCfg = getFactoryConfig()
385+ let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.")
386+ let slippageContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactorySlippageContract]), "Error. Incorrect slippage contract address.")
387+ let actions = commonPut(i, slippageTolerance, true)
388+ let amtToEmit = actions._1
389+ let lpAssetId = actions._2
390+ let state = actions._3
391+ let inAmt = actions._4
392+ let realInAmt = actions._5
393+ let inPrice = actions._6
394+ let realInPrice = actions._7
395+ let amId = actions._8
396+ let prId = actions._9
397+ let diffInAmtAsset = (inAmt - realInAmt)
398+ let diffInPriceAsset = (inPrice - realInPrice)
399+ let emitInv = invoke(factoryContract, "emit", [amtToEmit], nil)
400+ if ((emitInv == emitInv))
401+ then {
402+ let slippageAInv = if ((inAmt > realInAmt))
403+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, diffInAmtAsset)])
404+ else nil
405+ if ((slippageAInv == slippageAInv))
406+ then {
407+ let slippagePInv = if ((inPrice > realInPrice))
408+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, diffInPriceAsset)])
409+ else nil
410+ if ((slippagePInv == slippagePInv))
411+ then {
412+ let lpStakeInv = if (shouldAutoStake)
413+ then invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, amtToEmit)])
414+ else nil
415+ if ((lpStakeInv == lpStakeInv))
416+ then (state :+ ScriptTransfer(i.caller, amtToEmit, lpAssetId))
417+ else throw("Strict value is not equal to itself.")
418+ }
419+ else throw("Strict value is not equal to itself.")
420+ }
375421 else throw("Strict value is not equal to itself.")
376422 }
423+ else throw("Strict value is not equal to itself.")
424+ }
425+
426+
427+
428+@Callable(i)
429+func putForFree () = {
430+ let actions = commonPut(i, 0, false)
431+ actions._3
377432 }
378433
379434
380435
381436 @Callable(i)
382437 func get () = {
383- let pmtAmountAsset = value(i.payments[0])
384- let pmtAssetId = value(pmtAmountAsset.assetId)
385- let pmtAssetAmount = pmtAmountAsset.amount
386- let results = privateEstimateGetOperation(toBase58String(pmtAssetId), pmtAssetAmount, toString(i.caller))
387- let outAmountAssetAmt = results._1
388- let outPriceAssetAmt = results._2
389- let amountAssetInternalId = results._3
390- let priceAssetInternalId = results._4
391- let amountAssetId = results._5
392- let priceAssetId = results._6
393- let poolAmountAssetBalance = results._7
394- let poolPriceAssetBalance = results._8
395- let poolLPBalance = results._9
396- let currentPrice = results._10
397- let poolStatus = parseIntValue(results._11)
398- if (if (isGlobalShutdown())
399- then true
400- else (poolStatus == PoolShutdown))
401- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
402- else {
403- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAssetAmount], [AttachedPayment(pmtAssetId, pmtAssetAmount)])
404- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
405- then if ((burnLPAssetOnFactory != "success"))
406- then throw("LP asset burn failed during emit call on factory.")
407- else [ScriptTransfer(i.caller, outAmountAssetAmt, if ((amountAssetId == "WAVES"))
408- then unit
409- else fromBase58String(amountAssetId)), ScriptTransfer(i.caller, outPriceAssetAmt, fromBase58String(priceAssetId)), StringEntry(keyPoolLiquidity(amountAssetInternalId, priceAssetInternalId), dataPoolLiquidity((poolAmountAssetBalance - outAmountAssetAmt), (poolPriceAssetBalance - outPriceAssetAmt), (poolLPBalance - pmtAssetAmount))), StringEntry(keyGetActionByUser(toString(i.caller), toBase58String(i.transactionId)), dataGetActionInfo(outAmountAssetAmt, outPriceAssetAmt, pmtAssetAmount, currentPrice, height, lastBlock.timestamp)), StringEntry(keyPriceLast(), ("%s__" + toString(currentPrice))), StringEntry(keyPriceHistory(height, lastBlock.timestamp), ("%s__" + toString(currentPrice)))]
410- else throw("Strict value is not equal to itself.")
411- }
438+ let res = commonGet(i)
439+ let outAmtAssetAmt = res._1
440+ let outPriceAssetAmt = res._2
441+ let pmtAssetAmt = res._3
442+ let pmtAssetId = res._4
443+ let actions = res._5
444+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAssetAmt], [AttachedPayment(pmtAssetId, pmtAssetAmt)])
445+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
446+ then actions
447+ else throw("Strict value is not equal to itself.")
412448 }
413449
414450
415451
416452 @Callable(i)
417-func activate (amountAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
453+func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
454+ let res = commonGet(i)
455+ let outAmtAssetAmt = res._1
456+ let outPriceAssetAmt = res._2
457+ let pmtAssetAmt = res._3
458+ let pmtAssetId = res._4
459+ let actions = res._5
460+ if ((noLessThenAmtAsset > outAmtAssetAmt))
461+ then throw(((("noLessThenAmtAsset failed: " + toString(outAmtAssetAmt)) + " < ") + toString(noLessThenAmtAsset)))
462+ else if ((noLessThenPriceAsset > outPriceAssetAmt))
463+ then throw(((("noLessThenPriceAsset failed: " + toString(outPriceAssetAmt)) + " < ") + toString(noLessThenPriceAsset)))
464+ else {
465+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAssetAmt], [AttachedPayment(pmtAssetId, pmtAssetAmt)])
466+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
467+ then actions
468+ else throw("Strict value is not equal to itself.")
469+ }
470+ }
471+
472+
473+
474+@Callable(i)
475+func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
418476 then throw("permissions denied")
419- else $Tuple2([StringEntry(keyAmountAsset(), amountAssetStr), StringEntry(keyPriceAsset(), priceAssetStr)], "success")
477+ else $Tuple2([StringEntry(keyAmtAsset(), amtAssetStr), StringEntry(keyPriceAsset(), priceAssetStr)], "success")
420478
421479
422480
423481 @Callable(i)
424482 func statsREADONLY () = {
425- let poolConfigDataList = getPoolConfig()
426- let lpAssetId = fromBase58String(poolConfigDataList[idxPoolLPAssetId])
427- let amountAssetId = poolConfigDataList[idxAmountAssetId]
428- let priceAssetId = poolConfigDataList[idxPriceAssetId]
429- let amountAssetInternalId = poolConfigDataList[idxAmountAssetInternalId]
430- let priceAssetInternalId = poolConfigDataList[idxPriceAssetInternalId]
431- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
432- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
433- let poolLiquidityDataList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
434- let poolLPBalance = parseIntValue(poolLiquidityDataList[idxPoolLPAssetAmt])
435- let accountAmountAssetBalance = privateGetAccountBalance(amountAssetId)
436- let accountPriceAssetBalance = privateGetAccountBalance(priceAssetId)
437- let pricesList = calculatePrices(accountAmountAssetBalance, accountPriceAssetBalance, poolLPBalance)
438- let currentPrice = pricesList[0]
439- let lpAmountAssetShare = pricesList[1]
483+ let cfg = getPoolConfig()
484+ let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
485+ let amtAssetId = cfg[idxAmtAssetId]
486+ let priceAssetId = cfg[idxPriceAssetId]
487+ let iAmtAssetId = cfg[idxIAmtAssetId]
488+ let iPriceAssetId = cfg[idxIPriceAssetId]
489+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
490+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
491+ let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
492+ let accAmtAssetBalance = getAccBalance(amtAssetId)
493+ let accPriceAssetBalance = getAccBalance(priceAssetId)
494+ let pricesList = calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
495+ let curPrice = pricesList[0]
496+ let lpAmtAssetShare = pricesList[1]
440497 let lpPriceAssetShare = pricesList[2]
441- let poolWeight = valueOrErrorMessage(getInteger(factoryContract, keyPoolWeight(toString(this))), "Pool doesn't have weight.")
442- $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accountAmountAssetBalance), toString(accountPriceAssetBalance), toString(poolLPBalance), toString(currentPrice), toString(lpAmountAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP))
498+ let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
499+ $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP))
443500 }
444501
445502
446503
447504 @Callable(i)
448-func evaluatePutByAmountAssetREADONLY (slippageTolerance,inAmountAssetAmt,userAddress) = {
449- let poolConfigDataList = getPoolConfig()
450- let lpAssetId = fromBase58String(poolConfigDataList[idxPoolLPAssetId])
451- let amountAssetId = poolConfigDataList[idxAmountAssetId]
452- let priceAssetId = poolConfigDataList[idxPriceAssetId]
453- let amountAssetInternalId = poolConfigDataList[idxAmountAssetInternalId]
454- let priceAssetInternalId = poolConfigDataList[idxPriceAssetInternalId]
455- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
456- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
457- let poolStatus = poolConfigDataList[idxPoolStatus]
458- let poolLiquidityDataList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
459- let poolLPBalance = parseIntValue(poolLiquidityDataList[idxPoolLPAssetAmt])
460- let accountAmountAssetBalance = privateGetAccountBalance(amountAssetId)
461- let accountPriceAssetBalance = privateGetAccountBalance(priceAssetId)
462- let accountAmountAssetBalanceCasted = privateCastToScaleOf(accountAmountAssetBalance, scale8, amoutAssetDecimals)
463- let accountPriceAssetBalanceCasted = privateCastToScaleOf(accountPriceAssetBalance, scale8, priceAssetDecimals)
464- let curentPrice = if ((poolLPBalance == 0))
465- then 0
466- else calculatePrice(accountPriceAssetBalanceCasted, accountAmountAssetBalanceCasted)
467- let inAmountAssetAmtCasted = privateCastToScaleOf(inAmountAssetAmt, scale8, amoutAssetDecimals)
468- let inPriceAssetAmtCalculated = fraction(inAmountAssetAmtCasted, curentPrice, scale8)
469- let inPriceAssetAmt = privateCastToScaleOf(inPriceAssetAmtCalculated, priceAssetDecimals, scale8)
470- let estimatedPutResults = privateEstimatePutOperation(slippageTolerance, inAmountAssetAmt, amountAssetId, inPriceAssetAmt, priceAssetId, userAddress, true)
471- let outLpAmountCalc = estimatedPutResults._1
472- let curentPriceCalc = estimatedPutResults._2
473- let poolAmountAssetBalanceCalc = estimatedPutResults._3
505+func evaluatePutByAmtAssetREADONLY (slippageTolerance,inAmtAssetAmt,userAddress) = {
506+ let cfg = getPoolConfig()
507+ let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
508+ let amtAssetId = cfg[idxAmtAssetId]
509+ let priceAssetId = cfg[idxPriceAssetId]
510+ let iAmtAssetId = cfg[idxIAmtAssetId]
511+ let iPriceAssetId = cfg[idxIPriceAssetId]
512+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
513+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
514+ let poolStatus = cfg[idxPoolStatus]
515+ let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
516+ let accAmtAssetBalance = getAccBalance(amtAssetId)
517+ let accPriceAssetBalance = getAccBalance(priceAssetId)
518+ let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
519+ let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
520+ let curPriceX18 = if ((poolLPBalance == 0))
521+ then toBigInt(0)
522+ else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18, scale18)
523+ let inAmtAssetAmtX18 = toX18(inAmtAssetAmt, amtAssetDcm)
524+ let inPriceAssetAmtX18 = fraction(inAmtAssetAmtX18, curPriceX18, scale18)
525+ let inPriceAssetAmt = fromX18(inPriceAssetAmtX18, priceAssetDcm)
526+ let estimatedPutResults = estimatePutOperation(slippageTolerance, inAmtAssetAmt, amtAssetId, inPriceAssetAmt, priceAssetId, userAddress, true)
527+ let outLpAmtCalc = estimatedPutResults._1
528+ let curPriceCalc = estimatedPutResults._2
529+ let poolAmtAssetBalanceCalc = estimatedPutResults._3
474530 let poolPriceAssetBalanceCAlc = estimatedPutResults._4
475531 let poolLPBalanceCalc = estimatedPutResults._5
476532 let poolStatusCalc = parseIntValue(estimatedPutResults._10)
477- $Tuple2(nil, makeString(["%d%d%d%d%d%d", toString(outLpAmountCalc), toString(curentPrice), toString(poolAmountAssetBalanceCalc), toString(poolPriceAssetBalanceCAlc), toString(poolLPBalanceCalc), toString(poolStatusCalc)], SEP))
533+ $Tuple2(nil, makeString(["%d%d%d%d%d%d", toString(outLpAmtCalc), toString(fromX18(curPriceX18, scale8)), toString(poolAmtAssetBalanceCalc), toString(poolPriceAssetBalanceCAlc), toString(poolLPBalanceCalc), toString(poolStatusCalc)], SEP))
478534 }
479535
480536
481537
482538 @Callable(i)
483539 func evaluatePutByPriceAssetREADONLY (slippageTolerance,inPriceAssetAmt,userAddress) = {
484- let poolConfigDataList = getPoolConfig()
485- let lpAssetId = fromBase58String(poolConfigDataList[idxPoolLPAssetId])
486- let amountAssetId = poolConfigDataList[idxAmountAssetId]
487- let priceAssetId = poolConfigDataList[idxPriceAssetId]
488- let amountAssetInternalId = poolConfigDataList[idxAmountAssetInternalId]
489- let priceAssetInternalId = poolConfigDataList[idxPriceAssetInternalId]
490- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
491- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
492- let poolStatus = poolConfigDataList[idxPoolStatus]
493- let poolLiquidityDataList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
494- let poolLPBalance = parseIntValue(poolLiquidityDataList[idxPoolLPAssetAmt])
495- let accountAmountAssetBalance = privateGetAccountBalance(amountAssetId)
496- let accountPriceAssetBalance = privateGetAccountBalance(priceAssetId)
497- let accountAmountAssetBalanceCasted = privateCastToScaleOf(accountAmountAssetBalance, scale8, amoutAssetDecimals)
498- let accountPriceAssetBalanceCasted = privateCastToScaleOf(accountPriceAssetBalance, scale8, priceAssetDecimals)
499- let inPriceAssetAmtCalculated = privateCastToScaleOf(inPriceAssetAmt, scale8, priceAssetDecimals)
500- let curentPrice = if ((poolLPBalance == 0))
501- then 0
502- else calculatePrice(accountPriceAssetBalanceCasted, accountAmountAssetBalanceCasted)
503- let inAmountAssetAmtCalculated = fraction(inPriceAssetAmtCalculated, scale8, curentPrice)
504- let inAmountAssetAmt = privateCastToScaleOf(inAmountAssetAmtCalculated, amoutAssetDecimals, scale8)
505- let estimatedPutResults = privateEstimatePutOperation(slippageTolerance, inAmountAssetAmt, amountAssetId, inPriceAssetAmt, priceAssetId, userAddress, true)
506- let outLpAmountCalc = estimatedPutResults._1
507- let curentPriceCalc = estimatedPutResults._2
508- let poolAmountAssetBalanceCalc = estimatedPutResults._3
540+ let cfg = getPoolConfig()
541+ let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
542+ let amtAssetId = cfg[idxAmtAssetId]
543+ let priceAssetId = cfg[idxPriceAssetId]
544+ let iAmtAssetId = cfg[idxIAmtAssetId]
545+ let iPriceAssetId = cfg[idxIPriceAssetId]
546+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
547+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
548+ let poolStatus = cfg[idxPoolStatus]
549+ let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
550+ let accAmtAssetBalance = getAccBalance(amtAssetId)
551+ let accPriceAssetBalance = getAccBalance(priceAssetId)
552+ let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
553+ let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
554+ let curPriceX18 = if ((poolLPBalance == 0))
555+ then toBigInt(0)
556+ else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18, scale18)
557+ let inPriceAssetAmtX18 = toX18(inPriceAssetAmt, priceAssetDcm)
558+ let inAmtAssetAmtX18 = fraction(inPriceAssetAmtX18, scale18, curPriceX18)
559+ let inAmtAssetAmt = fromX18(inAmtAssetAmtX18, amtAssetDcm)
560+ let estimatedPutResults = estimatePutOperation(slippageTolerance, inAmtAssetAmt, amtAssetId, inPriceAssetAmt, priceAssetId, userAddress, true)
561+ let outLpAmtCalc = estimatedPutResults._1
562+ let curPriceCalc = estimatedPutResults._2
563+ let poolAmtAssetBalanceCalc = estimatedPutResults._3
509564 let poolPriceAssetBalanceCAlc = estimatedPutResults._4
510565 let poolLPBalanceCalc = estimatedPutResults._5
511566 let poolStatusCalc = parseIntValue(estimatedPutResults._10)
512- $Tuple2(nil, makeString(["%d%d%d%d%d%d", toString(outLpAmountCalc), toString(curentPrice), toString(poolAmountAssetBalanceCalc), toString(poolPriceAssetBalanceCAlc), toString(poolLPBalanceCalc), toString(poolStatusCalc)], SEP))
567+ $Tuple2(nil, makeString(["%d%d%d%d%d%d", toString(outLpAmtCalc), toString(fromX18(curPriceX18, scale8)), toString(poolAmtAssetBalanceCalc), toString(poolPriceAssetBalanceCAlc), toString(poolLPBalanceCalc), toString(poolStatusCalc)], SEP))
513568 }
514569
515570
516571
517572 @Callable(i)
518-func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmount,userAddress) = {
519- let results = privateEstimateGetOperation(paymentLpAssetId, paymentLpAmount, userAddress)
520- let outAmountAssetAmt = results._1
521- let outPriceAssetAmt = results._2
522- let poolAmountAssetBalance = results._7
523- let poolPriceAssetBalance = results._8
524- let poolLPBalance = results._9
525- let currentPrice = results._10
526- let poolStatus = parseIntValue(results._11)
527- $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmountAssetAmt), toString(outPriceAssetAmt), toString(poolAmountAssetBalance), toString(poolPriceAssetBalance), toString(poolLPBalance), toString(currentPrice), toString(poolStatus)], SEP))
573+func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt,userAddress) = {
574+ let res = estimateGetOperation(paymentLpAssetId, paymentLpAmt, userAddress)
575+ let outAmtAssetAmt = res._1
576+ let outPriceAssetAmt = res._2
577+ let poolAmtAssetBalance = res._7
578+ let poolPriceAssetBalance = res._8
579+ let poolLPBalance = res._9
580+ let curPrice = res._10
581+ let poolStatus = parseIntValue(res._11)
582+ $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmtAssetAmt), toString(outPriceAssetAmt), toString(poolAmtAssetBalance), toString(poolPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(poolStatus)], SEP))
528583 }
529-
530-
531-
532-@Callable(i)
533-func hashREADONLY () = $Tuple2(nil, toBase64String(value(scriptHash(this))))
534584
535585
536586 @Verifier(tx)
537587 func verify () = match tx {
538588 case order: Order =>
539- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
589+ if (validateMatcherOrderAllowed(order))
590+ then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
591+ else false
540592 case _ =>
541- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
593+ let managerPublic = valueOrElse(getString(this, keyManagerPublicKey()), EMPTY)
594+ if ((managerPublic == EMPTY))
595+ then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
596+ else sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(managerPublic))
542597 }
543598
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let lPdecimals = 8
55
66 let scale8 = 100000000
77
88 let scale8BigInt = toBigInt(100000000)
99
1010 let scale18 = toBigInt(1000000000000000000)
1111
1212 let SEP = "__"
13+
14+let EMPTY = ""
1315
1416 let PoolActive = 1
1517
1618 let PoolPutDisabled = 2
1719
1820 let PoolMatcherDisabled = 3
1921
2022 let PoolShutdown = 4
2123
2224 let idxPoolAddress = 1
2325
2426 let idxPoolStatus = 2
2527
2628 let idxPoolLPAssetId = 3
2729
28-let idxAmountAssetId = 4
30+let idxAmtAssetId = 4
2931
3032 let idxPriceAssetId = 5
3133
32-let idxAmountAssetDecimals = 6
34+let idxAmtAssetDcm = 6
3335
34-let idxPriceAssetDecimals = 7
36+let idxPriceAssetDcm = 7
3537
36-let idxAmountAssetInternalId = 8
38+let idxIAmtAssetId = 8
3739
38-let idxPriceAssetInternalId = 9
40+let idxIPriceAssetId = 9
3941
40-let idxLPAssetDecimals = 10
42+let idxLPAssetDcm = 10
4143
42-let idxMatcherPublicKey = 11
43-
44-let idxPoolAmountAssetAmt = 1
44+let idxPoolAmtAssetAmt = 1
4545
4646 let idxPoolPriceAssetAmt = 2
4747
4848 let idxPoolLPAssetAmt = 3
4949
5050 let idxFactoryStakingContract = 1
5151
52-let idxFactoryBoostingConfig = 2
52+let idxFactorySlippageContract = 7
53+
54+func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
55+
56+
57+func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
58+
59+
60+func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
61+
5362
5463 func keyFactoryContract () = "%s__factoryContract"
64+
65+
66+func keyManagerPublicKey () = "%s__managerPublicKey"
5567
5668
5769 func keyPriceLast () = "%s%s__price__last"
5870
5971
6072 func keyPriceHistory (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
6173
6274
63-func keyPoolLiquidity (internalAmountAsset,internalPriceAsset) = (((("%d%d%s__" + internalAmountAsset) + "__") + internalPriceAsset) + "__locked")
64-
65-
6675 func keyPutActionByUser (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
6776
6877
6978 func keyGetActionByUser (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
7079
7180
72-func keyAmountAsset () = "%s__amountAsset"
81+func keyAmtAsset () = "%s__amountAsset"
7382
7483
7584 func keyPriceAsset () = "%s__priceAsset"
76-
77-
78-func keyKCurrent () = "%s%s__K_current"
7985
8086
8187 func keyKHistoric (h,timestamp) = makeString(["%s%s%d%d__K_history", toString(h), toString(timestamp)], SEP)
8288
8389
8490 func keyFactoryConfig () = "%s__factoryConfig"
8591
8692
8793 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
8894
8995
90-func keyPoolConfig (amountAssetInternal,priceAssetInternal) = (((("%d%d%s__" + amountAssetInternal) + "__") + priceAssetInternal) + "__config")
96+func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
9197
9298
9399 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
94100
95101
96102 func keyAllPoolsShutdown () = "%s__shutdown"
97103
98104
99105 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
100106
101107
102-let factoryContract = addressFromStringValue(valueOrErrorMessage(getString(this, keyFactoryContract()), "No Factory Account found."))
108+func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
109+
110+
111+func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
112+
113+
114+let factoryContract = addressFromStringValue(getStringOrFail(this, keyFactoryContract()))
103115
104116 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
105117
106118
107119 func getPoolConfig () = {
108- let poolAmountAsset = valueOrErrorMessage(getString(this, keyAmountAsset()), "No config for amount asset found")
109- let poolPriceAsset = valueOrErrorMessage(getString(this, keyPriceAsset()), "No config for price asset found")
110- let poolPriceAssetInternal = valueOrErrorMessage(getInteger(factoryContract, keyMappingsBaseAsset2internalId(poolPriceAsset)), "No config for internal price asset found")
111- let poolAmountAssetInternal = valueOrErrorMessage(getInteger(factoryContract, keyMappingsBaseAsset2internalId(poolAmountAsset)), "No config for internal amount asset found")
112- split(valueOrErrorMessage(getString(factoryContract, keyPoolConfig(toString(poolAmountAssetInternal), toString(poolPriceAssetInternal))), "No factory config found for pool assets."), SEP)
120+ let amtAsset = getStringOrFail(this, keyAmtAsset())
121+ let priceAsset = getStringOrFail(this, keyPriceAsset())
122+ let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
123+ let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
124+ split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
113125 }
114126
115127
116-func getFactoryConfig () = split(valueOrErrorMessage(getString(factoryContract, keyFactoryConfig()), "No factory config found."), SEP)
128+func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
117129
118130
119-func getPoolLiquidity (amountAssetInternalId,priceAssetInternalId) = {
120- let currentPoolLiquidityValue = getString(this, keyPoolLiquidity(amountAssetInternalId, priceAssetInternalId))
121- if (isDefined(currentPoolLiquidityValue))
122- then split(value(currentPoolLiquidityValue), SEP)
123- else ["", "0", "0", "0"]
124- }
131+func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP)
125132
126133
127-func dataPoolLiquidity (amountAssetLocked,priceAssetLocked,lpTokenLocked) = makeString(["%d%d%d", toString(amountAssetLocked), toString(priceAssetLocked), toString(lpTokenLocked)], SEP)
134+func dataGetActionInfo (outAmtAssetAmt,outPriceAssetAmt,inLpAmt,price,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d", toString(outAmtAssetAmt), toString(outPriceAssetAmt), toString(inLpAmt), toString(price), toString(txHeight), toString(txTimestamp)], SEP)
128135
129136
130-func dataPutActionInfo (inAmountAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d%d", toString(inAmountAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp)], SEP)
131-
132-
133-func dataGetActionInfo (outAmountAssetAmt,outPriceAssetAmt,inLpAmt,price,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d", toString(outAmountAssetAmt), toString(outPriceAssetAmt), toString(inLpAmt), toString(price), toString(txHeight), toString(txTimestamp)], SEP)
134-
135-
136-func privateCastToScaleOf (amount,resultScale,currentScale) = fraction(amount, resultScale, currentScale)
137-
138-
139-func privateBigIntCastToScaleOf (amount,resultScale,currentScale) = fraction(amount, resultScale, currentScale)
140-
141-
142-func calculatePrice (priceAssetLockedAmt,amountAssetlLockedAmt) = fraction(priceAssetLockedAmt, scale8, amountAssetlLockedAmt)
143-
144-
145-func calculatePriceBigInt (priceAssetLockedAmt,amountAssetlLockedAmt) = toInt(fraction(priceAssetLockedAmt, scale8BigInt, amountAssetlLockedAmt))
146-
147-
148-func privateCalculatePrice (amoutAssetDecimals,priceAssetDecimals,amountAssetAmt,priceAssetAmt) = {
149- let amountAssetAmtCasted = privateCastToScaleOf(amountAssetAmt, scale8, amoutAssetDecimals)
150- let priceAssetAmtCasted = privateCastToScaleOf(priceAssetAmt, scale8, priceAssetDecimals)
151- calculatePrice(priceAssetAmtCasted, amountAssetAmtCasted)
152- }
153-
154-
155-func privateGetAccountBalance (assetId) = if ((assetId == "WAVES"))
137+func getAccBalance (assetId) = if ((assetId == "WAVES"))
156138 then wavesBalance(this).available
157139 else assetBalance(this, fromBase58String(assetId))
158140
159141
160-func calculatePrices (amountAssetAmt,priceAssetAmt,lpAmount) = {
161- let poolConfigDataList = getPoolConfig()
162- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
163- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
164- let poolPrice = privateCalculatePrice(amoutAssetDecimals, priceAssetDecimals, amountAssetAmt, priceAssetAmt)
165- let amountAssetPoolLockedAmt = privateCastToScaleOf(amountAssetAmt, scale8, amoutAssetDecimals)
166- let priceAssetPoolLockedAmt = privateCastToScaleOf(priceAssetAmt, scale8, priceAssetDecimals)
167- let lpPriceInAmountAsset = calculatePrice(amountAssetPoolLockedAmt, lpAmount)
168- let lpPriceInPriceAsset = calculatePrice(priceAssetPoolLockedAmt, lpAmount)
169-[poolPrice, lpPriceInAmountAsset, lpPriceInPriceAsset]
142+func calcPriceBigInt (priceAssetLockedAmt,amtAssetlLockedAmt,resultScale) = fraction(priceAssetLockedAmt, resultScale, amtAssetlLockedAmt)
143+
144+
145+func privateCalcPrice (amtAssetDcm,priceAssetDcm,amtAssetAmt,priceAssetAmt) = {
146+ let amtAssetAmtX18 = toX18(amtAssetAmt, amtAssetDcm)
147+ let priceAssetAmtX18 = toX18(priceAssetAmt, priceAssetDcm)
148+ toInt(calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18, scale8BigInt))
170149 }
171150
172151
173-func privateEstimateGetOperation (paymentLpAssetId,paymentLpAmount,userAddress) = {
152+func calcPrices (amtAssetAmt,priceAssetAmt,lpAmt) = {
153+ let cfg = getPoolConfig()
154+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
155+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
156+ let poolPrice = privateCalcPrice(amtAssetDcm, priceAssetDcm, amtAssetAmt, priceAssetAmt)
157+ let amtAssetAmtX18 = toX18(amtAssetAmt, amtAssetDcm)
158+ let priceAssetAmtX18 = toX18(priceAssetAmt, priceAssetDcm)
159+ let lpAmtX18 = toX18(lpAmt, scale8)
160+ let lpPriceInAmtAsset = toInt(calcPriceBigInt(amtAssetAmtX18, lpAmtX18, scale8BigInt))
161+ let lpPriceInPriceAsset = toInt(calcPriceBigInt(priceAssetAmtX18, lpAmtX18, scale8BigInt))
162+[poolPrice, lpPriceInAmtAsset, lpPriceInPriceAsset]
163+ }
164+
165+
166+func estimateGetOperation (paymentLpAssetId,paymentLpAmt,userAddress) = {
174167 let poolConfigList = getPoolConfig()
175168 let lpAssetId = poolConfigList[idxPoolLPAssetId]
176- let amountAssetId = poolConfigList[idxAmountAssetId]
169+ let amtAssetId = poolConfigList[idxAmtAssetId]
177170 let priceAssetId = poolConfigList[idxPriceAssetId]
178- let amountAssetInternalId = poolConfigList[idxAmountAssetInternalId]
179- let priceAssetInternalId = poolConfigList[idxPriceAssetInternalId]
180- let amoutAssetDecimals = parseIntValue(poolConfigList[idxAmountAssetDecimals])
181- let priceAssetDecimals = parseIntValue(poolConfigList[idxPriceAssetDecimals])
171+ let iAmtAssetId = poolConfigList[idxIAmtAssetId]
172+ let iPriceAssetId = poolConfigList[idxIPriceAssetId]
173+ let amtAssetDcm = parseIntValue(poolConfigList[idxAmtAssetDcm])
174+ let priceAssetDcm = parseIntValue(poolConfigList[idxPriceAssetDcm])
182175 let poolStatus = poolConfigList[idxPoolStatus]
183- let poolLiquidityList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
184- let poolLPBalance = parseIntValue(poolLiquidityList[idxPoolLPAssetAmt])
185- let poolAmountAssetBalance = parseIntValue(poolLiquidityList[idxPoolAmountAssetAmt])
186- let poolPriceAssetBalance = parseIntValue(poolLiquidityList[idxPoolPriceAssetAmt])
176+ let poolLPBalance = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
187177 if ((lpAssetId != paymentLpAssetId))
188178 then throw("Invalid asset passed.")
189179 else {
190- let amountAssetPoolLockedAmt = privateBigIntCastToScaleOf(toBigInt(privateGetAccountBalance(amountAssetId)), scale18, toBigInt(amoutAssetDecimals))
191- let priceAssetPoolLockedAmt = privateBigIntCastToScaleOf(toBigInt(privateGetAccountBalance(priceAssetId)), scale18, toBigInt(priceAssetDecimals))
192- let currentPrice = calculatePriceBigInt(priceAssetPoolLockedAmt, amountAssetPoolLockedAmt)
193- let paymentLpAmountBuf = privateBigIntCastToScaleOf(toBigInt(paymentLpAmount), scale18, scale8BigInt)
194- let poolLPBalanceBuf = privateBigIntCastToScaleOf(toBigInt(poolLPBalance), scale18, scale8BigInt)
195- let outAmountAssetAmt = fraction(amountAssetPoolLockedAmt, paymentLpAmountBuf, poolLPBalanceBuf)
196- let outPriceAssetAmt = fraction(priceAssetPoolLockedAmt, paymentLpAmountBuf, poolLPBalanceBuf)
197- let outAmountAssetAmtFinal = toInt(privateBigIntCastToScaleOf(outAmountAssetAmt, toBigInt(amoutAssetDecimals), scale18))
198- let outPriceAssetAmtFinal = toInt(privateBigIntCastToScaleOf(outPriceAssetAmt, toBigInt(priceAssetDecimals), scale18))
199- $Tuple11(outAmountAssetAmtFinal, outPriceAssetAmtFinal, amountAssetInternalId, priceAssetInternalId, amountAssetId, priceAssetId, poolAmountAssetBalance, poolPriceAssetBalance, poolLPBalance, currentPrice, poolStatus)
180+ let amtAssetBalance = getAccBalance(amtAssetId)
181+ let amtAssetBalanceX18 = toX18(amtAssetBalance, amtAssetDcm)
182+ let priceAssetBalance = getAccBalance(priceAssetId)
183+ let priceAssetBalanceX18 = toX18(priceAssetBalance, priceAssetDcm)
184+ let curPrice = toInt(calcPriceBigInt(priceAssetBalanceX18, amtAssetBalanceX18, scale8BigInt))
185+ let paymentLpAmtX18 = toX18(paymentLpAmt, scale8)
186+ let poolLPBalanceX18 = toX18(poolLPBalance, scale8)
187+ let outAmtAssetAmt = fraction(amtAssetBalanceX18, paymentLpAmtX18, poolLPBalanceX18)
188+ let outPriceAssetAmt = fraction(priceAssetBalanceX18, paymentLpAmtX18, poolLPBalanceX18)
189+ let outAmtAssetAmtFinal = fromX18(outAmtAssetAmt, amtAssetDcm)
190+ let outPriceAssetAmtFinal = fromX18(outPriceAssetAmt, priceAssetDcm)
191+ $Tuple11(outAmtAssetAmtFinal, outPriceAssetAmtFinal, iAmtAssetId, iPriceAssetId, amtAssetId, priceAssetId, amtAssetBalance, priceAssetBalance, poolLPBalance, curPrice, poolStatus)
200192 }
201193 }
202194
203195
204-func privateEstimatePutOperation (slippageTolerance,inAmountAssetAmt,inAmountAssetId,inPriceAssetAmt,inPriceAssetId,userAddress,isEvaluate) = {
205- let poolConfigDataList = getPoolConfig()
206- let lpAssetId = fromBase58String(poolConfigDataList[idxPoolLPAssetId])
207- let amountAssetId = poolConfigDataList[idxAmountAssetId]
208- let priceAssetId = poolConfigDataList[idxPriceAssetId]
209- let amountAssetInternalId = poolConfigDataList[idxAmountAssetInternalId]
210- let priceAssetInternalId = poolConfigDataList[idxPriceAssetInternalId]
211- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
212- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
213- let poolStatus = poolConfigDataList[idxPoolStatus]
214- let poolLiquidityDataList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
215- let poolAmountAssetBalance = parseIntValue(poolLiquidityDataList[idxPoolAmountAssetAmt])
216- let poolPriceAssetBalance = parseIntValue(poolLiquidityDataList[idxPoolPriceAssetAmt])
217- let poolLPBalance = parseIntValue(poolLiquidityDataList[idxPoolLPAssetAmt])
218- if (if ((amountAssetId != inAmountAssetId))
196+func estimatePutOperation (slippageTolerance,inAmtAssetAmt,inAmtAssetId,inPriceAssetAmt,inPriceAssetId,userAddress,isEvaluate) = {
197+ let cfg = getPoolConfig()
198+ let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
199+ let amtAssetId = cfg[idxAmtAssetId]
200+ let priceAssetId = cfg[idxPriceAssetId]
201+ let iAmtAssetId = cfg[idxIAmtAssetId]
202+ let iPriceAssetId = cfg[idxIPriceAssetId]
203+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
204+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
205+ let poolStatus = cfg[idxPoolStatus]
206+ let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
207+ if (if ((amtAssetId != inAmtAssetId))
219208 then true
220209 else (priceAssetId != inPriceAssetId))
221- then throw("Invalid amount or price asset passed.")
210+ then throw("Invalid amt or price asset passed.")
222211 else {
223- let accountAmountAssetBalance = if (isEvaluate)
224- then privateGetAccountBalance(amountAssetId)
225- else (privateGetAccountBalance(amountAssetId) - inAmountAssetAmt)
226- let accountPriceAssetBalance = if (isEvaluate)
227- then privateGetAccountBalance(priceAssetId)
228- else (privateGetAccountBalance(priceAssetId) - inPriceAssetAmt)
229- let amoutAssetDecimalsBigInt = toBigInt(amoutAssetDecimals)
230- let priceAssetDecimalsBigInt = toBigInt(priceAssetDecimals)
231- let inAmountAssetAmtCalculated = privateBigIntCastToScaleOf(toBigInt(inAmountAssetAmt), scale18, amoutAssetDecimalsBigInt)
232- let inPriceAssetAmtCalculated = privateBigIntCastToScaleOf(toBigInt(inPriceAssetAmt), scale18, priceAssetDecimalsBigInt)
233- let userPrice = calculatePriceBigInt(inPriceAssetAmtCalculated, inAmountAssetAmtCalculated)
234- let amountAssetPoolLockedAmt = privateBigIntCastToScaleOf(toBigInt(accountAmountAssetBalance), scale18, amoutAssetDecimalsBigInt)
235- let priceAssetPoolLockedAmt = privateBigIntCastToScaleOf(toBigInt(accountPriceAssetBalance), scale18, priceAssetDecimalsBigInt)
236- let curentPrice = if ((poolLPBalance == 0))
212+ let accAmtAssetBalance = if (isEvaluate)
213+ then getAccBalance(amtAssetId)
214+ else (getAccBalance(amtAssetId) - inAmtAssetAmt)
215+ let accPriceAssetBalance = if (isEvaluate)
216+ then getAccBalance(priceAssetId)
217+ else (getAccBalance(priceAssetId) - inPriceAssetAmt)
218+ let inAmtAssetAmtX18 = toX18(inAmtAssetAmt, amtAssetDcm)
219+ let inPriceAssetAmtX18 = toX18(inPriceAssetAmt, priceAssetDcm)
220+ let userPrice = toInt(calcPriceBigInt(inPriceAssetAmtX18, inAmtAssetAmtX18, scale8BigInt))
221+ let accAmtAssetBalanceX18 = toX18(accAmtAssetBalance, amtAssetDcm)
222+ let accPriceAssetBalanceX18 = toX18(accPriceAssetBalance, priceAssetDcm)
223+ let curPrice = if ((poolLPBalance == 0))
237224 then 0
238- else calculatePriceBigInt(priceAssetPoolLockedAmt, amountAssetPoolLockedAmt)
239- let slippage = if ((curentPrice == 0))
225+ else toInt(calcPriceBigInt(accPriceAssetBalanceX18, accAmtAssetBalanceX18, scale8BigInt))
226+ let slippage = if ((curPrice == 0))
240227 then 0
241- else if ((curentPrice > userPrice))
242- then fraction((curentPrice - userPrice), 100, curentPrice)
243- else fraction((userPrice - curentPrice), 100, curentPrice)
244- if (if ((curentPrice != 0))
245- then ((slippage * scale8) > slippageTolerance)
228+ else if ((curPrice > userPrice))
229+ then fraction((curPrice - userPrice), scale8, curPrice)
230+ else fraction((userPrice - curPrice), scale8, curPrice)
231+ if (if ((curPrice != 0))
232+ then (slippage > slippageTolerance)
246233 else false)
247- then throw(((("Price slippage " + toString((slippage * scale8))) + " exceeded the passed limit of ") + toString(slippageTolerance)))
234+ then throw(((("Price slippage " + toString(slippage)) + " exceeded the passed limit of ") + toString(slippageTolerance)))
248235 else {
249- let finalPrice = calculatePriceBigInt((priceAssetPoolLockedAmt + inPriceAssetAmtCalculated), (amountAssetPoolLockedAmt + inAmountAssetAmtCalculated))
250- let outLpAmount = if ((poolLPBalance == 0))
236+ let res = if ((poolLPBalance == 0))
251237 then {
252- let lpResultBuf = pow((inAmountAssetAmtCalculated * inPriceAssetAmtCalculated), 0, toBigInt(5), 1, 0, DOWN)
253- toInt(privateBigIntCastToScaleOf(lpResultBuf, scale8BigInt, scale18))
238+ let lpResultBuf = pow((inAmtAssetAmtX18 * inPriceAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
239+ $Tuple4(fromX18(lpResultBuf, scale8), fromX18(inAmtAssetAmtX18, amtAssetDcm), fromX18(inPriceAssetAmtX18, priceAssetDcm), toInt(calcPriceBigInt((accPriceAssetBalanceX18 + inPriceAssetAmtX18), (accAmtAssetBalanceX18 + inAmtAssetAmtX18), scale8BigInt)))
254240 }
255241 else {
256- let poolLPBalanceBuf = privateBigIntCastToScaleOf(toBigInt(poolLPBalance), scale18, scale8BigInt)
257- let lpAmtByAmountAsset = toInt(privateBigIntCastToScaleOf(fraction(poolLPBalanceBuf, inAmountAssetAmtCalculated, amountAssetPoolLockedAmt), scale8BigInt, scale18))
258- let lpAmtByPriceAsset = toInt(privateBigIntCastToScaleOf(fraction(poolLPBalanceBuf, inPriceAssetAmtCalculated, priceAssetPoolLockedAmt), scale8BigInt, scale18))
259- if ((lpAmtByPriceAsset > lpAmtByAmountAsset))
260- then lpAmtByAmountAsset
261- else lpAmtByPriceAsset
242+ let poolLPBalanceX18 = toX18(poolLPBalance, scale8)
243+ let curPriceX18 = toX18(curPrice, scale8)
244+ let pEqByA = fraction(curPriceX18, inAmtAssetAmtX18, scale18)
245+ let resAssetsToPut = if ((pEqByA > inPriceAssetAmtX18))
246+ then $Tuple2(fraction(inPriceAssetAmtX18, scale18, curPriceX18), inPriceAssetAmtX18)
247+ else $Tuple2(inAmtAssetAmtX18, pEqByA)
248+ let lpResult = fromX18(fraction(poolLPBalanceX18, resAssetsToPut._2, accPriceAssetBalanceX18), scale8)
249+ $Tuple4(lpResult, fromX18(resAssetsToPut._1, amtAssetDcm), fromX18(resAssetsToPut._2, priceAssetDcm), toInt(calcPriceBigInt((accPriceAssetBalanceX18 + resAssetsToPut._2), (accAmtAssetBalanceX18 + resAssetsToPut._1), scale8BigInt)))
262250 }
263- if ((0 >= outLpAmount))
251+ if ((0 >= res._1))
264252 then throw("Invalid calculations. LP calculated is less than zero.")
265- else $Tuple10(outLpAmount, finalPrice, poolAmountAssetBalance, poolPriceAssetBalance, poolLPBalance, amountAssetInternalId, priceAssetInternalId, lpAssetId, slippage, poolStatus)
253+ else $Tuple12(res._1, res._4, accAmtAssetBalance, accPriceAssetBalance, poolLPBalance, iAmtAssetId, iPriceAssetId, lpAssetId, slippage, poolStatus, res._2, res._3)
266254 }
267255 }
268256 }
269257
270258
271259 func validateMatcherOrderAllowed (order) = {
272- let poolConfigDataList = getPoolConfig()
273- let amountAssetId = poolConfigDataList[idxAmountAssetId]
274- let priceAssetId = poolConfigDataList[idxPriceAssetId]
275- let poolStatus = parseIntValue(poolConfigDataList[idxPoolStatus])
276- let matcherPublicKeyStr = poolConfigDataList[idxMatcherPublicKey]
277- let amountAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
278- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
279- let accountAmountAssetBalance = privateGetAccountBalance(amountAssetId)
280- let accountPriceAssetBalance = privateGetAccountBalance(priceAssetId)
281- let currentPrice = if ((order.orderType == Buy))
282- then privateCalculatePrice(amountAssetDecimals, priceAssetDecimals, (accountAmountAssetBalance + order.amount), accountPriceAssetBalance)
283- else privateCalculatePrice(amountAssetDecimals, priceAssetDecimals, (accountAmountAssetBalance + order.amount), accountPriceAssetBalance)
284- let isPoolStatusValid = if (if (if (isGlobalShutdown())
260+ let cfg = getPoolConfig()
261+ let amtAssetId = cfg[idxAmtAssetId]
262+ let priceAssetId = cfg[idxPriceAssetId]
263+ let poolStatus = parseIntValue(cfg[idxPoolStatus])
264+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
265+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
266+ let accAmtAssetBalance = getAccBalance(amtAssetId)
267+ let accPriceAssetBalance = getAccBalance(priceAssetId)
268+ let curPrice = if ((order.orderType == Buy))
269+ then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
270+ else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
271+ if (if (if (isGlobalShutdown())
285272 then true
286273 else (poolStatus == PoolMatcherDisabled))
287274 then true
288275 else (poolStatus == PoolShutdown))
289- then false
290- else true
291- let isValidMatcherSign = true
292- let orderAmountAsset = order.assetPair.amountAsset
293- let orderAmountAssetStr = if ((orderAmountAsset == unit))
294- then "WAVES"
295- else toBase58String(value(orderAmountAsset))
296- let orderPriceAsset = order.assetPair.priceAsset
297- let orderPriceAssetStr = if ((orderPriceAsset == unit))
298- then "WAVES"
299- else toBase58String(value(orderPriceAsset))
300- let isValidAssetPair = if (if ((orderAmountAssetStr != amountAssetId))
301- then true
302- else (orderPriceAssetStr != priceAssetId))
303- then false
304- else true
305- let orderPrice = order.price
306- let priceDecimals = fraction(scale8, priceAssetDecimals, amountAssetDecimals)
307- let castedOrderPrice = privateCastToScaleOf(orderPrice, scale8, priceDecimals)
308- let isOrderPriceValid = if ((order.orderType == Buy))
309- then (currentPrice >= castedOrderPrice)
310- else (castedOrderPrice >= currentPrice)
311- if (if (if (isValidAssetPair)
312- then isValidMatcherSign
313- else false)
314- then isPoolStatusValid
315- else false)
316- then isOrderPriceValid
317- else false
276+ then throw("Exchange operations disabled")
277+ else {
278+ let orderAmtAsset = order.assetPair.amountAsset
279+ let orderAmtAssetStr = if ((orderAmtAsset == unit))
280+ then "WAVES"
281+ else toBase58String(value(orderAmtAsset))
282+ let orderPriceAsset = order.assetPair.priceAsset
283+ let orderPriceAssetStr = if ((orderPriceAsset == unit))
284+ then "WAVES"
285+ else toBase58String(value(orderPriceAsset))
286+ if (if ((orderAmtAssetStr != amtAssetId))
287+ then true
288+ else (orderPriceAssetStr != priceAssetId))
289+ then throw("Wrong order assets.")
290+ else {
291+ let orderPrice = order.price
292+ let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
293+ let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
294+ let isOrderPriceValid = if ((order.orderType == Buy))
295+ then (curPrice >= castedOrderPrice)
296+ else (castedOrderPrice >= curPrice)
297+ if (!(isOrderPriceValid))
298+ then throw(((("Order price leads to K decrease. castedOrderPrice=" + toString(castedOrderPrice)) + " curPrice=") + toString(curPrice)))
299+ else true
300+ }
301+ }
318302 }
319303
320304
321-@Callable(i)
322-func constructor (factoryContract) = if ((i.caller != this))
323- then throw("permissions denied")
324- else [StringEntry(keyFactoryContract(), factoryContract)]
305+func commonGet (i) = {
306+ let pmtAmtAsset = value(i.payments[0])
307+ let pmtAssetId = value(pmtAmtAsset.assetId)
308+ let pmtAssetAmt = pmtAmtAsset.amount
309+ let res = estimateGetOperation(toBase58String(pmtAssetId), pmtAssetAmt, toString(i.caller))
310+ let outAmtAssetAmt = res._1
311+ let outPriceAssetAmt = res._2
312+ let iAmtAssetId = res._3
313+ let iPriceAssetId = res._4
314+ let amtAssetId = res._5
315+ let priceAssetId = res._6
316+ let poolAmtAssetBalance = res._7
317+ let poolPriceAssetBalance = res._8
318+ let poolLPBalance = res._9
319+ let curPrice = res._10
320+ let poolStatus = parseIntValue(res._11)
321+ if (if (isGlobalShutdown())
322+ then true
323+ else (poolStatus == PoolShutdown))
324+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
325+ else $Tuple5(outAmtAssetAmt, outPriceAssetAmt, pmtAssetAmt, pmtAssetId, [ScriptTransfer(i.caller, outAmtAssetAmt, if ((amtAssetId == "WAVES"))
326+ then unit
327+ else fromBase58String(amtAssetId)), ScriptTransfer(i.caller, outPriceAssetAmt, if ((priceAssetId == "WAVES"))
328+ then unit
329+ else fromBase58String(priceAssetId)), StringEntry(keyGetActionByUser(toString(i.caller), toBase58String(i.transactionId)), dataGetActionInfo(outAmtAssetAmt, outPriceAssetAmt, pmtAssetAmt, curPrice, height, lastBlock.timestamp)), StringEntry(keyPriceLast(), ("%s__" + toString(curPrice))), StringEntry(keyPriceHistory(height, lastBlock.timestamp), ("%s__" + toString(curPrice)))])
330+ }
325331
326332
327-
328-@Callable(i)
329-func put (slippageTolerance,shouldAutoStake) = {
330- let factoryConfigList = getFactoryConfig()
331- let stakingContract = valueOrErrorMessage(addressFromString(factoryConfigList[idxFactoryStakingContract]), "Error. Incorrect staking address.")
332- let pmtAmountAsset = value(i.payments[0])
333- let inAmountAssetAmt = pmtAmountAsset.amount
334- let inAmountAssetId = if (!(isDefined(pmtAmountAsset.assetId)))
333+func commonPut (i,slippageTolerance,emitLp) = {
334+ let pmtAmtAsset = value(i.payments[0])
335+ let inAmtAssetAmt = pmtAmtAsset.amount
336+ let inAmtAssetId = if (!(isDefined(pmtAmtAsset.assetId)))
335337 then fromBase58String("WAVES")
336- else value(pmtAmountAsset.assetId)
338+ else value(pmtAmtAsset.assetId)
337339 let pmtPriceAsset = value(i.payments[1])
338340 let inPriceAssetAmt = pmtPriceAsset.amount
339341 let inPriceAssetId = if (!(isDefined(pmtPriceAsset.assetId)))
340342 then fromBase58String("WAVES")
341343 else value(pmtPriceAsset.assetId)
342- let estimatedPutResults = privateEstimatePutOperation(slippageTolerance, inAmountAssetAmt, toBase58String(inAmountAssetId), inPriceAssetAmt, toBase58String(inPriceAssetId), toString(i.caller), false)
343- let outLpAmount = estimatedPutResults._1
344- let curentPrice = estimatedPutResults._2
345- let poolAmountAssetBalance = estimatedPutResults._3
346- let poolPriceAssetBalance = estimatedPutResults._4
347- let poolLPBalance = estimatedPutResults._5
348- let amountAssetInternalId = estimatedPutResults._6
349- let priceAssetInternalId = estimatedPutResults._7
350- let lpAssetId = estimatedPutResults._8
351- let slippageCalculated = estimatedPutResults._9
352- let poolStatus = parseIntValue(estimatedPutResults._10)
344+ let estPut = estimatePutOperation(slippageTolerance, inAmtAssetAmt, toBase58String(inAmtAssetId), inPriceAssetAmt, toBase58String(inPriceAssetId), toString(i.caller), false)
345+ let outLpAmt = estPut._1
346+ let curPrice = estPut._2
347+ let poolAmtAssetBalance = estPut._3
348+ let poolPriceAssetBalance = estPut._4
349+ let poolLPBalance = estPut._5
350+ let iAmtAssetId = estPut._6
351+ let iPriceAssetId = estPut._7
352+ let lpAssetId = estPut._8
353+ let slippageCalc = estPut._9
354+ let poolStatus = parseIntValue(estPut._10)
355+ let realAmtAssetIn = estPut._11
356+ let realPriceAssetIn = estPut._12
353357 if (if (if (isGlobalShutdown())
354358 then true
355359 else (poolStatus == PoolPutDisabled))
356360 then true
357361 else (poolStatus == PoolShutdown))
358362 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
359363 else {
360- let emitLPAssetOnFactory = invoke(factoryContract, "emit", [outLpAmount], nil)
361- if ((emitLPAssetOnFactory == emitLPAssetOnFactory))
362- then if ((emitLPAssetOnFactory != "success"))
363- then throw("LP asset reissue failed during emit call on factory.")
364- else {
365- let results = [StringEntry(keyPriceLast(), ("%s__" + toString(curentPrice))), StringEntry(keyPriceHistory(height, lastBlock.timestamp), ("%s__" + toString(curentPrice))), StringEntry(keyPutActionByUser(toString(i.caller), toBase58String(i.transactionId)), dataPutActionInfo(inAmountAssetAmt, inPriceAssetAmt, outLpAmount, curentPrice, slippageTolerance, slippageCalculated, height, lastBlock.timestamp)), StringEntry(keyPoolLiquidity(amountAssetInternalId, priceAssetInternalId), dataPoolLiquidity((poolAmountAssetBalance + inAmountAssetAmt), (poolPriceAssetBalance + inPriceAssetAmt), (poolLPBalance + outLpAmount)))]
366- if (shouldAutoStake)
367- then {
368- let stake = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, outLpAmount)])
369- if ((stake == stake))
370- then results
371- else throw("Strict value is not equal to itself.")
372- }
373- else (results :+ ScriptTransfer(i.caller, outLpAmount, lpAssetId))
374- }
364+ let lpAmtToEmit = if (!(emitLp))
365+ then 0
366+ else outLpAmt
367+ let diffInAmtAsset = (inAmtAssetAmt - realAmtAssetIn)
368+ let diffInPriceAsset = (inPriceAssetAmt - realPriceAssetIn)
369+ let dataStateWrite = [StringEntry(keyPriceLast(), ("%s__" + toString(curPrice))), StringEntry(keyPriceHistory(height, lastBlock.timestamp), ("%s__" + toString(curPrice))), StringEntry(keyPutActionByUser(toString(i.caller), toBase58String(i.transactionId)), dataPutActionInfo(realAmtAssetIn, realPriceAssetIn, lpAmtToEmit, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, diffInAmtAsset, diffInPriceAsset))]
370+ $Tuple9(lpAmtToEmit, lpAssetId, dataStateWrite, inAmtAssetAmt, realAmtAssetIn, inPriceAssetAmt, realPriceAssetIn, pmtAmtAsset.assetId, pmtPriceAsset.assetId)
371+ }
372+ }
373+
374+
375+@Callable(i)
376+func constructor (factoryContract,managerPublicKey) = if ((i.caller != this))
377+ then throw("permissions denied")
378+ else [StringEntry(keyFactoryContract(), factoryContract), StringEntry(keyManagerPublicKey(), managerPublicKey)]
379+
380+
381+
382+@Callable(i)
383+func put (slippageTolerance,shouldAutoStake) = {
384+ let factoryCfg = getFactoryConfig()
385+ let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.")
386+ let slippageContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactorySlippageContract]), "Error. Incorrect slippage contract address.")
387+ let actions = commonPut(i, slippageTolerance, true)
388+ let amtToEmit = actions._1
389+ let lpAssetId = actions._2
390+ let state = actions._3
391+ let inAmt = actions._4
392+ let realInAmt = actions._5
393+ let inPrice = actions._6
394+ let realInPrice = actions._7
395+ let amId = actions._8
396+ let prId = actions._9
397+ let diffInAmtAsset = (inAmt - realInAmt)
398+ let diffInPriceAsset = (inPrice - realInPrice)
399+ let emitInv = invoke(factoryContract, "emit", [amtToEmit], nil)
400+ if ((emitInv == emitInv))
401+ then {
402+ let slippageAInv = if ((inAmt > realInAmt))
403+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, diffInAmtAsset)])
404+ else nil
405+ if ((slippageAInv == slippageAInv))
406+ then {
407+ let slippagePInv = if ((inPrice > realInPrice))
408+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, diffInPriceAsset)])
409+ else nil
410+ if ((slippagePInv == slippagePInv))
411+ then {
412+ let lpStakeInv = if (shouldAutoStake)
413+ then invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, amtToEmit)])
414+ else nil
415+ if ((lpStakeInv == lpStakeInv))
416+ then (state :+ ScriptTransfer(i.caller, amtToEmit, lpAssetId))
417+ else throw("Strict value is not equal to itself.")
418+ }
419+ else throw("Strict value is not equal to itself.")
420+ }
375421 else throw("Strict value is not equal to itself.")
376422 }
423+ else throw("Strict value is not equal to itself.")
424+ }
425+
426+
427+
428+@Callable(i)
429+func putForFree () = {
430+ let actions = commonPut(i, 0, false)
431+ actions._3
377432 }
378433
379434
380435
381436 @Callable(i)
382437 func get () = {
383- let pmtAmountAsset = value(i.payments[0])
384- let pmtAssetId = value(pmtAmountAsset.assetId)
385- let pmtAssetAmount = pmtAmountAsset.amount
386- let results = privateEstimateGetOperation(toBase58String(pmtAssetId), pmtAssetAmount, toString(i.caller))
387- let outAmountAssetAmt = results._1
388- let outPriceAssetAmt = results._2
389- let amountAssetInternalId = results._3
390- let priceAssetInternalId = results._4
391- let amountAssetId = results._5
392- let priceAssetId = results._6
393- let poolAmountAssetBalance = results._7
394- let poolPriceAssetBalance = results._8
395- let poolLPBalance = results._9
396- let currentPrice = results._10
397- let poolStatus = parseIntValue(results._11)
398- if (if (isGlobalShutdown())
399- then true
400- else (poolStatus == PoolShutdown))
401- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
402- else {
403- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAssetAmount], [AttachedPayment(pmtAssetId, pmtAssetAmount)])
404- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
405- then if ((burnLPAssetOnFactory != "success"))
406- then throw("LP asset burn failed during emit call on factory.")
407- else [ScriptTransfer(i.caller, outAmountAssetAmt, if ((amountAssetId == "WAVES"))
408- then unit
409- else fromBase58String(amountAssetId)), ScriptTransfer(i.caller, outPriceAssetAmt, fromBase58String(priceAssetId)), StringEntry(keyPoolLiquidity(amountAssetInternalId, priceAssetInternalId), dataPoolLiquidity((poolAmountAssetBalance - outAmountAssetAmt), (poolPriceAssetBalance - outPriceAssetAmt), (poolLPBalance - pmtAssetAmount))), StringEntry(keyGetActionByUser(toString(i.caller), toBase58String(i.transactionId)), dataGetActionInfo(outAmountAssetAmt, outPriceAssetAmt, pmtAssetAmount, currentPrice, height, lastBlock.timestamp)), StringEntry(keyPriceLast(), ("%s__" + toString(currentPrice))), StringEntry(keyPriceHistory(height, lastBlock.timestamp), ("%s__" + toString(currentPrice)))]
410- else throw("Strict value is not equal to itself.")
411- }
438+ let res = commonGet(i)
439+ let outAmtAssetAmt = res._1
440+ let outPriceAssetAmt = res._2
441+ let pmtAssetAmt = res._3
442+ let pmtAssetId = res._4
443+ let actions = res._5
444+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAssetAmt], [AttachedPayment(pmtAssetId, pmtAssetAmt)])
445+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
446+ then actions
447+ else throw("Strict value is not equal to itself.")
412448 }
413449
414450
415451
416452 @Callable(i)
417-func activate (amountAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
453+func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
454+ let res = commonGet(i)
455+ let outAmtAssetAmt = res._1
456+ let outPriceAssetAmt = res._2
457+ let pmtAssetAmt = res._3
458+ let pmtAssetId = res._4
459+ let actions = res._5
460+ if ((noLessThenAmtAsset > outAmtAssetAmt))
461+ then throw(((("noLessThenAmtAsset failed: " + toString(outAmtAssetAmt)) + " < ") + toString(noLessThenAmtAsset)))
462+ else if ((noLessThenPriceAsset > outPriceAssetAmt))
463+ then throw(((("noLessThenPriceAsset failed: " + toString(outPriceAssetAmt)) + " < ") + toString(noLessThenPriceAsset)))
464+ else {
465+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAssetAmt], [AttachedPayment(pmtAssetId, pmtAssetAmt)])
466+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
467+ then actions
468+ else throw("Strict value is not equal to itself.")
469+ }
470+ }
471+
472+
473+
474+@Callable(i)
475+func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
418476 then throw("permissions denied")
419- else $Tuple2([StringEntry(keyAmountAsset(), amountAssetStr), StringEntry(keyPriceAsset(), priceAssetStr)], "success")
477+ else $Tuple2([StringEntry(keyAmtAsset(), amtAssetStr), StringEntry(keyPriceAsset(), priceAssetStr)], "success")
420478
421479
422480
423481 @Callable(i)
424482 func statsREADONLY () = {
425- let poolConfigDataList = getPoolConfig()
426- let lpAssetId = fromBase58String(poolConfigDataList[idxPoolLPAssetId])
427- let amountAssetId = poolConfigDataList[idxAmountAssetId]
428- let priceAssetId = poolConfigDataList[idxPriceAssetId]
429- let amountAssetInternalId = poolConfigDataList[idxAmountAssetInternalId]
430- let priceAssetInternalId = poolConfigDataList[idxPriceAssetInternalId]
431- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
432- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
433- let poolLiquidityDataList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
434- let poolLPBalance = parseIntValue(poolLiquidityDataList[idxPoolLPAssetAmt])
435- let accountAmountAssetBalance = privateGetAccountBalance(amountAssetId)
436- let accountPriceAssetBalance = privateGetAccountBalance(priceAssetId)
437- let pricesList = calculatePrices(accountAmountAssetBalance, accountPriceAssetBalance, poolLPBalance)
438- let currentPrice = pricesList[0]
439- let lpAmountAssetShare = pricesList[1]
483+ let cfg = getPoolConfig()
484+ let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
485+ let amtAssetId = cfg[idxAmtAssetId]
486+ let priceAssetId = cfg[idxPriceAssetId]
487+ let iAmtAssetId = cfg[idxIAmtAssetId]
488+ let iPriceAssetId = cfg[idxIPriceAssetId]
489+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
490+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
491+ let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
492+ let accAmtAssetBalance = getAccBalance(amtAssetId)
493+ let accPriceAssetBalance = getAccBalance(priceAssetId)
494+ let pricesList = calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
495+ let curPrice = pricesList[0]
496+ let lpAmtAssetShare = pricesList[1]
440497 let lpPriceAssetShare = pricesList[2]
441- let poolWeight = valueOrErrorMessage(getInteger(factoryContract, keyPoolWeight(toString(this))), "Pool doesn't have weight.")
442- $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accountAmountAssetBalance), toString(accountPriceAssetBalance), toString(poolLPBalance), toString(currentPrice), toString(lpAmountAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP))
498+ let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
499+ $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP))
443500 }
444501
445502
446503
447504 @Callable(i)
448-func evaluatePutByAmountAssetREADONLY (slippageTolerance,inAmountAssetAmt,userAddress) = {
449- let poolConfigDataList = getPoolConfig()
450- let lpAssetId = fromBase58String(poolConfigDataList[idxPoolLPAssetId])
451- let amountAssetId = poolConfigDataList[idxAmountAssetId]
452- let priceAssetId = poolConfigDataList[idxPriceAssetId]
453- let amountAssetInternalId = poolConfigDataList[idxAmountAssetInternalId]
454- let priceAssetInternalId = poolConfigDataList[idxPriceAssetInternalId]
455- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
456- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
457- let poolStatus = poolConfigDataList[idxPoolStatus]
458- let poolLiquidityDataList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
459- let poolLPBalance = parseIntValue(poolLiquidityDataList[idxPoolLPAssetAmt])
460- let accountAmountAssetBalance = privateGetAccountBalance(amountAssetId)
461- let accountPriceAssetBalance = privateGetAccountBalance(priceAssetId)
462- let accountAmountAssetBalanceCasted = privateCastToScaleOf(accountAmountAssetBalance, scale8, amoutAssetDecimals)
463- let accountPriceAssetBalanceCasted = privateCastToScaleOf(accountPriceAssetBalance, scale8, priceAssetDecimals)
464- let curentPrice = if ((poolLPBalance == 0))
465- then 0
466- else calculatePrice(accountPriceAssetBalanceCasted, accountAmountAssetBalanceCasted)
467- let inAmountAssetAmtCasted = privateCastToScaleOf(inAmountAssetAmt, scale8, amoutAssetDecimals)
468- let inPriceAssetAmtCalculated = fraction(inAmountAssetAmtCasted, curentPrice, scale8)
469- let inPriceAssetAmt = privateCastToScaleOf(inPriceAssetAmtCalculated, priceAssetDecimals, scale8)
470- let estimatedPutResults = privateEstimatePutOperation(slippageTolerance, inAmountAssetAmt, amountAssetId, inPriceAssetAmt, priceAssetId, userAddress, true)
471- let outLpAmountCalc = estimatedPutResults._1
472- let curentPriceCalc = estimatedPutResults._2
473- let poolAmountAssetBalanceCalc = estimatedPutResults._3
505+func evaluatePutByAmtAssetREADONLY (slippageTolerance,inAmtAssetAmt,userAddress) = {
506+ let cfg = getPoolConfig()
507+ let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
508+ let amtAssetId = cfg[idxAmtAssetId]
509+ let priceAssetId = cfg[idxPriceAssetId]
510+ let iAmtAssetId = cfg[idxIAmtAssetId]
511+ let iPriceAssetId = cfg[idxIPriceAssetId]
512+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
513+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
514+ let poolStatus = cfg[idxPoolStatus]
515+ let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
516+ let accAmtAssetBalance = getAccBalance(amtAssetId)
517+ let accPriceAssetBalance = getAccBalance(priceAssetId)
518+ let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
519+ let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
520+ let curPriceX18 = if ((poolLPBalance == 0))
521+ then toBigInt(0)
522+ else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18, scale18)
523+ let inAmtAssetAmtX18 = toX18(inAmtAssetAmt, amtAssetDcm)
524+ let inPriceAssetAmtX18 = fraction(inAmtAssetAmtX18, curPriceX18, scale18)
525+ let inPriceAssetAmt = fromX18(inPriceAssetAmtX18, priceAssetDcm)
526+ let estimatedPutResults = estimatePutOperation(slippageTolerance, inAmtAssetAmt, amtAssetId, inPriceAssetAmt, priceAssetId, userAddress, true)
527+ let outLpAmtCalc = estimatedPutResults._1
528+ let curPriceCalc = estimatedPutResults._2
529+ let poolAmtAssetBalanceCalc = estimatedPutResults._3
474530 let poolPriceAssetBalanceCAlc = estimatedPutResults._4
475531 let poolLPBalanceCalc = estimatedPutResults._5
476532 let poolStatusCalc = parseIntValue(estimatedPutResults._10)
477- $Tuple2(nil, makeString(["%d%d%d%d%d%d", toString(outLpAmountCalc), toString(curentPrice), toString(poolAmountAssetBalanceCalc), toString(poolPriceAssetBalanceCAlc), toString(poolLPBalanceCalc), toString(poolStatusCalc)], SEP))
533+ $Tuple2(nil, makeString(["%d%d%d%d%d%d", toString(outLpAmtCalc), toString(fromX18(curPriceX18, scale8)), toString(poolAmtAssetBalanceCalc), toString(poolPriceAssetBalanceCAlc), toString(poolLPBalanceCalc), toString(poolStatusCalc)], SEP))
478534 }
479535
480536
481537
482538 @Callable(i)
483539 func evaluatePutByPriceAssetREADONLY (slippageTolerance,inPriceAssetAmt,userAddress) = {
484- let poolConfigDataList = getPoolConfig()
485- let lpAssetId = fromBase58String(poolConfigDataList[idxPoolLPAssetId])
486- let amountAssetId = poolConfigDataList[idxAmountAssetId]
487- let priceAssetId = poolConfigDataList[idxPriceAssetId]
488- let amountAssetInternalId = poolConfigDataList[idxAmountAssetInternalId]
489- let priceAssetInternalId = poolConfigDataList[idxPriceAssetInternalId]
490- let amoutAssetDecimals = parseIntValue(poolConfigDataList[idxAmountAssetDecimals])
491- let priceAssetDecimals = parseIntValue(poolConfigDataList[idxPriceAssetDecimals])
492- let poolStatus = poolConfigDataList[idxPoolStatus]
493- let poolLiquidityDataList = getPoolLiquidity(amountAssetInternalId, priceAssetInternalId)
494- let poolLPBalance = parseIntValue(poolLiquidityDataList[idxPoolLPAssetAmt])
495- let accountAmountAssetBalance = privateGetAccountBalance(amountAssetId)
496- let accountPriceAssetBalance = privateGetAccountBalance(priceAssetId)
497- let accountAmountAssetBalanceCasted = privateCastToScaleOf(accountAmountAssetBalance, scale8, amoutAssetDecimals)
498- let accountPriceAssetBalanceCasted = privateCastToScaleOf(accountPriceAssetBalance, scale8, priceAssetDecimals)
499- let inPriceAssetAmtCalculated = privateCastToScaleOf(inPriceAssetAmt, scale8, priceAssetDecimals)
500- let curentPrice = if ((poolLPBalance == 0))
501- then 0
502- else calculatePrice(accountPriceAssetBalanceCasted, accountAmountAssetBalanceCasted)
503- let inAmountAssetAmtCalculated = fraction(inPriceAssetAmtCalculated, scale8, curentPrice)
504- let inAmountAssetAmt = privateCastToScaleOf(inAmountAssetAmtCalculated, amoutAssetDecimals, scale8)
505- let estimatedPutResults = privateEstimatePutOperation(slippageTolerance, inAmountAssetAmt, amountAssetId, inPriceAssetAmt, priceAssetId, userAddress, true)
506- let outLpAmountCalc = estimatedPutResults._1
507- let curentPriceCalc = estimatedPutResults._2
508- let poolAmountAssetBalanceCalc = estimatedPutResults._3
540+ let cfg = getPoolConfig()
541+ let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
542+ let amtAssetId = cfg[idxAmtAssetId]
543+ let priceAssetId = cfg[idxPriceAssetId]
544+ let iAmtAssetId = cfg[idxIAmtAssetId]
545+ let iPriceAssetId = cfg[idxIPriceAssetId]
546+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
547+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
548+ let poolStatus = cfg[idxPoolStatus]
549+ let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
550+ let accAmtAssetBalance = getAccBalance(amtAssetId)
551+ let accPriceAssetBalance = getAccBalance(priceAssetId)
552+ let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
553+ let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
554+ let curPriceX18 = if ((poolLPBalance == 0))
555+ then toBigInt(0)
556+ else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18, scale18)
557+ let inPriceAssetAmtX18 = toX18(inPriceAssetAmt, priceAssetDcm)
558+ let inAmtAssetAmtX18 = fraction(inPriceAssetAmtX18, scale18, curPriceX18)
559+ let inAmtAssetAmt = fromX18(inAmtAssetAmtX18, amtAssetDcm)
560+ let estimatedPutResults = estimatePutOperation(slippageTolerance, inAmtAssetAmt, amtAssetId, inPriceAssetAmt, priceAssetId, userAddress, true)
561+ let outLpAmtCalc = estimatedPutResults._1
562+ let curPriceCalc = estimatedPutResults._2
563+ let poolAmtAssetBalanceCalc = estimatedPutResults._3
509564 let poolPriceAssetBalanceCAlc = estimatedPutResults._4
510565 let poolLPBalanceCalc = estimatedPutResults._5
511566 let poolStatusCalc = parseIntValue(estimatedPutResults._10)
512- $Tuple2(nil, makeString(["%d%d%d%d%d%d", toString(outLpAmountCalc), toString(curentPrice), toString(poolAmountAssetBalanceCalc), toString(poolPriceAssetBalanceCAlc), toString(poolLPBalanceCalc), toString(poolStatusCalc)], SEP))
567+ $Tuple2(nil, makeString(["%d%d%d%d%d%d", toString(outLpAmtCalc), toString(fromX18(curPriceX18, scale8)), toString(poolAmtAssetBalanceCalc), toString(poolPriceAssetBalanceCAlc), toString(poolLPBalanceCalc), toString(poolStatusCalc)], SEP))
513568 }
514569
515570
516571
517572 @Callable(i)
518-func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmount,userAddress) = {
519- let results = privateEstimateGetOperation(paymentLpAssetId, paymentLpAmount, userAddress)
520- let outAmountAssetAmt = results._1
521- let outPriceAssetAmt = results._2
522- let poolAmountAssetBalance = results._7
523- let poolPriceAssetBalance = results._8
524- let poolLPBalance = results._9
525- let currentPrice = results._10
526- let poolStatus = parseIntValue(results._11)
527- $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmountAssetAmt), toString(outPriceAssetAmt), toString(poolAmountAssetBalance), toString(poolPriceAssetBalance), toString(poolLPBalance), toString(currentPrice), toString(poolStatus)], SEP))
573+func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt,userAddress) = {
574+ let res = estimateGetOperation(paymentLpAssetId, paymentLpAmt, userAddress)
575+ let outAmtAssetAmt = res._1
576+ let outPriceAssetAmt = res._2
577+ let poolAmtAssetBalance = res._7
578+ let poolPriceAssetBalance = res._8
579+ let poolLPBalance = res._9
580+ let curPrice = res._10
581+ let poolStatus = parseIntValue(res._11)
582+ $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmtAssetAmt), toString(outPriceAssetAmt), toString(poolAmtAssetBalance), toString(poolPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(poolStatus)], SEP))
528583 }
529-
530-
531-
532-@Callable(i)
533-func hashREADONLY () = $Tuple2(nil, toBase64String(value(scriptHash(this))))
534584
535585
536586 @Verifier(tx)
537587 func verify () = match tx {
538588 case order: Order =>
539- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
589+ if (validateMatcherOrderAllowed(order))
590+ then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
591+ else false
540592 case _ =>
541- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
593+ let managerPublic = valueOrElse(getString(this, keyManagerPublicKey()), EMPTY)
594+ if ((managerPublic == EMPTY))
595+ then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
596+ else sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(managerPublic))
542597 }
543598

github/deemru/w8io/026f985 
113.68 ms