tx · D9JhMuaXZVdL6NfjXE3uqWACEoAquoHKPv8rKT18pSfS 3N8f95pbYUxzxmecdHsqeCQXPUoDRSWdGG9: -0.02800000 Waves 2022.08.31 16:33 [2208703] smart account 3N8f95pbYUxzxmecdHsqeCQXPUoDRSWdGG9 > SELF 0.00000000 Waves
{ "type": 13, "id": "D9JhMuaXZVdL6NfjXE3uqWACEoAquoHKPv8rKT18pSfS", "fee": 2800000, "feeAssetId": null, "timestamp": 1661952579789, "version": 2, "chainId": 84, "sender": "3N8f95pbYUxzxmecdHsqeCQXPUoDRSWdGG9", "senderPublicKey": "AGk8X2naFtJSxDiemU3uYY2vUUxjpjdCCL4fWTGt5Dhn", "proofs": [ "3tFhrVgSpPjW76vnAY5KT28TAzxY1x5CWDoaZy5Mau1ngXS2ZC5jyGQdS8njuzEwega2etNQL5dk6ff2Uk8S5dcw" ], "script": "base64:BgJ/CAISAwoBCBIDCgEIEgASBAoCAQQSBwoFAQEBAQQSAwoBARIAEgcKBQEBAQgBEgQKAgEBEgMKAQESBAoCCAgSBAoCCAgSBAoCCAESABIDCgEIEgUKAwEBARIECgIIARIECgIBARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCE4ABnNjYWxlOACAwtcvAAxzY2FsZThCaWdJbnQJALYCAQCAwtcvAAdzY2FsZTE4CQC2AgEAgICQu7rWrfANAAp6ZXJvQmlnSW50CQC2AgEAAAAJb25lQmlnSW50CQC2AgEAAQAKc2xpcHBhZ2U0RAkAtgIBCQBlAgUGc2NhbGU4CQBpAgkAaAIFBnNjYWxlOAABBQZzY2FsZTgABUFtdWx0AgMxMDAABURjb252AgExAANTRVACAl9fAAVFTVBUWQIAAApQb29sQWN0aXZlAAEAClBvb2xQdXREaXMAAgAOUG9vbE1hdGNoZXJEaXMAAwAMUG9vbFNodXRkb3duAAQADmlkeFBvb2xBZGRyZXNzAAEACWlkeFBvb2xTdAACAAlpZHhMUEFzSWQAAwAJaWR4QW1Bc0lkAAQACWlkeFByQXNJZAAFAA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JQdWIJAQJtcAAECm9yZGVyVmFsaWQJAQNtb2EBBQVvcmRlcgQLc2VuZGVyVmFsaWQJAPQDAwgFBW9yZGVyCWJvZHlCeXRlcwkAkQMCCAUFb3JkZXIGcHJvb2ZzAAAIBQVvcmRlcg9zZW5kZXJQdWJsaWNLZXkEDG1hdGNoZXJWYWxpZAkA9AMDCAUFb3JkZXIJYm9keUJ5dGVzCQCRAwIIBQVvcmRlcgZwcm9vZnMAAQUKbWF0Y2hlclB1YgMDAwUKb3JkZXJWYWxpZAULc2VuZGVyVmFsaWQHBQxtYXRjaGVyVmFsaWQHBgkBA3RvZQMFCm9yZGVyVmFsaWQFC3NlbmRlclZhbGlkBQxtYXRjaGVyVmFsaWQDCQABAgUHJG1hdGNoMAIUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAXMFByRtYXRjaDAEB25ld0hhc2gJAPYDAQkBBXZhbHVlAQgFAXMGc2NyaXB0BAthbGxvd2VkSGFzaAkA2wQBCQEFdmFsdWUBCQCdCAIFA2ZjYQkBHGtleUFsbG93ZWRMcFN0YWJsZVNjcmlwdEhhc2gABAtjdXJyZW50SGFzaAkA8QcBBQR0aGlzAwMJAAACBQthbGxvd2VkSGFzaAUHbmV3SGFzaAkBAiE9AgULY3VycmVudEhhc2gFB25ld0hhc2gHBgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5CQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXm8emkr", "height": 2208703, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: D2tsMVcWdW1sszvEEWH9j8cUqQaUSLqgM4oy7hmTd8Qi Next: E72bvt47Q2WuXn2bc7kpjy6MFZuFzTsgajAb5v3UWVFs Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let defaultDecimals = 1000000 | |
5 | - | ||
6 | 4 | let scale8 = 100000000 | |
7 | 5 | ||
8 | 6 | let scale8BigInt = toBigInt(100000000) | |
9 | 7 | ||
10 | 8 | let scale18 = toBigInt(1000000000000000000) | |
11 | - | ||
12 | - | let thousand = 1000 | |
13 | 9 | ||
14 | 10 | let zeroBigInt = toBigInt(0) | |
15 | 11 | ||
57 | 53 | ||
58 | 54 | let idxFactGwxRewCntr = 10 | |
59 | 55 | ||
60 | - | let | |
56 | + | let delay = "%s__delay" | |
61 | 57 | ||
62 | - | func | |
58 | + | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 59 | ||
64 | 60 | ||
65 | - | func | |
61 | + | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 62 | ||
67 | 63 | ||
68 | 64 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
73 | 69 | else val | |
74 | 70 | ||
75 | 71 | ||
76 | - | func | |
72 | + | func fc () = "%s__factoryContract" | |
77 | 73 | ||
78 | 74 | ||
79 | - | func | |
75 | + | func mpk () = "%s__managerPublicKey" | |
80 | 76 | ||
81 | 77 | ||
82 | - | func | |
78 | + | func pmpk () = "%s__pendingManagerPublicKey" | |
83 | 79 | ||
84 | 80 | ||
85 | - | func | |
81 | + | func pl () = "%s%s__price__last" | |
86 | 82 | ||
87 | 83 | ||
88 | - | func | |
84 | + | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
89 | 85 | ||
90 | 86 | ||
91 | - | func | |
87 | + | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
92 | 88 | ||
93 | 89 | ||
94 | - | func | |
90 | + | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
95 | 91 | ||
96 | 92 | ||
97 | - | func | |
93 | + | func aa () = "%s__amountAsset" | |
98 | 94 | ||
99 | 95 | ||
100 | - | func | |
96 | + | func pa () = "%s__priceAsset" | |
101 | 97 | ||
102 | 98 | ||
103 | - | func | |
99 | + | func amp () = "%s__amp" | |
104 | 100 | ||
105 | 101 | ||
106 | - | func | |
102 | + | func ada () = "%s__addonAddr" | |
107 | 103 | ||
108 | 104 | ||
109 | - | let keyFeePermille = "%s__feePermille" | |
110 | - | ||
111 | - | let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault) | |
112 | - | ||
113 | - | func keyFactoryConfig () = "%s__factoryConfig" | |
105 | + | func lgotc (caller) = makeString(["%s%s__lastGetOneTknCall", caller], SEP) | |
114 | 106 | ||
115 | 107 | ||
116 | - | func | |
108 | + | func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
117 | 109 | ||
118 | 110 | ||
119 | - | func | |
111 | + | func fcfg () = "%s__factoryConfig" | |
120 | 112 | ||
121 | 113 | ||
122 | - | func | |
114 | + | func mtpk () = "%s%s__matcher__publicKey" | |
123 | 115 | ||
124 | 116 | ||
125 | - | func | |
117 | + | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
126 | 118 | ||
127 | 119 | ||
128 | - | func | |
120 | + | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
129 | 121 | ||
130 | 122 | ||
131 | - | func throwOrderError (orV,sendrV,matchV) = throwErr(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
123 | + | func aps () = "%s__shutdown" | |
124 | + | ||
125 | + | ||
126 | + | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
127 | + | ||
128 | + | ||
129 | + | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
132 | 130 | ||
133 | 131 | ||
134 | 132 | func str (val) = match val { | |
135 | 133 | case valStr: String => | |
136 | 134 | valStr | |
137 | 135 | case _ => | |
138 | - | | |
136 | + | throw("fail cast to String") | |
139 | 137 | } | |
140 | 138 | ||
141 | 139 | ||
142 | - | func | |
140 | + | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
143 | 141 | ||
144 | 142 | ||
145 | - | func | |
143 | + | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
146 | 144 | ||
147 | 145 | ||
148 | - | let | |
146 | + | let fca = addressFromStringValue(strf(this, fc())) | |
149 | 147 | ||
150 | - | let | |
148 | + | let A = strf(this, amp()) | |
151 | 149 | ||
152 | - | func | |
150 | + | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
153 | 151 | ||
154 | 152 | ||
155 | - | func | |
153 | + | func mp () = fromBase58String(strf(fca, mtpk())) | |
156 | 154 | ||
157 | 155 | ||
158 | - | let matcherAddress = addressFromPublicKey(getMatcherPubOrFail()) | |
159 | - | ||
160 | - | func getPoolConfig () = { | |
161 | - | let amtAs = getStringOrFail(this, keyAmountAsset()) | |
162 | - | let priceAs = getStringOrFail(this, keyPriceAsset()) | |
163 | - | let iPriceAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAs)) | |
164 | - | let iAmtAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAs)) | |
165 | - | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAs), toString(iPriceAs))), SEP) | |
156 | + | func gpc () = { | |
157 | + | let amtAs = strf(this, aa()) | |
158 | + | let priceAs = strf(this, pa()) | |
159 | + | let iPriceAs = intf(fca, mba(priceAs)) | |
160 | + | let iAmtAs = intf(fca, mba(amtAs)) | |
161 | + | split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP) | |
166 | 162 | } | |
167 | 163 | ||
168 | 164 | ||
169 | - | func | |
165 | + | func gfc () = split(strf(fca, fcfg()), SEP) | |
170 | 166 | ||
171 | 167 | ||
172 | 168 | 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) | |
180 | 176 | else assetBalance(this, fromBase58String(assetId)) | |
181 | 177 | ||
182 | 178 | ||
183 | - | func | |
179 | + | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
184 | 180 | ||
185 | 181 | ||
186 | - | func | |
187 | - | let diff = fraction(( | |
182 | + | func vad (A1,A2,slippage) = { | |
183 | + | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
188 | 184 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
189 | 185 | if (!(pass)) | |
190 | - | then | |
191 | - | else $Tuple2(pass, min([ | |
186 | + | then throw(("Big slpg: " + toString(diff))) | |
187 | + | else $Tuple2(pass, min([A1, A2])) | |
192 | 188 | } | |
193 | 189 | ||
194 | 190 | ||
195 | - | func | |
191 | + | func vd (D1,D0,slpg) = { | |
196 | 192 | let diff = fraction(D0, scale8BigInt, D1) | |
197 | - | let fail = ( | |
193 | + | let fail = (slpg > diff) | |
198 | 194 | if (if (fail) | |
199 | 195 | then true | |
200 | 196 | else (D0 > D1)) | |
201 | - | then | |
197 | + | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
202 | 198 | else fail | |
203 | 199 | } | |
204 | 200 | ||
205 | 201 | ||
206 | - | func | |
207 | - | let amtAsAmtX18 = | |
208 | - | let prAsAmtX18 = | |
209 | - | | |
202 | + | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
203 | + | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
204 | + | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
205 | + | cpbi(prAsAmtX18, amtAsAmtX18) | |
210 | 206 | } | |
211 | 207 | ||
212 | 208 | ||
213 | 209 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
214 | - | let cfg = | |
210 | + | let cfg = gpc() | |
215 | 211 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
216 | 212 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
217 | - | let priceX18 = | |
218 | - | let amAmtX18 = | |
219 | - | let prAmtX18 = | |
220 | - | let lpAmtX18 = | |
221 | - | let lpPrInAmAsX18 = | |
222 | - | let lpPrInPrAsX18 = | |
213 | + | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
214 | + | let amAmtX18 = t1(amAmt, amtAsDcm) | |
215 | + | let prAmtX18 = t1(prAmt, prAsDcm) | |
216 | + | let lpAmtX18 = t1(lpAmt, scale8) | |
217 | + | let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18) | |
218 | + | let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18) | |
223 | 219 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
224 | 220 | } | |
225 | 221 | ||
226 | 222 | ||
227 | 223 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
228 | 224 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
229 | - | [ | |
225 | + | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
230 | 226 | } | |
231 | 227 | ||
232 | 228 | ||
233 | - | func | |
234 | - | let cfg = | |
235 | - | let | |
236 | - | let | |
237 | - | let | |
238 | - | let | |
239 | - | let | |
229 | + | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
230 | + | let cfg = gpc() | |
231 | + | let lpId = cfg[idxLPAsId] | |
232 | + | let amId = cfg[idxAmAsId] | |
233 | + | let prId = cfg[idxPrAsId] | |
234 | + | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
235 | + | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
240 | 236 | let sts = cfg[idxPoolSt] | |
241 | - | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), "Wrong LP id").quantity | |
242 | - | let validationBlock = if ((lpAssetId == paymentAssetId)) | |
243 | - | then true | |
244 | - | else throwErr("Wrong payment asset") | |
245 | - | if ((validationBlock == validationBlock)) | |
246 | - | then { | |
247 | - | let amountBalance = getAccBalance(amountId) | |
248 | - | let priceBalance = getAccBalance(priceId) | |
249 | - | let amountBalanceDefaultDecimals = fraction(amountBalance, defaultDecimals, amountDecimals) | |
250 | - | let priceBalanceDefaultDecimals = fraction(priceBalance, defaultDecimals, priceDecimals) | |
251 | - | let amountBalanceX18 = toX18(amountBalanceDefaultDecimals, defaultDecimals) | |
252 | - | let priceBalanceX18 = toX18(priceBalanceDefaultDecimals, defaultDecimals) | |
253 | - | let currentPriceX18 = calcPriceBigInt(priceBalanceX18, amountBalanceX18) | |
254 | - | let curPrice = fromX18(currentPriceX18, scale8) | |
255 | - | let paymentLpAmountX18 = toX18(paymentLpAmount, scale8) | |
256 | - | let lpEmissionX18 = toX18(lpEmission, scale8) | |
257 | - | let outAmountAmountX18 = fraction(amountBalanceX18, paymentLpAmountX18, lpEmissionX18) | |
258 | - | let outPriceAmountX18 = fraction(priceBalanceX18, paymentLpAmountX18, lpEmissionX18) | |
259 | - | let outAmountAmountDefaultDecimals = fromX18(outAmountAmountX18, defaultDecimals) | |
260 | - | let outPriceAmountDefaultDecimals = fromX18(outPriceAmountX18, defaultDecimals) | |
261 | - | let outAmountAmount = fraction(outAmountAmountDefaultDecimals, amountDecimals, defaultDecimals) | |
262 | - | let outPriceAmount = fraction(outPriceAmountDefaultDecimals, priceDecimals, defaultDecimals) | |
237 | + | let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity | |
238 | + | if ((lpId != pmtAssetId)) | |
239 | + | then throw("Wrong pmt asset") | |
240 | + | else { | |
241 | + | let amBalance = getAccBalance(amId) | |
242 | + | let amBalanceX18 = t1(amBalance, amDcm) | |
243 | + | let prBalance = getAccBalance(prId) | |
244 | + | let prBalanceX18 = t1(prBalance, prDcm) | |
245 | + | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
246 | + | let curPrice = f1(curPriceX18, scale8) | |
247 | + | let pmtLpAmtX18 = t1(pmtLpAmt, scale8) | |
248 | + | let lpEmissX18 = t1(lpEmiss, scale8) | |
249 | + | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
250 | + | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
251 | + | let outAmAmt = f1(outAmAmtX18, amDcm) | |
252 | + | let outPrAmt = f1(outPrAmtX18, prDcm) | |
263 | 253 | let state = if ((txId58 == "")) | |
264 | 254 | then nil | |
265 | - | else [ScriptTransfer(userAddress, | |
255 | + | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
266 | 256 | then unit | |
267 | - | else fromBase58String( | |
257 | + | else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES")) | |
268 | 258 | then unit | |
269 | - | else fromBase58String( | |
270 | - | $Tuple10( | |
259 | + | 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)] | |
260 | + | $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state) | |
271 | 261 | } | |
272 | - | else throw("Strict value is not equal to itself.") | |
273 | 262 | } | |
274 | 263 | ||
275 | 264 | ||
276 | - | func | |
277 | - | let cfg = | |
278 | - | let | |
279 | - | let | |
280 | - | let | |
281 | - | let | |
282 | - | let | |
283 | - | let | |
284 | - | let | |
265 | + | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
266 | + | let cfg = gpc() | |
267 | + | let lpId = fromBase58String(cfg[idxLPAsId]) | |
268 | + | let amIdStr = cfg[idxAmAsId] | |
269 | + | let prIdStr = cfg[idxPrAsId] | |
270 | + | let inAmIdStr = cfg[idxIAmtAsId] | |
271 | + | let inPrIdStr = cfg[idxIPriceAsId] | |
272 | + | let amtDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
273 | + | let priceDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
285 | 274 | let sts = cfg[idxPoolSt] | |
286 | - | let | |
287 | - | let | |
288 | - | then getAccBalance( | |
275 | + | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
276 | + | let amBalance = if (isEval) | |
277 | + | then getAccBalance(amIdStr) | |
289 | 278 | else if (if (isOneAsset) | |
290 | - | then ( | |
279 | + | then (pmtId == amIdStr) | |
291 | 280 | else false) | |
292 | - | then (getAccBalance( | |
281 | + | then (getAccBalance(amIdStr) - pmtAmt) | |
293 | 282 | else if (isOneAsset) | |
294 | - | then getAccBalance( | |
295 | - | else (getAccBalance( | |
296 | - | let | |
297 | - | then getAccBalance( | |
283 | + | then getAccBalance(amIdStr) | |
284 | + | else (getAccBalance(amIdStr) - inAmAmt) | |
285 | + | let prBalance = if (isEval) | |
286 | + | then getAccBalance(prIdStr) | |
298 | 287 | else if (if (isOneAsset) | |
299 | - | then ( | |
288 | + | then (pmtId == prIdStr) | |
300 | 289 | else false) | |
301 | - | then (getAccBalance( | |
290 | + | then (getAccBalance(prIdStr) - pmtAmt) | |
302 | 291 | else if (isOneAsset) | |
303 | - | then getAccBalance(priceIdStr) | |
304 | - | else (getAccBalance(priceIdStr) - inPriceAssetAmount) | |
305 | - | let amountBalanceDefaultDecimals = fraction(amountBalance, defaultDecimals, amountDecimals) | |
306 | - | let priceBalanceDefaultDecimals = fraction(priceBalance, defaultDecimals, priceDecimals) | |
307 | - | let inAmountAssetAmountDefaultDecimals = fraction(inAmountAssetAmount, defaultDecimals, amountDecimals) | |
308 | - | let inPriceAssetAmountDefaultDecimals = fraction(inPriceAssetAmount, defaultDecimals, priceDecimals) | |
309 | - | let inAmountAssetAmountX18 = toX18(inAmountAssetAmountDefaultDecimals, defaultDecimals) | |
310 | - | let inPriceAssetAmountX18 = toX18(inPriceAssetAmountDefaultDecimals, defaultDecimals) | |
311 | - | let userPriceX18 = calcPriceBigInt(inPriceAssetAmountX18, inAmountAssetAmountX18) | |
312 | - | let amountBalanceX18 = toX18(amountBalanceDefaultDecimals, defaultDecimals) | |
313 | - | let priceBalanceX18 = toX18(priceBalanceDefaultDecimals, defaultDecimals) | |
314 | - | let r = if ((lpEmission == 0)) | |
292 | + | then getAccBalance(prIdStr) | |
293 | + | else (getAccBalance(prIdStr) - inPrAmt) | |
294 | + | let inAmAssetAmtX18 = t1(inAmAmt, amtDcm) | |
295 | + | let inPrAssetAmtX18 = t1(inPrAmt, priceDcm) | |
296 | + | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
297 | + | let amBalanceX18 = t1(amBalance, amtDcm) | |
298 | + | let prBalanceX18 = t1(prBalance, priceDcm) | |
299 | + | let r = if ((lpEm == 0)) | |
315 | 300 | then { | |
316 | - | let | |
301 | + | let curPriceX18 = zeroBigInt | |
317 | 302 | let slippageX18 = zeroBigInt | |
318 | - | let | |
319 | - | $Tuple5( | |
303 | + | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
304 | + | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
320 | 305 | } | |
321 | 306 | else { | |
322 | - | let | |
323 | - | let slippageRealX18 = fraction(abs(( | |
324 | - | let slippageX18 = | |
325 | - | | |
307 | + | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
308 | + | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
309 | + | let slippageX18 = t1(slippage, scale8) | |
310 | + | if (if ((curPriceX18 != zeroBigInt)) | |
326 | 311 | then (slippageRealX18 > slippageX18) | |
327 | - | else false) == false)) | |
328 | - | then true | |
329 | - | else throwErr(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
330 | - | if ((validateSlippage == validateSlippage)) | |
331 | - | then { | |
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, defaultDecimals), fromX18(expectedPriceAssetAmountX18, defaultDecimals), currentPriceX18, slippageX18) | |
312 | + | else false) | |
313 | + | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
314 | + | else { | |
315 | + | let lpEmissionX18 = t1(lpEm, scale8) | |
316 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
317 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
318 | + | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
319 | + | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
320 | + | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
321 | + | let expAmtAssetAmtX18 = expectedAmts._1 | |
322 | + | let expPriceAssetAmtX18 = expectedAmts._2 | |
323 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
324 | + | $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18) | |
342 | 325 | } | |
343 | - | else throw("Strict value is not equal to itself.") | |
344 | 326 | } | |
345 | - | let calculateLpAmount = r._1 | |
346 | - | let calculateAmountAssetPayment = fraction(r._2, amountDecimals, defaultDecimals) | |
347 | - | let calculatePriceAssetPayment = fraction(r._3, priceDecimals, defaultDecimals) | |
348 | - | let currentPrice = fromX18(r._4, scale8) | |
349 | - | let slippageCalculate = fromX18(r._5, scale8) | |
350 | - | let checkCalcLpAmount = if ((calculateLpAmount > 0)) | |
351 | - | then true | |
352 | - | else throwErr("LP <= 0") | |
353 | - | if ((checkCalcLpAmount == checkCalcLpAmount)) | |
354 | - | then { | |
355 | - | let emitLpAmount = if (!(emitLp)) | |
327 | + | let calcLpAmt = r._1 | |
328 | + | let calcAmAssetPmt = r._2 | |
329 | + | let calcPrAssetPmt = r._3 | |
330 | + | let curPrice = f1(r._4, scale8) | |
331 | + | let slippageCalc = f1(r._5, scale8) | |
332 | + | if ((0 >= calcLpAmt)) | |
333 | + | then throw("LP <= 0") | |
334 | + | else { | |
335 | + | let emitLpAmt = if (!(emitLp)) | |
356 | 336 | then 0 | |
357 | - | else | |
358 | - | let | |
359 | - | let | |
360 | - | let $ | |
361 | - | then ( | |
337 | + | else calcLpAmt | |
338 | + | let amDiff = (inAmAmt - calcAmAssetPmt) | |
339 | + | let prDiff = (inPrAmt - calcPrAssetPmt) | |
340 | + | let $t01560115946 = if (if (isOneAsset) | |
341 | + | then (pmtId == amIdStr) | |
362 | 342 | else false) | |
363 | - | then $Tuple2( | |
343 | + | then $Tuple2(pmtAmt, 0) | |
364 | 344 | else if (if (isOneAsset) | |
365 | - | then ( | |
345 | + | then (pmtId == prIdStr) | |
366 | 346 | else false) | |
367 | - | then $Tuple2(0, | |
368 | - | else $Tuple2( | |
369 | - | let writeAmAmt = $ | |
370 | - | let writePrAmt = $ | |
371 | - | let commonState = [IntegerEntry( | |
372 | - | $Tuple13( | |
347 | + | then $Tuple2(0, pmtAmt) | |
348 | + | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
349 | + | let writeAmAmt = $t01560115946._1 | |
350 | + | let writePrAmt = $t01560115946._2 | |
351 | + | 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))] | |
352 | + | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
373 | 353 | } | |
374 | - | else throw("Strict value is not equal to itself.") | |
375 | 354 | } | |
376 | 355 | ||
377 | 356 | ||
378 | - | func | |
379 | - | let cfg = | |
357 | + | func moa (order) = { | |
358 | + | let cfg = gpc() | |
380 | 359 | let amtAsId = cfg[idxAmAsId] | |
381 | 360 | let prAsId = cfg[idxPrAsId] | |
382 | 361 | let sts = parseIntValue(cfg[idxPoolSt]) | |
384 | 363 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
385 | 364 | let accAmtAsBalance = getAccBalance(amtAsId) | |
386 | 365 | let accPrAsBalance = getAccBalance(prAsId) | |
387 | - | let | |
388 | - | then | |
389 | - | else | |
390 | - | let curPrice = | |
391 | - | if (if (if ( | |
366 | + | let curPriceX18 = if ((order.orderType == Buy)) | |
367 | + | then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance) | |
368 | + | else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance) | |
369 | + | let curPrice = f1(curPriceX18, scale8) | |
370 | + | if (if (if (igs()) | |
392 | 371 | then true | |
393 | 372 | else (sts == PoolMatcherDis)) | |
394 | 373 | then true | |
395 | 374 | else (sts == PoolShutdown)) | |
396 | - | then | |
375 | + | then throw("Admin blocked") | |
397 | 376 | else { | |
398 | 377 | let orAmtAsset = order.assetPair.amountAsset | |
399 | 378 | let orAmtAsStr = if ((orAmtAsset == unit)) | |
406 | 385 | if (if ((orAmtAsStr != amtAsId)) | |
407 | 386 | then true | |
408 | 387 | else (orPrAsStr != prAsId)) | |
409 | - | then | |
388 | + | then throw("Wr assets") | |
410 | 389 | else { | |
411 | 390 | let orderPrice = order.price | |
412 | - | let | |
413 | - | let castOrderPrice = ts(orderPrice, scale8, | |
391 | + | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
392 | + | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
414 | 393 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
415 | 394 | then (curPrice >= castOrderPrice) | |
416 | 395 | else (castOrderPrice >= curPrice) | |
420 | 399 | } | |
421 | 400 | ||
422 | 401 | ||
423 | - | func commonGet (i) = { | |
424 | - | let checkPayments = if ((size(i.payments) == 1)) | |
425 | - | then true | |
426 | - | else throwErr("1 payment expected") | |
427 | - | if ((checkPayments == checkPayments)) | |
428 | - | then { | |
429 | - | let payment = value(i.payments[0]) | |
430 | - | let paymentAssetId = value(payment.assetId) | |
431 | - | let paymentAmount = payment.amount | |
432 | - | let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(paymentAssetId), paymentAmount, i.caller) | |
433 | - | let outAmountAmount = r._1 | |
434 | - | let outPriceAmount = r._2 | |
435 | - | let sts = parseIntValue(r._9) | |
436 | - | let state = r._10 | |
437 | - | if (if (isGlobalShutdown()) | |
438 | - | then true | |
439 | - | else (sts == PoolShutdown)) | |
440 | - | then throwErr(("Admin blocked: " + toString(sts))) | |
441 | - | else $Tuple5(outAmountAmount, outPriceAmount, paymentAmount, paymentAssetId, state) | |
442 | - | } | |
443 | - | else throw("Strict value is not equal to itself.") | |
444 | - | } | |
402 | + | func cg (i) = if ((size(i.payments) != 1)) | |
403 | + | then throw("1 pmnt exp") | |
404 | + | else { | |
405 | + | let pmt = value(i.payments[0]) | |
406 | + | let pmtAssetId = value(pmt.assetId) | |
407 | + | let pmtAmt = pmt.amount | |
408 | + | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
409 | + | let outAmAmt = r._1 | |
410 | + | let outPrAmt = r._2 | |
411 | + | let sts = parseIntValue(r._9) | |
412 | + | let state = r._10 | |
413 | + | if (if (igs()) | |
414 | + | then true | |
415 | + | else (sts == PoolShutdown)) | |
416 | + | then throw(("Admin blocked: " + toString(sts))) | |
417 | + | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
418 | + | } | |
445 | 419 | ||
446 | 420 | ||
447 | - | func | |
448 | - | let r = | |
421 | + | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
422 | + | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, pmtAmt, pmtId) | |
449 | 423 | let sts = parseIntValue(r._8) | |
450 | - | if (if (if ( | |
424 | + | if (if (if (igs()) | |
451 | 425 | then true | |
452 | 426 | else (sts == PoolPutDis)) | |
453 | 427 | then true | |
454 | 428 | else (sts == PoolShutdown)) | |
455 | - | then | |
429 | + | then throw(("Blocked:" + toString(sts))) | |
456 | 430 | else r | |
457 | 431 | } | |
458 | 432 | ||
459 | 433 | ||
460 | - | func takeFee (amount) = { | |
461 | - | let fee = fraction(amount, feePermille, thousand) | |
462 | - | $Tuple2((amount - fee), fee) | |
463 | - | } | |
464 | - | ||
465 | - | ||
466 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
434 | + | func m () = match getString(mpk()) { | |
467 | 435 | case s: String => | |
468 | 436 | fromBase58String(s) | |
469 | 437 | case _: Unit => | |
473 | 441 | } | |
474 | 442 | ||
475 | 443 | ||
476 | - | func | |
444 | + | func pm () = match getString(pmpk()) { | |
477 | 445 | case s: String => | |
478 | 446 | fromBase58String(s) | |
479 | 447 | case _: Unit => | |
483 | 451 | } | |
484 | 452 | ||
485 | 453 | ||
486 | - | let pd = | |
454 | + | let pd = throw("Permission denied") | |
487 | 455 | ||
488 | - | func | |
456 | + | func mm (i) = match m() { | |
489 | 457 | case pk: ByteVector => | |
490 | 458 | if ((i.callerPublicKey == pk)) | |
491 | 459 | then true | |
500 | 468 | ||
501 | 469 | ||
502 | 470 | @Callable(i) | |
503 | - | func constructor ( | |
504 | - | let | |
505 | - | if (( | |
506 | - | then [StringEntry( | |
471 | + | func constructor (fc) = { | |
472 | + | let c = mm(i) | |
473 | + | if ((c == c)) | |
474 | + | then [StringEntry(fc(), fc)] | |
507 | 475 | else throw("Strict value is not equal to itself.") | |
508 | 476 | } | |
509 | 477 | ||
511 | 479 | ||
512 | 480 | @Callable(i) | |
513 | 481 | func setManager (pendingManagerPublicKey) = { | |
514 | - | let | |
515 | - | if (( | |
482 | + | let c = mm(i) | |
483 | + | if ((c == c)) | |
516 | 484 | then { | |
517 | - | let | |
518 | - | if (( | |
519 | - | then [StringEntry( | |
485 | + | let cm = fromBase58String(pendingManagerPublicKey) | |
486 | + | if ((cm == cm)) | |
487 | + | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
520 | 488 | else throw("Strict value is not equal to itself.") | |
521 | 489 | } | |
522 | 490 | else throw("Strict value is not equal to itself.") | |
526 | 494 | ||
527 | 495 | @Callable(i) | |
528 | 496 | func confirmManager () = { | |
529 | - | let | |
530 | - | let | |
497 | + | let p = pm() | |
498 | + | let hpm = if (isDefined(p)) | |
531 | 499 | then true | |
532 | - | else | |
533 | - | if (( | |
500 | + | else throw("No pending manager") | |
501 | + | if ((hpm == hpm)) | |
534 | 502 | then { | |
535 | - | let | |
503 | + | let cpm = if ((i.callerPublicKey == value(p))) | |
536 | 504 | then true | |
537 | - | else | |
538 | - | if (( | |
539 | - | then [StringEntry( | |
505 | + | else throw("You are not pending manager") | |
506 | + | if ((cpm == cpm)) | |
507 | + | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
540 | 508 | else throw("Strict value is not equal to itself.") | |
541 | 509 | } | |
542 | 510 | else throw("Strict value is not equal to itself.") | |
545 | 513 | ||
546 | 514 | ||
547 | 515 | @Callable(i) | |
548 | - | func put (slippage,autoStake) = { | |
549 | - | let factCfg = getFactoryConfig() | |
550 | - | let stakingContract = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wrong staking contract") | |
551 | - | let slippageContract = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wrogn slippage contract") | |
552 | - | let slippageCheck = if ((slippage >= 0)) | |
553 | - | then true | |
554 | - | else throwErr("wrong slippage") | |
555 | - | if ((slippageCheck == slippageCheck)) | |
556 | - | then { | |
557 | - | let paymentsCheck = if ((size(i.payments) == 2)) | |
558 | - | then true | |
559 | - | else throwErr("2 payments expected") | |
560 | - | if ((paymentsCheck == paymentsCheck)) | |
561 | - | then { | |
562 | - | 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, "") | |
563 | - | let emitLpAmount = estimatePut._2 | |
564 | - | let lpAssetId = estimatePut._7 | |
565 | - | let state = estimatePut._9 | |
566 | - | let amountDiff = estimatePut._10 | |
567 | - | let priceDiff = estimatePut._11 | |
568 | - | let amountId = estimatePut._12 | |
569 | - | let priceId = estimatePut._13 | |
570 | - | let r = invoke(factoryContract, "emit", [emitLpAmount], nil) | |
571 | - | if ((r == r)) | |
572 | - | then { | |
573 | - | let el = match r { | |
574 | - | case legacy: Address => | |
575 | - | invoke(legacy, "emit", [emitLpAmount], nil) | |
576 | - | case _ => | |
577 | - | unit | |
578 | - | } | |
579 | - | if ((el == el)) | |
516 | + | func put (slip,autoStake) = { | |
517 | + | let factCfg = gfc() | |
518 | + | let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr") | |
519 | + | let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr") | |
520 | + | if ((0 > slip)) | |
521 | + | then throw("Wrong slippage") | |
522 | + | else if ((size(i.payments) != 2)) | |
523 | + | then throw("2 pmnts expd") | |
524 | + | else { | |
525 | + | 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, "") | |
526 | + | let emitLpAmt = e._2 | |
527 | + | let lpAssetId = e._7 | |
528 | + | let state = e._9 | |
529 | + | let amDiff = e._10 | |
530 | + | let prDiff = e._11 | |
531 | + | let amId = e._12 | |
532 | + | let prId = e._13 | |
533 | + | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
534 | + | if ((r == r)) | |
535 | + | then { | |
536 | + | let el = match r { | |
537 | + | case legacy: Address => | |
538 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
539 | + | case _ => | |
540 | + | unit | |
541 | + | } | |
542 | + | if ((el == el)) | |
543 | + | then { | |
544 | + | let sa = if ((amDiff > 0)) | |
545 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
546 | + | else nil | |
547 | + | if ((sa == sa)) | |
548 | + | then { | |
549 | + | let sp = if ((prDiff > 0)) | |
550 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
551 | + | else nil | |
552 | + | if ((sp == sp)) | |
553 | + | then { | |
554 | + | let lpTrnsfr = if (autoStake) | |
555 | + | then { | |
556 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
557 | + | if ((ss == ss)) | |
558 | + | then nil | |
559 | + | else throw("Strict value is not equal to itself.") | |
560 | + | } | |
561 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
562 | + | (state ++ lpTrnsfr) | |
563 | + | } | |
564 | + | else throw("Strict value is not equal to itself.") | |
565 | + | } | |
566 | + | else throw("Strict value is not equal to itself.") | |
567 | + | } | |
568 | + | else throw("Strict value is not equal to itself.") | |
569 | + | } | |
570 | + | else throw("Strict value is not equal to itself.") | |
571 | + | } | |
572 | + | } | |
573 | + | ||
574 | + | ||
575 | + | ||
576 | + | @Callable(i) | |
577 | + | func putOneTkn (amAssetPart,prAssetPart,outLp,slippage,autoStake) = { | |
578 | + | let cfg = gfc() | |
579 | + | let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr") | |
580 | + | let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr") | |
581 | + | let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr") | |
582 | + | let poolCfg = gpc() | |
583 | + | let amId = poolCfg[idxAmAsId] | |
584 | + | let prId = poolCfg[idxPrAsId] | |
585 | + | let amDcm = parseIntValue(poolCfg[idxAmtAsDcm]) | |
586 | + | let prDcm = parseIntValue(poolCfg[idxPriceAsDcm]) | |
587 | + | let addon = valueOrElse(getString(this, ada()), "") | |
588 | + | let userAddress = if ((addon == toString(i.caller))) | |
589 | + | then i.originCaller | |
590 | + | else i.caller | |
591 | + | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
592 | + | let check = reentrantInvoke(addonContract, "ensureCanPutOneTkn", [toString(userAddress)], nil) | |
593 | + | if ((check == check)) | |
594 | + | then if (if (if (if ((0 >= slippage)) | |
595 | + | then true | |
596 | + | else (0 >= amAssetPart)) | |
597 | + | then true | |
598 | + | else (0 >= prAssetPart)) | |
599 | + | then true | |
600 | + | else (0 >= outLp)) | |
601 | + | then throw("Wrong params") | |
602 | + | else if ((size(i.payments) != 1)) | |
603 | + | then throw("1 pmnt expd") | |
604 | + | else { | |
605 | + | let pmt = value(i.payments[0]) | |
606 | + | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
607 | + | let pmtAmt = pmt.amount | |
608 | + | if ((10000000 > pmtAmt)) | |
609 | + | then throw("Wrong pmt amt") | |
610 | + | else { | |
611 | + | let amBalance = getAccBalance(amId) | |
612 | + | let prBalance = getAccBalance(prId) | |
613 | + | let $t02485925435 = if ((pmtAssetId == amId)) | |
614 | + | then if (if ((pmtAmt > amBalance)) | |
615 | + | then true | |
616 | + | else (amAssetPart > pmtAmt)) | |
617 | + | then throw("invalid payment amount") | |
618 | + | else $Tuple6((amBalance - pmtAmt), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
619 | + | else if ((pmtAssetId == prId)) | |
620 | + | then if (if ((pmtAmt > prBalance)) | |
621 | + | then true | |
622 | + | else (prAssetPart > pmtAmt)) | |
623 | + | then throw("invalid payment amount") | |
624 | + | else $Tuple6(amBalance, (prBalance - pmtAmt), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
625 | + | else throw("wrong pmtAssetId") | |
626 | + | let amBalanceNow = $t02485925435._1 | |
627 | + | let prBalanceNow = $t02485925435._2 | |
628 | + | let virtSwapInAm = $t02485925435._3 | |
629 | + | let virtSwapOutPr = $t02485925435._4 | |
630 | + | let virtSwapInPr = $t02485925435._5 | |
631 | + | let virtSwapOutAm = $t02485925435._6 | |
632 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
633 | + | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
634 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
635 | + | if ((D0vsD1 == D0vsD1)) | |
580 | 636 | then { | |
581 | - | let sa = if ((amountDiff > 0)) | |
582 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amountId, amountDiff)]) | |
583 | - | else nil | |
584 | - | if ((sa == sa)) | |
637 | + | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
638 | + | let estimLP = estPut._2 | |
639 | + | let lpAssetId = estPut._7 | |
640 | + | let state = estPut._9 | |
641 | + | let amDiff = estPut._10 | |
642 | + | let prDiff = estPut._11 | |
643 | + | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
644 | + | let emitLpAmt = toInt(lpCalcRes._2) | |
645 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
646 | + | if ((e == e)) | |
585 | 647 | then { | |
586 | - | let sp = if ((priceDiff > 0)) | |
587 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(priceId, priceDiff)]) | |
588 | - | else nil | |
589 | - | if ((sp == sp)) | |
648 | + | let el = match e { | |
649 | + | case legacy: Address => | |
650 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
651 | + | case _ => | |
652 | + | unit | |
653 | + | } | |
654 | + | if ((el == el)) | |
590 | 655 | then { | |
591 | - | let lpTrasfer = if (autoStake) | |
656 | + | let sa = if ((amDiff > 0)) | |
657 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
658 | + | else nil | |
659 | + | if ((sa == sa)) | |
592 | 660 | then { | |
593 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmount)]) | |
594 | - | if ((ss == ss)) | |
595 | - | then nil | |
661 | + | let sp = if ((prDiff > 0)) | |
662 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
663 | + | else nil | |
664 | + | if ((sp == sp)) | |
665 | + | then { | |
666 | + | let lpTrnsfr = if (autoStake) | |
667 | + | then { | |
668 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
669 | + | if ((ss == ss)) | |
670 | + | then nil | |
671 | + | else throw("Strict value is not equal to itself.") | |
672 | + | } | |
673 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
674 | + | (state ++ lpTrnsfr) | |
675 | + | } | |
596 | 676 | else throw("Strict value is not equal to itself.") | |
597 | 677 | } | |
598 | - | else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)] | |
599 | - | (state ++ lpTrasfer) | |
678 | + | else throw("Strict value is not equal to itself.") | |
600 | 679 | } | |
601 | 680 | else throw("Strict value is not equal to itself.") | |
602 | 681 | } | |
604 | 683 | } | |
605 | 684 | else throw("Strict value is not equal to itself.") | |
606 | 685 | } | |
607 | - | else throw("Strict value is not equal to itself.") | |
608 | 686 | } | |
609 | - | else throw("Strict value is not equal to itself.") | |
610 | - | } | |
611 | 687 | else throw("Strict value is not equal to itself.") | |
612 | 688 | } | |
613 | 689 | ||
614 | 690 | ||
615 | 691 | ||
616 | 692 | @Callable(i) | |
617 | - | func putOneTkn (amountAssetPart,priceAssetPart,outLp,slippage,autoStake) = { | |
618 | - | let cfg = getFactoryConfig() | |
619 | - | let stakingContract = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wrong staking contract") | |
620 | - | let slippageContract = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wrong slippage contract") | |
621 | - | let gwxRewardContract = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wrong gwx reward contract") | |
622 | - | let poolCfg = getPoolConfig() | |
623 | - | let amountId = poolCfg[idxAmAsId] | |
624 | - | let priceId = poolCfg[idxPrAsId] | |
625 | - | let amountDecimals = parseIntValue(poolCfg[idxAmtAsDcm]) | |
626 | - | let priceDecimals = parseIntValue(poolCfg[idxPriceAsDcm]) | |
627 | - | let addon = valueOrElse(getString(this, keyAddonAddress()), "") | |
628 | - | let userAddress = if ((addon == toString(i.caller))) | |
629 | - | then i.originCaller | |
630 | - | else i.caller | |
631 | - | if (if (if (if ((0 >= slippage)) | |
632 | - | then true | |
633 | - | else (0 >= amountAssetPart)) | |
634 | - | then true | |
635 | - | else (0 >= priceAssetPart)) | |
636 | - | then true | |
637 | - | else (0 >= outLp)) | |
638 | - | then throwErr("Wrong params") | |
639 | - | else if ((size(i.payments) != 1)) | |
640 | - | then throwErr("1 payment expected") | |
641 | - | else { | |
642 | - | let payment = value(i.payments[0]) | |
643 | - | let paymentAssetId = toBase58String(value(payment.assetId)) | |
644 | - | let paymentAmountRaw = payment.amount | |
645 | - | let $t02656926628 = takeFee(paymentAmountRaw) | |
646 | - | let paymentAmount = $t02656926628._1 | |
647 | - | let feeAmount = $t02656926628._2 | |
648 | - | if (if (if ((amountAssetPart > paymentAmount)) | |
649 | - | then true | |
650 | - | else (priceAssetPart > paymentAmount)) | |
651 | - | then true | |
652 | - | else (10000000 > paymentAmount)) | |
653 | - | then throwErr("wrong payment amount") | |
654 | - | else { | |
655 | - | let amountBalance = getAccBalance(amountId) | |
656 | - | let priceBalance = getAccBalance(priceId) | |
657 | - | let $t02689327348 = if ((paymentAssetId == amountId)) | |
658 | - | then $Tuple6((amountBalance - paymentAmount), priceBalance, (paymentAmount - amountAssetPart), priceAssetPart, 0, 0) | |
659 | - | else if ((paymentAssetId == priceId)) | |
660 | - | then $Tuple6(amountBalance, (priceBalance - paymentAmount), 0, 0, (paymentAmount - priceAssetPart), amountAssetPart) | |
661 | - | else throwErr("wrong paymentAssetId") | |
662 | - | let amountBalanceNow = $t02689327348._1 | |
663 | - | let priceBalanceNow = $t02689327348._2 | |
664 | - | let virtSwapInAm = $t02689327348._3 | |
665 | - | let virtSwapOutPr = $t02689327348._4 | |
666 | - | let virtSwapInPr = $t02689327348._5 | |
667 | - | let virtSwapOutAm = $t02689327348._6 | |
668 | - | let D0 = invoke(gwxRewardContract, "calcD", [toString(amountBalanceNow), toString(priceBalanceNow), amplificator, Amult, Dconv], nil) | |
669 | - | let D1 = invoke(gwxRewardContract, "calcD", [toString(toBigInt(((amountBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((priceBalanceNow + virtSwapInPr) - virtSwapOutPr))), amplificator, Amult, Dconv], nil) | |
670 | - | let D0vsD1 = validateD(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
671 | - | if ((D0vsD1 == D0vsD1)) | |
672 | - | then { | |
673 | - | let estimatePut = commonPut(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amountId), amountAssetPart), AttachedPayment(fromBase58String(priceId), priceAssetPart), slippage, true, true, paymentAmount, paymentAssetId) | |
674 | - | let estimateLP = estimatePut._2 | |
675 | - | let lpAssetId = estimatePut._7 | |
676 | - | let state = estimatePut._9 | |
677 | - | let amountDiff = estimatePut._10 | |
678 | - | let priceDiff = estimatePut._11 | |
679 | - | let lpCalcRes = validateAbsDiff(toBigInt(estimateLP), toBigInt(outLp), toBigInt(slippage)) | |
680 | - | let emitLpAmount = toInt(lpCalcRes._2) | |
681 | - | let e = invoke(factoryContract, "emit", [emitLpAmount], nil) | |
682 | - | if ((e == e)) | |
683 | - | then { | |
684 | - | let el = match e { | |
685 | - | case legacy: Address => | |
686 | - | invoke(legacy, "emit", [emitLpAmount], nil) | |
687 | - | case _ => | |
688 | - | unit | |
689 | - | } | |
690 | - | if ((el == el)) | |
691 | - | then { | |
692 | - | let sa = if ((amountDiff > 0)) | |
693 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(fromBase58String(amountId), amountDiff)]) | |
694 | - | else nil | |
695 | - | if ((sa == sa)) | |
696 | - | then { | |
697 | - | let sp = if ((priceDiff > 0)) | |
698 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(fromBase58String(priceId), priceDiff)]) | |
699 | - | else nil | |
700 | - | if ((sp == sp)) | |
701 | - | then { | |
702 | - | let lpTrasfer = if (autoStake) | |
703 | - | then { | |
704 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmount)]) | |
705 | - | if ((ss == ss)) | |
706 | - | then nil | |
707 | - | else throw("Strict value is not equal to itself.") | |
708 | - | } | |
709 | - | else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)] | |
710 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
711 | - | then [ScriptTransfer(matcherAddress, feeAmount, fromBase58String(paymentAssetId))] | |
712 | - | else nil | |
713 | - | ((state ++ lpTrasfer) ++ sendFeeToMatcher) | |
714 | - | } | |
715 | - | else throw("Strict value is not equal to itself.") | |
716 | - | } | |
717 | - | else throw("Strict value is not equal to itself.") | |
718 | - | } | |
719 | - | else throw("Strict value is not equal to itself.") | |
720 | - | } | |
721 | - | else throw("Strict value is not equal to itself.") | |
722 | - | } | |
723 | - | else throw("Strict value is not equal to itself.") | |
724 | - | } | |
725 | - | } | |
726 | - | } | |
727 | - | ||
728 | - | ||
729 | - | ||
730 | - | @Callable(i) | |
731 | - | func putForFree (maxslippage) = if ((0 > maxslippage)) | |
732 | - | then throwErr("wrong slippage") | |
693 | + | func putForFree (maxSlpg) = if ((0 > maxSlpg)) | |
694 | + | then throw("Wrong slpg") | |
733 | 695 | else if ((size(i.payments) != 2)) | |
734 | - | then | |
696 | + | then throw("2 pmnts expd") | |
735 | 697 | else { | |
736 | - | let | |
737 | - | | |
698 | + | 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, "") | |
699 | + | estPut._9 | |
738 | 700 | } | |
739 | 701 | ||
740 | 702 | ||
741 | 703 | ||
742 | 704 | @Callable(i) | |
743 | 705 | func get () = { | |
744 | - | let r = | |
706 | + | let r = cg(i) | |
745 | 707 | let outAmtAmt = r._1 | |
746 | - | let | |
747 | - | let | |
748 | - | let | |
708 | + | let outPrAmt = r._2 | |
709 | + | let pmtAmt = r._3 | |
710 | + | let pmtAssetId = r._4 | |
749 | 711 | let state = r._5 | |
750 | - | let b = invoke( | |
712 | + | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
751 | 713 | if ((b == b)) | |
752 | 714 | then state | |
753 | 715 | else throw("Strict value is not equal to itself.") | |
757 | 719 | ||
758 | 720 | @Callable(i) | |
759 | 721 | func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1)) | |
760 | - | then | |
722 | + | then throw("1 pmnt expd") | |
761 | 723 | else { | |
762 | - | let cfg = | |
763 | - | let | |
764 | - | let | |
765 | - | let | |
766 | - | let | |
767 | - | let | |
724 | + | let cfg = gpc() | |
725 | + | let lpId = cfg[idxLPAsId] | |
726 | + | let amId = cfg[idxAmAsId] | |
727 | + | let prId = cfg[idxPrAsId] | |
728 | + | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
729 | + | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
768 | 730 | let sts = cfg[idxPoolSt] | |
769 | - | let factCfg = | |
770 | - | let | |
771 | - | let | |
772 | - | let addon = valueOrElse(getString(this, | |
731 | + | let factCfg = gfc() | |
732 | + | let gwxCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wr sl addr") | |
733 | + | let pmt = value(i.payments[0]) | |
734 | + | let addon = valueOrElse(getString(this, ada()), "") | |
773 | 735 | let userAddress = if ((addon == toString(i.caller))) | |
774 | 736 | then i.originCaller | |
775 | 737 | else i.caller | |
776 | 738 | let txId58 = toBase58String(i.transactionId) | |
777 | - | let paymentAssetId = value(payment.assetId) | |
778 | - | let paymentAmount = payment.amount | |
779 | - | if ((1000000000 > paymentAmount)) | |
780 | - | then throwErr("Min payment 10 LP") | |
781 | - | else if (if (if ((0 > slippage)) | |
782 | - | then true | |
783 | - | else (0 > exchResult)) | |
784 | - | then true | |
785 | - | else (0 > outAmount)) | |
786 | - | then throwErr("Wrong params") | |
787 | - | else if ((lpAssetId != toBase58String(paymentAssetId))) | |
788 | - | then throwErr("Wrong LP") | |
789 | - | else { | |
790 | - | let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(paymentAssetId), paymentAmount, i.caller) | |
791 | - | let estimAmAmt = r._1 | |
792 | - | let estimPrAmt = r._2 | |
793 | - | let amountBalance = getAccBalance(amountId) | |
794 | - | let priceBalance = getAccBalance(priceId) | |
795 | - | let $t03249632964 = if ((outAssetId == amountId)) | |
796 | - | then $Tuple7((amountBalance - estimAmAmt), (priceBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
797 | - | else if ((outAssetId == priceId)) | |
798 | - | then $Tuple7((amountBalance - estimAmAmt), (priceBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
799 | - | else throwErr("wrong outAssetId") | |
800 | - | let amountBalanceNow = $t03249632964._1 | |
801 | - | let priceBalanceNow = $t03249632964._2 | |
802 | - | let virtSwapInAm = $t03249632964._3 | |
803 | - | let virtSwapOutPr = $t03249632964._4 | |
804 | - | let virtSwapInPr = $t03249632964._5 | |
805 | - | let virtSwapOutAm = $t03249632964._6 | |
806 | - | let totalGet = $t03249632964._7 | |
807 | - | if (if ((0 > virtSwapInAm)) | |
808 | - | then true | |
809 | - | else (0 > virtSwapInPr)) | |
810 | - | then throwErr("Wrong calc") | |
811 | - | else { | |
812 | - | let D0 = invoke(gwxRewardContract, "calcD", [toString(amountBalanceNow), toString(priceBalanceNow), amplificator, Amult, Dconv], nil) | |
813 | - | let D1 = invoke(gwxRewardContract, "calcD", [toString(((amountBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((priceBalanceNow + virtSwapOutPr) - virtSwapInPr)), amplificator, Amult, Dconv], nil) | |
814 | - | let D0vsD1 = validateD(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
815 | - | if ((D0vsD1 == D0vsD1)) | |
816 | - | then { | |
817 | - | let finalRes = validateAbsDiff(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
818 | - | if ((finalRes == finalRes)) | |
819 | - | then { | |
820 | - | let $t03363333741 = if ((outAssetId == amountId)) | |
821 | - | then $Tuple2(toInt(finalRes._2), 0) | |
822 | - | else $Tuple2(0, toInt(finalRes._2)) | |
823 | - | let outAm = $t03363333741._1 | |
824 | - | let outPr = $t03363333741._2 | |
825 | - | let totalAmountRaw = (outAm + outPr) | |
826 | - | let $t03378133836 = takeFee(totalAmountRaw) | |
827 | - | let totalAmount = $t03378133836._1 | |
828 | - | let feeAmount = $t03378133836._2 | |
829 | - | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
830 | - | then unit | |
831 | - | else fromBase58String(outAssetId) | |
832 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
833 | - | then [ScriptTransfer(matcherAddress, feeAmount, outAssetIdOrWaves)] | |
834 | - | else nil | |
835 | - | let decimals = if ((amountDecimals >= priceDecimals)) | |
836 | - | then amountDecimals | |
837 | - | else priceDecimals | |
838 | - | if ((decimals == decimals)) | |
839 | - | then { | |
840 | - | let curPrX18 = calcPriceBigInt(toX18(priceBalance, decimals), toX18(amountBalance, decimals)) | |
841 | - | let curPr = fromX18(curPrX18, scale8) | |
842 | - | 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)] | |
843 | - | if ((state == state)) | |
844 | - | then { | |
845 | - | let burn = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
846 | - | if ((burn == burn)) | |
847 | - | then (state ++ sendFeeToMatcher) | |
848 | - | else throw("Strict value is not equal to itself.") | |
849 | - | } | |
850 | - | else throw("Strict value is not equal to itself.") | |
851 | - | } | |
852 | - | else throw("Strict value is not equal to itself.") | |
853 | - | } | |
854 | - | else throw("Strict value is not equal to itself.") | |
855 | - | } | |
856 | - | else throw("Strict value is not equal to itself.") | |
857 | - | } | |
858 | - | } | |
739 | + | let pmtAssetId = value(pmt.assetId) | |
740 | + | let pmtAmt = pmt.amount | |
741 | + | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
742 | + | let check = reentrantInvoke(addonContract, "ensureCanGetOneTkn", [toString(userAddress)], nil) | |
743 | + | if ((check == check)) | |
744 | + | then if ((1000000000 > pmtAmt)) | |
745 | + | then throw("Min pmt 10 LP") | |
746 | + | else if (if (if ((0 > slippage)) | |
747 | + | then true | |
748 | + | else (0 > exchResult)) | |
749 | + | then true | |
750 | + | else (0 > outAmount)) | |
751 | + | then throw("Wrong params") | |
752 | + | else if ((lpId != toBase58String(pmtAssetId))) | |
753 | + | then throw("Wrong LP") | |
754 | + | else { | |
755 | + | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
756 | + | let estimAmAmt = r._1 | |
757 | + | let estimPrAmt = r._2 | |
758 | + | let amBalance = getAccBalance(amId) | |
759 | + | let prBalance = getAccBalance(prId) | |
760 | + | let $t03046630923 = if ((outAssetId == amId)) | |
761 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
762 | + | else if ((outAssetId == prId)) | |
763 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
764 | + | else throw("wrong outAssetId") | |
765 | + | let amBalanceNow = $t03046630923._1 | |
766 | + | let prBalanceNow = $t03046630923._2 | |
767 | + | let virtSwapInAm = $t03046630923._3 | |
768 | + | let virtSwapOutPr = $t03046630923._4 | |
769 | + | let virtSwapInPr = $t03046630923._5 | |
770 | + | let virtSwapOutAm = $t03046630923._6 | |
771 | + | let totalGet = $t03046630923._7 | |
772 | + | if (if ((0 > virtSwapInAm)) | |
773 | + | then true | |
774 | + | else (0 > virtSwapInPr)) | |
775 | + | then throw("Wrong calc") | |
776 | + | else { | |
777 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
778 | + | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
779 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
780 | + | if ((D0vsD1 == D0vsD1)) | |
781 | + | then { | |
782 | + | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
783 | + | if ((finalRes == finalRes)) | |
784 | + | then { | |
785 | + | let $t03162831732 = if ((outAssetId == amId)) | |
786 | + | then $Tuple2(toInt(finalRes._2), 0) | |
787 | + | else $Tuple2(0, toInt(finalRes._2)) | |
788 | + | let outAm = $t03162831732._1 | |
789 | + | let outPr = $t03162831732._2 | |
790 | + | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
791 | + | let curPr = f1(curPrX18, scale8) | |
792 | + | let state = [ScriptTransfer(userAddress, (outAm + outPr), if ((outAssetId == "WAVES")) | |
793 | + | then unit | |
794 | + | 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)] | |
795 | + | if ((state == state)) | |
796 | + | then { | |
797 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
798 | + | if ((burn == burn)) | |
799 | + | then state | |
800 | + | else throw("Strict value is not equal to itself.") | |
801 | + | } | |
802 | + | else throw("Strict value is not equal to itself.") | |
803 | + | } | |
804 | + | else throw("Strict value is not equal to itself.") | |
805 | + | } | |
806 | + | else throw("Strict value is not equal to itself.") | |
807 | + | } | |
808 | + | } | |
809 | + | else throw("Strict value is not equal to itself.") | |
859 | 810 | } | |
860 | 811 | ||
861 | 812 | ||
862 | 813 | ||
863 | 814 | @Callable(i) | |
864 | 815 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
865 | - | let r = | |
866 | - | let | |
867 | - | let | |
868 | - | let | |
869 | - | let | |
816 | + | let r = cg(i) | |
817 | + | let outAmAmt = r._1 | |
818 | + | let outPrAmt = r._2 | |
819 | + | let pmtAmt = r._3 | |
820 | + | let pmtAssetId = r._4 | |
870 | 821 | let state = r._5 | |
871 | - | let checkOutAmountAmount = if ((outAmountAmount >= noLessThenAmtAsset)) | |
872 | - | then true | |
873 | - | else throwErr(((("Failed: " + toString(outAmountAmount)) + " < ") + toString(noLessThenAmtAsset))) | |
874 | - | if ((checkOutAmountAmount == checkOutAmountAmount)) | |
875 | - | then { | |
876 | - | let checkOutPriceAmount = if ((outPriceAmount >= noLessThenPriceAsset)) | |
877 | - | then true | |
878 | - | else throwErr(((("Failed: " + toString(outPriceAmount)) + " < ") + toString(noLessThenPriceAsset))) | |
879 | - | if ((checkOutPriceAmount == checkOutPriceAmount)) | |
880 | - | then { | |
881 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
882 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
883 | - | then state | |
884 | - | else throw("Strict value is not equal to itself.") | |
885 | - | } | |
886 | - | else throw("Strict value is not equal to itself.") | |
887 | - | } | |
888 | - | else throw("Strict value is not equal to itself.") | |
822 | + | if ((noLessThenAmtAsset > outAmAmt)) | |
823 | + | then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
824 | + | else if ((noLessThenPriceAsset > outPrAmt)) | |
825 | + | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
826 | + | else { | |
827 | + | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
828 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
829 | + | then state | |
830 | + | else throw("Strict value is not equal to itself.") | |
831 | + | } | |
889 | 832 | } | |
890 | 833 | ||
891 | 834 | ||
893 | 836 | @Callable(i) | |
894 | 837 | func unstakeAndGet (amount) = { | |
895 | 838 | let checkPayments = if ((size(i.payments) != 0)) | |
896 | - | then | |
839 | + | then throw("No pmnts expd") | |
897 | 840 | else true | |
898 | 841 | if ((checkPayments == checkPayments)) | |
899 | 842 | then { | |
900 | - | let cfg = | |
901 | - | let factoryCfg = | |
843 | + | let cfg = gpc() | |
844 | + | let factoryCfg = gfc() | |
902 | 845 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
903 | - | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), " | |
846 | + | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
904 | 847 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
905 | 848 | if ((unstakeInv == unstakeInv)) | |
906 | 849 | then { | |
907 | - | let r = | |
850 | + | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
908 | 851 | let sts = parseIntValue(r._9) | |
909 | 852 | let state = r._10 | |
910 | - | let v = if (if ( | |
853 | + | let v = if (if (igs()) | |
911 | 854 | then true | |
912 | 855 | else (sts == PoolShutdown)) | |
913 | - | then | |
856 | + | then throw(("Blocked: " + toString(sts))) | |
914 | 857 | else true | |
915 | 858 | if ((v == v)) | |
916 | 859 | then { | |
917 | - | let burnA = invoke( | |
860 | + | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
918 | 861 | if ((burnA == burnA)) | |
919 | 862 | then state | |
920 | 863 | else throw("Strict value is not equal to itself.") | |
929 | 872 | ||
930 | 873 | ||
931 | 874 | @Callable(i) | |
932 | - | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString( | |
933 | - | then | |
934 | - | else $Tuple2([StringEntry( | |
875 | + | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
876 | + | then throw("denied") | |
877 | + | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
935 | 878 | ||
936 | 879 | ||
937 | 880 | ||
938 | 881 | @Callable(i) | |
939 | - | func setS (k,v) = if ((toString(i.caller) != | |
882 | + | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
940 | 883 | then pd | |
941 | 884 | else [StringEntry(k, v)] | |
942 | 885 | ||
943 | 886 | ||
944 | 887 | ||
945 | 888 | @Callable(i) | |
946 | - | func setI (k,v) = if ((toString(i.caller) != | |
889 | + | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
947 | 890 | then pd | |
948 | 891 | else [IntegerEntry(k, v)] | |
949 | 892 | ||
950 | 893 | ||
951 | 894 | ||
952 | 895 | @Callable(i) | |
953 | - | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, | |
896 | + | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
954 | 897 | ||
955 | 898 | ||
956 | 899 | ||
968 | 911 | ||
969 | 912 | ||
970 | 913 | @Callable(i) | |
971 | - | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, | |
914 | + | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
972 | 915 | ||
973 | 916 | ||
974 | 917 | ||
975 | 918 | @Callable(i) | |
976 | - | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString( | |
919 | + | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
977 | 920 | ||
978 | 921 | ||
979 | 922 | ||
980 | 923 | @Callable(i) | |
981 | - | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString( | |
924 | + | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
982 | 925 | ||
983 | 926 | ||
984 | 927 | ||
985 | 928 | @Callable(i) | |
986 | - | func estimatePutOperationWrapperREADONLY (txId58,slippage, | |
929 | + | 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, "")) | |
987 | 930 | ||
988 | 931 | ||
989 | 932 | ||
990 | 933 | @Callable(i) | |
991 | - | func estimateGetOperationWrapperREADONLY (txId58, | |
992 | - | let r = | |
934 | + | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
935 | + | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
993 | 936 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
994 | 937 | } | |
995 | 938 | ||
996 | 939 | ||
997 | 940 | @Verifier(tx) | |
998 | - | func verify () = match tx { | |
999 | - | case order: Order => | |
1000 | - | let mtchPub = getMatcherPubOrFail() | |
1001 | - | let orV = validateMatcherOrderAllowed(order) | |
1002 | - | let sndrV = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1003 | - | let mtchV = sigVerify(order.bodyBytes, order.proofs[1], mtchPub) | |
1004 | - | if (if (if (orV) | |
1005 | - | then sndrV | |
1006 | - | else false) | |
1007 | - | then mtchV | |
1008 | - | else false) | |
1009 | - | then true | |
1010 | - | else throwOrderError(orV, sndrV, mtchV) | |
1011 | - | case _ => | |
1012 | - | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1013 | - | case pk: ByteVector => | |
1014 | - | pk | |
1015 | - | case _: Unit => | |
1016 | - | tx.senderPublicKey | |
1017 | - | case _ => | |
1018 | - | throw("Match error") | |
1019 | - | } | |
1020 | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1021 | - | } | |
941 | + | func verify () = { | |
942 | + | let targetPublicKey = match m() { | |
943 | + | case pk: ByteVector => | |
944 | + | pk | |
945 | + | case _: Unit => | |
946 | + | tx.senderPublicKey | |
947 | + | case _ => | |
948 | + | throw("Match error") | |
949 | + | } | |
950 | + | match tx { | |
951 | + | case order: Order => | |
952 | + | let matcherPub = mp() | |
953 | + | let orderValid = moa(order) | |
954 | + | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
955 | + | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
956 | + | if (if (if (orderValid) | |
957 | + | then senderValid | |
958 | + | else false) | |
959 | + | then matcherValid | |
960 | + | else false) | |
961 | + | then true | |
962 | + | else toe(orderValid, senderValid, matcherValid) | |
963 | + | case s: SetScriptTransaction => | |
964 | + | let newHash = blake2b256(value(s.script)) | |
965 | + | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
966 | + | let currentHash = scriptHash(this) | |
967 | + | if (if ((allowedHash == newHash)) | |
968 | + | then (currentHash != newHash) | |
969 | + | else false) | |
970 | + | then true | |
971 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
972 | + | case _ => | |
973 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
974 | + | } | |
975 | + | } | |
1022 | 976 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let defaultDecimals = 1000000 | |
5 | - | ||
6 | 4 | let scale8 = 100000000 | |
7 | 5 | ||
8 | 6 | let scale8BigInt = toBigInt(100000000) | |
9 | 7 | ||
10 | 8 | let scale18 = toBigInt(1000000000000000000) | |
11 | - | ||
12 | - | let thousand = 1000 | |
13 | 9 | ||
14 | 10 | let zeroBigInt = toBigInt(0) | |
15 | 11 | ||
16 | 12 | let oneBigInt = toBigInt(1) | |
17 | 13 | ||
18 | 14 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
19 | 15 | ||
20 | 16 | let Amult = "100" | |
21 | 17 | ||
22 | 18 | let Dconv = "1" | |
23 | 19 | ||
24 | 20 | let SEP = "__" | |
25 | 21 | ||
26 | 22 | let EMPTY = "" | |
27 | 23 | ||
28 | 24 | let PoolActive = 1 | |
29 | 25 | ||
30 | 26 | let PoolPutDis = 2 | |
31 | 27 | ||
32 | 28 | let PoolMatcherDis = 3 | |
33 | 29 | ||
34 | 30 | let PoolShutdown = 4 | |
35 | 31 | ||
36 | 32 | let idxPoolAddress = 1 | |
37 | 33 | ||
38 | 34 | let idxPoolSt = 2 | |
39 | 35 | ||
40 | 36 | let idxLPAsId = 3 | |
41 | 37 | ||
42 | 38 | let idxAmAsId = 4 | |
43 | 39 | ||
44 | 40 | let idxPrAsId = 5 | |
45 | 41 | ||
46 | 42 | let idxAmtAsDcm = 6 | |
47 | 43 | ||
48 | 44 | let idxPriceAsDcm = 7 | |
49 | 45 | ||
50 | 46 | let idxIAmtAsId = 8 | |
51 | 47 | ||
52 | 48 | let idxIPriceAsId = 9 | |
53 | 49 | ||
54 | 50 | let idxFactStakCntr = 1 | |
55 | 51 | ||
56 | 52 | let idxFactSlippCntr = 7 | |
57 | 53 | ||
58 | 54 | let idxFactGwxRewCntr = 10 | |
59 | 55 | ||
60 | - | let | |
56 | + | let delay = "%s__delay" | |
61 | 57 | ||
62 | - | func | |
58 | + | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 59 | ||
64 | 60 | ||
65 | - | func | |
61 | + | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
66 | 62 | ||
67 | 63 | ||
68 | 64 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
69 | 65 | ||
70 | 66 | ||
71 | 67 | func abs (val) = if ((zeroBigInt > val)) | |
72 | 68 | then -(val) | |
73 | 69 | else val | |
74 | 70 | ||
75 | 71 | ||
76 | - | func | |
72 | + | func fc () = "%s__factoryContract" | |
77 | 73 | ||
78 | 74 | ||
79 | - | func | |
75 | + | func mpk () = "%s__managerPublicKey" | |
80 | 76 | ||
81 | 77 | ||
82 | - | func | |
78 | + | func pmpk () = "%s__pendingManagerPublicKey" | |
83 | 79 | ||
84 | 80 | ||
85 | - | func | |
81 | + | func pl () = "%s%s__price__last" | |
86 | 82 | ||
87 | 83 | ||
88 | - | func | |
84 | + | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
89 | 85 | ||
90 | 86 | ||
91 | - | func | |
87 | + | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
92 | 88 | ||
93 | 89 | ||
94 | - | func | |
90 | + | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
95 | 91 | ||
96 | 92 | ||
97 | - | func | |
93 | + | func aa () = "%s__amountAsset" | |
98 | 94 | ||
99 | 95 | ||
100 | - | func | |
96 | + | func pa () = "%s__priceAsset" | |
101 | 97 | ||
102 | 98 | ||
103 | - | func | |
99 | + | func amp () = "%s__amp" | |
104 | 100 | ||
105 | 101 | ||
106 | - | func | |
102 | + | func ada () = "%s__addonAddr" | |
107 | 103 | ||
108 | 104 | ||
109 | - | let keyFeePermille = "%s__feePermille" | |
110 | - | ||
111 | - | let feePermille = valueOrElse(getInteger(this, keyFeePermille), feePermilleDefault) | |
112 | - | ||
113 | - | func keyFactoryConfig () = "%s__factoryConfig" | |
105 | + | func lgotc (caller) = makeString(["%s%s__lastGetOneTknCall", caller], SEP) | |
114 | 106 | ||
115 | 107 | ||
116 | - | func | |
108 | + | func lsotc (caller) = makeString(["%s%s__lastPutOneTknCall", caller], SEP) | |
117 | 109 | ||
118 | 110 | ||
119 | - | func | |
111 | + | func fcfg () = "%s__factoryConfig" | |
120 | 112 | ||
121 | 113 | ||
122 | - | func | |
114 | + | func mtpk () = "%s%s__matcher__publicKey" | |
123 | 115 | ||
124 | 116 | ||
125 | - | func | |
117 | + | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
126 | 118 | ||
127 | 119 | ||
128 | - | func | |
120 | + | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
129 | 121 | ||
130 | 122 | ||
131 | - | func throwOrderError (orV,sendrV,matchV) = throwErr(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
123 | + | func aps () = "%s__shutdown" | |
124 | + | ||
125 | + | ||
126 | + | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
127 | + | ||
128 | + | ||
129 | + | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
132 | 130 | ||
133 | 131 | ||
134 | 132 | func str (val) = match val { | |
135 | 133 | case valStr: String => | |
136 | 134 | valStr | |
137 | 135 | case _ => | |
138 | - | | |
136 | + | throw("fail cast to String") | |
139 | 137 | } | |
140 | 138 | ||
141 | 139 | ||
142 | - | func | |
140 | + | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
143 | 141 | ||
144 | 142 | ||
145 | - | func | |
143 | + | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
146 | 144 | ||
147 | 145 | ||
148 | - | let | |
146 | + | let fca = addressFromStringValue(strf(this, fc())) | |
149 | 147 | ||
150 | - | let | |
148 | + | let A = strf(this, amp()) | |
151 | 149 | ||
152 | - | func | |
150 | + | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
153 | 151 | ||
154 | 152 | ||
155 | - | func | |
153 | + | func mp () = fromBase58String(strf(fca, mtpk())) | |
156 | 154 | ||
157 | 155 | ||
158 | - | let matcherAddress = addressFromPublicKey(getMatcherPubOrFail()) | |
159 | - | ||
160 | - | func getPoolConfig () = { | |
161 | - | let amtAs = getStringOrFail(this, keyAmountAsset()) | |
162 | - | let priceAs = getStringOrFail(this, keyPriceAsset()) | |
163 | - | let iPriceAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAs)) | |
164 | - | let iAmtAs = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAs)) | |
165 | - | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAs), toString(iPriceAs))), SEP) | |
156 | + | func gpc () = { | |
157 | + | let amtAs = strf(this, aa()) | |
158 | + | let priceAs = strf(this, pa()) | |
159 | + | let iPriceAs = intf(fca, mba(priceAs)) | |
160 | + | let iAmtAs = intf(fca, mba(amtAs)) | |
161 | + | split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP) | |
166 | 162 | } | |
167 | 163 | ||
168 | 164 | ||
169 | - | func | |
165 | + | func gfc () = split(strf(fca, fcfg()), SEP) | |
170 | 166 | ||
171 | 167 | ||
172 | 168 | 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) | |
173 | 169 | ||
174 | 170 | ||
175 | 171 | 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) | |
176 | 172 | ||
177 | 173 | ||
178 | 174 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
179 | 175 | then wavesBalance(this).available | |
180 | 176 | else assetBalance(this, fromBase58String(assetId)) | |
181 | 177 | ||
182 | 178 | ||
183 | - | func | |
179 | + | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
184 | 180 | ||
185 | 181 | ||
186 | - | func | |
187 | - | let diff = fraction(( | |
182 | + | func vad (A1,A2,slippage) = { | |
183 | + | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
188 | 184 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
189 | 185 | if (!(pass)) | |
190 | - | then | |
191 | - | else $Tuple2(pass, min([ | |
186 | + | then throw(("Big slpg: " + toString(diff))) | |
187 | + | else $Tuple2(pass, min([A1, A2])) | |
192 | 188 | } | |
193 | 189 | ||
194 | 190 | ||
195 | - | func | |
191 | + | func vd (D1,D0,slpg) = { | |
196 | 192 | let diff = fraction(D0, scale8BigInt, D1) | |
197 | - | let fail = ( | |
193 | + | let fail = (slpg > diff) | |
198 | 194 | if (if (fail) | |
199 | 195 | then true | |
200 | 196 | else (D0 > D1)) | |
201 | - | then | |
197 | + | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
202 | 198 | else fail | |
203 | 199 | } | |
204 | 200 | ||
205 | 201 | ||
206 | - | func | |
207 | - | let amtAsAmtX18 = | |
208 | - | let prAsAmtX18 = | |
209 | - | | |
202 | + | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
203 | + | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
204 | + | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
205 | + | cpbi(prAsAmtX18, amtAsAmtX18) | |
210 | 206 | } | |
211 | 207 | ||
212 | 208 | ||
213 | 209 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
214 | - | let cfg = | |
210 | + | let cfg = gpc() | |
215 | 211 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
216 | 212 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
217 | - | let priceX18 = | |
218 | - | let amAmtX18 = | |
219 | - | let prAmtX18 = | |
220 | - | let lpAmtX18 = | |
221 | - | let lpPrInAmAsX18 = | |
222 | - | let lpPrInPrAsX18 = | |
213 | + | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
214 | + | let amAmtX18 = t1(amAmt, amtAsDcm) | |
215 | + | let prAmtX18 = t1(prAmt, prAsDcm) | |
216 | + | let lpAmtX18 = t1(lpAmt, scale8) | |
217 | + | let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18) | |
218 | + | let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18) | |
223 | 219 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
224 | 220 | } | |
225 | 221 | ||
226 | 222 | ||
227 | 223 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
228 | 224 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
229 | - | [ | |
225 | + | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
230 | 226 | } | |
231 | 227 | ||
232 | 228 | ||
233 | - | func | |
234 | - | let cfg = | |
235 | - | let | |
236 | - | let | |
237 | - | let | |
238 | - | let | |
239 | - | let | |
229 | + | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
230 | + | let cfg = gpc() | |
231 | + | let lpId = cfg[idxLPAsId] | |
232 | + | let amId = cfg[idxAmAsId] | |
233 | + | let prId = cfg[idxPrAsId] | |
234 | + | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
235 | + | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
240 | 236 | let sts = cfg[idxPoolSt] | |
241 | - | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), "Wrong LP id").quantity | |
242 | - | let validationBlock = if ((lpAssetId == paymentAssetId)) | |
243 | - | then true | |
244 | - | else throwErr("Wrong payment asset") | |
245 | - | if ((validationBlock == validationBlock)) | |
246 | - | then { | |
247 | - | let amountBalance = getAccBalance(amountId) | |
248 | - | let priceBalance = getAccBalance(priceId) | |
249 | - | let amountBalanceDefaultDecimals = fraction(amountBalance, defaultDecimals, amountDecimals) | |
250 | - | let priceBalanceDefaultDecimals = fraction(priceBalance, defaultDecimals, priceDecimals) | |
251 | - | let amountBalanceX18 = toX18(amountBalanceDefaultDecimals, defaultDecimals) | |
252 | - | let priceBalanceX18 = toX18(priceBalanceDefaultDecimals, defaultDecimals) | |
253 | - | let currentPriceX18 = calcPriceBigInt(priceBalanceX18, amountBalanceX18) | |
254 | - | let curPrice = fromX18(currentPriceX18, scale8) | |
255 | - | let paymentLpAmountX18 = toX18(paymentLpAmount, scale8) | |
256 | - | let lpEmissionX18 = toX18(lpEmission, scale8) | |
257 | - | let outAmountAmountX18 = fraction(amountBalanceX18, paymentLpAmountX18, lpEmissionX18) | |
258 | - | let outPriceAmountX18 = fraction(priceBalanceX18, paymentLpAmountX18, lpEmissionX18) | |
259 | - | let outAmountAmountDefaultDecimals = fromX18(outAmountAmountX18, defaultDecimals) | |
260 | - | let outPriceAmountDefaultDecimals = fromX18(outPriceAmountX18, defaultDecimals) | |
261 | - | let outAmountAmount = fraction(outAmountAmountDefaultDecimals, amountDecimals, defaultDecimals) | |
262 | - | let outPriceAmount = fraction(outPriceAmountDefaultDecimals, priceDecimals, defaultDecimals) | |
237 | + | let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity | |
238 | + | if ((lpId != pmtAssetId)) | |
239 | + | then throw("Wrong pmt asset") | |
240 | + | else { | |
241 | + | let amBalance = getAccBalance(amId) | |
242 | + | let amBalanceX18 = t1(amBalance, amDcm) | |
243 | + | let prBalance = getAccBalance(prId) | |
244 | + | let prBalanceX18 = t1(prBalance, prDcm) | |
245 | + | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
246 | + | let curPrice = f1(curPriceX18, scale8) | |
247 | + | let pmtLpAmtX18 = t1(pmtLpAmt, scale8) | |
248 | + | let lpEmissX18 = t1(lpEmiss, scale8) | |
249 | + | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
250 | + | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
251 | + | let outAmAmt = f1(outAmAmtX18, amDcm) | |
252 | + | let outPrAmt = f1(outPrAmtX18, prDcm) | |
263 | 253 | let state = if ((txId58 == "")) | |
264 | 254 | then nil | |
265 | - | else [ScriptTransfer(userAddress, | |
255 | + | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
266 | 256 | then unit | |
267 | - | else fromBase58String( | |
257 | + | else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES")) | |
268 | 258 | then unit | |
269 | - | else fromBase58String( | |
270 | - | $Tuple10( | |
259 | + | 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)] | |
260 | + | $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state) | |
271 | 261 | } | |
272 | - | else throw("Strict value is not equal to itself.") | |
273 | 262 | } | |
274 | 263 | ||
275 | 264 | ||
276 | - | func | |
277 | - | let cfg = | |
278 | - | let | |
279 | - | let | |
280 | - | let | |
281 | - | let | |
282 | - | let | |
283 | - | let | |
284 | - | let | |
265 | + | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
266 | + | let cfg = gpc() | |
267 | + | let lpId = fromBase58String(cfg[idxLPAsId]) | |
268 | + | let amIdStr = cfg[idxAmAsId] | |
269 | + | let prIdStr = cfg[idxPrAsId] | |
270 | + | let inAmIdStr = cfg[idxIAmtAsId] | |
271 | + | let inPrIdStr = cfg[idxIPriceAsId] | |
272 | + | let amtDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
273 | + | let priceDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
285 | 274 | let sts = cfg[idxPoolSt] | |
286 | - | let | |
287 | - | let | |
288 | - | then getAccBalance( | |
275 | + | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
276 | + | let amBalance = if (isEval) | |
277 | + | then getAccBalance(amIdStr) | |
289 | 278 | else if (if (isOneAsset) | |
290 | - | then ( | |
279 | + | then (pmtId == amIdStr) | |
291 | 280 | else false) | |
292 | - | then (getAccBalance( | |
281 | + | then (getAccBalance(amIdStr) - pmtAmt) | |
293 | 282 | else if (isOneAsset) | |
294 | - | then getAccBalance( | |
295 | - | else (getAccBalance( | |
296 | - | let | |
297 | - | then getAccBalance( | |
283 | + | then getAccBalance(amIdStr) | |
284 | + | else (getAccBalance(amIdStr) - inAmAmt) | |
285 | + | let prBalance = if (isEval) | |
286 | + | then getAccBalance(prIdStr) | |
298 | 287 | else if (if (isOneAsset) | |
299 | - | then ( | |
288 | + | then (pmtId == prIdStr) | |
300 | 289 | else false) | |
301 | - | then (getAccBalance( | |
290 | + | then (getAccBalance(prIdStr) - pmtAmt) | |
302 | 291 | else if (isOneAsset) | |
303 | - | then getAccBalance(priceIdStr) | |
304 | - | else (getAccBalance(priceIdStr) - inPriceAssetAmount) | |
305 | - | let amountBalanceDefaultDecimals = fraction(amountBalance, defaultDecimals, amountDecimals) | |
306 | - | let priceBalanceDefaultDecimals = fraction(priceBalance, defaultDecimals, priceDecimals) | |
307 | - | let inAmountAssetAmountDefaultDecimals = fraction(inAmountAssetAmount, defaultDecimals, amountDecimals) | |
308 | - | let inPriceAssetAmountDefaultDecimals = fraction(inPriceAssetAmount, defaultDecimals, priceDecimals) | |
309 | - | let inAmountAssetAmountX18 = toX18(inAmountAssetAmountDefaultDecimals, defaultDecimals) | |
310 | - | let inPriceAssetAmountX18 = toX18(inPriceAssetAmountDefaultDecimals, defaultDecimals) | |
311 | - | let userPriceX18 = calcPriceBigInt(inPriceAssetAmountX18, inAmountAssetAmountX18) | |
312 | - | let amountBalanceX18 = toX18(amountBalanceDefaultDecimals, defaultDecimals) | |
313 | - | let priceBalanceX18 = toX18(priceBalanceDefaultDecimals, defaultDecimals) | |
314 | - | let r = if ((lpEmission == 0)) | |
292 | + | then getAccBalance(prIdStr) | |
293 | + | else (getAccBalance(prIdStr) - inPrAmt) | |
294 | + | let inAmAssetAmtX18 = t1(inAmAmt, amtDcm) | |
295 | + | let inPrAssetAmtX18 = t1(inPrAmt, priceDcm) | |
296 | + | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
297 | + | let amBalanceX18 = t1(amBalance, amtDcm) | |
298 | + | let prBalanceX18 = t1(prBalance, priceDcm) | |
299 | + | let r = if ((lpEm == 0)) | |
315 | 300 | then { | |
316 | - | let | |
301 | + | let curPriceX18 = zeroBigInt | |
317 | 302 | let slippageX18 = zeroBigInt | |
318 | - | let | |
319 | - | $Tuple5( | |
303 | + | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
304 | + | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
320 | 305 | } | |
321 | 306 | else { | |
322 | - | let | |
323 | - | let slippageRealX18 = fraction(abs(( | |
324 | - | let slippageX18 = | |
325 | - | | |
307 | + | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
308 | + | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
309 | + | let slippageX18 = t1(slippage, scale8) | |
310 | + | if (if ((curPriceX18 != zeroBigInt)) | |
326 | 311 | then (slippageRealX18 > slippageX18) | |
327 | - | else false) == false)) | |
328 | - | then true | |
329 | - | else throwErr(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
330 | - | if ((validateSlippage == validateSlippage)) | |
331 | - | then { | |
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, defaultDecimals), fromX18(expectedPriceAssetAmountX18, defaultDecimals), currentPriceX18, slippageX18) | |
312 | + | else false) | |
313 | + | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
314 | + | else { | |
315 | + | let lpEmissionX18 = t1(lpEm, scale8) | |
316 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
317 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
318 | + | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
319 | + | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
320 | + | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
321 | + | let expAmtAssetAmtX18 = expectedAmts._1 | |
322 | + | let expPriceAssetAmtX18 = expectedAmts._2 | |
323 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
324 | + | $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18) | |
342 | 325 | } | |
343 | - | else throw("Strict value is not equal to itself.") | |
344 | 326 | } | |
345 | - | let calculateLpAmount = r._1 | |
346 | - | let calculateAmountAssetPayment = fraction(r._2, amountDecimals, defaultDecimals) | |
347 | - | let calculatePriceAssetPayment = fraction(r._3, priceDecimals, defaultDecimals) | |
348 | - | let currentPrice = fromX18(r._4, scale8) | |
349 | - | let slippageCalculate = fromX18(r._5, scale8) | |
350 | - | let checkCalcLpAmount = if ((calculateLpAmount > 0)) | |
351 | - | then true | |
352 | - | else throwErr("LP <= 0") | |
353 | - | if ((checkCalcLpAmount == checkCalcLpAmount)) | |
354 | - | then { | |
355 | - | let emitLpAmount = if (!(emitLp)) | |
327 | + | let calcLpAmt = r._1 | |
328 | + | let calcAmAssetPmt = r._2 | |
329 | + | let calcPrAssetPmt = r._3 | |
330 | + | let curPrice = f1(r._4, scale8) | |
331 | + | let slippageCalc = f1(r._5, scale8) | |
332 | + | if ((0 >= calcLpAmt)) | |
333 | + | then throw("LP <= 0") | |
334 | + | else { | |
335 | + | let emitLpAmt = if (!(emitLp)) | |
356 | 336 | then 0 | |
357 | - | else | |
358 | - | let | |
359 | - | let | |
360 | - | let $ | |
361 | - | then ( | |
337 | + | else calcLpAmt | |
338 | + | let amDiff = (inAmAmt - calcAmAssetPmt) | |
339 | + | let prDiff = (inPrAmt - calcPrAssetPmt) | |
340 | + | let $t01560115946 = if (if (isOneAsset) | |
341 | + | then (pmtId == amIdStr) | |
362 | 342 | else false) | |
363 | - | then $Tuple2( | |
343 | + | then $Tuple2(pmtAmt, 0) | |
364 | 344 | else if (if (isOneAsset) | |
365 | - | then ( | |
345 | + | then (pmtId == prIdStr) | |
366 | 346 | else false) | |
367 | - | then $Tuple2(0, | |
368 | - | else $Tuple2( | |
369 | - | let writeAmAmt = $ | |
370 | - | let writePrAmt = $ | |
371 | - | let commonState = [IntegerEntry( | |
372 | - | $Tuple13( | |
347 | + | then $Tuple2(0, pmtAmt) | |
348 | + | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
349 | + | let writeAmAmt = $t01560115946._1 | |
350 | + | let writePrAmt = $t01560115946._2 | |
351 | + | 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))] | |
352 | + | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
373 | 353 | } | |
374 | - | else throw("Strict value is not equal to itself.") | |
375 | 354 | } | |
376 | 355 | ||
377 | 356 | ||
378 | - | func | |
379 | - | let cfg = | |
357 | + | func moa (order) = { | |
358 | + | let cfg = gpc() | |
380 | 359 | let amtAsId = cfg[idxAmAsId] | |
381 | 360 | let prAsId = cfg[idxPrAsId] | |
382 | 361 | let sts = parseIntValue(cfg[idxPoolSt]) | |
383 | 362 | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
384 | 363 | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
385 | 364 | let accAmtAsBalance = getAccBalance(amtAsId) | |
386 | 365 | let accPrAsBalance = getAccBalance(prAsId) | |
387 | - | let | |
388 | - | then | |
389 | - | else | |
390 | - | let curPrice = | |
391 | - | if (if (if ( | |
366 | + | let curPriceX18 = if ((order.orderType == Buy)) | |
367 | + | then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance) | |
368 | + | else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance) | |
369 | + | let curPrice = f1(curPriceX18, scale8) | |
370 | + | if (if (if (igs()) | |
392 | 371 | then true | |
393 | 372 | else (sts == PoolMatcherDis)) | |
394 | 373 | then true | |
395 | 374 | else (sts == PoolShutdown)) | |
396 | - | then | |
375 | + | then throw("Admin blocked") | |
397 | 376 | else { | |
398 | 377 | let orAmtAsset = order.assetPair.amountAsset | |
399 | 378 | let orAmtAsStr = if ((orAmtAsset == unit)) | |
400 | 379 | then "WAVES" | |
401 | 380 | else toBase58String(value(orAmtAsset)) | |
402 | 381 | let orPrAsset = order.assetPair.priceAsset | |
403 | 382 | let orPrAsStr = if ((orPrAsset == unit)) | |
404 | 383 | then "WAVES" | |
405 | 384 | else toBase58String(value(orPrAsset)) | |
406 | 385 | if (if ((orAmtAsStr != amtAsId)) | |
407 | 386 | then true | |
408 | 387 | else (orPrAsStr != prAsId)) | |
409 | - | then | |
388 | + | then throw("Wr assets") | |
410 | 389 | else { | |
411 | 390 | let orderPrice = order.price | |
412 | - | let | |
413 | - | let castOrderPrice = ts(orderPrice, scale8, | |
391 | + | let priceDcm = fraction(scale8, prAsDcm, amtAsDcm) | |
392 | + | let castOrderPrice = ts(orderPrice, scale8, priceDcm) | |
414 | 393 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
415 | 394 | then (curPrice >= castOrderPrice) | |
416 | 395 | else (castOrderPrice >= curPrice) | |
417 | 396 | true | |
418 | 397 | } | |
419 | 398 | } | |
420 | 399 | } | |
421 | 400 | ||
422 | 401 | ||
423 | - | func commonGet (i) = { | |
424 | - | let checkPayments = if ((size(i.payments) == 1)) | |
425 | - | then true | |
426 | - | else throwErr("1 payment expected") | |
427 | - | if ((checkPayments == checkPayments)) | |
428 | - | then { | |
429 | - | let payment = value(i.payments[0]) | |
430 | - | let paymentAssetId = value(payment.assetId) | |
431 | - | let paymentAmount = payment.amount | |
432 | - | let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(paymentAssetId), paymentAmount, i.caller) | |
433 | - | let outAmountAmount = r._1 | |
434 | - | let outPriceAmount = r._2 | |
435 | - | let sts = parseIntValue(r._9) | |
436 | - | let state = r._10 | |
437 | - | if (if (isGlobalShutdown()) | |
438 | - | then true | |
439 | - | else (sts == PoolShutdown)) | |
440 | - | then throwErr(("Admin blocked: " + toString(sts))) | |
441 | - | else $Tuple5(outAmountAmount, outPriceAmount, paymentAmount, paymentAssetId, state) | |
442 | - | } | |
443 | - | else throw("Strict value is not equal to itself.") | |
444 | - | } | |
402 | + | func cg (i) = if ((size(i.payments) != 1)) | |
403 | + | then throw("1 pmnt exp") | |
404 | + | else { | |
405 | + | let pmt = value(i.payments[0]) | |
406 | + | let pmtAssetId = value(pmt.assetId) | |
407 | + | let pmtAmt = pmt.amount | |
408 | + | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
409 | + | let outAmAmt = r._1 | |
410 | + | let outPrAmt = r._2 | |
411 | + | let sts = parseIntValue(r._9) | |
412 | + | let state = r._10 | |
413 | + | if (if (igs()) | |
414 | + | then true | |
415 | + | else (sts == PoolShutdown)) | |
416 | + | then throw(("Admin blocked: " + toString(sts))) | |
417 | + | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
418 | + | } | |
445 | 419 | ||
446 | 420 | ||
447 | - | func | |
448 | - | let r = | |
421 | + | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,pmtAmt,pmtId) = { | |
422 | + | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, false, emitLp, isOneAsset, pmtAmt, pmtId) | |
449 | 423 | let sts = parseIntValue(r._8) | |
450 | - | if (if (if ( | |
424 | + | if (if (if (igs()) | |
451 | 425 | then true | |
452 | 426 | else (sts == PoolPutDis)) | |
453 | 427 | then true | |
454 | 428 | else (sts == PoolShutdown)) | |
455 | - | then | |
429 | + | then throw(("Blocked:" + toString(sts))) | |
456 | 430 | else r | |
457 | 431 | } | |
458 | 432 | ||
459 | 433 | ||
460 | - | func takeFee (amount) = { | |
461 | - | let fee = fraction(amount, feePermille, thousand) | |
462 | - | $Tuple2((amount - fee), fee) | |
463 | - | } | |
464 | - | ||
465 | - | ||
466 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
434 | + | func m () = match getString(mpk()) { | |
467 | 435 | case s: String => | |
468 | 436 | fromBase58String(s) | |
469 | 437 | case _: Unit => | |
470 | 438 | unit | |
471 | 439 | case _ => | |
472 | 440 | throw("Match error") | |
473 | 441 | } | |
474 | 442 | ||
475 | 443 | ||
476 | - | func | |
444 | + | func pm () = match getString(pmpk()) { | |
477 | 445 | case s: String => | |
478 | 446 | fromBase58String(s) | |
479 | 447 | case _: Unit => | |
480 | 448 | unit | |
481 | 449 | case _ => | |
482 | 450 | throw("Match error") | |
483 | 451 | } | |
484 | 452 | ||
485 | 453 | ||
486 | - | let pd = | |
454 | + | let pd = throw("Permission denied") | |
487 | 455 | ||
488 | - | func | |
456 | + | func mm (i) = match m() { | |
489 | 457 | case pk: ByteVector => | |
490 | 458 | if ((i.callerPublicKey == pk)) | |
491 | 459 | then true | |
492 | 460 | else pd | |
493 | 461 | case _: Unit => | |
494 | 462 | if ((i.caller == this)) | |
495 | 463 | then true | |
496 | 464 | else pd | |
497 | 465 | case _ => | |
498 | 466 | throw("Match error") | |
499 | 467 | } | |
500 | 468 | ||
501 | 469 | ||
502 | 470 | @Callable(i) | |
503 | - | func constructor ( | |
504 | - | let | |
505 | - | if (( | |
506 | - | then [StringEntry( | |
471 | + | func constructor (fc) = { | |
472 | + | let c = mm(i) | |
473 | + | if ((c == c)) | |
474 | + | then [StringEntry(fc(), fc)] | |
507 | 475 | else throw("Strict value is not equal to itself.") | |
508 | 476 | } | |
509 | 477 | ||
510 | 478 | ||
511 | 479 | ||
512 | 480 | @Callable(i) | |
513 | 481 | func setManager (pendingManagerPublicKey) = { | |
514 | - | let | |
515 | - | if (( | |
482 | + | let c = mm(i) | |
483 | + | if ((c == c)) | |
516 | 484 | then { | |
517 | - | let | |
518 | - | if (( | |
519 | - | then [StringEntry( | |
485 | + | let cm = fromBase58String(pendingManagerPublicKey) | |
486 | + | if ((cm == cm)) | |
487 | + | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
520 | 488 | else throw("Strict value is not equal to itself.") | |
521 | 489 | } | |
522 | 490 | else throw("Strict value is not equal to itself.") | |
523 | 491 | } | |
524 | 492 | ||
525 | 493 | ||
526 | 494 | ||
527 | 495 | @Callable(i) | |
528 | 496 | func confirmManager () = { | |
529 | - | let | |
530 | - | let | |
497 | + | let p = pm() | |
498 | + | let hpm = if (isDefined(p)) | |
531 | 499 | then true | |
532 | - | else | |
533 | - | if (( | |
500 | + | else throw("No pending manager") | |
501 | + | if ((hpm == hpm)) | |
534 | 502 | then { | |
535 | - | let | |
503 | + | let cpm = if ((i.callerPublicKey == value(p))) | |
536 | 504 | then true | |
537 | - | else | |
538 | - | if (( | |
539 | - | then [StringEntry( | |
505 | + | else throw("You are not pending manager") | |
506 | + | if ((cpm == cpm)) | |
507 | + | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
540 | 508 | else throw("Strict value is not equal to itself.") | |
541 | 509 | } | |
542 | 510 | else throw("Strict value is not equal to itself.") | |
543 | 511 | } | |
544 | 512 | ||
545 | 513 | ||
546 | 514 | ||
547 | 515 | @Callable(i) | |
548 | - | func put (slippage,autoStake) = { | |
549 | - | let factCfg = getFactoryConfig() | |
550 | - | let stakingContract = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wrong staking contract") | |
551 | - | let slippageContract = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wrogn slippage contract") | |
552 | - | let slippageCheck = if ((slippage >= 0)) | |
553 | - | then true | |
554 | - | else throwErr("wrong slippage") | |
555 | - | if ((slippageCheck == slippageCheck)) | |
556 | - | then { | |
557 | - | let paymentsCheck = if ((size(i.payments) == 2)) | |
558 | - | then true | |
559 | - | else throwErr("2 payments expected") | |
560 | - | if ((paymentsCheck == paymentsCheck)) | |
561 | - | then { | |
562 | - | 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, "") | |
563 | - | let emitLpAmount = estimatePut._2 | |
564 | - | let lpAssetId = estimatePut._7 | |
565 | - | let state = estimatePut._9 | |
566 | - | let amountDiff = estimatePut._10 | |
567 | - | let priceDiff = estimatePut._11 | |
568 | - | let amountId = estimatePut._12 | |
569 | - | let priceId = estimatePut._13 | |
570 | - | let r = invoke(factoryContract, "emit", [emitLpAmount], nil) | |
571 | - | if ((r == r)) | |
572 | - | then { | |
573 | - | let el = match r { | |
574 | - | case legacy: Address => | |
575 | - | invoke(legacy, "emit", [emitLpAmount], nil) | |
576 | - | case _ => | |
577 | - | unit | |
578 | - | } | |
579 | - | if ((el == el)) | |
516 | + | func put (slip,autoStake) = { | |
517 | + | let factCfg = gfc() | |
518 | + | let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr") | |
519 | + | let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr") | |
520 | + | if ((0 > slip)) | |
521 | + | then throw("Wrong slippage") | |
522 | + | else if ((size(i.payments) != 2)) | |
523 | + | then throw("2 pmnts expd") | |
524 | + | else { | |
525 | + | 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, "") | |
526 | + | let emitLpAmt = e._2 | |
527 | + | let lpAssetId = e._7 | |
528 | + | let state = e._9 | |
529 | + | let amDiff = e._10 | |
530 | + | let prDiff = e._11 | |
531 | + | let amId = e._12 | |
532 | + | let prId = e._13 | |
533 | + | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
534 | + | if ((r == r)) | |
535 | + | then { | |
536 | + | let el = match r { | |
537 | + | case legacy: Address => | |
538 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
539 | + | case _ => | |
540 | + | unit | |
541 | + | } | |
542 | + | if ((el == el)) | |
543 | + | then { | |
544 | + | let sa = if ((amDiff > 0)) | |
545 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
546 | + | else nil | |
547 | + | if ((sa == sa)) | |
548 | + | then { | |
549 | + | let sp = if ((prDiff > 0)) | |
550 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
551 | + | else nil | |
552 | + | if ((sp == sp)) | |
553 | + | then { | |
554 | + | let lpTrnsfr = if (autoStake) | |
555 | + | then { | |
556 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
557 | + | if ((ss == ss)) | |
558 | + | then nil | |
559 | + | else throw("Strict value is not equal to itself.") | |
560 | + | } | |
561 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
562 | + | (state ++ lpTrnsfr) | |
563 | + | } | |
564 | + | else throw("Strict value is not equal to itself.") | |
565 | + | } | |
566 | + | else throw("Strict value is not equal to itself.") | |
567 | + | } | |
568 | + | else throw("Strict value is not equal to itself.") | |
569 | + | } | |
570 | + | else throw("Strict value is not equal to itself.") | |
571 | + | } | |
572 | + | } | |
573 | + | ||
574 | + | ||
575 | + | ||
576 | + | @Callable(i) | |
577 | + | func putOneTkn (amAssetPart,prAssetPart,outLp,slippage,autoStake) = { | |
578 | + | let cfg = gfc() | |
579 | + | let stakingCntr = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wr st addr") | |
580 | + | let slipCntr = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wr sl addr") | |
581 | + | let gwxCntr = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wr gwx addr") | |
582 | + | let poolCfg = gpc() | |
583 | + | let amId = poolCfg[idxAmAsId] | |
584 | + | let prId = poolCfg[idxPrAsId] | |
585 | + | let amDcm = parseIntValue(poolCfg[idxAmtAsDcm]) | |
586 | + | let prDcm = parseIntValue(poolCfg[idxPriceAsDcm]) | |
587 | + | let addon = valueOrElse(getString(this, ada()), "") | |
588 | + | let userAddress = if ((addon == toString(i.caller))) | |
589 | + | then i.originCaller | |
590 | + | else i.caller | |
591 | + | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
592 | + | let check = reentrantInvoke(addonContract, "ensureCanPutOneTkn", [toString(userAddress)], nil) | |
593 | + | if ((check == check)) | |
594 | + | then if (if (if (if ((0 >= slippage)) | |
595 | + | then true | |
596 | + | else (0 >= amAssetPart)) | |
597 | + | then true | |
598 | + | else (0 >= prAssetPart)) | |
599 | + | then true | |
600 | + | else (0 >= outLp)) | |
601 | + | then throw("Wrong params") | |
602 | + | else if ((size(i.payments) != 1)) | |
603 | + | then throw("1 pmnt expd") | |
604 | + | else { | |
605 | + | let pmt = value(i.payments[0]) | |
606 | + | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
607 | + | let pmtAmt = pmt.amount | |
608 | + | if ((10000000 > pmtAmt)) | |
609 | + | then throw("Wrong pmt amt") | |
610 | + | else { | |
611 | + | let amBalance = getAccBalance(amId) | |
612 | + | let prBalance = getAccBalance(prId) | |
613 | + | let $t02485925435 = if ((pmtAssetId == amId)) | |
614 | + | then if (if ((pmtAmt > amBalance)) | |
615 | + | then true | |
616 | + | else (amAssetPart > pmtAmt)) | |
617 | + | then throw("invalid payment amount") | |
618 | + | else $Tuple6((amBalance - pmtAmt), prBalance, (pmtAmt - amAssetPart), prAssetPart, 0, 0) | |
619 | + | else if ((pmtAssetId == prId)) | |
620 | + | then if (if ((pmtAmt > prBalance)) | |
621 | + | then true | |
622 | + | else (prAssetPart > pmtAmt)) | |
623 | + | then throw("invalid payment amount") | |
624 | + | else $Tuple6(amBalance, (prBalance - pmtAmt), 0, 0, (pmtAmt - prAssetPart), amAssetPart) | |
625 | + | else throw("wrong pmtAssetId") | |
626 | + | let amBalanceNow = $t02485925435._1 | |
627 | + | let prBalanceNow = $t02485925435._2 | |
628 | + | let virtSwapInAm = $t02485925435._3 | |
629 | + | let virtSwapOutPr = $t02485925435._4 | |
630 | + | let virtSwapInPr = $t02485925435._5 | |
631 | + | let virtSwapOutAm = $t02485925435._6 | |
632 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
633 | + | let D1 = invoke(gwxCntr, "calcD", [toString(toBigInt(((amBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((prBalanceNow + virtSwapInPr) - virtSwapOutPr))), A, Amult, Dconv], nil) | |
634 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
635 | + | if ((D0vsD1 == D0vsD1)) | |
580 | 636 | then { | |
581 | - | let sa = if ((amountDiff > 0)) | |
582 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amountId, amountDiff)]) | |
583 | - | else nil | |
584 | - | if ((sa == sa)) | |
637 | + | let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amId), amAssetPart), AttachedPayment(fromBase58String(prId), prAssetPart), slippage, true, true, pmtAmt, pmtAssetId) | |
638 | + | let estimLP = estPut._2 | |
639 | + | let lpAssetId = estPut._7 | |
640 | + | let state = estPut._9 | |
641 | + | let amDiff = estPut._10 | |
642 | + | let prDiff = estPut._11 | |
643 | + | let lpCalcRes = vad(toBigInt(estimLP), toBigInt(outLp), toBigInt(slippage)) | |
644 | + | let emitLpAmt = toInt(lpCalcRes._2) | |
645 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
646 | + | if ((e == e)) | |
585 | 647 | then { | |
586 | - | let sp = if ((priceDiff > 0)) | |
587 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(priceId, priceDiff)]) | |
588 | - | else nil | |
589 | - | if ((sp == sp)) | |
648 | + | let el = match e { | |
649 | + | case legacy: Address => | |
650 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
651 | + | case _ => | |
652 | + | unit | |
653 | + | } | |
654 | + | if ((el == el)) | |
590 | 655 | then { | |
591 | - | let lpTrasfer = if (autoStake) | |
656 | + | let sa = if ((amDiff > 0)) | |
657 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(amId), amDiff)]) | |
658 | + | else nil | |
659 | + | if ((sa == sa)) | |
592 | 660 | then { | |
593 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmount)]) | |
594 | - | if ((ss == ss)) | |
595 | - | then nil | |
661 | + | let sp = if ((prDiff > 0)) | |
662 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(fromBase58String(prId), prDiff)]) | |
663 | + | else nil | |
664 | + | if ((sp == sp)) | |
665 | + | then { | |
666 | + | let lpTrnsfr = if (autoStake) | |
667 | + | then { | |
668 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
669 | + | if ((ss == ss)) | |
670 | + | then nil | |
671 | + | else throw("Strict value is not equal to itself.") | |
672 | + | } | |
673 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
674 | + | (state ++ lpTrnsfr) | |
675 | + | } | |
596 | 676 | else throw("Strict value is not equal to itself.") | |
597 | 677 | } | |
598 | - | else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)] | |
599 | - | (state ++ lpTrasfer) | |
678 | + | else throw("Strict value is not equal to itself.") | |
600 | 679 | } | |
601 | 680 | else throw("Strict value is not equal to itself.") | |
602 | 681 | } | |
603 | 682 | else throw("Strict value is not equal to itself.") | |
604 | 683 | } | |
605 | 684 | else throw("Strict value is not equal to itself.") | |
606 | 685 | } | |
607 | - | else throw("Strict value is not equal to itself.") | |
608 | 686 | } | |
609 | - | else throw("Strict value is not equal to itself.") | |
610 | - | } | |
611 | 687 | else throw("Strict value is not equal to itself.") | |
612 | 688 | } | |
613 | 689 | ||
614 | 690 | ||
615 | 691 | ||
616 | 692 | @Callable(i) | |
617 | - | func putOneTkn (amountAssetPart,priceAssetPart,outLp,slippage,autoStake) = { | |
618 | - | let cfg = getFactoryConfig() | |
619 | - | let stakingContract = valueOrErrorMessage(addressFromString(cfg[idxFactStakCntr]), "Wrong staking contract") | |
620 | - | let slippageContract = valueOrErrorMessage(addressFromString(cfg[idxFactSlippCntr]), "Wrong slippage contract") | |
621 | - | let gwxRewardContract = valueOrErrorMessage(addressFromString(cfg[idxFactGwxRewCntr]), "Wrong gwx reward contract") | |
622 | - | let poolCfg = getPoolConfig() | |
623 | - | let amountId = poolCfg[idxAmAsId] | |
624 | - | let priceId = poolCfg[idxPrAsId] | |
625 | - | let amountDecimals = parseIntValue(poolCfg[idxAmtAsDcm]) | |
626 | - | let priceDecimals = parseIntValue(poolCfg[idxPriceAsDcm]) | |
627 | - | let addon = valueOrElse(getString(this, keyAddonAddress()), "") | |
628 | - | let userAddress = if ((addon == toString(i.caller))) | |
629 | - | then i.originCaller | |
630 | - | else i.caller | |
631 | - | if (if (if (if ((0 >= slippage)) | |
632 | - | then true | |
633 | - | else (0 >= amountAssetPart)) | |
634 | - | then true | |
635 | - | else (0 >= priceAssetPart)) | |
636 | - | then true | |
637 | - | else (0 >= outLp)) | |
638 | - | then throwErr("Wrong params") | |
639 | - | else if ((size(i.payments) != 1)) | |
640 | - | then throwErr("1 payment expected") | |
641 | - | else { | |
642 | - | let payment = value(i.payments[0]) | |
643 | - | let paymentAssetId = toBase58String(value(payment.assetId)) | |
644 | - | let paymentAmountRaw = payment.amount | |
645 | - | let $t02656926628 = takeFee(paymentAmountRaw) | |
646 | - | let paymentAmount = $t02656926628._1 | |
647 | - | let feeAmount = $t02656926628._2 | |
648 | - | if (if (if ((amountAssetPart > paymentAmount)) | |
649 | - | then true | |
650 | - | else (priceAssetPart > paymentAmount)) | |
651 | - | then true | |
652 | - | else (10000000 > paymentAmount)) | |
653 | - | then throwErr("wrong payment amount") | |
654 | - | else { | |
655 | - | let amountBalance = getAccBalance(amountId) | |
656 | - | let priceBalance = getAccBalance(priceId) | |
657 | - | let $t02689327348 = if ((paymentAssetId == amountId)) | |
658 | - | then $Tuple6((amountBalance - paymentAmount), priceBalance, (paymentAmount - amountAssetPart), priceAssetPart, 0, 0) | |
659 | - | else if ((paymentAssetId == priceId)) | |
660 | - | then $Tuple6(amountBalance, (priceBalance - paymentAmount), 0, 0, (paymentAmount - priceAssetPart), amountAssetPart) | |
661 | - | else throwErr("wrong paymentAssetId") | |
662 | - | let amountBalanceNow = $t02689327348._1 | |
663 | - | let priceBalanceNow = $t02689327348._2 | |
664 | - | let virtSwapInAm = $t02689327348._3 | |
665 | - | let virtSwapOutPr = $t02689327348._4 | |
666 | - | let virtSwapInPr = $t02689327348._5 | |
667 | - | let virtSwapOutAm = $t02689327348._6 | |
668 | - | let D0 = invoke(gwxRewardContract, "calcD", [toString(amountBalanceNow), toString(priceBalanceNow), amplificator, Amult, Dconv], nil) | |
669 | - | let D1 = invoke(gwxRewardContract, "calcD", [toString(toBigInt(((amountBalanceNow + virtSwapInAm) - virtSwapOutAm))), toString(toBigInt(((priceBalanceNow + virtSwapInPr) - virtSwapOutPr))), amplificator, Amult, Dconv], nil) | |
670 | - | let D0vsD1 = validateD(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
671 | - | if ((D0vsD1 == D0vsD1)) | |
672 | - | then { | |
673 | - | let estimatePut = commonPut(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(fromBase58String(amountId), amountAssetPart), AttachedPayment(fromBase58String(priceId), priceAssetPart), slippage, true, true, paymentAmount, paymentAssetId) | |
674 | - | let estimateLP = estimatePut._2 | |
675 | - | let lpAssetId = estimatePut._7 | |
676 | - | let state = estimatePut._9 | |
677 | - | let amountDiff = estimatePut._10 | |
678 | - | let priceDiff = estimatePut._11 | |
679 | - | let lpCalcRes = validateAbsDiff(toBigInt(estimateLP), toBigInt(outLp), toBigInt(slippage)) | |
680 | - | let emitLpAmount = toInt(lpCalcRes._2) | |
681 | - | let e = invoke(factoryContract, "emit", [emitLpAmount], nil) | |
682 | - | if ((e == e)) | |
683 | - | then { | |
684 | - | let el = match e { | |
685 | - | case legacy: Address => | |
686 | - | invoke(legacy, "emit", [emitLpAmount], nil) | |
687 | - | case _ => | |
688 | - | unit | |
689 | - | } | |
690 | - | if ((el == el)) | |
691 | - | then { | |
692 | - | let sa = if ((amountDiff > 0)) | |
693 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(fromBase58String(amountId), amountDiff)]) | |
694 | - | else nil | |
695 | - | if ((sa == sa)) | |
696 | - | then { | |
697 | - | let sp = if ((priceDiff > 0)) | |
698 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(fromBase58String(priceId), priceDiff)]) | |
699 | - | else nil | |
700 | - | if ((sp == sp)) | |
701 | - | then { | |
702 | - | let lpTrasfer = if (autoStake) | |
703 | - | then { | |
704 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmount)]) | |
705 | - | if ((ss == ss)) | |
706 | - | then nil | |
707 | - | else throw("Strict value is not equal to itself.") | |
708 | - | } | |
709 | - | else [ScriptTransfer(i.caller, emitLpAmount, lpAssetId)] | |
710 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
711 | - | then [ScriptTransfer(matcherAddress, feeAmount, fromBase58String(paymentAssetId))] | |
712 | - | else nil | |
713 | - | ((state ++ lpTrasfer) ++ sendFeeToMatcher) | |
714 | - | } | |
715 | - | else throw("Strict value is not equal to itself.") | |
716 | - | } | |
717 | - | else throw("Strict value is not equal to itself.") | |
718 | - | } | |
719 | - | else throw("Strict value is not equal to itself.") | |
720 | - | } | |
721 | - | else throw("Strict value is not equal to itself.") | |
722 | - | } | |
723 | - | else throw("Strict value is not equal to itself.") | |
724 | - | } | |
725 | - | } | |
726 | - | } | |
727 | - | ||
728 | - | ||
729 | - | ||
730 | - | @Callable(i) | |
731 | - | func putForFree (maxslippage) = if ((0 > maxslippage)) | |
732 | - | then throwErr("wrong slippage") | |
693 | + | func putForFree (maxSlpg) = if ((0 > maxSlpg)) | |
694 | + | then throw("Wrong slpg") | |
733 | 695 | else if ((size(i.payments) != 2)) | |
734 | - | then | |
696 | + | then throw("2 pmnts expd") | |
735 | 697 | else { | |
736 | - | let | |
737 | - | | |
698 | + | 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, "") | |
699 | + | estPut._9 | |
738 | 700 | } | |
739 | 701 | ||
740 | 702 | ||
741 | 703 | ||
742 | 704 | @Callable(i) | |
743 | 705 | func get () = { | |
744 | - | let r = | |
706 | + | let r = cg(i) | |
745 | 707 | let outAmtAmt = r._1 | |
746 | - | let | |
747 | - | let | |
748 | - | let | |
708 | + | let outPrAmt = r._2 | |
709 | + | let pmtAmt = r._3 | |
710 | + | let pmtAssetId = r._4 | |
749 | 711 | let state = r._5 | |
750 | - | let b = invoke( | |
712 | + | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
751 | 713 | if ((b == b)) | |
752 | 714 | then state | |
753 | 715 | else throw("Strict value is not equal to itself.") | |
754 | 716 | } | |
755 | 717 | ||
756 | 718 | ||
757 | 719 | ||
758 | 720 | @Callable(i) | |
759 | 721 | func getOneTkn (exchResult,notUsed,outAmount,outAssetId,slippage) = if ((size(i.payments) != 1)) | |
760 | - | then | |
722 | + | then throw("1 pmnt expd") | |
761 | 723 | else { | |
762 | - | let cfg = | |
763 | - | let | |
764 | - | let | |
765 | - | let | |
766 | - | let | |
767 | - | let | |
724 | + | let cfg = gpc() | |
725 | + | let lpId = cfg[idxLPAsId] | |
726 | + | let amId = cfg[idxAmAsId] | |
727 | + | let prId = cfg[idxPrAsId] | |
728 | + | let amDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
729 | + | let prDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
768 | 730 | let sts = cfg[idxPoolSt] | |
769 | - | let factCfg = | |
770 | - | let | |
771 | - | let | |
772 | - | let addon = valueOrElse(getString(this, | |
731 | + | let factCfg = gfc() | |
732 | + | let gwxCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactGwxRewCntr]), "Wr sl addr") | |
733 | + | let pmt = value(i.payments[0]) | |
734 | + | let addon = valueOrElse(getString(this, ada()), "") | |
773 | 735 | let userAddress = if ((addon == toString(i.caller))) | |
774 | 736 | then i.originCaller | |
775 | 737 | else i.caller | |
776 | 738 | let txId58 = toBase58String(i.transactionId) | |
777 | - | let paymentAssetId = value(payment.assetId) | |
778 | - | let paymentAmount = payment.amount | |
779 | - | if ((1000000000 > paymentAmount)) | |
780 | - | then throwErr("Min payment 10 LP") | |
781 | - | else if (if (if ((0 > slippage)) | |
782 | - | then true | |
783 | - | else (0 > exchResult)) | |
784 | - | then true | |
785 | - | else (0 > outAmount)) | |
786 | - | then throwErr("Wrong params") | |
787 | - | else if ((lpAssetId != toBase58String(paymentAssetId))) | |
788 | - | then throwErr("Wrong LP") | |
789 | - | else { | |
790 | - | let r = estimateGetOperation(toBase58String(i.transactionId), toBase58String(paymentAssetId), paymentAmount, i.caller) | |
791 | - | let estimAmAmt = r._1 | |
792 | - | let estimPrAmt = r._2 | |
793 | - | let amountBalance = getAccBalance(amountId) | |
794 | - | let priceBalance = getAccBalance(priceId) | |
795 | - | let $t03249632964 = if ((outAssetId == amountId)) | |
796 | - | then $Tuple7((amountBalance - estimAmAmt), (priceBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
797 | - | else if ((outAssetId == priceId)) | |
798 | - | then $Tuple7((amountBalance - estimAmAmt), (priceBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
799 | - | else throwErr("wrong outAssetId") | |
800 | - | let amountBalanceNow = $t03249632964._1 | |
801 | - | let priceBalanceNow = $t03249632964._2 | |
802 | - | let virtSwapInAm = $t03249632964._3 | |
803 | - | let virtSwapOutPr = $t03249632964._4 | |
804 | - | let virtSwapInPr = $t03249632964._5 | |
805 | - | let virtSwapOutAm = $t03249632964._6 | |
806 | - | let totalGet = $t03249632964._7 | |
807 | - | if (if ((0 > virtSwapInAm)) | |
808 | - | then true | |
809 | - | else (0 > virtSwapInPr)) | |
810 | - | then throwErr("Wrong calc") | |
811 | - | else { | |
812 | - | let D0 = invoke(gwxRewardContract, "calcD", [toString(amountBalanceNow), toString(priceBalanceNow), amplificator, Amult, Dconv], nil) | |
813 | - | let D1 = invoke(gwxRewardContract, "calcD", [toString(((amountBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((priceBalanceNow + virtSwapOutPr) - virtSwapInPr)), amplificator, Amult, Dconv], nil) | |
814 | - | let D0vsD1 = validateD(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
815 | - | if ((D0vsD1 == D0vsD1)) | |
816 | - | then { | |
817 | - | let finalRes = validateAbsDiff(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
818 | - | if ((finalRes == finalRes)) | |
819 | - | then { | |
820 | - | let $t03363333741 = if ((outAssetId == amountId)) | |
821 | - | then $Tuple2(toInt(finalRes._2), 0) | |
822 | - | else $Tuple2(0, toInt(finalRes._2)) | |
823 | - | let outAm = $t03363333741._1 | |
824 | - | let outPr = $t03363333741._2 | |
825 | - | let totalAmountRaw = (outAm + outPr) | |
826 | - | let $t03378133836 = takeFee(totalAmountRaw) | |
827 | - | let totalAmount = $t03378133836._1 | |
828 | - | let feeAmount = $t03378133836._2 | |
829 | - | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
830 | - | then unit | |
831 | - | else fromBase58String(outAssetId) | |
832 | - | let sendFeeToMatcher = if ((feeAmount > 0)) | |
833 | - | then [ScriptTransfer(matcherAddress, feeAmount, outAssetIdOrWaves)] | |
834 | - | else nil | |
835 | - | let decimals = if ((amountDecimals >= priceDecimals)) | |
836 | - | then amountDecimals | |
837 | - | else priceDecimals | |
838 | - | if ((decimals == decimals)) | |
839 | - | then { | |
840 | - | let curPrX18 = calcPriceBigInt(toX18(priceBalance, decimals), toX18(amountBalance, decimals)) | |
841 | - | let curPr = fromX18(curPrX18, scale8) | |
842 | - | 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)] | |
843 | - | if ((state == state)) | |
844 | - | then { | |
845 | - | let burn = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
846 | - | if ((burn == burn)) | |
847 | - | then (state ++ sendFeeToMatcher) | |
848 | - | else throw("Strict value is not equal to itself.") | |
849 | - | } | |
850 | - | else throw("Strict value is not equal to itself.") | |
851 | - | } | |
852 | - | else throw("Strict value is not equal to itself.") | |
853 | - | } | |
854 | - | else throw("Strict value is not equal to itself.") | |
855 | - | } | |
856 | - | else throw("Strict value is not equal to itself.") | |
857 | - | } | |
858 | - | } | |
739 | + | let pmtAssetId = value(pmt.assetId) | |
740 | + | let pmtAmt = pmt.amount | |
741 | + | let addonContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(ada()), "no addons")), "addon address in not valid") | |
742 | + | let check = reentrantInvoke(addonContract, "ensureCanGetOneTkn", [toString(userAddress)], nil) | |
743 | + | if ((check == check)) | |
744 | + | then if ((1000000000 > pmtAmt)) | |
745 | + | then throw("Min pmt 10 LP") | |
746 | + | else if (if (if ((0 > slippage)) | |
747 | + | then true | |
748 | + | else (0 > exchResult)) | |
749 | + | then true | |
750 | + | else (0 > outAmount)) | |
751 | + | then throw("Wrong params") | |
752 | + | else if ((lpId != toBase58String(pmtAssetId))) | |
753 | + | then throw("Wrong LP") | |
754 | + | else { | |
755 | + | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
756 | + | let estimAmAmt = r._1 | |
757 | + | let estimPrAmt = r._2 | |
758 | + | let amBalance = getAccBalance(amId) | |
759 | + | let prBalance = getAccBalance(prId) | |
760 | + | let $t03046630923 = if ((outAssetId == amId)) | |
761 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), exchResult, estimPrAmt, 0, 0, (estimAmAmt + exchResult)) | |
762 | + | else if ((outAssetId == prId)) | |
763 | + | then $Tuple7((amBalance - estimAmAmt), (prBalance - estimPrAmt), 0, 0, exchResult, estimAmAmt, (estimPrAmt + exchResult)) | |
764 | + | else throw("wrong outAssetId") | |
765 | + | let amBalanceNow = $t03046630923._1 | |
766 | + | let prBalanceNow = $t03046630923._2 | |
767 | + | let virtSwapInAm = $t03046630923._3 | |
768 | + | let virtSwapOutPr = $t03046630923._4 | |
769 | + | let virtSwapInPr = $t03046630923._5 | |
770 | + | let virtSwapOutAm = $t03046630923._6 | |
771 | + | let totalGet = $t03046630923._7 | |
772 | + | if (if ((0 > virtSwapInAm)) | |
773 | + | then true | |
774 | + | else (0 > virtSwapInPr)) | |
775 | + | then throw("Wrong calc") | |
776 | + | else { | |
777 | + | let D0 = invoke(gwxCntr, "calcD", [toString(amBalanceNow), toString(prBalanceNow), A, Amult, Dconv], nil) | |
778 | + | let D1 = invoke(gwxCntr, "calcD", [toString(((amBalanceNow - virtSwapInAm) + virtSwapOutAm)), toString(((prBalanceNow + virtSwapOutPr) - virtSwapInPr)), A, Amult, Dconv], nil) | |
779 | + | let D0vsD1 = vd(parseBigIntValue(str(D1)), parseBigIntValue(str(D0)), slippage4D) | |
780 | + | if ((D0vsD1 == D0vsD1)) | |
781 | + | then { | |
782 | + | let finalRes = vad(toBigInt(totalGet), toBigInt(outAmount), toBigInt(slippage)) | |
783 | + | if ((finalRes == finalRes)) | |
784 | + | then { | |
785 | + | let $t03162831732 = if ((outAssetId == amId)) | |
786 | + | then $Tuple2(toInt(finalRes._2), 0) | |
787 | + | else $Tuple2(0, toInt(finalRes._2)) | |
788 | + | let outAm = $t03162831732._1 | |
789 | + | let outPr = $t03162831732._2 | |
790 | + | let curPrX18 = cpbi(t1(prBalance, prDcm), t1(amBalance, amDcm)) | |
791 | + | let curPr = f1(curPrX18, scale8) | |
792 | + | let state = [ScriptTransfer(userAddress, (outAm + outPr), if ((outAssetId == "WAVES")) | |
793 | + | then unit | |
794 | + | 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)] | |
795 | + | if ((state == state)) | |
796 | + | then { | |
797 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
798 | + | if ((burn == burn)) | |
799 | + | then state | |
800 | + | else throw("Strict value is not equal to itself.") | |
801 | + | } | |
802 | + | else throw("Strict value is not equal to itself.") | |
803 | + | } | |
804 | + | else throw("Strict value is not equal to itself.") | |
805 | + | } | |
806 | + | else throw("Strict value is not equal to itself.") | |
807 | + | } | |
808 | + | } | |
809 | + | else throw("Strict value is not equal to itself.") | |
859 | 810 | } | |
860 | 811 | ||
861 | 812 | ||
862 | 813 | ||
863 | 814 | @Callable(i) | |
864 | 815 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
865 | - | let r = | |
866 | - | let | |
867 | - | let | |
868 | - | let | |
869 | - | let | |
816 | + | let r = cg(i) | |
817 | + | let outAmAmt = r._1 | |
818 | + | let outPrAmt = r._2 | |
819 | + | let pmtAmt = r._3 | |
820 | + | let pmtAssetId = r._4 | |
870 | 821 | let state = r._5 | |
871 | - | let checkOutAmountAmount = if ((outAmountAmount >= noLessThenAmtAsset)) | |
872 | - | then true | |
873 | - | else throwErr(((("Failed: " + toString(outAmountAmount)) + " < ") + toString(noLessThenAmtAsset))) | |
874 | - | if ((checkOutAmountAmount == checkOutAmountAmount)) | |
875 | - | then { | |
876 | - | let checkOutPriceAmount = if ((outPriceAmount >= noLessThenPriceAsset)) | |
877 | - | then true | |
878 | - | else throwErr(((("Failed: " + toString(outPriceAmount)) + " < ") + toString(noLessThenPriceAsset))) | |
879 | - | if ((checkOutPriceAmount == checkOutPriceAmount)) | |
880 | - | then { | |
881 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
882 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
883 | - | then state | |
884 | - | else throw("Strict value is not equal to itself.") | |
885 | - | } | |
886 | - | else throw("Strict value is not equal to itself.") | |
887 | - | } | |
888 | - | else throw("Strict value is not equal to itself.") | |
822 | + | if ((noLessThenAmtAsset > outAmAmt)) | |
823 | + | then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
824 | + | else if ((noLessThenPriceAsset > outPrAmt)) | |
825 | + | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
826 | + | else { | |
827 | + | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
828 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
829 | + | then state | |
830 | + | else throw("Strict value is not equal to itself.") | |
831 | + | } | |
889 | 832 | } | |
890 | 833 | ||
891 | 834 | ||
892 | 835 | ||
893 | 836 | @Callable(i) | |
894 | 837 | func unstakeAndGet (amount) = { | |
895 | 838 | let checkPayments = if ((size(i.payments) != 0)) | |
896 | - | then | |
839 | + | then throw("No pmnts expd") | |
897 | 840 | else true | |
898 | 841 | if ((checkPayments == checkPayments)) | |
899 | 842 | then { | |
900 | - | let cfg = | |
901 | - | let factoryCfg = | |
843 | + | let cfg = gpc() | |
844 | + | let factoryCfg = gfc() | |
902 | 845 | let lpAssetId = fromBase58String(cfg[idxLPAsId]) | |
903 | - | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), " | |
846 | + | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
904 | 847 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
905 | 848 | if ((unstakeInv == unstakeInv)) | |
906 | 849 | then { | |
907 | - | let r = | |
850 | + | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
908 | 851 | let sts = parseIntValue(r._9) | |
909 | 852 | let state = r._10 | |
910 | - | let v = if (if ( | |
853 | + | let v = if (if (igs()) | |
911 | 854 | then true | |
912 | 855 | else (sts == PoolShutdown)) | |
913 | - | then | |
856 | + | then throw(("Blocked: " + toString(sts))) | |
914 | 857 | else true | |
915 | 858 | if ((v == v)) | |
916 | 859 | then { | |
917 | - | let burnA = invoke( | |
860 | + | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
918 | 861 | if ((burnA == burnA)) | |
919 | 862 | then state | |
920 | 863 | else throw("Strict value is not equal to itself.") | |
921 | 864 | } | |
922 | 865 | else throw("Strict value is not equal to itself.") | |
923 | 866 | } | |
924 | 867 | else throw("Strict value is not equal to itself.") | |
925 | 868 | } | |
926 | 869 | else throw("Strict value is not equal to itself.") | |
927 | 870 | } | |
928 | 871 | ||
929 | 872 | ||
930 | 873 | ||
931 | 874 | @Callable(i) | |
932 | - | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString( | |
933 | - | then | |
934 | - | else $Tuple2([StringEntry( | |
875 | + | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
876 | + | then throw("denied") | |
877 | + | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
935 | 878 | ||
936 | 879 | ||
937 | 880 | ||
938 | 881 | @Callable(i) | |
939 | - | func setS (k,v) = if ((toString(i.caller) != | |
882 | + | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
940 | 883 | then pd | |
941 | 884 | else [StringEntry(k, v)] | |
942 | 885 | ||
943 | 886 | ||
944 | 887 | ||
945 | 888 | @Callable(i) | |
946 | - | func setI (k,v) = if ((toString(i.caller) != | |
889 | + | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
947 | 890 | then pd | |
948 | 891 | else [IntegerEntry(k, v)] | |
949 | 892 | ||
950 | 893 | ||
951 | 894 | ||
952 | 895 | @Callable(i) | |
953 | - | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, | |
896 | + | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
954 | 897 | ||
955 | 898 | ||
956 | 899 | ||
957 | 900 | @Callable(i) | |
958 | 901 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
959 | 902 | ||
960 | 903 | ||
961 | 904 | ||
962 | 905 | @Callable(i) | |
963 | 906 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
964 | 907 | let pr = calcPrices(amAmt, prAmt, lpAmt) | |
965 | 908 | $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])]) | |
966 | 909 | } | |
967 | 910 | ||
968 | 911 | ||
969 | 912 | ||
970 | 913 | @Callable(i) | |
971 | - | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, | |
914 | + | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
972 | 915 | ||
973 | 916 | ||
974 | 917 | ||
975 | 918 | @Callable(i) | |
976 | - | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString( | |
919 | + | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
977 | 920 | ||
978 | 921 | ||
979 | 922 | ||
980 | 923 | @Callable(i) | |
981 | - | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString( | |
924 | + | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
982 | 925 | ||
983 | 926 | ||
984 | 927 | ||
985 | 928 | @Callable(i) | |
986 | - | func estimatePutOperationWrapperREADONLY (txId58,slippage, | |
929 | + | 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, "")) | |
987 | 930 | ||
988 | 931 | ||
989 | 932 | ||
990 | 933 | @Callable(i) | |
991 | - | func estimateGetOperationWrapperREADONLY (txId58, | |
992 | - | let r = | |
934 | + | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
935 | + | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
993 | 936 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
994 | 937 | } | |
995 | 938 | ||
996 | 939 | ||
997 | 940 | @Verifier(tx) | |
998 | - | func verify () = match tx { | |
999 | - | case order: Order => | |
1000 | - | let mtchPub = getMatcherPubOrFail() | |
1001 | - | let orV = validateMatcherOrderAllowed(order) | |
1002 | - | let sndrV = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1003 | - | let mtchV = sigVerify(order.bodyBytes, order.proofs[1], mtchPub) | |
1004 | - | if (if (if (orV) | |
1005 | - | then sndrV | |
1006 | - | else false) | |
1007 | - | then mtchV | |
1008 | - | else false) | |
1009 | - | then true | |
1010 | - | else throwOrderError(orV, sndrV, mtchV) | |
1011 | - | case _ => | |
1012 | - | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1013 | - | case pk: ByteVector => | |
1014 | - | pk | |
1015 | - | case _: Unit => | |
1016 | - | tx.senderPublicKey | |
1017 | - | case _ => | |
1018 | - | throw("Match error") | |
1019 | - | } | |
1020 | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1021 | - | } | |
941 | + | func verify () = { | |
942 | + | let targetPublicKey = match m() { | |
943 | + | case pk: ByteVector => | |
944 | + | pk | |
945 | + | case _: Unit => | |
946 | + | tx.senderPublicKey | |
947 | + | case _ => | |
948 | + | throw("Match error") | |
949 | + | } | |
950 | + | match tx { | |
951 | + | case order: Order => | |
952 | + | let matcherPub = mp() | |
953 | + | let orderValid = moa(order) | |
954 | + | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
955 | + | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
956 | + | if (if (if (orderValid) | |
957 | + | then senderValid | |
958 | + | else false) | |
959 | + | then matcherValid | |
960 | + | else false) | |
961 | + | then true | |
962 | + | else toe(orderValid, senderValid, matcherValid) | |
963 | + | case s: SetScriptTransaction => | |
964 | + | let newHash = blake2b256(value(s.script)) | |
965 | + | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
966 | + | let currentHash = scriptHash(this) | |
967 | + | if (if ((allowedHash == newHash)) | |
968 | + | then (currentHash != newHash) | |
969 | + | else false) | |
970 | + | then true | |
971 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
972 | + | case _ => | |
973 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
974 | + | } | |
975 | + | } | |
1022 | 976 |
github/deemru/w8io/169f3d6 190.14 ms ◑