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:AAIFAAAAAAAAC68IAhIDCgEIEgMKAQgSABIECgIBBBIHCgUBAQEBBBIDCgEBEgASBwoFAQEBCAESBAoCAQESAwoBARIECgIICBIECgIICBIECgIIARIAEgMKAQgSBQoDAQEBEgQKAggBEgQKAgEBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIIgZzY2FsZTgiDHNjYWxlOEJpZ0ludCIHc2NhbGUxOCIKemVyb0JpZ0ludCIJb25lQmlnSW50IgpzbGlwcGFnZTREIgVBbXVsdCIFRGNvbnYiA1NFUCIFRU1QVFkiClBvb2xBY3RpdmUiClBvb2xQdXREaXMiDlBvb2xNYXRjaGVyRGlzIgxQb29sU2h1dGRvd24iDmlkeFBvb2xBZGRyZXNzIglpZHhQb29sU3QiCWlkeExQQXNJZCIJaWR4QW1Bc0lkIglpZHhQckFzSWQiC2lkeEFtdEFzRGNtIg1pZHhQcmljZUFzRGNtIgtpZHhJQW10QXNJZCINaWR4SVByaWNlQXNJZCIPaWR4RmFjdFN0YWtDbnRyIhBpZHhGYWN0U2xpcHBDbnRyIhFpZHhGYWN0R3d4UmV3Q250ciIFZGVsYX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JjdwAAAAJfOQgFAAAAAmN3AAAAA18xMAAAAAEAAAACZUoBAAAAAmVLAAAAAAQAAAACYXIFAAAAAmVKAwkAAAEAAAACBQAAAAJhcgIAAAAFT3JkZXIEAAAAAmNSBQAAAAJhcgQAAAACZUwJAQAAAAJhQQAAAAAEAAAAAmFuCQEAAAACY1EAAAABBQAAAAJjUgQAAAACZU0JAAH0AAAAAwgFAAAAAmNSAAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACY1IAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACY1IAAAAPc2VuZGVyUHVibGljS2V5BAAAAAJlTgkAAfQAAAADCAUAAAACY1IAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJjUgAAAAZwcm9vZnMAAAAAAAAAAAEFAAAAAmVMAwMDBQAAAAJhbgUAAAACZU0HBQAAAAJlTgcGCQEAAAACYW0AAAADBQAAAAJhbgUAAAACZU0FAAAAAmVOBAAAAAJlTwQAAAACZVAJAQAAAAJkagAAAAADCQAAAQAAAAIFAAAAAmVQAgAAAApCeXRlVmVjdG9yBAAAAAJkbwUAAAACZVAFAAAAAmRvAwkAAAEAAAACBQAAAAJlUAIAAAAEVW5pdAgFAAAAAmVKAAAAD3NlbmRlclB1YmxpY0tleQkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgkAAfQAAAADCAUAAAACZUoAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJlSgAAAAZwcm9vZnMAAAAAAAAAAAAFAAAAAmVPWWxU3g==", "chainId": 84, "height": 2189920, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7TWuUDmGmaHU9G5CzN24GHdhCC47BJSULNmFnTyEkjjf Next: 2AWT5EHVe8NkNLvUiWTvDwGUaX777YQFHy5D5FXNVA6G Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let scale8 = 100000000 | |
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | - | ||
10 | - | let thousand = 1000 | |
11 | 9 | ||
12 | 10 | let zeroBigInt = toBigInt(0) | |
13 | 11 | ||
55 | 53 | ||
56 | 54 | let idxFactGwxRewCntr = 10 | |
57 | 55 | ||
58 | - | let | |
56 | + | let delay = "%s__delay" | |
59 | 57 | ||
60 | - | func | |
58 | + | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
61 | 59 | ||
62 | 60 | ||
63 | - | func | |
61 | + | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
64 | 62 | ||
65 | 63 | ||
66 | 64 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
71 | 69 | else val | |
72 | 70 | ||
73 | 71 | ||
74 | - | func | |
72 | + | func fc () = "%s__factoryContract" | |
75 | 73 | ||
76 | 74 | ||
77 | - | func | |
75 | + | func mpk () = "%s__managerPublicKey" | |
78 | 76 | ||
79 | 77 | ||
80 | - | func | |
78 | + | func pmpk () = "%s__pendingManagerPublicKey" | |
81 | 79 | ||
82 | 80 | ||
83 | - | func | |
81 | + | func pl () = "%s%s__price__last" | |
84 | 82 | ||
85 | 83 | ||
86 | - | func | |
84 | + | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
87 | 85 | ||
88 | 86 | ||
89 | - | func | |
87 | + | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
90 | 88 | ||
91 | 89 | ||
92 | - | func | |
90 | + | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
93 | 91 | ||
94 | 92 | ||
95 | - | func | |
93 | + | func aa () = "%s__amountAsset" | |
96 | 94 | ||
97 | 95 | ||
98 | - | func | |
96 | + | func pa () = "%s__priceAsset" | |
99 | 97 | ||
100 | 98 | ||
101 | - | func | |
99 | + | func amp () = "%s__amp" | |
102 | 100 | ||
103 | 101 | ||
104 | - | func | |
102 | + | func ada () = "%s__addonAddr" | |
105 | 103 | ||
106 | 104 | ||
107 | - | ||
105 | + | func lgotc (caller) = makeString(["%s%s__lastGetOneTknCall", caller], SEP) | |
108 | 106 | ||
109 | - | let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault) | |
107 | + | ||
108 | + | func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
109 | + | ||
110 | 110 | ||
111 | 111 | func fcfg () = "%s__factoryConfig" | |
112 | 112 | ||
123 | 123 | func aps () = "%s__shutdown" | |
124 | 124 | ||
125 | 125 | ||
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))) | |
130 | 127 | ||
131 | 128 | ||
132 | 129 | func str (val) = match val { | |
133 | 130 | case valStr: String => | |
134 | 131 | valStr | |
135 | 132 | case _ => | |
136 | - | | |
133 | + | throw("fail cast to String") | |
137 | 134 | } | |
138 | 135 | ||
139 | 136 | ||
140 | - | func | |
137 | + | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
141 | 138 | ||
142 | 139 | ||
143 | - | func | |
140 | + | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
144 | 141 | ||
145 | 142 | ||
146 | - | let | |
143 | + | let fca = addressFromStringValue(strf(this, fc())) | |
147 | 144 | ||
148 | - | let | |
145 | + | let A = strf(this, amp()) | |
149 | 146 | ||
150 | - | func | |
147 | + | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
151 | 148 | ||
152 | 149 | ||
153 | - | func | |
150 | + | func mp () = fromBase58String(strf(fca, mtpk())) | |
154 | 151 | ||
155 | 152 | ||
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) | |
164 | 159 | } | |
165 | 160 | ||
166 | 161 | ||
167 | - | func | |
162 | + | func gfc () = split(strf(fca, fcfg()), SEP) | |
168 | 163 | ||
169 | 164 | ||
170 | 165 | 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) | |
178 | 173 | else assetBalance(this, fromBase58String(assetId)) | |
179 | 174 | ||
180 | 175 | ||
181 | - | func | |
176 | + | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
182 | 177 | ||
183 | 178 | ||
184 | - | func | |
185 | - | let diff = fraction(( | |
179 | + | func vad (A1,A2,slippage) = { | |
180 | + | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
186 | 181 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
187 | 182 | if (!(pass)) | |
188 | - | then | |
189 | - | else $Tuple2(pass, min([ | |
183 | + | then throw(("Big slpg: " + toString(diff))) | |
184 | + | else $Tuple2(pass, min([A1, A2])) | |
190 | 185 | } | |
191 | 186 | ||
192 | 187 | ||
193 | - | func | |
188 | + | func vd (D1,D0,slpg) = { | |
194 | 189 | let diff = fraction(D0, scale8BigInt, D1) | |
195 | - | let fail = ( | |
190 | + | let fail = (slpg > diff) | |
196 | 191 | if (if (fail) | |
197 | 192 | then true | |
198 | 193 | else (D0 > D1)) | |
199 | - | then | |
194 | + | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
200 | 195 | else fail | |
201 | 196 | } | |
202 | 197 | ||
203 | 198 | ||
204 | - | func | |
205 | - | let amtAsAmtX18 = | |
206 | - | let prAsAmtX18 = | |
207 | - | | |
199 | + | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
200 | + | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
201 | + | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
202 | + | cpbi(prAsAmtX18, amtAsAmtX18) | |
208 | 203 | } | |
209 | 204 | ||
210 | 205 | ||
211 | 206 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
212 | - | let cfg = | |
207 | + | let cfg = gpc() | |
213 | 208 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
214 | 209 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
215 | - | let priceX18 = | |
216 | - | let amAmtX18 = | |
217 | - | let prAmtX18 = | |
218 | - | let lpAmtX18 = | |
219 | - | let lpPrInAmAsX18 = | |
220 | - | let lpPrInPrAsX18 = | |
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) | |
221 | 216 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
222 | 217 | } | |
223 | 218 | ||
224 | 219 | ||
225 | 220 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
226 | 221 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
227 | - | [ | |
222 | + | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
228 | 223 | } | |
229 | 224 | ||
230 | 225 | ||
231 | - | func | |
232 | - | let cfg = | |
233 | - | let | |
234 | - | let | |
235 | - | let | |
236 | - | let | |
237 | - | let | |
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]) | |
238 | 233 | 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) | |
272 | 258 | } | |
273 | - | else throw("Strict value is not equal to itself.") | |
274 | 259 | } | |
275 | 260 | ||
276 | 261 | ||
277 | - | func | |
278 | - | let cfg = | |
279 | - | let | |
280 | - | let | |
281 | - | let | |
282 | - | let | |
283 | - | let | |
284 | - | let | |
285 | - | let | |
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]) | |
286 | 271 | let sts = cfg[idxPoolSt] | |
287 | - | let | |
288 | - | let | |
289 | - | then getAccBalance( | |
272 | + | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
273 | + | let amBalance = if (isEval) | |
274 | + | then getAccBalance(amIdStr) | |
290 | 275 | else if (if (isOneAsset) | |
291 | - | then ( | |
276 | + | then (pmtId == amIdStr) | |
292 | 277 | else false) | |
293 | - | then (getAccBalance( | |
278 | + | then (getAccBalance(amIdStr) - pmtAmt) | |
294 | 279 | else if (isOneAsset) | |
295 | - | then getAccBalance( | |
296 | - | else (getAccBalance( | |
297 | - | let | |
298 | - | then getAccBalance( | |
280 | + | then getAccBalance(amIdStr) | |
281 | + | else (getAccBalance(amIdStr) - inAmAmt) | |
282 | + | let prBalance = if (isEval) | |
283 | + | then getAccBalance(prIdStr) | |
299 | 284 | else if (if (isOneAsset) | |
300 | - | then ( | |
285 | + | then (pmtId == prIdStr) | |
301 | 286 | else false) | |
302 | - | then (getAccBalance( | |
287 | + | then (getAccBalance(prIdStr) - pmtAmt) | |
303 | 288 | 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)) | |
310 | 297 | 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) | |
322 | 322 | } | |
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.") | |
374 | 323 | } | |
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 | + | } | |
376 | 351 | } | |
377 | 352 | ||
378 | 353 | ||
379 | - | func | |
380 | - | let cfg = | |
354 | + | func moa (order) = { | |
355 | + | let cfg = gpc() | |
381 | 356 | let amtAsId = cfg[idxAmAsId] | |
382 | 357 | let prAsId = cfg[idxPrAsId] | |
383 | 358 | let sts = parseIntValue(cfg[idxPoolSt]) | |
385 | 360 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
386 | 361 | let accAmtAsBalance = getAccBalance(amtAsId) | |
387 | 362 | let accPrAsBalance = getAccBalance(prAsId) | |
388 | - | let | |
389 | - | then | |
390 | - | else | |
391 | - | let curPrice = | |
392 | - | if (if (if ( | |
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()) | |
393 | 368 | then true | |
394 | 369 | else (sts == PoolMatcherDis)) | |
395 | 370 | then true | |
396 | 371 | else (sts == PoolShutdown)) | |
397 | - | then | |
372 | + | then throw("Admin blocked") | |
398 | 373 | else { | |
399 | 374 | let orAmtAsset = order.assetPair.amountAsset | |
400 | 375 | let orAmtAsStr = if ((orAmtAsset == unit)) | |
407 | 382 | if (if ((orAmtAsStr != amtAsId)) | |
408 | 383 | then true | |
409 | 384 | else (orPrAsStr != prAsId)) | |
410 | - | then | |
385 | + | then throw("Wr assets") | |
411 | 386 | else { | |
412 | 387 | let orderPrice = order.price | |
413 | - | let | |
414 | - | let castOrderPrice = ts(orderPrice, scale8, | |
388 | + | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
389 | + | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
415 | 390 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
416 | 391 | then (curPrice >= castOrderPrice) | |
417 | 392 | else (castOrderPrice >= curPrice) | |
421 | 396 | } | |
422 | 397 | ||
423 | 398 | ||
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 | + | } | |
446 | 416 | ||
447 | 417 | ||
448 | - | func | |
449 | - | let r = | |
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) | |
450 | 420 | let sts = parseIntValue(r._8) | |
451 | - | if (if (if ( | |
421 | + | if (if (if (igs()) | |
452 | 422 | then true | |
453 | 423 | else (sts == PoolPutDis)) | |
454 | 424 | then true | |
455 | 425 | else (sts == PoolShutdown)) | |
456 | - | then | |
426 | + | then throw(("Blocked:" + toString(sts))) | |
457 | 427 | else r | |
458 | 428 | } | |
459 | 429 | ||
460 | 430 | ||
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()) { | |
468 | 432 | case s: String => | |
469 | 433 | fromBase58String(s) | |
470 | 434 | case _: Unit => | |
474 | 438 | } | |
475 | 439 | ||
476 | 440 | ||
477 | - | func | |
441 | + | func pm () = match getString(pmpk()) { | |
478 | 442 | case s: String => | |
479 | 443 | fromBase58String(s) | |
480 | 444 | case _: Unit => | |
484 | 448 | } | |
485 | 449 | ||
486 | 450 | ||
487 | - | let pd = | |
451 | + | let pd = throw("Permission denied") | |
488 | 452 | ||
489 | - | func | |
453 | + | func mm (i) = match m() { | |
490 | 454 | case pk: ByteVector => | |
491 | 455 | if ((i.callerPublicKey == pk)) | |
492 | 456 | then true | |
501 | 465 | ||
502 | 466 | ||
503 | 467 | @Callable(i) | |
504 | - | func constructor ( | |
505 | - | let | |
506 | - | if (( | |
507 | - | then [StringEntry( | |
468 | + | func constructor (fc) = { | |
469 | + | let c = mm(i) | |
470 | + | if ((c == c)) | |
471 | + | then [StringEntry(fc(), fc)] | |
508 | 472 | else throw("Strict value is not equal to itself.") | |
509 | 473 | } | |
510 | 474 | ||
512 | 476 | ||
513 | 477 | @Callable(i) | |
514 | 478 | func setManager (pendingManagerPublicKey) = { | |
515 | - | let | |
516 | - | if (( | |
479 | + | let c = mm(i) | |
480 | + | if ((c == c)) | |
517 | 481 | then { | |
518 | - | let | |
519 | - | if (( | |
520 | - | then [StringEntry( | |
482 | + | let cm = fromBase58String(pendingManagerPublicKey) | |
483 | + | if ((cm == cm)) | |
484 | + | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
521 | 485 | else throw("Strict value is not equal to itself.") | |
522 | 486 | } | |
523 | 487 | else throw("Strict value is not equal to itself.") | |
527 | 491 | ||
528 | 492 | @Callable(i) | |
529 | 493 | func confirmManager () = { | |
530 | - | let | |
531 | - | let | |
494 | + | let p = pm() | |
495 | + | let hpm = if (isDefined(p)) | |
532 | 496 | then true | |
533 | - | else | |
534 | - | if (( | |
497 | + | else throw("No pending manager") | |
498 | + | if ((hpm == hpm)) | |
535 | 499 | then { | |
536 | - | let | |
500 | + | let cpm = if ((i.callerPublicKey == value(p))) | |
537 | 501 | then true | |
538 | - | else | |
539 | - | if (( | |
540 | - | then [StringEntry( | |
502 | + | else throw("You are not pending manager") | |
503 | + | if ((cpm == cpm)) | |
504 | + | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
541 | 505 | else throw("Strict value is not equal to itself.") | |
542 | 506 | } | |
543 | 507 | else throw("Strict value is not equal to itself.") | |
546 | 510 | ||
547 | 511 | ||
548 | 512 | @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)) | |
581 | 629 | 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)) | |
586 | 640 | 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)) | |
591 | 648 | 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)) | |
593 | 653 | 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 | + | } | |
597 | 669 | else throw("Strict value is not equal to itself.") | |
598 | 670 | } | |
599 | - | else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)] | |
600 | - | (state ++ lpTrasfer) | |
671 | + | else throw("Strict value is not equal to itself.") | |
601 | 672 | } | |
602 | 673 | else throw("Strict value is not equal to itself.") | |
603 | 674 | } | |
605 | 676 | } | |
606 | 677 | else throw("Strict value is not equal to itself.") | |
607 | 678 | } | |
608 | - | else throw("Strict value is not equal to itself.") | |
609 | 679 | } | |
610 | - | else throw("Strict value is not equal to itself.") | |
611 | - | } | |
612 | 680 | else throw("Strict value is not equal to itself.") | |
613 | 681 | } | |
614 | 682 | ||
615 | 683 | ||
616 | 684 | ||
617 | 685 | @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") | |
734 | 688 | else if ((size(i.payments) != 2)) | |
735 | - | then | |
689 | + | then throw("2 pmnts expd") | |
736 | 690 | else { | |
737 | - | let | |
738 | - | | |
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 | |
739 | 693 | } | |
740 | 694 | ||
741 | 695 | ||
742 | 696 | ||
743 | 697 | @Callable(i) | |
744 | 698 | func get () = { | |
745 | - | let r = | |
699 | + | let r = cg(i) | |
746 | 700 | let outAmtAmt = r._1 | |
747 | - | let | |
748 | - | let | |
749 | - | let | |
701 | + | let outPrAmt = r._2 | |
702 | + | let pmtAmt = r._3 | |
703 | + | let pmtAssetId = r._4 | |
750 | 704 | let state = r._5 | |
751 | - | let b = invoke( | |
705 | + | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
752 | 706 | if ((b == b)) | |
753 | 707 | then state | |
754 | 708 | else throw("Strict value is not equal to itself.") | |
758 | 712 | ||
759 | 713 | @Callable(i) | |
760 | 714 | func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1)) | |
761 | - | then | |
715 | + | then throw("1 pmnt expd") | |
762 | 716 | else { | |
763 | - | let cfg = | |
764 | - | let | |
765 | - | let | |
766 | - | let | |
767 | - | let | |
768 | - | let | |
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]) | |
769 | 723 | let sts = cfg[idxPoolSt] | |
770 | - | let factCfg = | |
771 | - | let | |
772 | - | let | |
773 | - | let addon = valueOrElse(getString(this, | |
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()), "") | |
774 | 728 | let userAddress = if ((addon == toString(i.caller))) | |
775 | 729 | then i.originCaller | |
776 | 730 | else i.caller | |
777 | 731 | 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.") | |
860 | 803 | } | |
861 | 804 | ||
862 | 805 | ||
863 | 806 | ||
864 | 807 | @Callable(i) | |
865 | 808 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
866 | - | let r = | |
867 | - | let | |
868 | - | let | |
869 | - | let | |
870 | - | let | |
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 | |
871 | 814 | 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 | + | } | |
890 | 825 | } | |
891 | 826 | ||
892 | 827 | ||
894 | 829 | @Callable(i) | |
895 | 830 | func unstakeAndGet (amount) = { | |
896 | 831 | let checkPayments = if ((size(i.payments) != 0)) | |
897 | - | then | |
832 | + | then throw("No pmnts expd") | |
898 | 833 | else true | |
899 | 834 | if ((checkPayments == checkPayments)) | |
900 | 835 | then { | |
901 | - | let cfg = | |
902 | - | let factoryCfg = | |
836 | + | let cfg = gpc() | |
837 | + | let factoryCfg = gfc() | |
903 | 838 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
904 | - | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), " | |
839 | + | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
905 | 840 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
906 | 841 | if ((unstakeInv == unstakeInv)) | |
907 | 842 | then { | |
908 | - | let r = | |
843 | + | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
909 | 844 | let sts = parseIntValue(r._9) | |
910 | 845 | let state = r._10 | |
911 | - | let v = if (if ( | |
846 | + | let v = if (if (igs()) | |
912 | 847 | then true | |
913 | 848 | else (sts == PoolShutdown)) | |
914 | - | then | |
849 | + | then throw(("Blocked: " + toString(sts))) | |
915 | 850 | else true | |
916 | 851 | if ((v == v)) | |
917 | 852 | then { | |
918 | - | let burnA = invoke( | |
853 | + | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
919 | 854 | if ((burnA == burnA)) | |
920 | 855 | then state | |
921 | 856 | else throw("Strict value is not equal to itself.") | |
930 | 865 | ||
931 | 866 | ||
932 | 867 | @Callable(i) | |
933 | - | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString( | |
934 | - | then | |
935 | - | else $Tuple2([StringEntry( | |
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") | |
936 | 871 | ||
937 | 872 | ||
938 | 873 | ||
939 | 874 | @Callable(i) | |
940 | - | func setS (k,v) = if ((toString(i.caller) != | |
875 | + | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
941 | 876 | then pd | |
942 | 877 | else [StringEntry(k, v)] | |
943 | 878 | ||
944 | 879 | ||
945 | 880 | ||
946 | 881 | @Callable(i) | |
947 | - | func setI (k,v) = if ((toString(i.caller) != | |
882 | + | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
948 | 883 | then pd | |
949 | 884 | else [IntegerEntry(k, v)] | |
950 | 885 | ||
951 | 886 | ||
952 | 887 | ||
953 | 888 | @Callable(i) | |
954 | - | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, | |
889 | + | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
955 | 890 | ||
956 | 891 | ||
957 | 892 | ||
969 | 904 | ||
970 | 905 | ||
971 | 906 | @Callable(i) | |
972 | - | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, | |
907 | + | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
973 | 908 | ||
974 | 909 | ||
975 | 910 | ||
976 | 911 | @Callable(i) | |
977 | - | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString( | |
912 | + | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
978 | 913 | ||
979 | 914 | ||
980 | 915 | ||
981 | 916 | @Callable(i) | |
982 | - | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString( | |
917 | + | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
983 | 918 | ||
984 | 919 | ||
985 | 920 | ||
986 | 921 | @Callable(i) | |
987 | - | func estimatePutOperationWrapperREADONLY (txId58,slippage, | |
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, "")) | |
988 | 923 | ||
989 | 924 | ||
990 | 925 | ||
991 | 926 | @Callable(i) | |
992 | - | func estimateGetOperationWrapperREADONLY (txId58, | |
993 | - | let r = | |
927 | + | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
928 | + | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
994 | 929 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
995 | 930 | } | |
996 | 931 | ||
998 | 933 | @Verifier(tx) | |
999 | 934 | func verify () = match tx { | |
1000 | 935 | case order: Order => | |
1001 | - | let mtchPub = | |
1002 | - | let orV = | |
936 | + | let mtchPub = mp() | |
937 | + | let orV = moa(order) | |
1003 | 938 | let sndrV = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1004 | 939 | let mtchV = sigVerify(order.bodyBytes, order.proofs[1], mtchPub) | |
1005 | 940 | if (if (if (orV) | |
1008 | 943 | then mtchV | |
1009 | 944 | else false) | |
1010 | 945 | then true | |
1011 | - | else | |
946 | + | else toe(orV, sndrV, mtchV) | |
1012 | 947 | case _ => | |
1013 | - | let targetPublicKey = match | |
948 | + | let targetPublicKey = match m() { | |
1014 | 949 | case pk: ByteVector => | |
1015 | 950 | pk | |
1016 | 951 | case _: Unit => |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let scale8 = 100000000 | |
5 | 5 | ||
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | - | ||
10 | - | let thousand = 1000 | |
11 | 9 | ||
12 | 10 | let zeroBigInt = toBigInt(0) | |
13 | 11 | ||
14 | 12 | let oneBigInt = toBigInt(1) | |
15 | 13 | ||
16 | 14 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
17 | 15 | ||
18 | 16 | let Amult = "100" | |
19 | 17 | ||
20 | 18 | let Dconv = "1" | |
21 | 19 | ||
22 | 20 | let SEP = "__" | |
23 | 21 | ||
24 | 22 | let EMPTY = "" | |
25 | 23 | ||
26 | 24 | let PoolActive = 1 | |
27 | 25 | ||
28 | 26 | let PoolPutDis = 2 | |
29 | 27 | ||
30 | 28 | let PoolMatcherDis = 3 | |
31 | 29 | ||
32 | 30 | let PoolShutdown = 4 | |
33 | 31 | ||
34 | 32 | let idxPoolAddress = 1 | |
35 | 33 | ||
36 | 34 | let idxPoolSt = 2 | |
37 | 35 | ||
38 | 36 | let idxLPAsId = 3 | |
39 | 37 | ||
40 | 38 | let idxAmAsId = 4 | |
41 | 39 | ||
42 | 40 | let idxPrAsId = 5 | |
43 | 41 | ||
44 | 42 | let idxAmtAsDcm = 6 | |
45 | 43 | ||
46 | 44 | let idxPriceAsDcm = 7 | |
47 | 45 | ||
48 | 46 | let idxIAmtAsId = 8 | |
49 | 47 | ||
50 | 48 | let idxIPriceAsId = 9 | |
51 | 49 | ||
52 | 50 | let idxFactStakCntr = 1 | |
53 | 51 | ||
54 | 52 | let idxFactSlippCntr = 7 | |
55 | 53 | ||
56 | 54 | let idxFactGwxRewCntr = 10 | |
57 | 55 | ||
58 | - | let | |
56 | + | let delay = "%s__delay" | |
59 | 57 | ||
60 | - | func | |
58 | + | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
61 | 59 | ||
62 | 60 | ||
63 | - | func | |
61 | + | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
64 | 62 | ||
65 | 63 | ||
66 | 64 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
67 | 65 | ||
68 | 66 | ||
69 | 67 | func abs (val) = if ((zeroBigInt > val)) | |
70 | 68 | then -(val) | |
71 | 69 | else val | |
72 | 70 | ||
73 | 71 | ||
74 | - | func | |
72 | + | func fc () = "%s__factoryContract" | |
75 | 73 | ||
76 | 74 | ||
77 | - | func | |
75 | + | func mpk () = "%s__managerPublicKey" | |
78 | 76 | ||
79 | 77 | ||
80 | - | func | |
78 | + | func pmpk () = "%s__pendingManagerPublicKey" | |
81 | 79 | ||
82 | 80 | ||
83 | - | func | |
81 | + | func pl () = "%s%s__price__last" | |
84 | 82 | ||
85 | 83 | ||
86 | - | func | |
84 | + | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
87 | 85 | ||
88 | 86 | ||
89 | - | func | |
87 | + | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
90 | 88 | ||
91 | 89 | ||
92 | - | func | |
90 | + | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
93 | 91 | ||
94 | 92 | ||
95 | - | func | |
93 | + | func aa () = "%s__amountAsset" | |
96 | 94 | ||
97 | 95 | ||
98 | - | func | |
96 | + | func pa () = "%s__priceAsset" | |
99 | 97 | ||
100 | 98 | ||
101 | - | func | |
99 | + | func amp () = "%s__amp" | |
102 | 100 | ||
103 | 101 | ||
104 | - | func | |
102 | + | func ada () = "%s__addonAddr" | |
105 | 103 | ||
106 | 104 | ||
107 | - | ||
105 | + | func lgotc (caller) = makeString(["%s%s__lastGetOneTknCall", caller], SEP) | |
108 | 106 | ||
109 | - | let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault) | |
107 | + | ||
108 | + | func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
109 | + | ||
110 | 110 | ||
111 | 111 | func fcfg () = "%s__factoryConfig" | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func mtpk () = "%s%s__matcher__publicKey" | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
118 | 118 | ||
119 | 119 | ||
120 | 120 | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | func aps () = "%s__shutdown" | |
124 | 124 | ||
125 | 125 | ||
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))) | |
130 | 127 | ||
131 | 128 | ||
132 | 129 | func str (val) = match val { | |
133 | 130 | case valStr: String => | |
134 | 131 | valStr | |
135 | 132 | case _ => | |
136 | - | | |
133 | + | throw("fail cast to String") | |
137 | 134 | } | |
138 | 135 | ||
139 | 136 | ||
140 | - | func | |
137 | + | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
141 | 138 | ||
142 | 139 | ||
143 | - | func | |
140 | + | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
144 | 141 | ||
145 | 142 | ||
146 | - | let | |
143 | + | let fca = addressFromStringValue(strf(this, fc())) | |
147 | 144 | ||
148 | - | let | |
145 | + | let A = strf(this, amp()) | |
149 | 146 | ||
150 | - | func | |
147 | + | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
151 | 148 | ||
152 | 149 | ||
153 | - | func | |
150 | + | func mp () = fromBase58String(strf(fca, mtpk())) | |
154 | 151 | ||
155 | 152 | ||
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) | |
164 | 159 | } | |
165 | 160 | ||
166 | 161 | ||
167 | - | func | |
162 | + | func gfc () = split(strf(fca, fcfg()), SEP) | |
168 | 163 | ||
169 | 164 | ||
170 | 165 | 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) | |
171 | 166 | ||
172 | 167 | ||
173 | 168 | 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) | |
174 | 169 | ||
175 | 170 | ||
176 | 171 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
177 | 172 | then wavesBalance(this).available | |
178 | 173 | else assetBalance(this, fromBase58String(assetId)) | |
179 | 174 | ||
180 | 175 | ||
181 | - | func | |
176 | + | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
182 | 177 | ||
183 | 178 | ||
184 | - | func | |
185 | - | let diff = fraction(( | |
179 | + | func vad (A1,A2,slippage) = { | |
180 | + | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
186 | 181 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
187 | 182 | if (!(pass)) | |
188 | - | then | |
189 | - | else $Tuple2(pass, min([ | |
183 | + | then throw(("Big slpg: " + toString(diff))) | |
184 | + | else $Tuple2(pass, min([A1, A2])) | |
190 | 185 | } | |
191 | 186 | ||
192 | 187 | ||
193 | - | func | |
188 | + | func vd (D1,D0,slpg) = { | |
194 | 189 | let diff = fraction(D0, scale8BigInt, D1) | |
195 | - | let fail = ( | |
190 | + | let fail = (slpg > diff) | |
196 | 191 | if (if (fail) | |
197 | 192 | then true | |
198 | 193 | else (D0 > D1)) | |
199 | - | then | |
194 | + | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
200 | 195 | else fail | |
201 | 196 | } | |
202 | 197 | ||
203 | 198 | ||
204 | - | func | |
205 | - | let amtAsAmtX18 = | |
206 | - | let prAsAmtX18 = | |
207 | - | | |
199 | + | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
200 | + | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
201 | + | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
202 | + | cpbi(prAsAmtX18, amtAsAmtX18) | |
208 | 203 | } | |
209 | 204 | ||
210 | 205 | ||
211 | 206 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
212 | - | let cfg = | |
207 | + | let cfg = gpc() | |
213 | 208 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
214 | 209 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
215 | - | let priceX18 = | |
216 | - | let amAmtX18 = | |
217 | - | let prAmtX18 = | |
218 | - | let lpAmtX18 = | |
219 | - | let lpPrInAmAsX18 = | |
220 | - | let lpPrInPrAsX18 = | |
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) | |
221 | 216 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
222 | 217 | } | |
223 | 218 | ||
224 | 219 | ||
225 | 220 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
226 | 221 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
227 | - | [ | |
222 | + | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
228 | 223 | } | |
229 | 224 | ||
230 | 225 | ||
231 | - | func | |
232 | - | let cfg = | |
233 | - | let | |
234 | - | let | |
235 | - | let | |
236 | - | let | |
237 | - | let | |
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]) | |
238 | 233 | 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) | |
272 | 258 | } | |
273 | - | else throw("Strict value is not equal to itself.") | |
274 | 259 | } | |
275 | 260 | ||
276 | 261 | ||
277 | - | func | |
278 | - | let cfg = | |
279 | - | let | |
280 | - | let | |
281 | - | let | |
282 | - | let | |
283 | - | let | |
284 | - | let | |
285 | - | let | |
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]) | |
286 | 271 | let sts = cfg[idxPoolSt] | |
287 | - | let | |
288 | - | let | |
289 | - | then getAccBalance( | |
272 | + | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
273 | + | let amBalance = if (isEval) | |
274 | + | then getAccBalance(amIdStr) | |
290 | 275 | else if (if (isOneAsset) | |
291 | - | then ( | |
276 | + | then (pmtId == amIdStr) | |
292 | 277 | else false) | |
293 | - | then (getAccBalance( | |
278 | + | then (getAccBalance(amIdStr) - pmtAmt) | |
294 | 279 | else if (isOneAsset) | |
295 | - | then getAccBalance( | |
296 | - | else (getAccBalance( | |
297 | - | let | |
298 | - | then getAccBalance( | |
280 | + | then getAccBalance(amIdStr) | |
281 | + | else (getAccBalance(amIdStr) - inAmAmt) | |
282 | + | let prBalance = if (isEval) | |
283 | + | then getAccBalance(prIdStr) | |
299 | 284 | else if (if (isOneAsset) | |
300 | - | then ( | |
285 | + | then (pmtId == prIdStr) | |
301 | 286 | else false) | |
302 | - | then (getAccBalance( | |
287 | + | then (getAccBalance(prIdStr) - pmtAmt) | |
303 | 288 | 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)) | |
310 | 297 | 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) | |
322 | 322 | } | |
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.") | |
374 | 323 | } | |
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 | + | } | |
376 | 351 | } | |
377 | 352 | ||
378 | 353 | ||
379 | - | func | |
380 | - | let cfg = | |
354 | + | func moa (order) = { | |
355 | + | let cfg = gpc() | |
381 | 356 | let amtAsId = cfg[idxAmAsId] | |
382 | 357 | let prAsId = cfg[idxPrAsId] | |
383 | 358 | let sts = parseIntValue(cfg[idxPoolSt]) | |
384 | 359 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
385 | 360 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
386 | 361 | let accAmtAsBalance = getAccBalance(amtAsId) | |
387 | 362 | let accPrAsBalance = getAccBalance(prAsId) | |
388 | - | let | |
389 | - | then | |
390 | - | else | |
391 | - | let curPrice = | |
392 | - | if (if (if ( | |
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()) | |
393 | 368 | then true | |
394 | 369 | else (sts == PoolMatcherDis)) | |
395 | 370 | then true | |
396 | 371 | else (sts == PoolShutdown)) | |
397 | - | then | |
372 | + | then throw("Admin blocked") | |
398 | 373 | else { | |
399 | 374 | let orAmtAsset = order.assetPair.amountAsset | |
400 | 375 | let orAmtAsStr = if ((orAmtAsset == unit)) | |
401 | 376 | then "WAVES" | |
402 | 377 | else toBase58String(value(orAmtAsset)) | |
403 | 378 | let orPrAsset = order.assetPair.priceAsset | |
404 | 379 | let orPrAsStr = if ((orPrAsset == unit)) | |
405 | 380 | then "WAVES" | |
406 | 381 | else toBase58String(value(orPrAsset)) | |
407 | 382 | if (if ((orAmtAsStr != amtAsId)) | |
408 | 383 | then true | |
409 | 384 | else (orPrAsStr != prAsId)) | |
410 | - | then | |
385 | + | then throw("Wr assets") | |
411 | 386 | else { | |
412 | 387 | let orderPrice = order.price | |
413 | - | let | |
414 | - | let castOrderPrice = ts(orderPrice, scale8, | |
388 | + | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
389 | + | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
415 | 390 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
416 | 391 | then (curPrice >= castOrderPrice) | |
417 | 392 | else (castOrderPrice >= curPrice) | |
418 | 393 | true | |
419 | 394 | } | |
420 | 395 | } | |
421 | 396 | } | |
422 | 397 | ||
423 | 398 | ||
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 | + | } | |
446 | 416 | ||
447 | 417 | ||
448 | - | func | |
449 | - | let r = | |
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) | |
450 | 420 | let sts = parseIntValue(r._8) | |
451 | - | if (if (if ( | |
421 | + | if (if (if (igs()) | |
452 | 422 | then true | |
453 | 423 | else (sts == PoolPutDis)) | |
454 | 424 | then true | |
455 | 425 | else (sts == PoolShutdown)) | |
456 | - | then | |
426 | + | then throw(("Blocked:" + toString(sts))) | |
457 | 427 | else r | |
458 | 428 | } | |
459 | 429 | ||
460 | 430 | ||
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()) { | |
468 | 432 | case s: String => | |
469 | 433 | fromBase58String(s) | |
470 | 434 | case _: Unit => | |
471 | 435 | unit | |
472 | 436 | case _ => | |
473 | 437 | throw("Match error") | |
474 | 438 | } | |
475 | 439 | ||
476 | 440 | ||
477 | - | func | |
441 | + | func pm () = match getString(pmpk()) { | |
478 | 442 | case s: String => | |
479 | 443 | fromBase58String(s) | |
480 | 444 | case _: Unit => | |
481 | 445 | unit | |
482 | 446 | case _ => | |
483 | 447 | throw("Match error") | |
484 | 448 | } | |
485 | 449 | ||
486 | 450 | ||
487 | - | let pd = | |
451 | + | let pd = throw("Permission denied") | |
488 | 452 | ||
489 | - | func | |
453 | + | func mm (i) = match m() { | |
490 | 454 | case pk: ByteVector => | |
491 | 455 | if ((i.callerPublicKey == pk)) | |
492 | 456 | then true | |
493 | 457 | else pd | |
494 | 458 | case _: Unit => | |
495 | 459 | if ((i.caller == this)) | |
496 | 460 | then true | |
497 | 461 | else pd | |
498 | 462 | case _ => | |
499 | 463 | throw("Match error") | |
500 | 464 | } | |
501 | 465 | ||
502 | 466 | ||
503 | 467 | @Callable(i) | |
504 | - | func constructor ( | |
505 | - | let | |
506 | - | if (( | |
507 | - | then [StringEntry( | |
468 | + | func constructor (fc) = { | |
469 | + | let c = mm(i) | |
470 | + | if ((c == c)) | |
471 | + | then [StringEntry(fc(), fc)] | |
508 | 472 | else throw("Strict value is not equal to itself.") | |
509 | 473 | } | |
510 | 474 | ||
511 | 475 | ||
512 | 476 | ||
513 | 477 | @Callable(i) | |
514 | 478 | func setManager (pendingManagerPublicKey) = { | |
515 | - | let | |
516 | - | if (( | |
479 | + | let c = mm(i) | |
480 | + | if ((c == c)) | |
517 | 481 | then { | |
518 | - | let | |
519 | - | if (( | |
520 | - | then [StringEntry( | |
482 | + | let cm = fromBase58String(pendingManagerPublicKey) | |
483 | + | if ((cm == cm)) | |
484 | + | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
521 | 485 | else throw("Strict value is not equal to itself.") | |
522 | 486 | } | |
523 | 487 | else throw("Strict value is not equal to itself.") | |
524 | 488 | } | |
525 | 489 | ||
526 | 490 | ||
527 | 491 | ||
528 | 492 | @Callable(i) | |
529 | 493 | func confirmManager () = { | |
530 | - | let | |
531 | - | let | |
494 | + | let p = pm() | |
495 | + | let hpm = if (isDefined(p)) | |
532 | 496 | then true | |
533 | - | else | |
534 | - | if (( | |
497 | + | else throw("No pending manager") | |
498 | + | if ((hpm == hpm)) | |
535 | 499 | then { | |
536 | - | let | |
500 | + | let cpm = if ((i.callerPublicKey == value(p))) | |
537 | 501 | then true | |
538 | - | else | |
539 | - | if (( | |
540 | - | then [StringEntry( | |
502 | + | else throw("You are not pending manager") | |
503 | + | if ((cpm == cpm)) | |
504 | + | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
541 | 505 | else throw("Strict value is not equal to itself.") | |
542 | 506 | } | |
543 | 507 | else throw("Strict value is not equal to itself.") | |
544 | 508 | } | |
545 | 509 | ||
546 | 510 | ||
547 | 511 | ||
548 | 512 | @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)) | |
581 | 629 | 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)) | |
586 | 640 | 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)) | |
591 | 648 | 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)) | |
593 | 653 | 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 | + | } | |
597 | 669 | else throw("Strict value is not equal to itself.") | |
598 | 670 | } | |
599 | - | else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)] | |
600 | - | (state ++ lpTrasfer) | |
671 | + | else throw("Strict value is not equal to itself.") | |
601 | 672 | } | |
602 | 673 | else throw("Strict value is not equal to itself.") | |
603 | 674 | } | |
604 | 675 | else throw("Strict value is not equal to itself.") | |
605 | 676 | } | |
606 | 677 | else throw("Strict value is not equal to itself.") | |
607 | 678 | } | |
608 | - | else throw("Strict value is not equal to itself.") | |
609 | 679 | } | |
610 | - | else throw("Strict value is not equal to itself.") | |
611 | - | } | |
612 | 680 | else throw("Strict value is not equal to itself.") | |
613 | 681 | } | |
614 | 682 | ||
615 | 683 | ||
616 | 684 | ||
617 | 685 | @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") | |
734 | 688 | else if ((size(i.payments) != 2)) | |
735 | - | then | |
689 | + | then throw("2 pmnts expd") | |
736 | 690 | else { | |
737 | - | let | |
738 | - | | |
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 | |
739 | 693 | } | |
740 | 694 | ||
741 | 695 | ||
742 | 696 | ||
743 | 697 | @Callable(i) | |
744 | 698 | func get () = { | |
745 | - | let r = | |
699 | + | let r = cg(i) | |
746 | 700 | let outAmtAmt = r._1 | |
747 | - | let | |
748 | - | let | |
749 | - | let | |
701 | + | let outPrAmt = r._2 | |
702 | + | let pmtAmt = r._3 | |
703 | + | let pmtAssetId = r._4 | |
750 | 704 | let state = r._5 | |
751 | - | let b = invoke( | |
705 | + | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
752 | 706 | if ((b == b)) | |
753 | 707 | then state | |
754 | 708 | else throw("Strict value is not equal to itself.") | |
755 | 709 | } | |
756 | 710 | ||
757 | 711 | ||
758 | 712 | ||
759 | 713 | @Callable(i) | |
760 | 714 | func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1)) | |
761 | - | then | |
715 | + | then throw("1 pmnt expd") | |
762 | 716 | else { | |
763 | - | let cfg = | |
764 | - | let | |
765 | - | let | |
766 | - | let | |
767 | - | let | |
768 | - | let | |
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]) | |
769 | 723 | let sts = cfg[idxPoolSt] | |
770 | - | let factCfg = | |
771 | - | let | |
772 | - | let | |
773 | - | let addon = valueOrElse(getString(this, | |
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()), "") | |
774 | 728 | let userAddress = if ((addon == toString(i.caller))) | |
775 | 729 | then i.originCaller | |
776 | 730 | else i.caller | |
777 | 731 | 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.") | |
860 | 803 | } | |
861 | 804 | ||
862 | 805 | ||
863 | 806 | ||
864 | 807 | @Callable(i) | |
865 | 808 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
866 | - | let r = | |
867 | - | let | |
868 | - | let | |
869 | - | let | |
870 | - | let | |
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 | |
871 | 814 | 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 | + | } | |
890 | 825 | } | |
891 | 826 | ||
892 | 827 | ||
893 | 828 | ||
894 | 829 | @Callable(i) | |
895 | 830 | func unstakeAndGet (amount) = { | |
896 | 831 | let checkPayments = if ((size(i.payments) != 0)) | |
897 | - | then | |
832 | + | then throw("No pmnts expd") | |
898 | 833 | else true | |
899 | 834 | if ((checkPayments == checkPayments)) | |
900 | 835 | then { | |
901 | - | let cfg = | |
902 | - | let factoryCfg = | |
836 | + | let cfg = gpc() | |
837 | + | let factoryCfg = gfc() | |
903 | 838 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
904 | - | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), " | |
839 | + | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
905 | 840 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
906 | 841 | if ((unstakeInv == unstakeInv)) | |
907 | 842 | then { | |
908 | - | let r = | |
843 | + | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
909 | 844 | let sts = parseIntValue(r._9) | |
910 | 845 | let state = r._10 | |
911 | - | let v = if (if ( | |
846 | + | let v = if (if (igs()) | |
912 | 847 | then true | |
913 | 848 | else (sts == PoolShutdown)) | |
914 | - | then | |
849 | + | then throw(("Blocked: " + toString(sts))) | |
915 | 850 | else true | |
916 | 851 | if ((v == v)) | |
917 | 852 | then { | |
918 | - | let burnA = invoke( | |
853 | + | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
919 | 854 | if ((burnA == burnA)) | |
920 | 855 | then state | |
921 | 856 | else throw("Strict value is not equal to itself.") | |
922 | 857 | } | |
923 | 858 | else throw("Strict value is not equal to itself.") | |
924 | 859 | } | |
925 | 860 | else throw("Strict value is not equal to itself.") | |
926 | 861 | } | |
927 | 862 | else throw("Strict value is not equal to itself.") | |
928 | 863 | } | |
929 | 864 | ||
930 | 865 | ||
931 | 866 | ||
932 | 867 | @Callable(i) | |
933 | - | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString( | |
934 | - | then | |
935 | - | else $Tuple2([StringEntry( | |
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") | |
936 | 871 | ||
937 | 872 | ||
938 | 873 | ||
939 | 874 | @Callable(i) | |
940 | - | func setS (k,v) = if ((toString(i.caller) != | |
875 | + | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
941 | 876 | then pd | |
942 | 877 | else [StringEntry(k, v)] | |
943 | 878 | ||
944 | 879 | ||
945 | 880 | ||
946 | 881 | @Callable(i) | |
947 | - | func setI (k,v) = if ((toString(i.caller) != | |
882 | + | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
948 | 883 | then pd | |
949 | 884 | else [IntegerEntry(k, v)] | |
950 | 885 | ||
951 | 886 | ||
952 | 887 | ||
953 | 888 | @Callable(i) | |
954 | - | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, | |
889 | + | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
955 | 890 | ||
956 | 891 | ||
957 | 892 | ||
958 | 893 | @Callable(i) | |
959 | 894 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
960 | 895 | ||
961 | 896 | ||
962 | 897 | ||
963 | 898 | @Callable(i) | |
964 | 899 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
965 | 900 | let pr = calcPrices(amAmt, prAmt, lpAmt) | |
966 | 901 | $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])]) | |
967 | 902 | } | |
968 | 903 | ||
969 | 904 | ||
970 | 905 | ||
971 | 906 | @Callable(i) | |
972 | - | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, | |
907 | + | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
973 | 908 | ||
974 | 909 | ||
975 | 910 | ||
976 | 911 | @Callable(i) | |
977 | - | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString( | |
912 | + | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
978 | 913 | ||
979 | 914 | ||
980 | 915 | ||
981 | 916 | @Callable(i) | |
982 | - | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString( | |
917 | + | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
983 | 918 | ||
984 | 919 | ||
985 | 920 | ||
986 | 921 | @Callable(i) | |
987 | - | func estimatePutOperationWrapperREADONLY (txId58,slippage, | |
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, "")) | |
988 | 923 | ||
989 | 924 | ||
990 | 925 | ||
991 | 926 | @Callable(i) | |
992 | - | func estimateGetOperationWrapperREADONLY (txId58, | |
993 | - | let r = | |
927 | + | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
928 | + | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
994 | 929 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
995 | 930 | } | |
996 | 931 | ||
997 | 932 | ||
998 | 933 | @Verifier(tx) | |
999 | 934 | func verify () = match tx { | |
1000 | 935 | case order: Order => | |
1001 | - | let mtchPub = | |
1002 | - | let orV = | |
936 | + | let mtchPub = mp() | |
937 | + | let orV = moa(order) | |
1003 | 938 | let sndrV = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1004 | 939 | let mtchV = sigVerify(order.bodyBytes, order.proofs[1], mtchPub) | |
1005 | 940 | if (if (if (orV) | |
1006 | 941 | then sndrV | |
1007 | 942 | else false) | |
1008 | 943 | then mtchV | |
1009 | 944 | else false) | |
1010 | 945 | then true | |
1011 | - | else | |
946 | + | else toe(orV, sndrV, mtchV) | |
1012 | 947 | case _ => | |
1013 | - | let targetPublicKey = match | |
948 | + | let targetPublicKey = match m() { | |
1014 | 949 | case pk: ByteVector => | |
1015 | 950 | pk | |
1016 | 951 | case _: Unit => | |
1017 | 952 | tx.senderPublicKey | |
1018 | 953 | case _ => | |
1019 | 954 | throw("Match error") | |
1020 | 955 | } | |
1021 | 956 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1022 | 957 | } | |
1023 | 958 |
github/deemru/w8io/026f985 181.26 ms ◑