tx · BywH8p8mvz2UZ5WuBUYW9n3uor1FpTrNEZy3dRdFhA5S

3MtP3m8hWMxYcyDxXB6n299KrsLLyT8ehni:  -0.01300000 Waves

2023.02.09 20:01 [2442355] smart account 3MtP3m8hWMxYcyDxXB6n299KrsLLyT8ehni > SELF 0.00000000 Waves

{ "type": 13, "id": "BywH8p8mvz2UZ5WuBUYW9n3uor1FpTrNEZy3dRdFhA5S", "fee": 1300000, "feeAssetId": null, "timestamp": 1675962062777, "version": 1, "sender": "3MtP3m8hWMxYcyDxXB6n299KrsLLyT8ehni", "senderPublicKey": "BRyVaCURUMe7ssUbXucteig1g44bGwWirJQzugKahUQ1", "proofs": [ "32cfp7u6vfR1e4Yqcv8X2oHhKtoVXdZYrnPobM5FbrSojHtZY4woCGFRUUquA1YJBhR45mY8CK72dcAX9sWkqasy" ], "script": "base64:BgIOCAIiAnR4IgZ2ZXJpZnkAAAEBYQEBYgAGXn9RmA==", "chainId": 84, "height": 2442355, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8Xg7j2AdyGjwm1G1bbaYJ7SgWSGE9KvwHbpw1gcs6f3E Next: 5JFezEPs4EWeQ6qqUMsU41nr2EaHE81djcK5mm1DDqMq Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let scale8 = 100000000
5-
6-let scale8BigInt = toBigInt(100000000)
7-
8-let scale18 = toBigInt(1000000000000000000)
9-
10-let zeroBigInt = toBigInt(0)
11-
12-let big0 = toBigInt(0)
13-
14-let big1 = toBigInt(1)
15-
16-let big2 = toBigInt(2)
17-
18-let big3 = toBigInt(3)
19-
20-let big4 = toBigInt(4)
21-
22-let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
23-
24-let wavesString = "WAVES"
25-
26-let Amult = "100"
27-
28-let Dconv = "1"
29-
30-let SEP = "__"
31-
32-let EMPTY = ""
33-
34-let PoolActive = 1
35-
36-let PoolPutDis = 2
37-
38-let PoolMatcherDis = 3
39-
40-let PoolShutdown = 4
41-
42-let idxPoolAddress = 1
43-
44-let idxPoolSt = 2
45-
46-let idxLPAsId = 3
47-
48-let idxAmAsId = 4
49-
50-let idxPrAsId = 5
51-
52-let idxAmtAsDcm = 6
53-
54-let idxPriceAsDcm = 7
55-
56-let idxIAmtAsId = 8
57-
58-let idxIPriceAsId = 9
59-
60-let idxFactStakCntr = 1
61-
62-let idxFactoryRestCntr = 6
63-
64-let idxFactSlippCntr = 7
65-
66-let idxFactGwxRewCntr = 10
67-
68-let feeDefault = fraction(10, scale8, 10000)
69-
70-func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
71-
72-
73-func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
74-
75-
76-func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
77-
78-
79-func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
80-
81-
82-func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult))
83-
84-
85-func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18)
86-
87-
88-func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
89-
90-
91-func abs (val) = if ((zeroBigInt > val))
92- then -(val)
93- else val
94-
95-
96-func absBigInt (val) = if ((zeroBigInt > val))
97- then -(val)
98- else val
99-
100-
101-func fc () = "%s__factoryContract"
102-
103-
104-func mpk () = "%s__managerPublicKey"
105-
106-
107-func pmpk () = "%s__pendingManagerPublicKey"
108-
109-
110-func pl () = "%s%s__price__last"
111-
112-
113-func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
114-
115-
116-func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
117-
118-
119-func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
120-
121-
122-func aa () = "%s__amountAsset"
123-
124-
125-func pa () = "%s__priceAsset"
126-
127-
128-func amp () = "%s__amp"
129-
130-
131-func ada () = "%s__addonAddr"
132-
133-
134-let keyFee = "%s__fee"
135-
136-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
137-
138-let keyDLp = makeString(["%s", "dLp"], SEP)
139-
140-let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
141-
142-let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
143-
144-let dLpRefreshDelayDefault = 30
145-
146-let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
147-
148-func fcfg () = "%s__factoryConfig"
149-
150-
151-func mtpk () = "%s%s__matcher__publicKey"
152-
153-
154-func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config")
155-
156-
157-func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr)
158-
159-
160-func aps () = "%s__shutdown"
161-
162-
163-func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash"
164-
165-
166-func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
167-
168-
169-func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
170-
171-
172-func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
173-
174-
175-func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
176-
177-
178-func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
179-
180-
181-func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
182-
183-
184-let fca = addressFromStringValue(strf(this, fc()))
185-
186-let inFee = {
187- let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil)
188- if ($isInstanceOf(@, "Int"))
189- then @
190- else throw(($getType(@) + " couldn't be cast to Int"))
191- }
192-
193-let outFee = {
194- let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil)
195- if ($isInstanceOf(@, "Int"))
196- then @
197- else throw(($getType(@) + " couldn't be cast to Int"))
198- }
199-
200-let A = strf(this, amp())
201-
202-func igs () = valueOrElse(getBoolean(fca, aps()), false)
203-
204-
205-func mp () = fromBase58String(strf(fca, mtpk()))
206-
207-
208-let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress()))
209-
210-func gpc () = {
211- let amtAs = strf(this, aa())
212- let priceAs = strf(this, pa())
213- let iPriceAs = intf(fca, mba(priceAs))
214- let iAmtAs = intf(fca, mba(amtAs))
215- split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
216- }
217-
218-
219-func parseAssetId (input) = if ((input == wavesString))
220- then unit
221- else fromBase58String(input)
222-
223-
224-func assetIdToString (input) = if ((input == unit))
225- then wavesString
226- else toBase58String(value(input))
227-
228-
229-func parsePoolConfig (poolConfig) = $Tuple9(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm]), fromBase58String(poolConfig[idxIAmtAsId]), fromBase58String(poolConfig[idxIPriceAsId]))
230-
231-
232-let poolConfigParsed = parsePoolConfig(gpc())
233-
234-let $t079658194 = poolConfigParsed
235-
236-let cfgPoolAddress = $t079658194._1
237-
238-let cfgPoolStatus = $t079658194._2
239-
240-let cfgLpAssetId = $t079658194._3
241-
242-let cfgAmountAssetId = $t079658194._4
243-
244-let cfgPriceAssetId = $t079658194._5
245-
246-let cfgAmountAssetDecimals = $t079658194._6
247-
248-let cfgPriceAssetDecimals = $t079658194._7
249-
250-let cfgInAmountAssedId = $t079658194._8
251-
252-let cfgInPriceAssetId = $t079658194._9
253-
254-func gfc () = split(strf(fca, fcfg()), SEP)
255-
256-
257-let factoryConfig = gfc()
258-
259-let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address")
260-
261-let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address")
262-
263-let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address")
264-
265-let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address")
266-
267-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)
268-
269-
270-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)
271-
272-
273-func getAccBalance (assetId) = if ((assetId == "WAVES"))
274- then wavesBalance(this).available
275- else assetBalance(this, fromBase58String(assetId))
276-
277-
278-func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
279-
280-
281-func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
282-
283-
284-func vad (A1,A2,slippage) = {
285- let diff = fraction((A1 - A2), scale8BigInt, A2)
286- let pass = ((slippage - abs(diff)) > zeroBigInt)
287- if (!(pass))
288- then throw(("Big slpg: " + toString(diff)))
289- else $Tuple2(pass, min([A1, A2]))
290- }
291-
292-
293-func vd (D1,D0,slpg) = {
294- let diff = fraction(D0, scale8BigInt, D1)
295- let fail = (slpg > diff)
296- if (if (fail)
297- then true
298- else (D0 > D1))
299- then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg)))
300- else fail
301- }
302-
303-
304-func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
305- let amtAsAmtX18 = t1(amAmt, amAssetDcm)
306- let prAsAmtX18 = t1(prAmt, prAssetDcm)
307- cpbi(prAsAmtX18, amtAsAmtX18)
308- }
309-
310-
311-func calcPrices (amAmt,prAmt,lpAmt) = {
312- let amtAsDcm = cfgAmountAssetDecimals
313- let prAsDcm = cfgPriceAssetDecimals
314- let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
315- let amAmtX18 = t1(amAmt, amtAsDcm)
316- let prAmtX18 = t1(prAmt, prAsDcm)
317- let lpAmtX18 = t1(lpAmt, scale8)
318- let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18)
319- let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18)
320-[priceX18, lpPrInAmAsX18, lpPrInPrAsX18]
321- }
322-
323-
324-func calculatePrices (amAmt,prAmt,lpAmt) = {
325- let p = calcPrices(amAmt, prAmt, lpAmt)
326-[f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)]
327- }
328-
329-
330-func takeFee (amount,fee) = {
331- let feeAmount = if ((fee == 0))
332- then 0
333- else fraction(amount, fee, scale8)
334- $Tuple2((amount - feeAmount), feeAmount)
335- }
336-
337-
338-func getD (xp) = {
339- let xp0 = xp[0]
340- let xp1 = xp[1]
341- let s = (xp0 + xp1)
342- if ((s == big0))
343- then big0
344- else {
345- let a = parseIntValue(A)
346- let ann = (a * 2)
347- let p = fraction(xp0, xp1, big1)
348- let xp0_xp1_n_n = fraction(p, big4, big1)
349- let ann_s = fraction(toBigInt(ann), s, big1)
350- let ann_1 = toBigInt((ann - 1))
351- func calcDNext (d) = {
352- let dd = fraction(d, d, big1)
353- let ddd = fraction(dd, d, big1)
354- let dp = fraction(ddd, big1, xp0_xp1_n_n)
355- fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)))
356- }
357-
358- func calc (acc,i) = if (acc._2)
359- then acc
360- else {
361- let d = acc._1
362- let dNext = calcDNext(d)
363- let dDiffRaw = (dNext - value(d))
364- let dDiff = if ((big0 > dDiffRaw))
365- then -(dDiffRaw)
366- else dDiffRaw
367- if ((big1 >= dDiff))
368- then $Tuple2(dNext, true)
369- else $Tuple2(dNext, false)
370- }
371-
372- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
373- let $t01269112739 = {
374- let $l = arr
375- let $s = size($l)
376- let $acc0 = $Tuple2(s, false)
377- func $f0_1 ($a,$i) = if (($i >= $s))
378- then $a
379- else calc($a, $l[$i])
380-
381- func $f0_2 ($a,$i) = if (($i >= $s))
382- then $a
383- else throw("List size exceeds 15")
384-
385- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
386- }
387- let d = $t01269112739._1
388- let found = $t01269112739._2
389- if (found)
390- then d
391- else throw(("D calculation error, D = " + toString(d)))
392- }
393- }
394-
395-
396-func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
397- let lpId = cfgLpAssetId
398- let amId = toBase58String(value(cfgAmountAssetId))
399- let prId = toBase58String(value(cfgPriceAssetId))
400- let amDcm = cfgAmountAssetDecimals
401- let prDcm = cfgPriceAssetDecimals
402- let sts = toString(cfgPoolStatus)
403- let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity
404- if ((toBase58String(lpId) != pmtAssetId))
405- then throw("Wrong pmt asset")
406- else {
407- let amBalance = getAccBalance(amId)
408- let amBalanceX18 = t1(amBalance, amDcm)
409- let prBalance = getAccBalance(prId)
410- let prBalanceX18 = t1(prBalance, prDcm)
411- let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
412- let curPrice = f1(curPriceX18, scale8)
413- let pmtLpAmtX18 = t1(pmtLpAmt, scale8)
414- let lpEmissX18 = t1(lpEmiss, scale8)
415- let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
416- let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
417- let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
418- let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
419- let state = if ((txId58 == ""))
420- then nil
421- else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
422- then unit
423- else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES"))
424- then unit
425- 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)]
426- $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state)
427- }
428- }
429-
430-
431-func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
432- let lpId = cfgLpAssetId
433- let amIdStr = toBase58String(value(cfgAmountAssetId))
434- let prIdStr = toBase58String(value(cfgPriceAssetId))
435- let inAmIdStr = cfgInAmountAssedId
436- let inPrIdStr = cfgInPriceAssetId
437- let amtDcm = cfgAmountAssetDecimals
438- let priceDcm = cfgPriceAssetDecimals
439- let sts = toString(cfgPoolStatus)
440- let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
441- let amBalance = if (isEval)
442- then getAccBalance(amIdStr)
443- else if (if (isOneAsset)
444- then (pmtId == amIdStr)
445- else false)
446- then (getAccBalance(amIdStr) - pmtAmt)
447- else if (isOneAsset)
448- then getAccBalance(amIdStr)
449- else (getAccBalance(amIdStr) - inAmAmt)
450- let prBalance = if (isEval)
451- then getAccBalance(prIdStr)
452- else if (if (isOneAsset)
453- then (pmtId == prIdStr)
454- else false)
455- then (getAccBalance(prIdStr) - pmtAmt)
456- else if (isOneAsset)
457- then getAccBalance(prIdStr)
458- else (getAccBalance(prIdStr) - inPrAmt)
459- let inAmAssetAmtX18 = t1(inAmAmt, amtDcm)
460- let inPrAssetAmtX18 = t1(inPrAmt, priceDcm)
461- let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
462- let amBalanceX18 = t1(amBalance, amtDcm)
463- let prBalanceX18 = t1(prBalance, priceDcm)
464- let D0 = getD([amBalanceX18, prBalanceX18])
465- let r = if ((lpEm == 0))
466- then {
467- let D1 = getD([(amBalanceX18 + inAmAssetAmtX18), (prBalanceX18 + inPrAssetAmtX18)])
468- let checkD = if ((D1 > D0))
469- then true
470- else throw("D1 should be greater than D0")
471- if ((checkD == checkD))
472- then {
473- let curPriceX18 = zeroBigInt
474- let slippageX18 = zeroBigInt
475- let lpAmtX18 = D1
476- $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
477- }
478- else throw("Strict value is not equal to itself.")
479- }
480- else {
481- let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
482- let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
483- let slippageX18 = t1(slippage, scale8)
484- if (if (if (validateSlippage)
485- then (curPriceX18 != zeroBigInt)
486- else false)
487- then (slippageRealX18 > slippageX18)
488- else false)
489- then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
490- else {
491- let lpEmissionX18 = t1(lpEm, scale8)
492- let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
493- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
494- let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
495- then $Tuple2(amViaPrX18, inPrAssetAmtX18)
496- else $Tuple2(inAmAssetAmtX18, prViaAmX18)
497- let expAmtAssetAmtX18 = expectedAmts._1
498- let expPriceAssetAmtX18 = expectedAmts._2
499- let D1 = getD([(amBalanceX18 + expAmtAssetAmtX18), (prBalanceX18 + expPriceAssetAmtX18)])
500- let checkD = if ((D1 > D0))
501- then true
502- else throw("D1 should be greater than D0")
503- if ((checkD == checkD))
504- then {
505- let lpAmtX18 = fraction(lpEmissionX18, (D1 - D0), D0)
506- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
507- }
508- else throw("Strict value is not equal to itself.")
509- }
510- }
511- let calcLpAmt = r._1
512- let calcAmAssetPmt = r._2
513- let calcPrAssetPmt = r._3
514- let curPrice = f1(r._4, scale8)
515- let slippageCalc = f1(r._5, scale8)
516- if ((0 >= calcLpAmt))
517- then throw("LP <= 0")
518- else {
519- let emitLpAmt = if (!(emitLp))
520- then 0
521- else calcLpAmt
522- let amDiff = (inAmAmt - calcAmAssetPmt)
523- let prDiff = (inPrAmt - calcPrAssetPmt)
524- let $t02057820923 = if (if (isOneAsset)
525- then (pmtId == amIdStr)
526- else false)
527- then $Tuple2(pmtAmt, 0)
528- else if (if (isOneAsset)
529- then (pmtId == prIdStr)
530- else false)
531- then $Tuple2(0, pmtAmt)
532- else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
533- let writeAmAmt = $t02057820923._1
534- let writePrAmt = $t02057820923._2
535- 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))]
536- $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
537- }
538- }
539-
540-
541-func getYD (xp,i,D) = {
542- let n = big2
543- let x = xp[if ((i == 0))
544- then 1
545- else 0]
546- let aPrecision = parseBigIntValue(Amult)
547- let a = (parseBigIntValue(A) * aPrecision)
548- let s = x
549- let ann = (a * n)
550- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
551- let b = ((s + ((D * aPrecision) / ann)) - D)
552- func calc (acc,cur) = {
553- let $t02211822138 = acc
554- let y = $t02211822138._1
555- let found = $t02211822138._2
556- if ((found != unit))
557- then acc
558- else {
559- let yNext = (((y * y) + c) / ((big2 * y) + b))
560- let yDiff = absBigInt((yNext - value(y)))
561- if ((big1 >= yDiff))
562- then $Tuple2(yNext, cur)
563- else $Tuple2(yNext, unit)
564- }
565- }
566-
567- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
568- let $t02244522492 = {
569- let $l = arr
570- let $s = size($l)
571- let $acc0 = $Tuple2(D, unit)
572- func $f0_1 ($a,$i) = if (($i >= $s))
573- then $a
574- else calc($a, $l[$i])
575-
576- func $f0_2 ($a,$i) = if (($i >= $s))
577- then $a
578- else throw("List size exceeds 15")
579-
580- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
581- }
582- let y = $t02244522492._1
583- let found = $t02244522492._2
584- if ((found != unit))
585- then y
586- else throw(("Y calculation error, Y = " + toString(y)))
587- }
588-
589-
590-func calcDLp (amountBalance,priceBalance,lpEmission) = {
591- let updatedDLp = fraction(getD([t1BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)), t1BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))]), scale18, lpEmission)
592- if ((lpEmission == big0))
593- then big0
594- else updatedDLp
595- }
596-
597-
598-func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
599- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
600- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
601- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
602- let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
603- currentDLp
604- }
605-
606-
607-func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
608- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
609- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
610- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
611- let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
612- let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
613- $Tuple2(actions, updatedDLp)
614- }
615-
616-
617-func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
618- then true
619- else throwErr("updated DLp lower than current DLp")
620-
621-
622-func validateMatcherOrderAllowed (order) = {
623- let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
624- let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
625- let amountAssetAmount = order.amount
626- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
627- let $t02469024902 = if ((order.orderType == Buy))
628- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
629- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
630- let amountAssetBalanceDelta = $t02469024902._1
631- let priceAssetBalanceDelta = $t02469024902._2
632- if (if (if (igs())
633- then true
634- else (cfgPoolStatus == PoolMatcherDis))
635- then true
636- else (cfgPoolStatus == PoolShutdown))
637- then throw("Admin blocked")
638- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
639- then true
640- else (order.assetPair.priceAsset != cfgPriceAssetId))
641- then throw("Wr assets")
642- else {
643- let dLp = parseBigIntValue(valueOrElse(getString(this, keyDLp), "0"))
644- let $t02524425344 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
645- let unusedActions = $t02524425344._1
646- let dLpNew = $t02524425344._2
647- let isOrderValid = (dLpNew >= dLp)
648- let info = makeString(["dLp=", toString(dLp), " dLpNew=", toString(dLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
649- $Tuple2(isOrderValid, info)
650- }
651- }
652-
653-
654-func cg (i) = if ((size(i.payments) != 1))
655- then throw("1 pmnt exp")
656- else {
657- let pmt = value(i.payments[0])
658- let pmtAssetId = value(pmt.assetId)
659- let pmtAmt = pmt.amount
660- let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
661- let outAmAmt = r._1
662- let outPrAmt = r._2
663- let sts = parseIntValue(r._9)
664- let state = r._10
665- if (if (igs())
666- then true
667- else (sts == PoolShutdown))
668- then throw(("Admin blocked: " + toString(sts)))
669- else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
670- }
671-
672-
673-func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
674- let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId)
675- let sts = parseIntValue(r._8)
676- if (if (if (igs())
677- then true
678- else (sts == PoolPutDis))
679- then true
680- else (sts == PoolShutdown))
681- then throw(("Blocked:" + toString(sts)))
682- else r
683- }
684-
685-
686-func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
687- let amId = toBase58String(value(cfgAmountAssetId))
688- let prId = toBase58String(value(cfgPriceAssetId))
689- let lpId = cfgLpAssetId
690- let amtDcm = cfgAmountAssetDecimals
691- let priceDcm = cfgPriceAssetDecimals
692- let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity)
693- let chechEmission = if ((lpAssetEmission > big0))
694- then true
695- else throw("initial deposit requires all coins")
696- if ((chechEmission == chechEmission))
697- then {
698- let amBalance = getAccBalance(amId)
699- let prBalance = getAccBalance(prId)
700- let $t02800028462 = if ((txId == ""))
701- then $Tuple2(amBalance, prBalance)
702- else if ((pmtAssetId == amId))
703- then if ((pmtAmtRaw > amBalance))
704- then throw("invalid payment amount")
705- else $Tuple2((amBalance - pmtAmtRaw), prBalance)
706- else if ((pmtAssetId == prId))
707- then if ((pmtAmtRaw > prBalance))
708- then throw("invalid payment amount")
709- else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
710- else throw("wrong pmtAssetId")
711- let amBalanceOld = $t02800028462._1
712- let prBalanceOld = $t02800028462._2
713- let $t02846828644 = if ((pmtAssetId == amId))
714- then $Tuple2(pmtAmtRaw, 0)
715- else if ((pmtAssetId == prId))
716- then $Tuple2(0, pmtAmtRaw)
717- else throw("invalid payment")
718- let amAmountRaw = $t02846828644._1
719- let prAmountRaw = $t02846828644._2
720- let $t02864828902 = if (withTakeFee)
721- then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
722- else $Tuple3(amAmountRaw, prAmountRaw, 0)
723- let amAmount = $t02864828902._1
724- let prAmount = $t02864828902._2
725- let feeAmount = $t02864828902._3
726- let amBalanceNew = (amBalanceOld + amAmount)
727- let prBalanceNew = (prBalanceOld + prAmount)
728- let D0 = getD([t1(amBalanceOld, cfgAmountAssetDecimals), t1(prBalanceOld, cfgPriceAssetDecimals)])
729- let D1 = getD([t1(amBalanceNew, cfgAmountAssetDecimals), t1(prBalanceNew, cfgPriceAssetDecimals)])
730- let checkD = if ((D1 > D0))
731- then true
732- else throw()
733- if ((checkD == checkD))
734- then {
735- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
736- let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
737- let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmountRaw, prAmountRaw, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))]
738- let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
739- let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8))
740- let priceAssetPart = (pmtAmtRaw - amountAssetPart)
741- let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld))
742- let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth))
743- $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus)
744- }
745- else throw("Strict value is not equal to itself.")
746- }
747- else throw("Strict value is not equal to itself.")
748- }
749-
750-
751-func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = {
752- let lpId = toBase58String(value(cfgLpAssetId))
753- let amId = toBase58String(value(cfgAmountAssetId))
754- let prId = toBase58String(value(cfgPriceAssetId))
755- let amDecimals = cfgAmountAssetDecimals
756- let prDecimals = cfgPriceAssetDecimals
757- let poolStatus = cfgPoolStatus
758- let userAddress = if ((caller == restContract))
759- then originCaller
760- else caller
761- let pmt = value(payments[0])
762- let pmtAssetId = value(pmt.assetId)
763- let pmtAmt = pmt.amount
764- let currentDLp = calcCurrentDLp(big0, big0, big0)
765- if ((currentDLp == currentDLp))
766- then {
767- let txId58 = toBase58String(transactionId)
768- if ((lpId != toBase58String(pmtAssetId)))
769- then throw("Wrong LP")
770- else {
771- let amBalance = getAccBalance(amId)
772- let prBalance = getAccBalance(prId)
773- let $t03101431125 = {
774- let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
775- if ($isInstanceOf(@, "(Int, Int)"))
776- then @
777- else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
778- }
779- if (($t03101431125 == $t03101431125))
780- then {
781- let feeAmount = $t03101431125._2
782- let totalGet = $t03101431125._1
783- let totalAmount = if (if ((minOutAmount > 0))
784- then (minOutAmount > totalGet)
785- else false)
786- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
787- else totalGet
788- let $t03131531622 = if ((outAssetId == amId))
789- then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
790- else if ((outAssetId == prId))
791- then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
792- else throw("invalid out asset id")
793- let outAm = $t03131531622._1
794- let outPr = $t03131531622._2
795- let amBalanceNew = $t03131531622._3
796- let prBalanceNew = $t03131531622._4
797- let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
798- let curPr = f1(curPrX18, scale8)
799- let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
800- then unit
801- else fromBase58String(outAssetId)
802- let sendFeeToMatcher = if ((feeAmount > 0))
803- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
804- else nil
805- let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
806- if ((state == state))
807- then {
808- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
809- if ((burn == burn))
810- then {
811- let $t03240732757 = {
812- let feeAmountForCalc = if ((this == feeCollectorAddress))
813- then 0
814- else feeAmount
815- let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
816- then true
817- else false
818- if (outInAmountAsset)
819- then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
820- else $Tuple2(0, -((totalGet + feeAmountForCalc)))
821- }
822- let amountAssetBalanceDelta = $t03240732757._1
823- let priceAssetBalanceDelta = $t03240732757._2
824- let $t03276032868 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
825- let refreshDLpActions = $t03276032868._1
826- let updatedDLp = $t03276032868._2
827- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
828- if ((isUpdatedDLpValid == isUpdatedDLpValid))
829- then $Tuple2((state ++ refreshDLpActions), totalAmount)
830- else throw("Strict value is not equal to itself.")
831- }
832- else throw("Strict value is not equal to itself.")
833- }
834- else throw("Strict value is not equal to itself.")
835- }
836- else throw("Strict value is not equal to itself.")
837- }
838- }
839- else throw("Strict value is not equal to itself.")
840- }
841-
842-
843-func m () = match getString(mpk()) {
844- case s: String =>
845- fromBase58String(s)
846- case _: Unit =>
847- unit
848- case _ =>
849- throw("Match error")
850-}
851-
852-
853-func pm () = match getString(pmpk()) {
854- case s: String =>
855- fromBase58String(s)
856- case _: Unit =>
857- unit
858- case _ =>
859- throw("Match error")
860-}
861-
862-
863-let pd = throw("Permission denied")
864-
865-func isManager (i) = match m() {
866- case pk: ByteVector =>
867- (i.callerPublicKey == pk)
868- case _: Unit =>
869- (i.caller == this)
870- case _ =>
871- throw("Match error")
872-}
873-
874-
875-func mm (i) = match m() {
876- case pk: ByteVector =>
877- if ((i.callerPublicKey == pk))
878- then true
879- else pd
880- case _: Unit =>
881- if ((i.caller == this))
882- then true
883- else pd
884- case _ =>
885- throw("Match error")
886-}
887-
888-
889-@Callable(i)
890-func constructor (fc) = {
891- let c = mm(i)
892- if ((c == c))
893- then [StringEntry(fc(), fc)]
894- else throw("Strict value is not equal to itself.")
895- }
8964
8975
8986
899-@Callable(i)
900-func setManager (pendingManagerPublicKey) = {
901- let c = mm(i)
902- if ((c == c))
903- then {
904- let cm = fromBase58String(pendingManagerPublicKey)
905- if ((cm == cm))
906- then [StringEntry(pmpk(), pendingManagerPublicKey)]
907- else throw("Strict value is not equal to itself.")
908- }
909- else throw("Strict value is not equal to itself.")
910- }
911-
912-
913-
914-@Callable(i)
915-func confirmManager () = {
916- let p = pm()
917- let hpm = if (isDefined(p))
918- then true
919- else throw("No pending manager")
920- if ((hpm == hpm))
921- then {
922- let cpm = if ((i.callerPublicKey == value(p)))
923- then true
924- else throw("You are not pending manager")
925- if ((cpm == cpm))
926- then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
927- else throw("Strict value is not equal to itself.")
928- }
929- else throw("Strict value is not equal to itself.")
930- }
931-
932-
933-
934-@Callable(i)
935-func put (slip,autoStake) = {
936- let factCfg = gfc()
937- let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
938- let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
939- if ((0 > slip))
940- then throw("Wrong slippage")
941- else if ((size(i.payments) != 2))
942- then throw("2 pmnts expd")
943- else {
944- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
945- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
946- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
947- if ((amountAssetBalance == amountAssetBalance))
948- then {
949- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
950- if ((priceAssetBalance == priceAssetBalance))
951- then {
952- let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
953- if ((lpAssetEmission == lpAssetEmission))
954- then {
955- let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
956- if ((currentDLp == currentDLp))
957- then {
958- 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, true, 0, "")
959- let emitLpAmt = e._2
960- let lpAssetId = e._7
961- let state = e._9
962- let amDiff = e._10
963- let prDiff = e._11
964- let amId = e._12
965- let prId = e._13
966- let r = invoke(fca, "emit", [emitLpAmt], nil)
967- if ((r == r))
968- then {
969- let el = match r {
970- case legacy: Address =>
971- invoke(legacy, "emit", [emitLpAmt], nil)
972- case _ =>
973- unit
974- }
975- if ((el == el))
976- then {
977- let sa = if ((amDiff > 0))
978- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
979- else nil
980- if ((sa == sa))
981- then {
982- let sp = if ((prDiff > 0))
983- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
984- else nil
985- if ((sp == sp))
986- then {
987- let lpTrnsfr = if (autoStake)
988- then {
989- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
990- if ((ss == ss))
991- then nil
992- else throw("Strict value is not equal to itself.")
993- }
994- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
995- let $t03701337155 = refreshDLpInternal(0, 0, 0)
996- let refreshDLpActions = $t03701337155._1
997- let updatedDLp = $t03701337155._2
998- let check = if ((updatedDLp >= currentDLp))
999- then true
1000- else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1001- if ((check == check))
1002- then {
1003- let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1004- if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1005- then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1006- else throw("Strict value is not equal to itself.")
1007- }
1008- else throw("Strict value is not equal to itself.")
1009- }
1010- else throw("Strict value is not equal to itself.")
1011- }
1012- else throw("Strict value is not equal to itself.")
1013- }
1014- else throw("Strict value is not equal to itself.")
1015- }
1016- else throw("Strict value is not equal to itself.")
1017- }
1018- else throw("Strict value is not equal to itself.")
1019- }
1020- else throw("Strict value is not equal to itself.")
1021- }
1022- else throw("Strict value is not equal to itself.")
1023- }
1024- else throw("Strict value is not equal to itself.")
1025- }
1026- }
1027-
1028-
1029-
1030-@Callable(i)
1031-func putOneTknV2 (minOutAmount,autoStake) = {
1032- let isPoolOneTokenOperationsDisabled = {
1033- let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
1034- if ($isInstanceOf(@, "Boolean"))
1035- then @
1036- else throw(($getType(@) + " couldn't be cast to Boolean"))
1037- }
1038- let isPutDisabled = if (if (if (igs())
1039- then true
1040- else (cfgPoolStatus == PoolPutDis))
1041- then true
1042- else (cfgPoolStatus == PoolShutdown))
1043- then true
1044- else isPoolOneTokenOperationsDisabled
1045- let checks = [if (if (!(isPutDisabled))
1046- then true
1047- else isManager(i))
1048- then true
1049- else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
1050- then true
1051- else throwErr("exactly 1 payment are expected")]
1052- if ((checks == checks))
1053- then {
1054- let amId = toBase58String(value(cfgAmountAssetId))
1055- let prId = toBase58String(value(cfgPriceAssetId))
1056- let lpId = cfgLpAssetId
1057- let amDecimals = cfgAmountAssetDecimals
1058- let prDecimals = cfgPriceAssetDecimals
1059- let userAddress = if ((i.caller == this))
1060- then i.originCaller
1061- else i.caller
1062- let pmt = value(i.payments[0])
1063- let pmtAssetId = toBase58String(value(pmt.assetId))
1064- let pmtAmt = pmt.amount
1065- let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1066- then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1067- else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1068- if ((currentDLp == currentDLp))
1069- then {
1070- let $t03879638954 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1071- if (($t03879638954 == $t03879638954))
1072- then {
1073- let feeAmount = $t03879638954._3
1074- let state = $t03879638954._2
1075- let estimLP = $t03879638954._1
1076- let emitLpAmt = if (if ((minOutAmount > 0))
1077- then (minOutAmount > estimLP)
1078- else false)
1079- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1080- else estimLP
1081- let e = invoke(fca, "emit", [emitLpAmt], nil)
1082- if ((e == e))
1083- then {
1084- let el = match e {
1085- case legacy: Address =>
1086- invoke(legacy, "emit", [emitLpAmt], nil)
1087- case _ =>
1088- unit
1089- }
1090- if ((el == el))
1091- then {
1092- let lpTrnsfr = if (autoStake)
1093- then {
1094- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1095- if ((ss == ss))
1096- then nil
1097- else throw("Strict value is not equal to itself.")
1098- }
1099- else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1100- let sendFeeToMatcher = if ((feeAmount > 0))
1101- then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1102- else nil
1103- let $t03976940118 = if ((this == feeCollectorAddress))
1104- then $Tuple2(0, 0)
1105- else {
1106- let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1107- then true
1108- else false
1109- if (paymentInAmountAsset)
1110- then $Tuple2(-(feeAmount), 0)
1111- else $Tuple2(0, -(feeAmount))
1112- }
1113- let amountAssetBalanceDelta = $t03976940118._1
1114- let priceAssetBalanceDelta = $t03976940118._2
1115- let $t04012140229 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1116- let refreshDLpActions = $t04012140229._1
1117- let updatedDLp = $t04012140229._2
1118- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1119- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1120- then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
1121- else throw("Strict value is not equal to itself.")
1122- }
1123- else throw("Strict value is not equal to itself.")
1124- }
1125- else throw("Strict value is not equal to itself.")
1126- }
1127- else throw("Strict value is not equal to itself.")
1128- }
1129- else throw("Strict value is not equal to itself.")
1130- }
1131- else throw("Strict value is not equal to itself.")
1132- }
1133-
1134-
1135-
1136-@Callable(i)
1137-func putForFree (maxSlpg) = if ((0 > maxSlpg))
1138- then throw("Wrong slpg")
1139- else if ((size(i.payments) != 2))
1140- then throw("2 pmnts expd")
1141- else {
1142- 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, true, 0, "")
1143- let state = estPut._9
1144- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1145- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1146- let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1147- if ((currentDLp == currentDLp))
1148- then {
1149- let $t04125941324 = refreshDLpInternal(0, 0, 0)
1150- let refreshDLpActions = $t04125941324._1
1151- let updatedDLp = $t04125941324._2
1152- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1153- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1154- then (state ++ refreshDLpActions)
1155- else throw("Strict value is not equal to itself.")
1156- }
1157- else throw("Strict value is not equal to itself.")
1158- }
1159-
1160-
1161-
1162-@Callable(i)
1163-func get () = {
1164- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1165- if ((currentDLp == currentDLp))
1166- then {
1167- let r = cg(i)
1168- let outAmtAmt = r._1
1169- let outPrAmt = r._2
1170- let pmtAmt = r._3
1171- let pmtAssetId = r._4
1172- let state = r._5
1173- let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1174- if ((b == b))
1175- then {
1176- let $t04249742579 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1177- let refreshDLpActions = $t04249742579._1
1178- let updatedDLp = $t04249742579._2
1179- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1180- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1181- then (state ++ refreshDLpActions)
1182- else throw("Strict value is not equal to itself.")
1183- }
1184- else throw("Strict value is not equal to itself.")
1185- }
1186- else throw("Strict value is not equal to itself.")
1187- }
1188-
1189-
1190-
1191-@Callable(i)
1192-func getOneTknV2 (outAssetId,minOutAmount) = {
1193- let isPoolOneTokenOperationsDisabled = {
1194- let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
1195- if ($isInstanceOf(@, "Boolean"))
1196- then @
1197- else throw(($getType(@) + " couldn't be cast to Boolean"))
1198- }
1199- let isGetDisabled = if (if (igs())
1200- then true
1201- else (cfgPoolStatus == PoolShutdown))
1202- then true
1203- else isPoolOneTokenOperationsDisabled
1204- let checks = [if (if (!(isGetDisabled))
1205- then true
1206- else isManager(i))
1207- then true
1208- else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
1209- then true
1210- else throwErr("exactly 1 payment are expected")]
1211- if ((checks == checks))
1212- then {
1213- let $t04319743352 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1214- let state = $t04319743352._1
1215- let totalAmount = $t04319743352._2
1216- $Tuple2(state, totalAmount)
1217- }
1218- else throw("Strict value is not equal to itself.")
1219- }
1220-
1221-
1222-
1223-@Callable(i)
1224-func refreshDLp () = {
1225- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1226- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1227- then unit
1228- else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1229- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1230- then {
1231- let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1232- let $t04387643940 = refreshDLpInternal(0, 0, 0)
1233- let dLpUpdateActions = $t04387643940._1
1234- let updatedDLp = $t04387643940._2
1235- let actions = if ((dLp != updatedDLp))
1236- then dLpUpdateActions
1237- else throwErr("nothing to refresh")
1238- $Tuple2(actions, toString(updatedDLp))
1239- }
1240- else throw("Strict value is not equal to itself.")
1241- }
1242-
1243-
1244-
1245-@Callable(i)
1246-func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1247- let amId = toBase58String(value(cfgAmountAssetId))
1248- let prId = toBase58String(value(cfgPriceAssetId))
1249- let lpId = toBase58String(value(cfgLpAssetId))
1250- let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
1251- let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
1252- let D0 = getD(xp)
1253- let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission))
1254- let index = if ((outAssetId == amId))
1255- then 0
1256- else if ((outAssetId == prId))
1257- then 1
1258- else throw("invalid out asset id")
1259- let newY = getYD(xp, index, D1)
1260- let dy = (xp[index] - newY)
1261- let totalGetRaw = max([0, toInt((dy - big1))])
1262- let $t04487044925 = takeFee(totalGetRaw, outFee)
1263- let totalGet = $t04487044925._1
1264- let feeAmount = $t04487044925._2
1265- $Tuple2(nil, $Tuple2(totalGet, feeAmount))
1266- }
1267-
1268-
1269-
1270-@Callable(i)
1271-func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1272- let amId = toBase58String(value(cfgAmountAssetId))
1273- let prId = toBase58String(value(cfgPriceAssetId))
1274- let lpId = toBase58String(value(cfgLpAssetId))
1275- let amBalance = getAccBalance(amId)
1276- let prBalance = getAccBalance(prId)
1277- let $t04530045415 = {
1278- let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
1279- if ($isInstanceOf(@, "(Int, Int)"))
1280- then @
1281- else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
1282- }
1283- let totalGet = $t04530045415._1
1284- let feeAmount = $t04530045415._2
1285- let r = ego("", lpId, lpAssetAmount, this)
1286- let outAmAmt = r._1
1287- let outPrAmt = r._2
1288- let sumOfGetAssets = (outAmAmt + outPrAmt)
1289- let bonus = if ((sumOfGetAssets == 0))
1290- then if ((totalGet == 0))
1291- then 0
1292- else throw("bonus calculation error")
1293- else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets)
1294- $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus))
1295- }
1296-
1297-
1298-
1299-@Callable(i)
1300-func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
1301- let r = cg(i)
1302- let outAmAmt = r._1
1303- let outPrAmt = r._2
1304- let pmtAmt = r._3
1305- let pmtAssetId = r._4
1306- let state = r._5
1307- if ((noLessThenAmtAsset > outAmAmt))
1308- then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
1309- else if ((noLessThenPriceAsset > outPrAmt))
1310- then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1311- else {
1312- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1313- if ((currentDLp == currentDLp))
1314- then {
1315- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1316- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1317- then {
1318- let $t04657946660 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1319- let refreshDLpActions = $t04657946660._1
1320- let updatedDLp = $t04657946660._2
1321- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1322- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1323- then (state ++ refreshDLpActions)
1324- else throw("Strict value is not equal to itself.")
1325- }
1326- else throw("Strict value is not equal to itself.")
1327- }
1328- else throw("Strict value is not equal to itself.")
1329- }
1330- }
1331-
1332-
1333-
1334-@Callable(i)
1335-func unstakeAndGet (amount) = {
1336- let checkPayments = if ((size(i.payments) != 0))
1337- then throw("No pmnts expd")
1338- else true
1339- if ((checkPayments == checkPayments))
1340- then {
1341- let factoryCfg = gfc()
1342- let lpAssetId = cfgLpAssetId
1343- let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1344- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1345- if ((currentDLp == currentDLp))
1346- then {
1347- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1348- if ((unstakeInv == unstakeInv))
1349- then {
1350- let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1351- let outAmAmt = r._1
1352- let outPrAmt = r._2
1353- let sts = parseIntValue(r._9)
1354- let state = r._10
1355- let v = if (if (igs())
1356- then true
1357- else (sts == PoolShutdown))
1358- then throw(("Blocked: " + toString(sts)))
1359- else true
1360- if ((v == v))
1361- then {
1362- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1363- if ((burnA == burnA))
1364- then {
1365- let $t04768747768 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1366- let refreshDLpActions = $t04768747768._1
1367- let updatedDLp = $t04768747768._2
1368- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1369- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1370- then (state ++ refreshDLpActions)
1371- else throw("Strict value is not equal to itself.")
1372- }
1373- else throw("Strict value is not equal to itself.")
1374- }
1375- else throw("Strict value is not equal to itself.")
1376- }
1377- else throw("Strict value is not equal to itself.")
1378- }
1379- else throw("Strict value is not equal to itself.")
1380- }
1381- else throw("Strict value is not equal to itself.")
1382- }
1383-
1384-
1385-
1386-@Callable(i)
1387-func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
1388- let isGetDisabled = if (igs())
1389- then true
1390- else (cfgPoolStatus == PoolShutdown)
1391- let checks = [if (!(isGetDisabled))
1392- then true
1393- else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
1394- then true
1395- else throw("no payments are expected")]
1396- if ((checks == checks))
1397- then {
1398- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1399- if ((currentDLp == currentDLp))
1400- then {
1401- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1402- if ((unstakeInv == unstakeInv))
1403- then {
1404- let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1405- let outAmAmt = res._1
1406- let outPrAmt = res._2
1407- let state = res._10
1408- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1409- then true
1410- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1411- then true
1412- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1413- if ((checkAmounts == checkAmounts))
1414- then {
1415- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1416- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1417- then {
1418- let $t04901949100 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1419- let refreshDLpActions = $t04901949100._1
1420- let updatedDLp = $t04901949100._2
1421- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1422- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1423- then (state ++ refreshDLpActions)
1424- else throw("Strict value is not equal to itself.")
1425- }
1426- else throw("Strict value is not equal to itself.")
1427- }
1428- else throw("Strict value is not equal to itself.")
1429- }
1430- else throw("Strict value is not equal to itself.")
1431- }
1432- else throw("Strict value is not equal to itself.")
1433- }
1434- else throw("Strict value is not equal to itself.")
1435- }
1436-
1437-
1438-
1439-@Callable(i)
1440-func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = {
1441- let isPoolOneTokenOperationsDisabled = {
1442- let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
1443- if ($isInstanceOf(@, "Boolean"))
1444- then @
1445- else throw(($getType(@) + " couldn't be cast to Boolean"))
1446- }
1447- let isGetDisabled = if (if (igs())
1448- then true
1449- else (cfgPoolStatus == PoolShutdown))
1450- then true
1451- else isPoolOneTokenOperationsDisabled
1452- let checks = [if (if (!(isGetDisabled))
1453- then true
1454- else isManager(i))
1455- then true
1456- else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
1457- then true
1458- else throwErr("no payments are expected")]
1459- if ((checks == checks))
1460- then {
1461- let factoryCfg = gfc()
1462- let lpAssetId = cfgLpAssetId
1463- let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1464- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
1465- if ((unstakeInv == unstakeInv))
1466- then {
1467- let $t04999550183 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1468- let state = $t04999550183._1
1469- let totalAmount = $t04999550183._2
1470- $Tuple2(state, totalAmount)
1471- }
1472- else throw("Strict value is not equal to itself.")
1473- }
1474- else throw("Strict value is not equal to itself.")
1475- }
1476-
1477-
1478-
1479-@Callable(i)
1480-func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1481- let $t05031150414 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1482- let lpAmount = $t05031150414._1
1483- let state = $t05031150414._2
1484- let feeAmount = $t05031150414._3
1485- let bonus = $t05031150414._4
1486- $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
1487- }
1488-
1489-
1490-
1491-@Callable(i)
1492-func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1493- let $t05056250666 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1494- let lpAmount = $t05056250666._1
1495- let state = $t05056250666._2
1496- let feeAmount = $t05056250666._3
1497- let bonus = $t05056250666._4
1498- $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
1499- }
1500-
1501-
1502-
1503-@Callable(i)
1504-func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
1505- then throw("denied")
1506- else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
1507-
1508-
1509-
1510-@Callable(i)
1511-func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
1512- then pd
1513- else [StringEntry(k, v)]
1514-
1515-
1516-
1517-@Callable(i)
1518-func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
1519- then pd
1520- else [IntegerEntry(k, v)]
1521-
1522-
1523-
1524-@Callable(i)
1525-func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
1526-
1527-
1528-
1529-@Callable(i)
1530-func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
1531-
1532-
1533-
1534-@Callable(i)
1535-func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
1536- let pr = calcPrices(amAmt, prAmt, lpAmt)
1537- $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])])
1538- }
1539-
1540-
1541-
1542-@Callable(i)
1543-func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
1544-
1545-
1546-
1547-@Callable(i)
1548-func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
1549-
1550-
1551-
1552-@Callable(i)
1553-func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
1554-
1555-
1556-
1557-@Callable(i)
1558-func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, true, false, 0, ""))
1559-
1560-
1561-
1562-@Callable(i)
1563-func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
1564- let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
1565- $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
1566- }
1567-
1568-
15697 @Verifier(tx)
1570-func verify () = {
1571- let targetPublicKey = match m() {
1572- case pk: ByteVector =>
1573- pk
1574- case _: Unit =>
1575- tx.senderPublicKey
1576- case _ =>
1577- throw("Match error")
1578- }
1579- match tx {
1580- case order: Order =>
1581- let matcherPub = mp()
1582- let $t05345853527 = validateMatcherOrderAllowed(order)
1583- let orderValid = $t05345853527._1
1584- let orderValidInfo = $t05345853527._2
1585- let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
1586- let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
1587- if (if (if (orderValid)
1588- then senderValid
1589- else false)
1590- then matcherValid
1591- else false)
1592- then true
1593- else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
1594- case s: SetScriptTransaction =>
1595- if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
1596- then true
1597- else {
1598- let newHash = blake2b256(value(s.script))
1599- let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1600- let currentHash = scriptHash(this)
1601- if ((allowedHash == newHash))
1602- then (currentHash != newHash)
1603- else false
1604- }
1605- case _ =>
1606- sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1607- }
1608- }
8+func verify () = true
16099

github/deemru/w8io/873ac7e 
111.15 ms