tx · FHFuEo3f5gS9dkWkpYJUAm5ft2KwiFXorwrhz6WGbojB

3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA:  -0.03400000 Waves

2022.08.18 15:37 [2189920] smart account 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA > SELF 0.00000000 Waves

{ "type": 13, "id": "FHFuEo3f5gS9dkWkpYJUAm5ft2KwiFXorwrhz6WGbojB", "fee": 3400000, "feeAssetId": null, "timestamp": 1660826302199, "version": 1, "sender": "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA", "senderPublicKey": "35yd3qw1gxKDxKwGAykHN9fANbXNWwseaUwbWDj24o3x", "proofs": [ "aM8FpRhukqYRzyNXQ3XNrR9BT7JHAtyQebx6k5F8DGXZAAAyeHufDNicPLWZtvHhb9Qdih7P4Qqzx9gm257Fypo" ], "script": "base64:AAIFAAAAAAAAC68IAhIDCgEIEgMKAQgSABIECgIBBBIHCgUBAQEBBBIDCgEBEgASBwoFAQEBCAESBAoCAQESAwoBARIECgIICBIECgIICBIECgIIARIAEgMKAQgSBQoDAQEBEgQKAggBEgQKAgEBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIIgZzY2FsZTgiDHNjYWxlOEJpZ0ludCIHc2NhbGUxOCIKemVyb0JpZ0ludCIJb25lQmlnSW50IgpzbGlwcGFnZTREIgVBbXVsdCIFRGNvbnYiA1NFUCIFRU1QVFkiClBvb2xBY3RpdmUiClBvb2xQdXREaXMiDlBvb2xNYXRjaGVyRGlzIgxQb29sU2h1dGRvd24iDmlkeFBvb2xBZGRyZXNzIglpZHhQb29sU3QiCWlkeExQQXNJZCIJaWR4QW1Bc0lkIglpZHhQckFzSWQiC2lkeEFtdEFzRGNtIg1pZHhQcmljZUFzRGNtIgtpZHhJQW10QXNJZCINaWR4SVByaWNlQXNJZCIPaWR4RmFjdFN0YWtDbnRyIhBpZHhGYWN0U2xpcHBDbnRyIhFpZHhGYWN0R3d4UmV3Q250ciIFZGVsY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AJjdwAAAAJfOQgFAAAAAmN3AAAAA18xMAAAAAEAAAACZUoBAAAAAmVLAAAAAAQAAAACYXIFAAAAAmVKAwkAAAEAAAACBQAAAAJhcgIAAAAFT3JkZXIEAAAAAmNSBQAAAAJhcgQAAAACZUwJAQAAAAJhQQAAAAAEAAAAAmFuCQEAAAACY1EAAAABBQAAAAJjUgQAAAACZU0JAAH0AAAAAwgFAAAAAmNSAAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACY1IAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACY1IAAAAPc2VuZGVyUHVibGljS2V5BAAAAAJlTgkAAfQAAAADCAUAAAACY1IAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJjUgAAAAZwcm9vZnMAAAAAAAAAAAEFAAAAAmVMAwMDBQAAAAJhbgUAAAACZU0HBQAAAAJlTgcGCQEAAAACYW0AAAADBQAAAAJhbgUAAAACZU0FAAAAAmVOBAAAAAJlTwQAAAACZVAJAQAAAAJkagAAAAADCQAAAQAAAAIFAAAAAmVQAgAAAApCeXRlVmVjdG9yBAAAAAJkbwUAAAACZVAFAAAAAmRvAwkAAAEAAAACBQAAAAJlUAIAAAAEVW5pdAgFAAAAAmVKAAAAD3NlbmRlclB1YmxpY0tleQkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgkAAfQAAAADCAUAAAACZUoAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJlSgAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAAmVPWWxU3g==", "chainId": 84, "height": 2189920, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7TWuUDmGmaHU9G5CzN24GHdhCC47BJSULNmFnTyEkjjf Next: 2AWT5EHVe8NkNLvUiWTvDwGUaX777YQFHy5D5FXNVA6G Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let scale8 = 100000000
66 let scale8BigInt = toBigInt(100000000)
77
88 let scale18 = toBigInt(1000000000000000000)
9-
10-let thousand = 1000
119
1210 let zeroBigInt = toBigInt(0)
1311
5553
5654 let idxFactGwxRewCntr = 10
5755
58-let feePermilleDefault = 0
56+let delay = "%s__delay"
5957
60-func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
58+func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6159
6260
63-func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
61+func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6462
6563
6664 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7169 else val
7270
7371
74-func keyFactoryContact () = "%s__factoryContract"
72+func fc () = "%s__factoryContract"
7573
7674
77-func keyManagerPublicKey () = "%s__managerPublicKey"
75+func mpk () = "%s__managerPublicKey"
7876
7977
80-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
78+func pmpk () = "%s__pendingManagerPublicKey"
8179
8280
83-func keyPriceLast () = "%s%s__price__last"
81+func pl () = "%s%s__price__last"
8482
8583
86-func keyPriceHistory (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
84+func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
8785
8886
89-func keyPutActionByUser (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
87+func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
9088
9189
92-func keyGetActionByUser (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
90+func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
9391
9492
95-func keyAmountAsset () = "%s__amountAsset"
93+func aa () = "%s__amountAsset"
9694
9795
98-func keyPriceAsset () = "%s__priceAsset"
96+func pa () = "%s__priceAsset"
9997
10098
101-func keyAmplificator () = "%s__amp"
99+func amp () = "%s__amp"
102100
103101
104-func keyAddonAddress () = "%s__addonAddr"
102+func ada () = "%s__addonAddr"
105103
106104
107-let keyFeePermille = "%s__feePermille"
105+func lgotc (caller) = makeString(["%s%s__lastGetOneTknCall", caller], SEP)
108106
109-let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault)
107+
108+func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP)
109+
110110
111111 func fcfg () = "%s__factoryConfig"
112112
123123 func aps () = "%s__shutdown"
124124
125125
126-func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
127-
128-
129-func throwOrderError (orV,sendrV,matchV) = throwErr(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
126+func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
130127
131128
132129 func str (val) = match val {
133130 case valStr: String =>
134131 valStr
135132 case _ =>
136- throwErr("fail cast to String")
133+ throw("fail cast to String")
137134 }
138135
139136
140-func getStringOrFail (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
137+func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
141138
142139
143-func getIntOrFail (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
140+func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
144141
145142
146-let factoryContract = addressFromStringValue(getStringOrFail(this, keyFactoryContact()))
143+let fca = addressFromStringValue(strf(this, fc()))
147144
148-let amplificator = getStringOrFail(this, keyAmplificator())
145+let A = strf(this, amp())
149146
150-func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, aps()), false)
147+func igs () = valueOrElse(getBoolean(fca, aps()), false)
151148
152149
153-func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, mtpk()))
150+func mp () = fromBase58String(strf(fca, mtpk()))
154151
155152
156-let matcherAddress = addressFromPublicKey(getMatcherPubOrFail())
157-
158-func getPoolConfig () = {
159- let amtAs = getStringOrFail(this, keyAmountAsset())
160- let priceAs = getStringOrFail(this, keyPriceAsset())
161- let iPriceAs = getIntOrFail(factoryContract, mba(priceAs))
162- let iAmtAs = getIntOrFail(factoryContract, mba(amtAs))
163- split(getStringOrFail(factoryContract, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
153+func gpc () = {
154+ let amtAs = strf(this, aa())
155+ let priceAs = strf(this, pa())
156+ let iPriceAs = intf(fca, mba(priceAs))
157+ let iAmtAs = intf(fca, mba(amtAs))
158+ split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
164159 }
165160
166161
167-func getFactoryConfig () = split(getStringOrFail(factoryContract, fcfg()), SEP)
162+func gfc () = split(strf(fca, fcfg()), SEP)
168163
169164
170165 func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slipByUser,slippageReal,txHeight,txTimestamp,slipageAmAmt,slipagePrAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slipByUser), toString(slippageReal), toString(txHeight), toString(txTimestamp), toString(slipageAmAmt), toString(slipagePrAmt)], SEP)
178173 else assetBalance(this, fromBase58String(assetId))
179174
180175
181-func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
176+func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
182177
183178
184-func validateAbsDiff (estimateLP,outLp,slippage) = {
185- let diff = fraction((estimateLP - outLp), scale8BigInt, outLp)
179+func vad (A1,A2,slippage) = {
180+ let diff = fraction((A1 - A2), scale8BigInt, A2)
186181 let pass = ((slippage - abs(diff)) > zeroBigInt)
187182 if (!(pass))
188- then throwErr(("Big slippage: " + toString(diff)))
189- else $Tuple2(pass, min([estimateLP, outLp]))
183+ then throw(("Big slpg: " + toString(diff)))
184+ else $Tuple2(pass, min([A1, A2]))
190185 }
191186
192187
193-func validateD (D1,D0,slippage) = {
188+func vd (D1,D0,slpg) = {
194189 let diff = fraction(D0, scale8BigInt, D1)
195- let fail = (slippage > diff)
190+ let fail = (slpg > diff)
196191 if (if (fail)
197192 then true
198193 else (D0 > D1))
199- then throwErr(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slippage)))
194+ then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg)))
200195 else fail
201196 }
202197
203198
204-func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
205- let amtAsAmtX18 = toX18(amAmt, amAssetDcm)
206- let prAsAmtX18 = toX18(prAmt, prAssetDcm)
207- calcPriceBigInt(prAsAmtX18, amtAsAmtX18)
199+func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
200+ let amtAsAmtX18 = t1(amAmt, amAssetDcm)
201+ let prAsAmtX18 = t1(prAmt, prAssetDcm)
202+ cpbi(prAsAmtX18, amtAsAmtX18)
208203 }
209204
210205
211206 func calcPrices (amAmt,prAmt,lpAmt) = {
212- let cfg = getPoolConfig()
207+ let cfg = gpc()
213208 let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
214209 let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
215- let priceX18 = privateCalcPrice(amtAsDcm, prAsDcm, amAmt, prAmt)
216- let amAmtX18 = toX18(amAmt, amtAsDcm)
217- let prAmtX18 = toX18(prAmt, prAsDcm)
218- let lpAmtX18 = toX18(lpAmt, scale8)
219- let lpPrInAmAsX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
220- let lpPrInPrAsX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
210+ let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
211+ let amAmtX18 = t1(amAmt, amtAsDcm)
212+ let prAmtX18 = t1(prAmt, prAsDcm)
213+ let lpAmtX18 = t1(lpAmt, scale8)
214+ let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18)
215+ let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18)
221216 [priceX18, lpPrInAmAsX18, lpPrInPrAsX18]
222217 }
223218
224219
225220 func calculatePrices (amAmt,prAmt,lpAmt) = {
226221 let p = calcPrices(amAmt, prAmt, lpAmt)
227-[fromX18(p[0], scale8), fromX18(p[1], scale8), fromX18(p[2], scale8)]
222+[f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)]
228223 }
229224
230225
231-func estimateGetOperation (txId58,paymentAssetId,paymentLpAmount,userAddress) = {
232- let cfg = getPoolConfig()
233- let lpAssetId = cfg[idxLPAsId]
234- let amountId = cfg[idxAmAsId]
235- let priceId = cfg[idxPrAsId]
236- let amountDecimals = parseIntValue(cfg[idxAmtAsDcm])
237- let priceDecimals = parseIntValue(cfg[idxPriceAsDcm])
226+func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
227+ let cfg = gpc()
228+ let lpId = cfg[idxLPAsId]
229+ let amId = cfg[idxAmAsId]
230+ let prId = cfg[idxPrAsId]
231+ let amDcm = parseIntValue(cfg[idxAmtAsDcm])
232+ let prDcm = parseIntValue(cfg[idxPriceAsDcm])
238233 let sts = cfg[idxPoolSt]
239- let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), "Wrong LP id").quantity
240- let validationBlock = if ((lpAssetId == paymentAssetId))
241- then true
242- else throwErr("Wrong payment asset")
243- if ((validationBlock == validationBlock))
244- then {
245- let decimals = if ((amountDecimals >= priceDecimals))
246- then amountDecimals
247- else priceDecimals
248- if ((decimals == decimals))
249- then {
250- let amountBalance = getAccBalance(amountId)
251- let amountBalanceX18 = toX18(amountBalance, decimals)
252- let priceBalance = getAccBalance(priceId)
253- let priceBalanceX18 = toX18(priceBalance, decimals)
254- let currentPriceX18 = calcPriceBigInt(priceBalanceX18, amountBalanceX18)
255- let curPrice = fromX18(currentPriceX18, scale8)
256- let paymentLpAmountX18 = toX18(paymentLpAmount, scale8)
257- let lpEmissionX18 = toX18(lpEmission, scale8)
258- let outAmountAmountX18 = fraction(amountBalanceX18, paymentLpAmountX18, lpEmissionX18)
259- let outPriceAmountX18 = fraction(priceBalanceX18, paymentLpAmountX18, lpEmissionX18)
260- let outAmountAmount = fromX18(outAmountAmountX18, decimals)
261- let outPriceAmount = fromX18(outPriceAmountX18, decimals)
262- let state = if ((txId58 == ""))
263- then nil
264- else [ScriptTransfer(userAddress, outAmountAmount, if ((amountId == "WAVES"))
265- then unit
266- else fromBase58String(amountId)), ScriptTransfer(userAddress, outPriceAmount, if ((priceId == "WAVES"))
267- then unit
268- else fromBase58String(priceId)), StringEntry(keyGetActionByUser(toString(userAddress), txId58), dataGetActionInfo(outAmountAmount, outPriceAmount, paymentLpAmount, curPrice, height, lastBlock.timestamp)), IntegerEntry(keyPriceLast(), curPrice), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), curPrice)]
269- $Tuple10(outAmountAmount, outPriceAmount, amountId, priceId, amountBalance, priceBalance, lpEmission, currentPriceX18, sts, state)
270- }
271- else throw("Strict value is not equal to itself.")
234+ let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
235+ if ((lpId != pmtAssetId))
236+ then throw("Wrong pmt asset")
237+ else {
238+ let amBalance = getAccBalance(amId)
239+ let amBalanceX18 = t1(amBalance, amDcm)
240+ let prBalance = getAccBalance(prId)
241+ let prBalanceX18 = t1(prBalance, prDcm)
242+ let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
243+ let curPrice = f1(curPriceX18, scale8)
244+ let pmtLpAmtX18 = t1(pmtLpAmt, scale8)
245+ let lpEmissX18 = t1(lpEmiss, scale8)
246+ let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
247+ let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
248+ let outAmAmt = f1(outAmAmtX18, amDcm)
249+ let outPrAmt = f1(outPrAmtX18, prDcm)
250+ let state = if ((txId58 == ""))
251+ then nil
252+ else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
253+ then unit
254+ else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES"))
255+ then unit
256+ else fromBase58String(prId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)]
257+ $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state)
272258 }
273- else throw("Strict value is not equal to itself.")
274259 }
275260
276261
277-func estimatePutOperation (txId58,slippageTolerance,inAmountAssetAmount,inAmountAssetId,inPriceAssetAmount,inPriceAssetId,userAddress,isEvaluate,emitLp,isOneAsset,paymentAmount,paymentId) = {
278- let cfg = getPoolConfig()
279- let lpAssetId = fromBase58String(cfg[idxLPAsId])
280- let amountIdStr = cfg[idxAmAsId]
281- let priceIdStr = cfg[idxPrAsId]
282- let inAmountIdStr = cfg[idxIAmtAsId]
283- let inPriceIdStr = cfg[idxIPriceAsId]
284- let amountDecimals = parseIntValue(cfg[idxAmtAsDcm])
285- let priceDecimals = parseIntValue(cfg[idxPriceAsDcm])
262+func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,pmtAmt,pmtId) = {
263+ let cfg = gpc()
264+ let lpId = fromBase58String(cfg[idxLPAsId])
265+ let amIdStr = cfg[idxAmAsId]
266+ let prIdStr = cfg[idxPrAsId]
267+ let inAmIdStr = cfg[idxIAmtAsId]
268+ let inPrIdStr = cfg[idxIPriceAsId]
269+ let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
270+ let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
286271 let sts = cfg[idxPoolSt]
287- let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), "Wrong lp asset").quantity
288- let amountBalance = if (isEvaluate)
289- then getAccBalance(amountIdStr)
272+ let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
273+ let amBalance = if (isEval)
274+ then getAccBalance(amIdStr)
290275 else if (if (isOneAsset)
291- then (paymentId == amountIdStr)
276+ then (pmtId == amIdStr)
292277 else false)
293- then (getAccBalance(amountIdStr) - paymentAmount)
278+ then (getAccBalance(amIdStr) - pmtAmt)
294279 else if (isOneAsset)
295- then getAccBalance(amountIdStr)
296- else (getAccBalance(amountIdStr) - inAmountAssetAmount)
297- let priceBalance = if (isEvaluate)
298- then getAccBalance(priceIdStr)
280+ then getAccBalance(amIdStr)
281+ else (getAccBalance(amIdStr) - inAmAmt)
282+ let prBalance = if (isEval)
283+ then getAccBalance(prIdStr)
299284 else if (if (isOneAsset)
300- then (paymentId == priceIdStr)
285+ then (pmtId == prIdStr)
301286 else false)
302- then (getAccBalance(priceIdStr) - paymentAmount)
287+ then (getAccBalance(prIdStr) - pmtAmt)
303288 else if (isOneAsset)
304- then getAccBalance(priceIdStr)
305- else (getAccBalance(priceIdStr) - inPriceAssetAmount)
306- let decimals = if ((amountDecimals >= priceDecimals))
307- then amountDecimals
308- else priceDecimals
309- if ((decimals == decimals))
289+ then getAccBalance(prIdStr)
290+ else (getAccBalance(prIdStr) - inPrAmt)
291+ let inAmAssetAmtX18 = t1(inAmAmt, amtDcm)
292+ let inPrAssetAmtX18 = t1(inPrAmt, priceDcm)
293+ let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
294+ let amBalanceX18 = t1(amBalance, amtDcm)
295+ let prBalanceX18 = t1(prBalance, priceDcm)
296+ let r = if ((lpEm == 0))
310297 then {
311- let inAmountAssetAmountX18 = toX18(inAmountAssetAmount, decimals)
312- let inPriceAssetAmountX18 = toX18(inPriceAssetAmount, decimals)
313- let userPriceX18 = calcPriceBigInt(inPriceAssetAmountX18, inAmountAssetAmountX18)
314- let amountBalanceX18 = toX18(amountBalance, decimals)
315- let priceBalanceX18 = toX18(priceBalance, decimals)
316- let r = if ((lpEmission == 0))
317- then {
318- let currentPriceX18 = zeroBigInt
319- let slippageX18 = zeroBigInt
320- let lpAmountX18 = pow((inAmountAssetAmountX18 * inPriceAssetAmountX18), 0, toBigInt(5), 1, 0, DOWN)
321- $Tuple5(fromX18(lpAmountX18, scale8), fromX18(inAmountAssetAmountX18, decimals), fromX18(inPriceAssetAmountX18, decimals), calcPriceBigInt((priceBalanceX18 + inPriceAssetAmountX18), (amountBalanceX18 + inAmountAssetAmountX18)), slippageX18)
298+ let curPriceX18 = zeroBigInt
299+ let slippageX18 = zeroBigInt
300+ let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
301+ $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
302+ }
303+ else {
304+ let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
305+ let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
306+ let slippageX18 = t1(slippage, scale8)
307+ if (if ((curPriceX18 != zeroBigInt))
308+ then (slippageRealX18 > slippageX18)
309+ else false)
310+ then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
311+ else {
312+ let lpEmissionX18 = t1(lpEm, scale8)
313+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
314+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
315+ let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
316+ then $Tuple2(amViaPrX18, inPrAssetAmtX18)
317+ else $Tuple2(inAmAssetAmtX18, prViaAmX18)
318+ let expAmtAssetAmtX18 = expectedAmts._1
319+ let expPriceAssetAmtX18 = expectedAmts._2
320+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
321+ $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
322322 }
323- else {
324- let currentPriceX18 = calcPriceBigInt(priceBalanceX18, amountBalanceX18)
325- let slippageRealX18 = fraction(abs((currentPriceX18 - userPriceX18)), scale18, currentPriceX18)
326- let slippageX18 = toX18(slippageTolerance, scale8)
327- if (if ((currentPriceX18 != zeroBigInt))
328- then (slippageRealX18 > slippageX18)
329- else false)
330- then throwErr(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
331- else {
332- let lpEmissionX18 = toX18(lpEmission, scale8)
333- let prViaAmX18 = fraction(inAmountAssetAmountX18, currentPriceX18, scale18)
334- let amViaPrX18 = fraction(inPriceAssetAmountX18, scale18, currentPriceX18)
335- let expectedAmounts = if ((prViaAmX18 > inPriceAssetAmountX18))
336- then $Tuple2(amViaPrX18, inAmountAssetAmountX18)
337- else $Tuple2(inAmountAssetAmountX18, prViaAmX18)
338- let expectedAmountAssetAmountX18 = expectedAmounts._1
339- let expectedPriceAssetAmountX18 = expectedAmounts._2
340- let lpAmountX18 = fraction(lpEmissionX18, expectedPriceAssetAmountX18, priceBalanceX18)
341- $Tuple5(fromX18(lpAmountX18, scale8), fromX18(expectedAmountAssetAmountX18, decimals), fromX18(expectedPriceAssetAmountX18, decimals), currentPriceX18, slippageX18)
342- }
343- }
344- let calculateLpAmount = r._1
345- let calculateAmountAssetPayment = r._2
346- let calculatePriceAssetPayment = r._3
347- let currentPrice = fromX18(r._4, scale8)
348- let slippageCalculate = fromX18(r._5, scale8)
349- let checkCalcLpAmount = if ((calculateLpAmount > 0))
350- then true
351- else throwErr("LP <= 0")
352- if ((checkCalcLpAmount == checkCalcLpAmount))
353- then {
354- let emitLpAmount = if (!(emitLp))
355- then 0
356- else calculateLpAmount
357- let amountDiff = (inAmountAssetAmount - calculateAmountAssetPayment)
358- let priceDiff = (inPriceAssetAmount - calculatePriceAssetPayment)
359- let $t01618916448 = if (if (isOneAsset)
360- then (paymentId == amountIdStr)
361- else false)
362- then $Tuple2(paymentAmount, 0)
363- else if (if (isOneAsset)
364- then (paymentId == priceIdStr)
365- else false)
366- then $Tuple2(0, paymentAmount)
367- else $Tuple2(calculateAmountAssetPayment, calculatePriceAssetPayment)
368- let writeAmAmt = $t01618916448._1
369- let writePrAmt = $t01618916448._2
370- let commonState = [IntegerEntry(keyPriceLast(), currentPrice), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), currentPrice), StringEntry(keyPutActionByUser(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmount, currentPrice, slippageTolerance, slippageCalculate, height, lastBlock.timestamp, amountDiff, priceDiff))]
371- $Tuple13(calculateLpAmount, emitLpAmount, currentPrice, amountBalance, priceBalance, lpEmission, lpAssetId, sts, commonState, amountDiff, priceDiff, inAmountAssetId, inPriceAssetId)
372- }
373- else throw("Strict value is not equal to itself.")
374323 }
375- else throw("Strict value is not equal to itself.")
324+ let calcLpAmt = r._1
325+ let calcAmAssetPmt = r._2
326+ let calcPrAssetPmt = r._3
327+ let curPrice = f1(r._4, scale8)
328+ let slippageCalc = f1(r._5, scale8)
329+ if ((0 >= calcLpAmt))
330+ then throw("LP <= 0")
331+ else {
332+ let emitLpAmt = if (!(emitLp))
333+ then 0
334+ else calcLpAmt
335+ let amDiff = (inAmAmt - calcAmAssetPmt)
336+ let prDiff = (inPrAmt - calcPrAssetPmt)
337+ let $t01553115876 = if (if (isOneAsset)
338+ then (pmtId == amIdStr)
339+ else false)
340+ then $Tuple2(pmtAmt, 0)
341+ else if (if (isOneAsset)
342+ then (pmtId == prIdStr)
343+ else false)
344+ then $Tuple2(0, pmtAmt)
345+ else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
346+ let writeAmAmt = $t01553115876._1
347+ let writePrAmt = $t01553115876._2
348+ let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))]
349+ $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
350+ }
376351 }
377352
378353
379-func validateMatcherOrderAllowed (order) = {
380- let cfg = getPoolConfig()
354+func moa (order) = {
355+ let cfg = gpc()
381356 let amtAsId = cfg[idxAmAsId]
382357 let prAsId = cfg[idxPrAsId]
383358 let sts = parseIntValue(cfg[idxPoolSt])
385360 let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
386361 let accAmtAsBalance = getAccBalance(amtAsId)
387362 let accPrAsBalance = getAccBalance(prAsId)
388- let currentPriceX18 = if ((order.orderType == Buy))
389- then privateCalcPrice(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
390- else privateCalcPrice(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
391- let curPrice = fromX18(currentPriceX18, scale8)
392- if (if (if (isGlobalShutdown())
363+ let curPriceX18 = if ((order.orderType == Buy))
364+ then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
365+ else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
366+ let curPrice = f1(curPriceX18, scale8)
367+ if (if (if (igs())
393368 then true
394369 else (sts == PoolMatcherDis))
395370 then true
396371 else (sts == PoolShutdown))
397- then throwErr("Admin blocked")
372+ then throw("Admin blocked")
398373 else {
399374 let orAmtAsset = order.assetPair.amountAsset
400375 let orAmtAsStr = if ((orAmtAsset == unit))
407382 if (if ((orAmtAsStr != amtAsId))
408383 then true
409384 else (orPrAsStr != prAsId))
410- then throwErr("Wr assets")
385+ then throw("Wr assets")
411386 else {
412387 let orderPrice = order.price
413- let priceDecimals = fraction(scale8, prAsDcm, amtAsDcm)
414- let castOrderPrice = ts(orderPrice, scale8, priceDecimals)
388+ let priceDcm = fraction(scale8, prAsDcm, amtAsDcm)
389+ let castOrderPrice = ts(orderPrice, scale8, priceDcm)
415390 let isOrderPriceValid = if ((order.orderType == Buy))
416391 then (curPrice >= castOrderPrice)
417392 else (castOrderPrice >= curPrice)
421396 }
422397
423398
424-func commonGet (i) = {
425- let checkPayments = if ((size(i.payments) == 1))
426- then true
427- else throwErr("1 payment expected")
428- if ((checkPayments == checkPayments))
429- then {
430- let payment = value(i.payments[0])
431- let paymentAssetId = value(payment.assetId)
432- let paymentAmount = payment.amount
433- let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(paymentAssetId), paymentAmount, i.caller)
434- let outAmountAmount = r._1
435- let outPriceAmount = r._2
436- let sts = parseIntValue(r._9)
437- let state = r._10
438- if (if (isGlobalShutdown())
439- then true
440- else (sts == PoolShutdown))
441- then throwErr(("Admin blocked: " + toString(sts)))
442- else $Tuple5(outAmountAmount, outPriceAmount, paymentAmount, paymentAssetId, state)
443- }
444- else throw("Strict value is not equal to itself.")
445- }
399+func cg (i) = if ((size(i.payments) != 1))
400+ then throw("1 pmnt exp")
401+ else {
402+ let pmt = value(i.payments[0])
403+ let pmtAssetId = value(pmt.assetId)
404+ let pmtAmt = pmt.amount
405+ let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
406+ let outAmAmt = r._1
407+ let outPrAmt = r._2
408+ let sts = parseIntValue(r._9)
409+ let state = r._10
410+ if (if (igs())
411+ then true
412+ else (sts == PoolShutdown))
413+ then throw(("Admin blocked: " + toString(sts)))
414+ else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
415+ }
446416
447417
448-func commonPut (caller,txId,amountAssetPayment,priceAssetPayment,slippage,emitLp,isOneAsset,paymentAmount,paymentId) = {
449- let r = estimatePutOperation(txId, slippage, value(amountAssetPayment).amount, value(amountAssetPayment).assetId, value(priceAssetPayment).amount, value(priceAssetPayment).assetId, caller, false, emitLp, isOneAsset, paymentAmount, paymentId)
418+func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,pmtAmt,pmtId) = {
419+ let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, pmtAmt, pmtId)
450420 let sts = parseIntValue(r._8)
451- if (if (if (isGlobalShutdown())
421+ if (if (if (igs())
452422 then true
453423 else (sts == PoolPutDis))
454424 then true
455425 else (sts == PoolShutdown))
456- then throwErr(("Blocked:" + toString(sts)))
426+ then throw(("Blocked:" + toString(sts)))
457427 else r
458428 }
459429
460430
461-func takeFee (amount) = {
462- let fee = fraction(amount, feePermille, thousand)
463- $Tuple2((amount - fee), fee)
464- }
465-
466-
467-func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
431+func m () = match getString(mpk()) {
468432 case s: String =>
469433 fromBase58String(s)
470434 case _: Unit =>
474438 }
475439
476440
477-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
441+func pm () = match getString(pmpk()) {
478442 case s: String =>
479443 fromBase58String(s)
480444 case _: Unit =>
484448 }
485449
486450
487-let pd = throwErr("Permission denied")
451+let pd = throw("Permission denied")
488452
489-func mustManager (i) = match managerPublicKeyOrUnit() {
453+func mm (i) = match m() {
490454 case pk: ByteVector =>
491455 if ((i.callerPublicKey == pk))
492456 then true
501465
502466
503467 @Callable(i)
504-func constructor (factoryContract) = {
505- let checkCaller = mustManager(i)
506- if ((checkCaller == checkCaller))
507- then [StringEntry(keyFactoryContact(), factoryContract)]
468+func constructor (fc) = {
469+ let c = mm(i)
470+ if ((c == c))
471+ then [StringEntry(fc(), fc)]
508472 else throw("Strict value is not equal to itself.")
509473 }
510474
512476
513477 @Callable(i)
514478 func setManager (pendingManagerPublicKey) = {
515- let checkCaller = mustManager(i)
516- if ((checkCaller == checkCaller))
479+ let c = mm(i)
480+ if ((c == c))
517481 then {
518- let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
519- if ((checkManagerPublicKey == checkManagerPublicKey))
520- then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
482+ let cm = fromBase58String(pendingManagerPublicKey)
483+ if ((cm == cm))
484+ then [StringEntry(pmpk(), pendingManagerPublicKey)]
521485 else throw("Strict value is not equal to itself.")
522486 }
523487 else throw("Strict value is not equal to itself.")
527491
528492 @Callable(i)
529493 func confirmManager () = {
530- let pm = pendingManagerPublicKeyOrUnit()
531- let hasPM = if (isDefined(pm))
494+ let p = pm()
495+ let hpm = if (isDefined(p))
532496 then true
533- else throwErr("No pending manager")
534- if ((hasPM == hasPM))
497+ else throw("No pending manager")
498+ if ((hpm == hpm))
535499 then {
536- let checkPM = if ((i.callerPublicKey == value(pm)))
500+ let cpm = if ((i.callerPublicKey == value(p)))
537501 then true
538- else throwErr("You are not pending manager")
539- if ((checkPM == checkPM))
540- then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
502+ else throw("You are not pending manager")
503+ if ((cpm == cpm))
504+ then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
541505 else throw("Strict value is not equal to itself.")
542506 }
543507 else throw("Strict value is not equal to itself.")
546510
547511
548512 @Callable(i)
549-func put (slippage,autoStake) = {
550- let factCfg = getFactoryConfig()
551- let stakingContract = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wrong staking contract")
552- let slippageContract = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wrogn slippage contract")
553- let slippageCheck = if ((slippage >= 0))
554- then true
555- else throwErr("wrong slippage")
556- if ((slippageCheck == slippageCheck))
557- then {
558- let paymentsCheck = if ((size(i.payments) == 2))
559- then true
560- else throwErr("2 payments expected")
561- if ((paymentsCheck == paymentsCheck))
562- then {
563- let estimatePut = commonPut(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slippage, true, false, 0, "")
564- let emitLpAmount = estimatePut._2
565- let lpAssetId = estimatePut._7
566- let state = estimatePut._9
567- let amountDiff = estimatePut._10
568- let priceDiff = estimatePut._11
569- let amountId = estimatePut._12
570- let priceId = estimatePut._13
571- let r = invoke(factoryContract, "emit", [emitLpAmount], nil)
572- if ((r == r))
573- then {
574- let el = match r {
575- case legacy: Address =>
576- invoke(legacy, "emit", [emitLpAmount], nil)
577- case _ =>
578- unit
579- }
580- if ((el == el))
513+func put (slip,autoStake) = {
514+ let factCfg = gfc()
515+ let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
516+ let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
517+ if ((0 > slip))
518+ then throw("Wrong slippage")
519+ else if ((size(i.payments) != 2))
520+ then throw("2 pmnts expd")
521+ else {
522+ let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, 0, "")
523+ let emitLpAmt = e._2
524+ let lpAssetId = e._7
525+ let state = e._9
526+ let amDiff = e._10
527+ let prDiff = e._11
528+ let amId = e._12
529+ let prId = e._13
530+ let r = invoke(fca, "emit", [emitLpAmt], nil)
531+ if ((r == r))
532+ then {
533+ let el = match r {
534+ case legacy: Address =>
535+ invoke(legacy, "emit", [emitLpAmt], nil)
536+ case _ =>
537+ unit
538+ }
539+ if ((el == el))
540+ then {
541+ let sa = if ((amDiff > 0))
542+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
543+ else nil
544+ if ((sa == sa))
545+ then {
546+ let sp = if ((prDiff > 0))
547+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
548+ else nil
549+ if ((sp == sp))
550+ then {
551+ let lpTrnsfr = if (autoStake)
552+ then {
553+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
554+ if ((ss == ss))
555+ then nil
556+ else throw("Strict value is not equal to itself.")
557+ }
558+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
559+ (state ++ lpTrnsfr)
560+ }
561+ else throw("Strict value is not equal to itself.")
562+ }
563+ else throw("Strict value is not equal to itself.")
564+ }
565+ else throw("Strict value is not equal to itself.")
566+ }
567+ else throw("Strict value is not equal to itself.")
568+ }
569+ }
570+
571+
572+
573+@Callable(i)
574+func putOneTkn (amAssetPart,prAssetPart,outLp,slippage,autoStake) = {
575+ let cfg = gfc()
576+ let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr")
577+ let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr")
578+ let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr")
579+ let poolCfg = gpc()
580+ let amId = poolCfg[idxAmAsId]
581+ let prId = poolCfg[idxPrAsId]
582+ let amDcm = parseIntValue(poolCfg[idxAmtAsDcm])
583+ let prDcm = parseIntValue(poolCfg[idxPriceAsDcm])
584+ let addon = valueOrElse(getString(this, ada()), "")
585+ let userAddress = if ((addon == toString(i.caller)))
586+ then i.originCaller
587+ else i.caller
588+ let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid")
589+ let check = reentrantInvoke(addonContract, "ensureCanPutOneTkn", [toString(userAddress)], nil)
590+ if ((check == check))
591+ then if (if (if (if ((0 >= slippage))
592+ then true
593+ else (0 >= amAssetPart))
594+ then true
595+ else (0 >= prAssetPart))
596+ then true
597+ else (0 >= outLp))
598+ then throw("Wrong params")
599+ else if ((size(i.payments) != 1))
600+ then throw("1 pmnt expd")
601+ else {
602+ let pmt = value(i.payments[0])
603+ let pmtAssetId = toBase58String(value(pmt.assetId))
604+ let pmtAmt = pmt.amount
605+ if (if (if ((amAssetPart > pmtAmt))
606+ then true
607+ else (prAssetPart > pmtAmt))
608+ then true
609+ else (10000000 > pmtAmt))
610+ then throw("Wrong pmt amt")
611+ else {
612+ let amBalance = getAccBalance(amId)
613+ let prBalance = getAccBalance(prId)
614+ let $t02483225212 = if ((pmtAssetId == amId))
615+ then $Tuple6((amBalance - pmtAmt), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0)
616+ else if ((pmtAssetId == prId))
617+ then $Tuple6(amBalance, (prBalance - pmtAmt), 0, 0, (pmtAmt - prAssetPart), amAssetPart)
618+ else throw("wrong pmtAssetId")
619+ let amBalanceNow = $t02483225212._1
620+ let prBalanceNow = $t02483225212._2
621+ let virtSwapInAm = $t02483225212._3
622+ let virtSwapOutPr = $t02483225212._4
623+ let virtSwapInPr = $t02483225212._5
624+ let virtSwapOutAm = $t02483225212._6
625+ let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil)
626+ let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil)
627+ let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D)
628+ if ((D0vsD1 == D0vsD1))
581629 then {
582- let sa = if ((amountDiff > 0))
583- then invoke(slippageContract, "put", nil, [AttachedPayment(amountId, amountDiff)])
584- else nil
585- if ((sa == sa))
630+ let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId)
631+ let estimLP = estPut._2
632+ let lpAssetId = estPut._7
633+ let state = estPut._9
634+ let amDiff = estPut._10
635+ let prDiff = estPut._11
636+ let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage))
637+ let emitLpAmt = toInt(lpCalcRes._2)
638+ let e = invoke(fca, "emit", [emitLpAmt], nil)
639+ if ((e == e))
586640 then {
587- let sp = if ((priceDiff > 0))
588- then invoke(slippageContract, "put", nil, [AttachedPayment(priceId, priceDiff)])
589- else nil
590- if ((sp == sp))
641+ let el = match e {
642+ case legacy: Address =>
643+ invoke(legacy, "emit", [emitLpAmt], nil)
644+ case _ =>
645+ unit
646+ }
647+ if ((el == el))
591648 then {
592- let lpTrasfer = if (autoStake)
649+ let sa = if ((amDiff > 0))
650+ then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)])
651+ else nil
652+ if ((sa == sa))
593653 then {
594- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmount)])
595- if ((ss == ss))
596- then nil
654+ let sp = if ((prDiff > 0))
655+ then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)])
656+ else nil
657+ if ((sp == sp))
658+ then {
659+ let lpTrnsfr = if (autoStake)
660+ then {
661+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
662+ if ((ss == ss))
663+ then nil
664+ else throw("Strict value is not equal to itself.")
665+ }
666+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
667+ (state ++ lpTrnsfr)
668+ }
597669 else throw("Strict value is not equal to itself.")
598670 }
599- else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)]
600- (state ++ lpTrasfer)
671+ else throw("Strict value is not equal to itself.")
601672 }
602673 else throw("Strict value is not equal to itself.")
603674 }
605676 }
606677 else throw("Strict value is not equal to itself.")
607678 }
608- else throw("Strict value is not equal to itself.")
609679 }
610- else throw("Strict value is not equal to itself.")
611- }
612680 else throw("Strict value is not equal to itself.")
613681 }
614682
615683
616684
617685 @Callable(i)
618-func putOneTkn (amountAssetPart,priceAssetPart,outLp,slippage,autoStake) = {
619- let cfg = getFactoryConfig()
620- let stakingContract = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wrong staking contract")
621- let slippageContract = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wrong slippage contract")
622- let gwxRewardContract = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wrong gwx reward contract")
623- let poolCfg = getPoolConfig()
624- let amountId = poolCfg[idxAmAsId]
625- let priceId = poolCfg[idxPrAsId]
626- let amountDecimals = parseIntValue(poolCfg[idxAmtAsDcm])
627- let priceDecimals = parseIntValue(poolCfg[idxPriceAsDcm])
628- let addon = valueOrElse(getString(this, keyAddonAddress()), "")
629- let userAddress = if ((addon == toString(i.caller)))
630- then i.originCaller
631- else i.caller
632- if (if (if (if ((0 >= slippage))
633- then true
634- else (0 >= amountAssetPart))
635- then true
636- else (0 >= priceAssetPart))
637- then true
638- else (0 >= outLp))
639- then throwErr("Wrong params")
640- else if ((size(i.payments) != 1))
641- then throwErr("1 payment expected")
642- else {
643- let payment = value(i.payments[0])
644- let paymentAssetId = toBase58String(value(payment.assetId))
645- let paymentAmountRaw = payment.amount
646- let $t02561725676 = takeFee(paymentAmountRaw)
647- let paymentAmount = $t02561725676._1
648- let feeAmount = $t02561725676._2
649- if (if (if ((amountAssetPart > paymentAmount))
650- then true
651- else (priceAssetPart > paymentAmount))
652- then true
653- else (10000000 > paymentAmount))
654- then throwErr("wrong payment amount")
655- else {
656- let amountBalance = getAccBalance(amountId)
657- let priceBalance = getAccBalance(priceId)
658- let $t02594026395 = if ((paymentAssetId == amountId))
659- then $Tuple6((amountBalance - paymentAmount), priceBalance, (paymentAmount - amountAssetPart), priceAssetPart, 0, 0)
660- else if ((paymentAssetId == priceId))
661- then $Tuple6(amountBalance, (priceBalance - paymentAmount), 0, 0, (paymentAmount - priceAssetPart), amountAssetPart)
662- else throwErr("wrong paymentAssetId")
663- let amountBalanceNow = $t02594026395._1
664- let priceBalanceNow = $t02594026395._2
665- let virtSwapInAm = $t02594026395._3
666- let virtSwapOutPr = $t02594026395._4
667- let virtSwapInPr = $t02594026395._5
668- let virtSwapOutAm = $t02594026395._6
669- let D0 = invoke(gwxRewardContract, "calcD", [toString(amountBalanceNow), toString(priceBalanceNow), amplificator, Amult, Dconv], nil)
670- let D1 = invoke(gwxRewardContract, "calcD", [toString(toBigInt(((amountBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((priceBalanceNow + virtSwapInPr) - virtSwapOutPr))), amplificator, Amult, Dconv], nil)
671- let D0vsD1 = validateD(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D)
672- if ((D0vsD1 == D0vsD1))
673- then {
674- let estimatePut = commonPut(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amountId), amountAssetPart), AttachedPayment(fromBase58String(priceId), priceAssetPart), slippage, true, true, paymentAmount, paymentAssetId)
675- let estimateLP = estimatePut._2
676- let lpAssetId = estimatePut._7
677- let state = estimatePut._9
678- let amountDiff = estimatePut._10
679- let priceDiff = estimatePut._11
680- let lpCalcRes = validateAbsDiff(toBigInt(estimateLP), toBigInt(outLp), toBigInt(slippage))
681- let emitLpAmount = toInt(lpCalcRes._2)
682- let e = invoke(factoryContract, "emit", [emitLpAmount], nil)
683- if ((e == e))
684- then {
685- let el = match e {
686- case legacy: Address =>
687- invoke(legacy, "emit", [emitLpAmount], nil)
688- case _ =>
689- unit
690- }
691- if ((el == el))
692- then {
693- let sa = if ((amountDiff > 0))
694- then invoke(slippageContract, "put", nil, [AttachedPayment(fromBase58String(amountId), amountDiff)])
695- else nil
696- if ((sa == sa))
697- then {
698- let sp = if ((priceDiff > 0))
699- then invoke(slippageContract, "put", nil, [AttachedPayment(fromBase58String(priceId), priceDiff)])
700- else nil
701- if ((sp == sp))
702- then {
703- let lpTrasfer = if (autoStake)
704- then {
705- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmount)])
706- if ((ss == ss))
707- then nil
708- else throw("Strict value is not equal to itself.")
709- }
710- else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)]
711- let sendFeeToMatcher = if ((feeAmount > 0))
712- then [ScriptTransfer(matcherAddress, feeAmount, fromBase58String(paymentAssetId))]
713- else nil
714- ((state ++ lpTrasfer) ++ sendFeeToMatcher)
715- }
716- else throw("Strict value is not equal to itself.")
717- }
718- else throw("Strict value is not equal to itself.")
719- }
720- else throw("Strict value is not equal to itself.")
721- }
722- else throw("Strict value is not equal to itself.")
723- }
724- else throw("Strict value is not equal to itself.")
725- }
726- }
727- }
728-
729-
730-
731-@Callable(i)
732-func putForFree (maxslippage) = if ((0 > maxslippage))
733- then throwErr("wrong slippage")
686+func putForFree (maxSlpg) = if ((0 > maxSlpg))
687+ then throw("Wrong slpg")
734688 else if ((size(i.payments) != 2))
735- then throwErr("2 payments expected")
689+ then throw("2 pmnts expd")
736690 else {
737- let estimatePut = commonPut(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxslippage, false, false, 0, "")
738- estimatePut._9
691+ let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, 0, "")
692+ estPut._9
739693 }
740694
741695
742696
743697 @Callable(i)
744698 func get () = {
745- let r = commonGet(i)
699+ let r = cg(i)
746700 let outAmtAmt = r._1
747- let outPriceAmount = r._2
748- let paymentAmount = r._3
749- let paymentAssetId = r._4
701+ let outPrAmt = r._2
702+ let pmtAmt = r._3
703+ let pmtAssetId = r._4
750704 let state = r._5
751- let b = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
705+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
752706 if ((b == b))
753707 then state
754708 else throw("Strict value is not equal to itself.")
758712
759713 @Callable(i)
760714 func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1))
761- then throwErr("1 payment expected")
715+ then throw("1 pmnt expd")
762716 else {
763- let cfg = getPoolConfig()
764- let lpAssetId = cfg[idxLPAsId]
765- let amountId = cfg[idxAmAsId]
766- let priceId = cfg[idxPrAsId]
767- let amountDecimals = parseIntValue(cfg[idxAmtAsDcm])
768- let priceDecimals = parseIntValue(cfg[idxPriceAsDcm])
717+ let cfg = gpc()
718+ let lpId = cfg[idxLPAsId]
719+ let amId = cfg[idxAmAsId]
720+ let prId = cfg[idxPrAsId]
721+ let amDcm = parseIntValue(cfg[idxAmtAsDcm])
722+ let prDcm = parseIntValue(cfg[idxPriceAsDcm])
769723 let sts = cfg[idxPoolSt]
770- let factCfg = getFactoryConfig()
771- let gwxRewardContract = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wrong gwxRewardContract address")
772- let payment = value(i.payments[0])
773- let addon = valueOrElse(getString(this, keyAddonAddress()), "")
724+ let factCfg = gfc()
725+ let gwxCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wr sl addr")
726+ let pmt = value(i.payments[0])
727+ let addon = valueOrElse(getString(this, ada()), "")
774728 let userAddress = if ((addon == toString(i.caller)))
775729 then i.originCaller
776730 else i.caller
777731 let txId58 = toBase58String(i.transactionId)
778- let paymentAssetId = value(payment.assetId)
779- let paymentAmount = payment.amount
780- if ((1000000000 > paymentAmount))
781- then throwErr("Min payment 10 LP")
782- else if (if (if ((0 > slippage))
783- then true
784- else (0 > exchResult))
785- then true
786- else (0 > outAmount))
787- then throwErr("Wrong params")
788- else if ((lpAssetId != toBase58String(paymentAssetId)))
789- then throwErr("Wrong LP")
790- else {
791- let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(paymentAssetId), paymentAmount, i.caller)
792- let estimAmAmt = r._1
793- let estimPrAmt = r._2
794- let amountBalance = getAccBalance(amountId)
795- let priceBalance = getAccBalance(priceId)
796- let $t03153432002 = if ((outAssetId == amountId))
797- then $Tuple7((amountBalance - estimAmAmt), (priceBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult))
798- else if ((outAssetId == priceId))
799- then $Tuple7((amountBalance - estimAmAmt), (priceBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult))
800- else throwErr("wrong outAssetId")
801- let amountBalanceNow = $t03153432002._1
802- let priceBalanceNow = $t03153432002._2
803- let virtSwapInAm = $t03153432002._3
804- let virtSwapOutPr = $t03153432002._4
805- let virtSwapInPr = $t03153432002._5
806- let virtSwapOutAm = $t03153432002._6
807- let totalGet = $t03153432002._7
808- if (if ((0 > virtSwapInAm))
809- then true
810- else (0 > virtSwapInPr))
811- then throwErr("Wrong calc")
812- else {
813- let D0 = invoke(gwxRewardContract, "calcD", [toString(amountBalanceNow), toString(priceBalanceNow), amplificator, Amult, Dconv], nil)
814- let D1 = invoke(gwxRewardContract, "calcD", [toString(((amountBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((priceBalanceNow + virtSwapOutPr) - virtSwapInPr)), amplificator, Amult, Dconv], nil)
815- let D0vsD1 = validateD(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D)
816- if ((D0vsD1 == D0vsD1))
817- then {
818- let finalRes = validateAbsDiff(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage))
819- if ((finalRes == finalRes))
820- then {
821- let $t03267132779 = if ((outAssetId == amountId))
822- then $Tuple2(toInt(finalRes._2), 0)
823- else $Tuple2(0, toInt(finalRes._2))
824- let outAm = $t03267132779._1
825- let outPr = $t03267132779._2
826- let totalAmountRaw = (outAm + outPr)
827- let $t03281932874 = takeFee(totalAmountRaw)
828- let totalAmount = $t03281932874._1
829- let feeAmount = $t03281932874._2
830- let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
831- then unit
832- else fromBase58String(outAssetId)
833- let sendFeeToMatcher = if ((feeAmount > 0))
834- then [ScriptTransfer(matcherAddress, feeAmount, outAssetIdOrWaves)]
835- else nil
836- let decimals = if ((amountDecimals >= priceDecimals))
837- then amountDecimals
838- else priceDecimals
839- if ((decimals == decimals))
840- then {
841- let curPrX18 = calcPriceBigInt(toX18(priceBalance, decimals), toX18(amountBalance, decimals))
842- let curPr = fromX18(curPrX18, scale8)
843- let state = [ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(keyGetActionByUser(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, paymentAmount, curPr, height, lastBlock.timestamp)), IntegerEntry(keyPriceLast(), curPr), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), curPr)]
844- if ((state == state))
845- then {
846- let burn = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
847- if ((burn == burn))
848- then (state ++ sendFeeToMatcher)
849- else throw("Strict value is not equal to itself.")
850- }
851- else throw("Strict value is not equal to itself.")
852- }
853- else throw("Strict value is not equal to itself.")
854- }
855- else throw("Strict value is not equal to itself.")
856- }
857- else throw("Strict value is not equal to itself.")
858- }
859- }
732+ let pmtAssetId = value(pmt.assetId)
733+ let pmtAmt = pmt.amount
734+ let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid")
735+ let check = reentrantInvoke(addonContract, "ensureCanGetOneTkn", [toString(userAddress)], nil)
736+ if ((check == check))
737+ then if ((1000000000 > pmtAmt))
738+ then throw("Min pmt 10 LP")
739+ else if (if (if ((0 > slippage))
740+ then true
741+ else (0 > exchResult))
742+ then true
743+ else (0 > outAmount))
744+ then throw("Wrong params")
745+ else if ((lpId != toBase58String(pmtAssetId)))
746+ then throw("Wrong LP")
747+ else {
748+ let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
749+ let estimAmAmt = r._1
750+ let estimPrAmt = r._2
751+ let amBalance = getAccBalance(amId)
752+ let prBalance = getAccBalance(prId)
753+ let $t03024330700 = if ((outAssetId == amId))
754+ then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult))
755+ else if ((outAssetId == prId))
756+ then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult))
757+ else throw("wrong outAssetId")
758+ let amBalanceNow = $t03024330700._1
759+ let prBalanceNow = $t03024330700._2
760+ let virtSwapInAm = $t03024330700._3
761+ let virtSwapOutPr = $t03024330700._4
762+ let virtSwapInPr = $t03024330700._5
763+ let virtSwapOutAm = $t03024330700._6
764+ let totalGet = $t03024330700._7
765+ if (if ((0 > virtSwapInAm))
766+ then true
767+ else (0 > virtSwapInPr))
768+ then throw("Wrong calc")
769+ else {
770+ let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil)
771+ let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil)
772+ let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D)
773+ if ((D0vsD1 == D0vsD1))
774+ then {
775+ let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage))
776+ if ((finalRes == finalRes))
777+ then {
778+ let $t03140531509 = if ((outAssetId == amId))
779+ then $Tuple2(toInt(finalRes._2), 0)
780+ else $Tuple2(0, toInt(finalRes._2))
781+ let outAm = $t03140531509._1
782+ let outPr = $t03140531509._2
783+ let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm))
784+ let curPr = f1(curPrX18, scale8)
785+ let state = [ScriptTransfer(userAddress, (outAm + outPr), if ((outAssetId == "WAVES"))
786+ then unit
787+ else fromBase58String(outAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)]
788+ if ((state == state))
789+ then {
790+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
791+ if ((burn == burn))
792+ then state
793+ else throw("Strict value is not equal to itself.")
794+ }
795+ else throw("Strict value is not equal to itself.")
796+ }
797+ else throw("Strict value is not equal to itself.")
798+ }
799+ else throw("Strict value is not equal to itself.")
800+ }
801+ }
802+ else throw("Strict value is not equal to itself.")
860803 }
861804
862805
863806
864807 @Callable(i)
865808 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
866- let r = commonGet(i)
867- let outAmountAmount = r._1
868- let outPriceAmount = r._2
869- let paymentAmount = r._3
870- let paymentAssetId = r._4
809+ let r = cg(i)
810+ let outAmAmt = r._1
811+ let outPrAmt = r._2
812+ let pmtAmt = r._3
813+ let pmtAssetId = r._4
871814 let state = r._5
872- let checkOutAmountAmount = if ((outAmountAmount >= noLessThenAmtAsset))
873- then true
874- else throwErr(((("Failed: " + toString(outAmountAmount)) + " < ") + toString(noLessThenAmtAsset)))
875- if ((checkOutAmountAmount == checkOutAmountAmount))
876- then {
877- let checkOutPriceAmount = if ((outPriceAmount >= noLessThenPriceAsset))
878- then true
879- else throwErr(((("Failed: " + toString(outPriceAmount)) + " < ") + toString(noLessThenPriceAsset)))
880- if ((checkOutPriceAmount == checkOutPriceAmount))
881- then {
882- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
883- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
884- then state
885- else throw("Strict value is not equal to itself.")
886- }
887- else throw("Strict value is not equal to itself.")
888- }
889- else throw("Strict value is not equal to itself.")
815+ if ((noLessThenAmtAsset > outAmAmt))
816+ then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
817+ else if ((noLessThenPriceAsset > outPrAmt))
818+ then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
819+ else {
820+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
821+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
822+ then state
823+ else throw("Strict value is not equal to itself.")
824+ }
890825 }
891826
892827
894829 @Callable(i)
895830 func unstakeAndGet (amount) = {
896831 let checkPayments = if ((size(i.payments) != 0))
897- then throwErr("no payments expected")
832+ then throw("No pmnts expd")
898833 else true
899834 if ((checkPayments == checkPayments))
900835 then {
901- let cfg = getPoolConfig()
902- let factoryCfg = getFactoryConfig()
836+ let cfg = gpc()
837+ let factoryCfg = gfc()
903838 let lpAssetId = fromBase58String(cfg[idxLPAsId])
904- let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "wrong")
839+ let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
905840 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
906841 if ((unstakeInv == unstakeInv))
907842 then {
908- let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
843+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
909844 let sts = parseIntValue(r._9)
910845 let state = r._10
911- let v = if (if (isGlobalShutdown())
846+ let v = if (if (igs())
912847 then true
913848 else (sts == PoolShutdown))
914- then throwErr(("Blocked: " + toString(sts)))
849+ then throw(("Blocked: " + toString(sts)))
915850 else true
916851 if ((v == v))
917852 then {
918- let burnA = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
853+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
919854 if ((burnA == burnA))
920855 then state
921856 else throw("Strict value is not equal to itself.")
930865
931866
932867 @Callable(i)
933-func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(factoryContract)))
934- then throwErr("denied")
935- else $Tuple2([StringEntry(keyAmountAsset(), amtAsStr), StringEntry(keyPriceAsset(), prAsStr)], "success")
868+func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
869+ then throw("denied")
870+ else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
936871
937872
938873
939874 @Callable(i)
940-func setS (k,v) = if ((toString(i.caller) != getStringOrFail(this, keyAddonAddress())))
875+func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
941876 then pd
942877 else [StringEntry(k, v)]
943878
944879
945880
946881 @Callable(i)
947-func setI (k,v) = if ((toString(i.caller) != getStringOrFail(this, keyAddonAddress())))
882+func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
948883 then pd
949884 else [IntegerEntry(k, v)]
950885
951886
952887
953888 @Callable(i)
954-func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
889+func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
955890
956891
957892
969904
970905
971906 @Callable(i)
972-func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resScaleMult))
907+func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
973908
974909
975910
976911 @Callable(i)
977-func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
912+func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
978913
979914
980915
981916 @Callable(i)
982-func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
917+func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
983918
984919
985920
986921 @Callable(i)
987-func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmountAssetAmount,inAmId,inPriceAssetAmount,inPrId,usrAddr,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippage, inAmountAssetAmount, inAmId, inPriceAssetAmount, inPrId, usrAddr, isEvaluate, emitLp, false, 0, ""))
922+func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, false, 0, ""))
988923
989924
990925
991926 @Callable(i)
992-func estimateGetOperationWrapperREADONLY (txId58,paymentAsId,paymentLpAmount,usrAddr) = {
993- let r = estimateGetOperation(txId58, paymentAsId, paymentLpAmount, addressFromStringValue(usrAddr))
927+func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
928+ let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
994929 $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
995930 }
996931
998933 @Verifier(tx)
999934 func verify () = match tx {
1000935 case order: Order =>
1001- let mtchPub = getMatcherPubOrFail()
1002- let orV = validateMatcherOrderAllowed(order)
936+ let mtchPub = mp()
937+ let orV = moa(order)
1003938 let sndrV = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
1004939 let mtchV = sigVerify(order.bodyBytes, order.proofs[1], mtchPub)
1005940 if (if (if (orV)
1008943 then mtchV
1009944 else false)
1010945 then true
1011- else throwOrderError(orV, sndrV, mtchV)
946+ else toe(orV, sndrV, mtchV)
1012947 case _ =>
1013- let targetPublicKey = match managerPublicKeyOrUnit() {
948+ let targetPublicKey = match m() {
1014949 case pk: ByteVector =>
1015950 pk
1016951 case _: Unit =>
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 6 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let scale8 = 100000000
55
66 let scale8BigInt = toBigInt(100000000)
77
88 let scale18 = toBigInt(1000000000000000000)
9-
10-let thousand = 1000
119
1210 let zeroBigInt = toBigInt(0)
1311
1412 let oneBigInt = toBigInt(1)
1513
1614 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
1715
1816 let Amult = "100"
1917
2018 let Dconv = "1"
2119
2220 let SEP = "__"
2321
2422 let EMPTY = ""
2523
2624 let PoolActive = 1
2725
2826 let PoolPutDis = 2
2927
3028 let PoolMatcherDis = 3
3129
3230 let PoolShutdown = 4
3331
3432 let idxPoolAddress = 1
3533
3634 let idxPoolSt = 2
3735
3836 let idxLPAsId = 3
3937
4038 let idxAmAsId = 4
4139
4240 let idxPrAsId = 5
4341
4442 let idxAmtAsDcm = 6
4543
4644 let idxPriceAsDcm = 7
4745
4846 let idxIAmtAsId = 8
4947
5048 let idxIPriceAsId = 9
5149
5250 let idxFactStakCntr = 1
5351
5452 let idxFactSlippCntr = 7
5553
5654 let idxFactGwxRewCntr = 10
5755
58-let feePermilleDefault = 0
56+let delay = "%s__delay"
5957
60-func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
58+func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6159
6260
63-func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
61+func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6462
6563
6664 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6765
6866
6967 func abs (val) = if ((zeroBigInt > val))
7068 then -(val)
7169 else val
7270
7371
74-func keyFactoryContact () = "%s__factoryContract"
72+func fc () = "%s__factoryContract"
7573
7674
77-func keyManagerPublicKey () = "%s__managerPublicKey"
75+func mpk () = "%s__managerPublicKey"
7876
7977
80-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
78+func pmpk () = "%s__pendingManagerPublicKey"
8179
8280
83-func keyPriceLast () = "%s%s__price__last"
81+func pl () = "%s%s__price__last"
8482
8583
86-func keyPriceHistory (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
84+func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
8785
8886
89-func keyPutActionByUser (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
87+func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
9088
9189
92-func keyGetActionByUser (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
90+func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
9391
9492
95-func keyAmountAsset () = "%s__amountAsset"
93+func aa () = "%s__amountAsset"
9694
9795
98-func keyPriceAsset () = "%s__priceAsset"
96+func pa () = "%s__priceAsset"
9997
10098
101-func keyAmplificator () = "%s__amp"
99+func amp () = "%s__amp"
102100
103101
104-func keyAddonAddress () = "%s__addonAddr"
102+func ada () = "%s__addonAddr"
105103
106104
107-let keyFeePermille = "%s__feePermille"
105+func lgotc (caller) = makeString(["%s%s__lastGetOneTknCall", caller], SEP)
108106
109-let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault)
107+
108+func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP)
109+
110110
111111 func fcfg () = "%s__factoryConfig"
112112
113113
114114 func mtpk () = "%s%s__matcher__publicKey"
115115
116116
117117 func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config")
118118
119119
120120 func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr)
121121
122122
123123 func aps () = "%s__shutdown"
124124
125125
126-func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
127-
128-
129-func throwOrderError (orV,sendrV,matchV) = throwErr(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
126+func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
130127
131128
132129 func str (val) = match val {
133130 case valStr: String =>
134131 valStr
135132 case _ =>
136- throwErr("fail cast to String")
133+ throw("fail cast to String")
137134 }
138135
139136
140-func getStringOrFail (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
137+func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
141138
142139
143-func getIntOrFail (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
140+func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
144141
145142
146-let factoryContract = addressFromStringValue(getStringOrFail(this, keyFactoryContact()))
143+let fca = addressFromStringValue(strf(this, fc()))
147144
148-let amplificator = getStringOrFail(this, keyAmplificator())
145+let A = strf(this, amp())
149146
150-func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, aps()), false)
147+func igs () = valueOrElse(getBoolean(fca, aps()), false)
151148
152149
153-func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, mtpk()))
150+func mp () = fromBase58String(strf(fca, mtpk()))
154151
155152
156-let matcherAddress = addressFromPublicKey(getMatcherPubOrFail())
157-
158-func getPoolConfig () = {
159- let amtAs = getStringOrFail(this, keyAmountAsset())
160- let priceAs = getStringOrFail(this, keyPriceAsset())
161- let iPriceAs = getIntOrFail(factoryContract, mba(priceAs))
162- let iAmtAs = getIntOrFail(factoryContract, mba(amtAs))
163- split(getStringOrFail(factoryContract, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
153+func gpc () = {
154+ let amtAs = strf(this, aa())
155+ let priceAs = strf(this, pa())
156+ let iPriceAs = intf(fca, mba(priceAs))
157+ let iAmtAs = intf(fca, mba(amtAs))
158+ split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
164159 }
165160
166161
167-func getFactoryConfig () = split(getStringOrFail(factoryContract, fcfg()), SEP)
162+func gfc () = split(strf(fca, fcfg()), SEP)
168163
169164
170165 func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slipByUser,slippageReal,txHeight,txTimestamp,slipageAmAmt,slipagePrAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slipByUser), toString(slippageReal), toString(txHeight), toString(txTimestamp), toString(slipageAmAmt), toString(slipagePrAmt)], SEP)
171166
172167
173168 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)
174169
175170
176171 func getAccBalance (assetId) = if ((assetId == "WAVES"))
177172 then wavesBalance(this).available
178173 else assetBalance(this, fromBase58String(assetId))
179174
180175
181-func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
176+func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
182177
183178
184-func validateAbsDiff (estimateLP,outLp,slippage) = {
185- let diff = fraction((estimateLP - outLp), scale8BigInt, outLp)
179+func vad (A1,A2,slippage) = {
180+ let diff = fraction((A1 - A2), scale8BigInt, A2)
186181 let pass = ((slippage - abs(diff)) > zeroBigInt)
187182 if (!(pass))
188- then throwErr(("Big slippage: " + toString(diff)))
189- else $Tuple2(pass, min([estimateLP, outLp]))
183+ then throw(("Big slpg: " + toString(diff)))
184+ else $Tuple2(pass, min([A1, A2]))
190185 }
191186
192187
193-func validateD (D1,D0,slippage) = {
188+func vd (D1,D0,slpg) = {
194189 let diff = fraction(D0, scale8BigInt, D1)
195- let fail = (slippage > diff)
190+ let fail = (slpg > diff)
196191 if (if (fail)
197192 then true
198193 else (D0 > D1))
199- then throwErr(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slippage)))
194+ then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg)))
200195 else fail
201196 }
202197
203198
204-func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
205- let amtAsAmtX18 = toX18(amAmt, amAssetDcm)
206- let prAsAmtX18 = toX18(prAmt, prAssetDcm)
207- calcPriceBigInt(prAsAmtX18, amtAsAmtX18)
199+func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
200+ let amtAsAmtX18 = t1(amAmt, amAssetDcm)
201+ let prAsAmtX18 = t1(prAmt, prAssetDcm)
202+ cpbi(prAsAmtX18, amtAsAmtX18)
208203 }
209204
210205
211206 func calcPrices (amAmt,prAmt,lpAmt) = {
212- let cfg = getPoolConfig()
207+ let cfg = gpc()
213208 let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
214209 let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
215- let priceX18 = privateCalcPrice(amtAsDcm, prAsDcm, amAmt, prAmt)
216- let amAmtX18 = toX18(amAmt, amtAsDcm)
217- let prAmtX18 = toX18(prAmt, prAsDcm)
218- let lpAmtX18 = toX18(lpAmt, scale8)
219- let lpPrInAmAsX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
220- let lpPrInPrAsX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
210+ let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
211+ let amAmtX18 = t1(amAmt, amtAsDcm)
212+ let prAmtX18 = t1(prAmt, prAsDcm)
213+ let lpAmtX18 = t1(lpAmt, scale8)
214+ let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18)
215+ let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18)
221216 [priceX18, lpPrInAmAsX18, lpPrInPrAsX18]
222217 }
223218
224219
225220 func calculatePrices (amAmt,prAmt,lpAmt) = {
226221 let p = calcPrices(amAmt, prAmt, lpAmt)
227-[fromX18(p[0], scale8), fromX18(p[1], scale8), fromX18(p[2], scale8)]
222+[f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)]
228223 }
229224
230225
231-func estimateGetOperation (txId58,paymentAssetId,paymentLpAmount,userAddress) = {
232- let cfg = getPoolConfig()
233- let lpAssetId = cfg[idxLPAsId]
234- let amountId = cfg[idxAmAsId]
235- let priceId = cfg[idxPrAsId]
236- let amountDecimals = parseIntValue(cfg[idxAmtAsDcm])
237- let priceDecimals = parseIntValue(cfg[idxPriceAsDcm])
226+func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
227+ let cfg = gpc()
228+ let lpId = cfg[idxLPAsId]
229+ let amId = cfg[idxAmAsId]
230+ let prId = cfg[idxPrAsId]
231+ let amDcm = parseIntValue(cfg[idxAmtAsDcm])
232+ let prDcm = parseIntValue(cfg[idxPriceAsDcm])
238233 let sts = cfg[idxPoolSt]
239- let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), "Wrong LP id").quantity
240- let validationBlock = if ((lpAssetId == paymentAssetId))
241- then true
242- else throwErr("Wrong payment asset")
243- if ((validationBlock == validationBlock))
244- then {
245- let decimals = if ((amountDecimals >= priceDecimals))
246- then amountDecimals
247- else priceDecimals
248- if ((decimals == decimals))
249- then {
250- let amountBalance = getAccBalance(amountId)
251- let amountBalanceX18 = toX18(amountBalance, decimals)
252- let priceBalance = getAccBalance(priceId)
253- let priceBalanceX18 = toX18(priceBalance, decimals)
254- let currentPriceX18 = calcPriceBigInt(priceBalanceX18, amountBalanceX18)
255- let curPrice = fromX18(currentPriceX18, scale8)
256- let paymentLpAmountX18 = toX18(paymentLpAmount, scale8)
257- let lpEmissionX18 = toX18(lpEmission, scale8)
258- let outAmountAmountX18 = fraction(amountBalanceX18, paymentLpAmountX18, lpEmissionX18)
259- let outPriceAmountX18 = fraction(priceBalanceX18, paymentLpAmountX18, lpEmissionX18)
260- let outAmountAmount = fromX18(outAmountAmountX18, decimals)
261- let outPriceAmount = fromX18(outPriceAmountX18, decimals)
262- let state = if ((txId58 == ""))
263- then nil
264- else [ScriptTransfer(userAddress, outAmountAmount, if ((amountId == "WAVES"))
265- then unit
266- else fromBase58String(amountId)), ScriptTransfer(userAddress, outPriceAmount, if ((priceId == "WAVES"))
267- then unit
268- else fromBase58String(priceId)), StringEntry(keyGetActionByUser(toString(userAddress), txId58), dataGetActionInfo(outAmountAmount, outPriceAmount, paymentLpAmount, curPrice, height, lastBlock.timestamp)), IntegerEntry(keyPriceLast(), curPrice), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), curPrice)]
269- $Tuple10(outAmountAmount, outPriceAmount, amountId, priceId, amountBalance, priceBalance, lpEmission, currentPriceX18, sts, state)
270- }
271- else throw("Strict value is not equal to itself.")
234+ let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
235+ if ((lpId != pmtAssetId))
236+ then throw("Wrong pmt asset")
237+ else {
238+ let amBalance = getAccBalance(amId)
239+ let amBalanceX18 = t1(amBalance, amDcm)
240+ let prBalance = getAccBalance(prId)
241+ let prBalanceX18 = t1(prBalance, prDcm)
242+ let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
243+ let curPrice = f1(curPriceX18, scale8)
244+ let pmtLpAmtX18 = t1(pmtLpAmt, scale8)
245+ let lpEmissX18 = t1(lpEmiss, scale8)
246+ let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
247+ let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
248+ let outAmAmt = f1(outAmAmtX18, amDcm)
249+ let outPrAmt = f1(outPrAmtX18, prDcm)
250+ let state = if ((txId58 == ""))
251+ then nil
252+ else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
253+ then unit
254+ else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES"))
255+ then unit
256+ else fromBase58String(prId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)]
257+ $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state)
272258 }
273- else throw("Strict value is not equal to itself.")
274259 }
275260
276261
277-func estimatePutOperation (txId58,slippageTolerance,inAmountAssetAmount,inAmountAssetId,inPriceAssetAmount,inPriceAssetId,userAddress,isEvaluate,emitLp,isOneAsset,paymentAmount,paymentId) = {
278- let cfg = getPoolConfig()
279- let lpAssetId = fromBase58String(cfg[idxLPAsId])
280- let amountIdStr = cfg[idxAmAsId]
281- let priceIdStr = cfg[idxPrAsId]
282- let inAmountIdStr = cfg[idxIAmtAsId]
283- let inPriceIdStr = cfg[idxIPriceAsId]
284- let amountDecimals = parseIntValue(cfg[idxAmtAsDcm])
285- let priceDecimals = parseIntValue(cfg[idxPriceAsDcm])
262+func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,pmtAmt,pmtId) = {
263+ let cfg = gpc()
264+ let lpId = fromBase58String(cfg[idxLPAsId])
265+ let amIdStr = cfg[idxAmAsId]
266+ let prIdStr = cfg[idxPrAsId]
267+ let inAmIdStr = cfg[idxIAmtAsId]
268+ let inPrIdStr = cfg[idxIPriceAsId]
269+ let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
270+ let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
286271 let sts = cfg[idxPoolSt]
287- let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), "Wrong lp asset").quantity
288- let amountBalance = if (isEvaluate)
289- then getAccBalance(amountIdStr)
272+ let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
273+ let amBalance = if (isEval)
274+ then getAccBalance(amIdStr)
290275 else if (if (isOneAsset)
291- then (paymentId == amountIdStr)
276+ then (pmtId == amIdStr)
292277 else false)
293- then (getAccBalance(amountIdStr) - paymentAmount)
278+ then (getAccBalance(amIdStr) - pmtAmt)
294279 else if (isOneAsset)
295- then getAccBalance(amountIdStr)
296- else (getAccBalance(amountIdStr) - inAmountAssetAmount)
297- let priceBalance = if (isEvaluate)
298- then getAccBalance(priceIdStr)
280+ then getAccBalance(amIdStr)
281+ else (getAccBalance(amIdStr) - inAmAmt)
282+ let prBalance = if (isEval)
283+ then getAccBalance(prIdStr)
299284 else if (if (isOneAsset)
300- then (paymentId == priceIdStr)
285+ then (pmtId == prIdStr)
301286 else false)
302- then (getAccBalance(priceIdStr) - paymentAmount)
287+ then (getAccBalance(prIdStr) - pmtAmt)
303288 else if (isOneAsset)
304- then getAccBalance(priceIdStr)
305- else (getAccBalance(priceIdStr) - inPriceAssetAmount)
306- let decimals = if ((amountDecimals >= priceDecimals))
307- then amountDecimals
308- else priceDecimals
309- if ((decimals == decimals))
289+ then getAccBalance(prIdStr)
290+ else (getAccBalance(prIdStr) - inPrAmt)
291+ let inAmAssetAmtX18 = t1(inAmAmt, amtDcm)
292+ let inPrAssetAmtX18 = t1(inPrAmt, priceDcm)
293+ let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
294+ let amBalanceX18 = t1(amBalance, amtDcm)
295+ let prBalanceX18 = t1(prBalance, priceDcm)
296+ let r = if ((lpEm == 0))
310297 then {
311- let inAmountAssetAmountX18 = toX18(inAmountAssetAmount, decimals)
312- let inPriceAssetAmountX18 = toX18(inPriceAssetAmount, decimals)
313- let userPriceX18 = calcPriceBigInt(inPriceAssetAmountX18, inAmountAssetAmountX18)
314- let amountBalanceX18 = toX18(amountBalance, decimals)
315- let priceBalanceX18 = toX18(priceBalance, decimals)
316- let r = if ((lpEmission == 0))
317- then {
318- let currentPriceX18 = zeroBigInt
319- let slippageX18 = zeroBigInt
320- let lpAmountX18 = pow((inAmountAssetAmountX18 * inPriceAssetAmountX18), 0, toBigInt(5), 1, 0, DOWN)
321- $Tuple5(fromX18(lpAmountX18, scale8), fromX18(inAmountAssetAmountX18, decimals), fromX18(inPriceAssetAmountX18, decimals), calcPriceBigInt((priceBalanceX18 + inPriceAssetAmountX18), (amountBalanceX18 + inAmountAssetAmountX18)), slippageX18)
298+ let curPriceX18 = zeroBigInt
299+ let slippageX18 = zeroBigInt
300+ let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
301+ $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
302+ }
303+ else {
304+ let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
305+ let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
306+ let slippageX18 = t1(slippage, scale8)
307+ if (if ((curPriceX18 != zeroBigInt))
308+ then (slippageRealX18 > slippageX18)
309+ else false)
310+ then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
311+ else {
312+ let lpEmissionX18 = t1(lpEm, scale8)
313+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
314+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
315+ let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
316+ then $Tuple2(amViaPrX18, inPrAssetAmtX18)
317+ else $Tuple2(inAmAssetAmtX18, prViaAmX18)
318+ let expAmtAssetAmtX18 = expectedAmts._1
319+ let expPriceAssetAmtX18 = expectedAmts._2
320+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
321+ $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
322322 }
323- else {
324- let currentPriceX18 = calcPriceBigInt(priceBalanceX18, amountBalanceX18)
325- let slippageRealX18 = fraction(abs((currentPriceX18 - userPriceX18)), scale18, currentPriceX18)
326- let slippageX18 = toX18(slippageTolerance, scale8)
327- if (if ((currentPriceX18 != zeroBigInt))
328- then (slippageRealX18 > slippageX18)
329- else false)
330- then throwErr(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
331- else {
332- let lpEmissionX18 = toX18(lpEmission, scale8)
333- let prViaAmX18 = fraction(inAmountAssetAmountX18, currentPriceX18, scale18)
334- let amViaPrX18 = fraction(inPriceAssetAmountX18, scale18, currentPriceX18)
335- let expectedAmounts = if ((prViaAmX18 > inPriceAssetAmountX18))
336- then $Tuple2(amViaPrX18, inAmountAssetAmountX18)
337- else $Tuple2(inAmountAssetAmountX18, prViaAmX18)
338- let expectedAmountAssetAmountX18 = expectedAmounts._1
339- let expectedPriceAssetAmountX18 = expectedAmounts._2
340- let lpAmountX18 = fraction(lpEmissionX18, expectedPriceAssetAmountX18, priceBalanceX18)
341- $Tuple5(fromX18(lpAmountX18, scale8), fromX18(expectedAmountAssetAmountX18, decimals), fromX18(expectedPriceAssetAmountX18, decimals), currentPriceX18, slippageX18)
342- }
343- }
344- let calculateLpAmount = r._1
345- let calculateAmountAssetPayment = r._2
346- let calculatePriceAssetPayment = r._3
347- let currentPrice = fromX18(r._4, scale8)
348- let slippageCalculate = fromX18(r._5, scale8)
349- let checkCalcLpAmount = if ((calculateLpAmount > 0))
350- then true
351- else throwErr("LP <= 0")
352- if ((checkCalcLpAmount == checkCalcLpAmount))
353- then {
354- let emitLpAmount = if (!(emitLp))
355- then 0
356- else calculateLpAmount
357- let amountDiff = (inAmountAssetAmount - calculateAmountAssetPayment)
358- let priceDiff = (inPriceAssetAmount - calculatePriceAssetPayment)
359- let $t01618916448 = if (if (isOneAsset)
360- then (paymentId == amountIdStr)
361- else false)
362- then $Tuple2(paymentAmount, 0)
363- else if (if (isOneAsset)
364- then (paymentId == priceIdStr)
365- else false)
366- then $Tuple2(0, paymentAmount)
367- else $Tuple2(calculateAmountAssetPayment, calculatePriceAssetPayment)
368- let writeAmAmt = $t01618916448._1
369- let writePrAmt = $t01618916448._2
370- let commonState = [IntegerEntry(keyPriceLast(), currentPrice), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), currentPrice), StringEntry(keyPutActionByUser(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmount, currentPrice, slippageTolerance, slippageCalculate, height, lastBlock.timestamp, amountDiff, priceDiff))]
371- $Tuple13(calculateLpAmount, emitLpAmount, currentPrice, amountBalance, priceBalance, lpEmission, lpAssetId, sts, commonState, amountDiff, priceDiff, inAmountAssetId, inPriceAssetId)
372- }
373- else throw("Strict value is not equal to itself.")
374323 }
375- else throw("Strict value is not equal to itself.")
324+ let calcLpAmt = r._1
325+ let calcAmAssetPmt = r._2
326+ let calcPrAssetPmt = r._3
327+ let curPrice = f1(r._4, scale8)
328+ let slippageCalc = f1(r._5, scale8)
329+ if ((0 >= calcLpAmt))
330+ then throw("LP <= 0")
331+ else {
332+ let emitLpAmt = if (!(emitLp))
333+ then 0
334+ else calcLpAmt
335+ let amDiff = (inAmAmt - calcAmAssetPmt)
336+ let prDiff = (inPrAmt - calcPrAssetPmt)
337+ let $t01553115876 = if (if (isOneAsset)
338+ then (pmtId == amIdStr)
339+ else false)
340+ then $Tuple2(pmtAmt, 0)
341+ else if (if (isOneAsset)
342+ then (pmtId == prIdStr)
343+ else false)
344+ then $Tuple2(0, pmtAmt)
345+ else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
346+ let writeAmAmt = $t01553115876._1
347+ let writePrAmt = $t01553115876._2
348+ let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))]
349+ $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
350+ }
376351 }
377352
378353
379-func validateMatcherOrderAllowed (order) = {
380- let cfg = getPoolConfig()
354+func moa (order) = {
355+ let cfg = gpc()
381356 let amtAsId = cfg[idxAmAsId]
382357 let prAsId = cfg[idxPrAsId]
383358 let sts = parseIntValue(cfg[idxPoolSt])
384359 let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
385360 let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
386361 let accAmtAsBalance = getAccBalance(amtAsId)
387362 let accPrAsBalance = getAccBalance(prAsId)
388- let currentPriceX18 = if ((order.orderType == Buy))
389- then privateCalcPrice(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
390- else privateCalcPrice(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
391- let curPrice = fromX18(currentPriceX18, scale8)
392- if (if (if (isGlobalShutdown())
363+ let curPriceX18 = if ((order.orderType == Buy))
364+ then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
365+ else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
366+ let curPrice = f1(curPriceX18, scale8)
367+ if (if (if (igs())
393368 then true
394369 else (sts == PoolMatcherDis))
395370 then true
396371 else (sts == PoolShutdown))
397- then throwErr("Admin blocked")
372+ then throw("Admin blocked")
398373 else {
399374 let orAmtAsset = order.assetPair.amountAsset
400375 let orAmtAsStr = if ((orAmtAsset == unit))
401376 then "WAVES"
402377 else toBase58String(value(orAmtAsset))
403378 let orPrAsset = order.assetPair.priceAsset
404379 let orPrAsStr = if ((orPrAsset == unit))
405380 then "WAVES"
406381 else toBase58String(value(orPrAsset))
407382 if (if ((orAmtAsStr != amtAsId))
408383 then true
409384 else (orPrAsStr != prAsId))
410- then throwErr("Wr assets")
385+ then throw("Wr assets")
411386 else {
412387 let orderPrice = order.price
413- let priceDecimals = fraction(scale8, prAsDcm, amtAsDcm)
414- let castOrderPrice = ts(orderPrice, scale8, priceDecimals)
388+ let priceDcm = fraction(scale8, prAsDcm, amtAsDcm)
389+ let castOrderPrice = ts(orderPrice, scale8, priceDcm)
415390 let isOrderPriceValid = if ((order.orderType == Buy))
416391 then (curPrice >= castOrderPrice)
417392 else (castOrderPrice >= curPrice)
418393 true
419394 }
420395 }
421396 }
422397
423398
424-func commonGet (i) = {
425- let checkPayments = if ((size(i.payments) == 1))
426- then true
427- else throwErr("1 payment expected")
428- if ((checkPayments == checkPayments))
429- then {
430- let payment = value(i.payments[0])
431- let paymentAssetId = value(payment.assetId)
432- let paymentAmount = payment.amount
433- let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(paymentAssetId), paymentAmount, i.caller)
434- let outAmountAmount = r._1
435- let outPriceAmount = r._2
436- let sts = parseIntValue(r._9)
437- let state = r._10
438- if (if (isGlobalShutdown())
439- then true
440- else (sts == PoolShutdown))
441- then throwErr(("Admin blocked: " + toString(sts)))
442- else $Tuple5(outAmountAmount, outPriceAmount, paymentAmount, paymentAssetId, state)
443- }
444- else throw("Strict value is not equal to itself.")
445- }
399+func cg (i) = if ((size(i.payments) != 1))
400+ then throw("1 pmnt exp")
401+ else {
402+ let pmt = value(i.payments[0])
403+ let pmtAssetId = value(pmt.assetId)
404+ let pmtAmt = pmt.amount
405+ let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
406+ let outAmAmt = r._1
407+ let outPrAmt = r._2
408+ let sts = parseIntValue(r._9)
409+ let state = r._10
410+ if (if (igs())
411+ then true
412+ else (sts == PoolShutdown))
413+ then throw(("Admin blocked: " + toString(sts)))
414+ else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
415+ }
446416
447417
448-func commonPut (caller,txId,amountAssetPayment,priceAssetPayment,slippage,emitLp,isOneAsset,paymentAmount,paymentId) = {
449- let r = estimatePutOperation(txId, slippage, value(amountAssetPayment).amount, value(amountAssetPayment).assetId, value(priceAssetPayment).amount, value(priceAssetPayment).assetId, caller, false, emitLp, isOneAsset, paymentAmount, paymentId)
418+func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,pmtAmt,pmtId) = {
419+ let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, pmtAmt, pmtId)
450420 let sts = parseIntValue(r._8)
451- if (if (if (isGlobalShutdown())
421+ if (if (if (igs())
452422 then true
453423 else (sts == PoolPutDis))
454424 then true
455425 else (sts == PoolShutdown))
456- then throwErr(("Blocked:" + toString(sts)))
426+ then throw(("Blocked:" + toString(sts)))
457427 else r
458428 }
459429
460430
461-func takeFee (amount) = {
462- let fee = fraction(amount, feePermille, thousand)
463- $Tuple2((amount - fee), fee)
464- }
465-
466-
467-func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
431+func m () = match getString(mpk()) {
468432 case s: String =>
469433 fromBase58String(s)
470434 case _: Unit =>
471435 unit
472436 case _ =>
473437 throw("Match error")
474438 }
475439
476440
477-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
441+func pm () = match getString(pmpk()) {
478442 case s: String =>
479443 fromBase58String(s)
480444 case _: Unit =>
481445 unit
482446 case _ =>
483447 throw("Match error")
484448 }
485449
486450
487-let pd = throwErr("Permission denied")
451+let pd = throw("Permission denied")
488452
489-func mustManager (i) = match managerPublicKeyOrUnit() {
453+func mm (i) = match m() {
490454 case pk: ByteVector =>
491455 if ((i.callerPublicKey == pk))
492456 then true
493457 else pd
494458 case _: Unit =>
495459 if ((i.caller == this))
496460 then true
497461 else pd
498462 case _ =>
499463 throw("Match error")
500464 }
501465
502466
503467 @Callable(i)
504-func constructor (factoryContract) = {
505- let checkCaller = mustManager(i)
506- if ((checkCaller == checkCaller))
507- then [StringEntry(keyFactoryContact(), factoryContract)]
468+func constructor (fc) = {
469+ let c = mm(i)
470+ if ((c == c))
471+ then [StringEntry(fc(), fc)]
508472 else throw("Strict value is not equal to itself.")
509473 }
510474
511475
512476
513477 @Callable(i)
514478 func setManager (pendingManagerPublicKey) = {
515- let checkCaller = mustManager(i)
516- if ((checkCaller == checkCaller))
479+ let c = mm(i)
480+ if ((c == c))
517481 then {
518- let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
519- if ((checkManagerPublicKey == checkManagerPublicKey))
520- then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
482+ let cm = fromBase58String(pendingManagerPublicKey)
483+ if ((cm == cm))
484+ then [StringEntry(pmpk(), pendingManagerPublicKey)]
521485 else throw("Strict value is not equal to itself.")
522486 }
523487 else throw("Strict value is not equal to itself.")
524488 }
525489
526490
527491
528492 @Callable(i)
529493 func confirmManager () = {
530- let pm = pendingManagerPublicKeyOrUnit()
531- let hasPM = if (isDefined(pm))
494+ let p = pm()
495+ let hpm = if (isDefined(p))
532496 then true
533- else throwErr("No pending manager")
534- if ((hasPM == hasPM))
497+ else throw("No pending manager")
498+ if ((hpm == hpm))
535499 then {
536- let checkPM = if ((i.callerPublicKey == value(pm)))
500+ let cpm = if ((i.callerPublicKey == value(p)))
537501 then true
538- else throwErr("You are not pending manager")
539- if ((checkPM == checkPM))
540- then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
502+ else throw("You are not pending manager")
503+ if ((cpm == cpm))
504+ then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
541505 else throw("Strict value is not equal to itself.")
542506 }
543507 else throw("Strict value is not equal to itself.")
544508 }
545509
546510
547511
548512 @Callable(i)
549-func put (slippage,autoStake) = {
550- let factCfg = getFactoryConfig()
551- let stakingContract = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wrong staking contract")
552- let slippageContract = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wrogn slippage contract")
553- let slippageCheck = if ((slippage >= 0))
554- then true
555- else throwErr("wrong slippage")
556- if ((slippageCheck == slippageCheck))
557- then {
558- let paymentsCheck = if ((size(i.payments) == 2))
559- then true
560- else throwErr("2 payments expected")
561- if ((paymentsCheck == paymentsCheck))
562- then {
563- let estimatePut = commonPut(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slippage, true, false, 0, "")
564- let emitLpAmount = estimatePut._2
565- let lpAssetId = estimatePut._7
566- let state = estimatePut._9
567- let amountDiff = estimatePut._10
568- let priceDiff = estimatePut._11
569- let amountId = estimatePut._12
570- let priceId = estimatePut._13
571- let r = invoke(factoryContract, "emit", [emitLpAmount], nil)
572- if ((r == r))
573- then {
574- let el = match r {
575- case legacy: Address =>
576- invoke(legacy, "emit", [emitLpAmount], nil)
577- case _ =>
578- unit
579- }
580- if ((el == el))
513+func put (slip,autoStake) = {
514+ let factCfg = gfc()
515+ let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
516+ let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
517+ if ((0 > slip))
518+ then throw("Wrong slippage")
519+ else if ((size(i.payments) != 2))
520+ then throw("2 pmnts expd")
521+ else {
522+ let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, 0, "")
523+ let emitLpAmt = e._2
524+ let lpAssetId = e._7
525+ let state = e._9
526+ let amDiff = e._10
527+ let prDiff = e._11
528+ let amId = e._12
529+ let prId = e._13
530+ let r = invoke(fca, "emit", [emitLpAmt], nil)
531+ if ((r == r))
532+ then {
533+ let el = match r {
534+ case legacy: Address =>
535+ invoke(legacy, "emit", [emitLpAmt], nil)
536+ case _ =>
537+ unit
538+ }
539+ if ((el == el))
540+ then {
541+ let sa = if ((amDiff > 0))
542+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
543+ else nil
544+ if ((sa == sa))
545+ then {
546+ let sp = if ((prDiff > 0))
547+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
548+ else nil
549+ if ((sp == sp))
550+ then {
551+ let lpTrnsfr = if (autoStake)
552+ then {
553+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
554+ if ((ss == ss))
555+ then nil
556+ else throw("Strict value is not equal to itself.")
557+ }
558+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
559+ (state ++ lpTrnsfr)
560+ }
561+ else throw("Strict value is not equal to itself.")
562+ }
563+ else throw("Strict value is not equal to itself.")
564+ }
565+ else throw("Strict value is not equal to itself.")
566+ }
567+ else throw("Strict value is not equal to itself.")
568+ }
569+ }
570+
571+
572+
573+@Callable(i)
574+func putOneTkn (amAssetPart,prAssetPart,outLp,slippage,autoStake) = {
575+ let cfg = gfc()
576+ let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr")
577+ let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr")
578+ let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr")
579+ let poolCfg = gpc()
580+ let amId = poolCfg[idxAmAsId]
581+ let prId = poolCfg[idxPrAsId]
582+ let amDcm = parseIntValue(poolCfg[idxAmtAsDcm])
583+ let prDcm = parseIntValue(poolCfg[idxPriceAsDcm])
584+ let addon = valueOrElse(getString(this, ada()), "")
585+ let userAddress = if ((addon == toString(i.caller)))
586+ then i.originCaller
587+ else i.caller
588+ let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid")
589+ let check = reentrantInvoke(addonContract, "ensureCanPutOneTkn", [toString(userAddress)], nil)
590+ if ((check == check))
591+ then if (if (if (if ((0 >= slippage))
592+ then true
593+ else (0 >= amAssetPart))
594+ then true
595+ else (0 >= prAssetPart))
596+ then true
597+ else (0 >= outLp))
598+ then throw("Wrong params")
599+ else if ((size(i.payments) != 1))
600+ then throw("1 pmnt expd")
601+ else {
602+ let pmt = value(i.payments[0])
603+ let pmtAssetId = toBase58String(value(pmt.assetId))
604+ let pmtAmt = pmt.amount
605+ if (if (if ((amAssetPart > pmtAmt))
606+ then true
607+ else (prAssetPart > pmtAmt))
608+ then true
609+ else (10000000 > pmtAmt))
610+ then throw("Wrong pmt amt")
611+ else {
612+ let amBalance = getAccBalance(amId)
613+ let prBalance = getAccBalance(prId)
614+ let $t02483225212 = if ((pmtAssetId == amId))
615+ then $Tuple6((amBalance - pmtAmt), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0)
616+ else if ((pmtAssetId == prId))
617+ then $Tuple6(amBalance, (prBalance - pmtAmt), 0, 0, (pmtAmt - prAssetPart), amAssetPart)
618+ else throw("wrong pmtAssetId")
619+ let amBalanceNow = $t02483225212._1
620+ let prBalanceNow = $t02483225212._2
621+ let virtSwapInAm = $t02483225212._3
622+ let virtSwapOutPr = $t02483225212._4
623+ let virtSwapInPr = $t02483225212._5
624+ let virtSwapOutAm = $t02483225212._6
625+ let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil)
626+ let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil)
627+ let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D)
628+ if ((D0vsD1 == D0vsD1))
581629 then {
582- let sa = if ((amountDiff > 0))
583- then invoke(slippageContract, "put", nil, [AttachedPayment(amountId, amountDiff)])
584- else nil
585- if ((sa == sa))
630+ let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId)
631+ let estimLP = estPut._2
632+ let lpAssetId = estPut._7
633+ let state = estPut._9
634+ let amDiff = estPut._10
635+ let prDiff = estPut._11
636+ let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage))
637+ let emitLpAmt = toInt(lpCalcRes._2)
638+ let e = invoke(fca, "emit", [emitLpAmt], nil)
639+ if ((e == e))
586640 then {
587- let sp = if ((priceDiff > 0))
588- then invoke(slippageContract, "put", nil, [AttachedPayment(priceId, priceDiff)])
589- else nil
590- if ((sp == sp))
641+ let el = match e {
642+ case legacy: Address =>
643+ invoke(legacy, "emit", [emitLpAmt], nil)
644+ case _ =>
645+ unit
646+ }
647+ if ((el == el))
591648 then {
592- let lpTrasfer = if (autoStake)
649+ let sa = if ((amDiff > 0))
650+ then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)])
651+ else nil
652+ if ((sa == sa))
593653 then {
594- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmount)])
595- if ((ss == ss))
596- then nil
654+ let sp = if ((prDiff > 0))
655+ then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)])
656+ else nil
657+ if ((sp == sp))
658+ then {
659+ let lpTrnsfr = if (autoStake)
660+ then {
661+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
662+ if ((ss == ss))
663+ then nil
664+ else throw("Strict value is not equal to itself.")
665+ }
666+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
667+ (state ++ lpTrnsfr)
668+ }
597669 else throw("Strict value is not equal to itself.")
598670 }
599- else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)]
600- (state ++ lpTrasfer)
671+ else throw("Strict value is not equal to itself.")
601672 }
602673 else throw("Strict value is not equal to itself.")
603674 }
604675 else throw("Strict value is not equal to itself.")
605676 }
606677 else throw("Strict value is not equal to itself.")
607678 }
608- else throw("Strict value is not equal to itself.")
609679 }
610- else throw("Strict value is not equal to itself.")
611- }
612680 else throw("Strict value is not equal to itself.")
613681 }
614682
615683
616684
617685 @Callable(i)
618-func putOneTkn (amountAssetPart,priceAssetPart,outLp,slippage,autoStake) = {
619- let cfg = getFactoryConfig()
620- let stakingContract = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wrong staking contract")
621- let slippageContract = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wrong slippage contract")
622- let gwxRewardContract = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wrong gwx reward contract")
623- let poolCfg = getPoolConfig()
624- let amountId = poolCfg[idxAmAsId]
625- let priceId = poolCfg[idxPrAsId]
626- let amountDecimals = parseIntValue(poolCfg[idxAmtAsDcm])
627- let priceDecimals = parseIntValue(poolCfg[idxPriceAsDcm])
628- let addon = valueOrElse(getString(this, keyAddonAddress()), "")
629- let userAddress = if ((addon == toString(i.caller)))
630- then i.originCaller
631- else i.caller
632- if (if (if (if ((0 >= slippage))
633- then true
634- else (0 >= amountAssetPart))
635- then true
636- else (0 >= priceAssetPart))
637- then true
638- else (0 >= outLp))
639- then throwErr("Wrong params")
640- else if ((size(i.payments) != 1))
641- then throwErr("1 payment expected")
642- else {
643- let payment = value(i.payments[0])
644- let paymentAssetId = toBase58String(value(payment.assetId))
645- let paymentAmountRaw = payment.amount
646- let $t02561725676 = takeFee(paymentAmountRaw)
647- let paymentAmount = $t02561725676._1
648- let feeAmount = $t02561725676._2
649- if (if (if ((amountAssetPart > paymentAmount))
650- then true
651- else (priceAssetPart > paymentAmount))
652- then true
653- else (10000000 > paymentAmount))
654- then throwErr("wrong payment amount")
655- else {
656- let amountBalance = getAccBalance(amountId)
657- let priceBalance = getAccBalance(priceId)
658- let $t02594026395 = if ((paymentAssetId == amountId))
659- then $Tuple6((amountBalance - paymentAmount), priceBalance, (paymentAmount - amountAssetPart), priceAssetPart, 0, 0)
660- else if ((paymentAssetId == priceId))
661- then $Tuple6(amountBalance, (priceBalance - paymentAmount), 0, 0, (paymentAmount - priceAssetPart), amountAssetPart)
662- else throwErr("wrong paymentAssetId")
663- let amountBalanceNow = $t02594026395._1
664- let priceBalanceNow = $t02594026395._2
665- let virtSwapInAm = $t02594026395._3
666- let virtSwapOutPr = $t02594026395._4
667- let virtSwapInPr = $t02594026395._5
668- let virtSwapOutAm = $t02594026395._6
669- let D0 = invoke(gwxRewardContract, "calcD", [toString(amountBalanceNow), toString(priceBalanceNow), amplificator, Amult, Dconv], nil)
670- let D1 = invoke(gwxRewardContract, "calcD", [toString(toBigInt(((amountBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((priceBalanceNow + virtSwapInPr) - virtSwapOutPr))), amplificator, Amult, Dconv], nil)
671- let D0vsD1 = validateD(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D)
672- if ((D0vsD1 == D0vsD1))
673- then {
674- let estimatePut = commonPut(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amountId), amountAssetPart), AttachedPayment(fromBase58String(priceId), priceAssetPart), slippage, true, true, paymentAmount, paymentAssetId)
675- let estimateLP = estimatePut._2
676- let lpAssetId = estimatePut._7
677- let state = estimatePut._9
678- let amountDiff = estimatePut._10
679- let priceDiff = estimatePut._11
680- let lpCalcRes = validateAbsDiff(toBigInt(estimateLP), toBigInt(outLp), toBigInt(slippage))
681- let emitLpAmount = toInt(lpCalcRes._2)
682- let e = invoke(factoryContract, "emit", [emitLpAmount], nil)
683- if ((e == e))
684- then {
685- let el = match e {
686- case legacy: Address =>
687- invoke(legacy, "emit", [emitLpAmount], nil)
688- case _ =>
689- unit
690- }
691- if ((el == el))
692- then {
693- let sa = if ((amountDiff > 0))
694- then invoke(slippageContract, "put", nil, [AttachedPayment(fromBase58String(amountId), amountDiff)])
695- else nil
696- if ((sa == sa))
697- then {
698- let sp = if ((priceDiff > 0))
699- then invoke(slippageContract, "put", nil, [AttachedPayment(fromBase58String(priceId), priceDiff)])
700- else nil
701- if ((sp == sp))
702- then {
703- let lpTrasfer = if (autoStake)
704- then {
705- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmount)])
706- if ((ss == ss))
707- then nil
708- else throw("Strict value is not equal to itself.")
709- }
710- else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)]
711- let sendFeeToMatcher = if ((feeAmount > 0))
712- then [ScriptTransfer(matcherAddress, feeAmount, fromBase58String(paymentAssetId))]
713- else nil
714- ((state ++ lpTrasfer) ++ sendFeeToMatcher)
715- }
716- else throw("Strict value is not equal to itself.")
717- }
718- else throw("Strict value is not equal to itself.")
719- }
720- else throw("Strict value is not equal to itself.")
721- }
722- else throw("Strict value is not equal to itself.")
723- }
724- else throw("Strict value is not equal to itself.")
725- }
726- }
727- }
728-
729-
730-
731-@Callable(i)
732-func putForFree (maxslippage) = if ((0 > maxslippage))
733- then throwErr("wrong slippage")
686+func putForFree (maxSlpg) = if ((0 > maxSlpg))
687+ then throw("Wrong slpg")
734688 else if ((size(i.payments) != 2))
735- then throwErr("2 payments expected")
689+ then throw("2 pmnts expd")
736690 else {
737- let estimatePut = commonPut(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxslippage, false, false, 0, "")
738- estimatePut._9
691+ let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, 0, "")
692+ estPut._9
739693 }
740694
741695
742696
743697 @Callable(i)
744698 func get () = {
745- let r = commonGet(i)
699+ let r = cg(i)
746700 let outAmtAmt = r._1
747- let outPriceAmount = r._2
748- let paymentAmount = r._3
749- let paymentAssetId = r._4
701+ let outPrAmt = r._2
702+ let pmtAmt = r._3
703+ let pmtAssetId = r._4
750704 let state = r._5
751- let b = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
705+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
752706 if ((b == b))
753707 then state
754708 else throw("Strict value is not equal to itself.")
755709 }
756710
757711
758712
759713 @Callable(i)
760714 func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1))
761- then throwErr("1 payment expected")
715+ then throw("1 pmnt expd")
762716 else {
763- let cfg = getPoolConfig()
764- let lpAssetId = cfg[idxLPAsId]
765- let amountId = cfg[idxAmAsId]
766- let priceId = cfg[idxPrAsId]
767- let amountDecimals = parseIntValue(cfg[idxAmtAsDcm])
768- let priceDecimals = parseIntValue(cfg[idxPriceAsDcm])
717+ let cfg = gpc()
718+ let lpId = cfg[idxLPAsId]
719+ let amId = cfg[idxAmAsId]
720+ let prId = cfg[idxPrAsId]
721+ let amDcm = parseIntValue(cfg[idxAmtAsDcm])
722+ let prDcm = parseIntValue(cfg[idxPriceAsDcm])
769723 let sts = cfg[idxPoolSt]
770- let factCfg = getFactoryConfig()
771- let gwxRewardContract = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wrong gwxRewardContract address")
772- let payment = value(i.payments[0])
773- let addon = valueOrElse(getString(this, keyAddonAddress()), "")
724+ let factCfg = gfc()
725+ let gwxCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wr sl addr")
726+ let pmt = value(i.payments[0])
727+ let addon = valueOrElse(getString(this, ada()), "")
774728 let userAddress = if ((addon == toString(i.caller)))
775729 then i.originCaller
776730 else i.caller
777731 let txId58 = toBase58String(i.transactionId)
778- let paymentAssetId = value(payment.assetId)
779- let paymentAmount = payment.amount
780- if ((1000000000 > paymentAmount))
781- then throwErr("Min payment 10 LP")
782- else if (if (if ((0 > slippage))
783- then true
784- else (0 > exchResult))
785- then true
786- else (0 > outAmount))
787- then throwErr("Wrong params")
788- else if ((lpAssetId != toBase58String(paymentAssetId)))
789- then throwErr("Wrong LP")
790- else {
791- let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(paymentAssetId), paymentAmount, i.caller)
792- let estimAmAmt = r._1
793- let estimPrAmt = r._2
794- let amountBalance = getAccBalance(amountId)
795- let priceBalance = getAccBalance(priceId)
796- let $t03153432002 = if ((outAssetId == amountId))
797- then $Tuple7((amountBalance - estimAmAmt), (priceBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult))
798- else if ((outAssetId == priceId))
799- then $Tuple7((amountBalance - estimAmAmt), (priceBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult))
800- else throwErr("wrong outAssetId")
801- let amountBalanceNow = $t03153432002._1
802- let priceBalanceNow = $t03153432002._2
803- let virtSwapInAm = $t03153432002._3
804- let virtSwapOutPr = $t03153432002._4
805- let virtSwapInPr = $t03153432002._5
806- let virtSwapOutAm = $t03153432002._6
807- let totalGet = $t03153432002._7
808- if (if ((0 > virtSwapInAm))
809- then true
810- else (0 > virtSwapInPr))
811- then throwErr("Wrong calc")
812- else {
813- let D0 = invoke(gwxRewardContract, "calcD", [toString(amountBalanceNow), toString(priceBalanceNow), amplificator, Amult, Dconv], nil)
814- let D1 = invoke(gwxRewardContract, "calcD", [toString(((amountBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((priceBalanceNow + virtSwapOutPr) - virtSwapInPr)), amplificator, Amult, Dconv], nil)
815- let D0vsD1 = validateD(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D)
816- if ((D0vsD1 == D0vsD1))
817- then {
818- let finalRes = validateAbsDiff(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage))
819- if ((finalRes == finalRes))
820- then {
821- let $t03267132779 = if ((outAssetId == amountId))
822- then $Tuple2(toInt(finalRes._2), 0)
823- else $Tuple2(0, toInt(finalRes._2))
824- let outAm = $t03267132779._1
825- let outPr = $t03267132779._2
826- let totalAmountRaw = (outAm + outPr)
827- let $t03281932874 = takeFee(totalAmountRaw)
828- let totalAmount = $t03281932874._1
829- let feeAmount = $t03281932874._2
830- let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
831- then unit
832- else fromBase58String(outAssetId)
833- let sendFeeToMatcher = if ((feeAmount > 0))
834- then [ScriptTransfer(matcherAddress, feeAmount, outAssetIdOrWaves)]
835- else nil
836- let decimals = if ((amountDecimals >= priceDecimals))
837- then amountDecimals
838- else priceDecimals
839- if ((decimals == decimals))
840- then {
841- let curPrX18 = calcPriceBigInt(toX18(priceBalance, decimals), toX18(amountBalance, decimals))
842- let curPr = fromX18(curPrX18, scale8)
843- let state = [ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(keyGetActionByUser(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, paymentAmount, curPr, height, lastBlock.timestamp)), IntegerEntry(keyPriceLast(), curPr), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), curPr)]
844- if ((state == state))
845- then {
846- let burn = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
847- if ((burn == burn))
848- then (state ++ sendFeeToMatcher)
849- else throw("Strict value is not equal to itself.")
850- }
851- else throw("Strict value is not equal to itself.")
852- }
853- else throw("Strict value is not equal to itself.")
854- }
855- else throw("Strict value is not equal to itself.")
856- }
857- else throw("Strict value is not equal to itself.")
858- }
859- }
732+ let pmtAssetId = value(pmt.assetId)
733+ let pmtAmt = pmt.amount
734+ let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid")
735+ let check = reentrantInvoke(addonContract, "ensureCanGetOneTkn", [toString(userAddress)], nil)
736+ if ((check == check))
737+ then if ((1000000000 > pmtAmt))
738+ then throw("Min pmt 10 LP")
739+ else if (if (if ((0 > slippage))
740+ then true
741+ else (0 > exchResult))
742+ then true
743+ else (0 > outAmount))
744+ then throw("Wrong params")
745+ else if ((lpId != toBase58String(pmtAssetId)))
746+ then throw("Wrong LP")
747+ else {
748+ let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
749+ let estimAmAmt = r._1
750+ let estimPrAmt = r._2
751+ let amBalance = getAccBalance(amId)
752+ let prBalance = getAccBalance(prId)
753+ let $t03024330700 = if ((outAssetId == amId))
754+ then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult))
755+ else if ((outAssetId == prId))
756+ then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult))
757+ else throw("wrong outAssetId")
758+ let amBalanceNow = $t03024330700._1
759+ let prBalanceNow = $t03024330700._2
760+ let virtSwapInAm = $t03024330700._3
761+ let virtSwapOutPr = $t03024330700._4
762+ let virtSwapInPr = $t03024330700._5
763+ let virtSwapOutAm = $t03024330700._6
764+ let totalGet = $t03024330700._7
765+ if (if ((0 > virtSwapInAm))
766+ then true
767+ else (0 > virtSwapInPr))
768+ then throw("Wrong calc")
769+ else {
770+ let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil)
771+ let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil)
772+ let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D)
773+ if ((D0vsD1 == D0vsD1))
774+ then {
775+ let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage))
776+ if ((finalRes == finalRes))
777+ then {
778+ let $t03140531509 = if ((outAssetId == amId))
779+ then $Tuple2(toInt(finalRes._2), 0)
780+ else $Tuple2(0, toInt(finalRes._2))
781+ let outAm = $t03140531509._1
782+ let outPr = $t03140531509._2
783+ let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm))
784+ let curPr = f1(curPrX18, scale8)
785+ let state = [ScriptTransfer(userAddress, (outAm + outPr), if ((outAssetId == "WAVES"))
786+ then unit
787+ else fromBase58String(outAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)]
788+ if ((state == state))
789+ then {
790+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
791+ if ((burn == burn))
792+ then state
793+ else throw("Strict value is not equal to itself.")
794+ }
795+ else throw("Strict value is not equal to itself.")
796+ }
797+ else throw("Strict value is not equal to itself.")
798+ }
799+ else throw("Strict value is not equal to itself.")
800+ }
801+ }
802+ else throw("Strict value is not equal to itself.")
860803 }
861804
862805
863806
864807 @Callable(i)
865808 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
866- let r = commonGet(i)
867- let outAmountAmount = r._1
868- let outPriceAmount = r._2
869- let paymentAmount = r._3
870- let paymentAssetId = r._4
809+ let r = cg(i)
810+ let outAmAmt = r._1
811+ let outPrAmt = r._2
812+ let pmtAmt = r._3
813+ let pmtAssetId = r._4
871814 let state = r._5
872- let checkOutAmountAmount = if ((outAmountAmount >= noLessThenAmtAsset))
873- then true
874- else throwErr(((("Failed: " + toString(outAmountAmount)) + " < ") + toString(noLessThenAmtAsset)))
875- if ((checkOutAmountAmount == checkOutAmountAmount))
876- then {
877- let checkOutPriceAmount = if ((outPriceAmount >= noLessThenPriceAsset))
878- then true
879- else throwErr(((("Failed: " + toString(outPriceAmount)) + " < ") + toString(noLessThenPriceAsset)))
880- if ((checkOutPriceAmount == checkOutPriceAmount))
881- then {
882- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
883- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
884- then state
885- else throw("Strict value is not equal to itself.")
886- }
887- else throw("Strict value is not equal to itself.")
888- }
889- else throw("Strict value is not equal to itself.")
815+ if ((noLessThenAmtAsset > outAmAmt))
816+ then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
817+ else if ((noLessThenPriceAsset > outPrAmt))
818+ then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
819+ else {
820+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
821+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
822+ then state
823+ else throw("Strict value is not equal to itself.")
824+ }
890825 }
891826
892827
893828
894829 @Callable(i)
895830 func unstakeAndGet (amount) = {
896831 let checkPayments = if ((size(i.payments) != 0))
897- then throwErr("no payments expected")
832+ then throw("No pmnts expd")
898833 else true
899834 if ((checkPayments == checkPayments))
900835 then {
901- let cfg = getPoolConfig()
902- let factoryCfg = getFactoryConfig()
836+ let cfg = gpc()
837+ let factoryCfg = gfc()
903838 let lpAssetId = fromBase58String(cfg[idxLPAsId])
904- let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "wrong")
839+ let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
905840 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
906841 if ((unstakeInv == unstakeInv))
907842 then {
908- let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
843+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
909844 let sts = parseIntValue(r._9)
910845 let state = r._10
911- let v = if (if (isGlobalShutdown())
846+ let v = if (if (igs())
912847 then true
913848 else (sts == PoolShutdown))
914- then throwErr(("Blocked: " + toString(sts)))
849+ then throw(("Blocked: " + toString(sts)))
915850 else true
916851 if ((v == v))
917852 then {
918- let burnA = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
853+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
919854 if ((burnA == burnA))
920855 then state
921856 else throw("Strict value is not equal to itself.")
922857 }
923858 else throw("Strict value is not equal to itself.")
924859 }
925860 else throw("Strict value is not equal to itself.")
926861 }
927862 else throw("Strict value is not equal to itself.")
928863 }
929864
930865
931866
932867 @Callable(i)
933-func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(factoryContract)))
934- then throwErr("denied")
935- else $Tuple2([StringEntry(keyAmountAsset(), amtAsStr), StringEntry(keyPriceAsset(), prAsStr)], "success")
868+func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
869+ then throw("denied")
870+ else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
936871
937872
938873
939874 @Callable(i)
940-func setS (k,v) = if ((toString(i.caller) != getStringOrFail(this, keyAddonAddress())))
875+func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
941876 then pd
942877 else [StringEntry(k, v)]
943878
944879
945880
946881 @Callable(i)
947-func setI (k,v) = if ((toString(i.caller) != getStringOrFail(this, keyAddonAddress())))
882+func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
948883 then pd
949884 else [IntegerEntry(k, v)]
950885
951886
952887
953888 @Callable(i)
954-func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
889+func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
955890
956891
957892
958893 @Callable(i)
959894 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
960895
961896
962897
963898 @Callable(i)
964899 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
965900 let pr = calcPrices(amAmt, prAmt, lpAmt)
966901 $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])])
967902 }
968903
969904
970905
971906 @Callable(i)
972-func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resScaleMult))
907+func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
973908
974909
975910
976911 @Callable(i)
977-func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
912+func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
978913
979914
980915
981916 @Callable(i)
982-func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
917+func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
983918
984919
985920
986921 @Callable(i)
987-func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmountAssetAmount,inAmId,inPriceAssetAmount,inPrId,usrAddr,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippage, inAmountAssetAmount, inAmId, inPriceAssetAmount, inPrId, usrAddr, isEvaluate, emitLp, false, 0, ""))
922+func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, false, 0, ""))
988923
989924
990925
991926 @Callable(i)
992-func estimateGetOperationWrapperREADONLY (txId58,paymentAsId,paymentLpAmount,usrAddr) = {
993- let r = estimateGetOperation(txId58, paymentAsId, paymentLpAmount, addressFromStringValue(usrAddr))
927+func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
928+ let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
994929 $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
995930 }
996931
997932
998933 @Verifier(tx)
999934 func verify () = match tx {
1000935 case order: Order =>
1001- let mtchPub = getMatcherPubOrFail()
1002- let orV = validateMatcherOrderAllowed(order)
936+ let mtchPub = mp()
937+ let orV = moa(order)
1003938 let sndrV = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
1004939 let mtchV = sigVerify(order.bodyBytes, order.proofs[1], mtchPub)
1005940 if (if (if (orV)
1006941 then sndrV
1007942 else false)
1008943 then mtchV
1009944 else false)
1010945 then true
1011- else throwOrderError(orV, sndrV, mtchV)
946+ else toe(orV, sndrV, mtchV)
1012947 case _ =>
1013- let targetPublicKey = match managerPublicKeyOrUnit() {
948+ let targetPublicKey = match m() {
1014949 case pk: ByteVector =>
1015950 pk
1016951 case _: Unit =>
1017952 tx.senderPublicKey
1018953 case _ =>
1019954 throw("Match error")
1020955 }
1021956 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1022957 }
1023958

github/deemru/w8io/026f985 
181.26 ms