tx · JBgaBA6LL8vWHByeKcujbj1if9ZtHh91DMobjhFcCaHC 3ND6qeDAKCuRg6oTgcC9KvNF5UfdS3J2SzR: -0.02800000 Waves 2022.06.15 16:44 [2097569] smart account 3ND6qeDAKCuRg6oTgcC9KvNF5UfdS3J2SzR > SELF 0.00000000 Waves
{ "type": 13, "id": "JBgaBA6LL8vWHByeKcujbj1if9ZtHh91DMobjhFcCaHC", "fee": 2800000, "feeAssetId": null, "timestamp": 1655300680660, "version": 2, "chainId": 84, "sender": "3ND6qeDAKCuRg6oTgcC9KvNF5UfdS3J2SzR", "senderPublicKey": "FnJniYXAWfwAQ3qtBt1aPAaNDyz1pHYUfCQu7QihnhLu", "proofs": [ "4N1m2MhXrmHaUZZUr8MbjtRnRa6ComgFds1fFEo6miWAjL2FjNJZ45ofjD9ftuAT8CwPF9TPNP3Dm72rqU8XzFKM" ], "script": "base64:AAIFAAAAAAAAADQIAhIDCgEIEgkKBwgICAgBCAgSAwoBARIAEgASBQoDCAgIEgQKAggBEgMKAQgSAwoBCBIAAAAAOQAAAAADU0VQAgAAAAJfXwAAAAAFRU1QVFkCAAAAAAEAAAAPZ2V0U3RyaW5nT3JGYWlsAAAAAQAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkJAAEsAAAAAgIAAAAVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQAAAANrZXkBAAAAEGdldEJvb2xlYW5PckZhaWwAAAABAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEGwAAAAIFAAAABHRoaXMFAAAAA2tleQkAASwAAAACAgAAABVObyBkYXRhIGZvciB0aGlzLmtleT0FAAAAA2tleQEAAAATa2V5TWFuYWdlclB1YmxpY0tleQAAAAAJAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAABBtYW5hZ2VyUHVibGljS2V5BQAAAANuaWwFAAAAA1NFUAE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HB8DyCT Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let lPdecimals = 8 | |
5 | - | ||
6 | - | let scale8 = 100000000 | |
7 | - | ||
8 | - | let scale8BigInt = toBigInt(100000000) | |
9 | - | ||
10 | - | let scale18 = toBigInt(1000000000000000000) | |
11 | - | ||
12 | - | let zeroBigInt = toBigInt(0) | |
13 | - | ||
14 | 4 | let SEP = "__" | |
15 | 5 | ||
16 | 6 | let EMPTY = "" | |
17 | 7 | ||
18 | - | let PoolActive = 1 | |
19 | - | ||
20 | - | let PoolPutDisabled = 2 | |
21 | - | ||
22 | - | let PoolMatcherDisabled = 3 | |
23 | - | ||
24 | - | let PoolShutdown = 4 | |
25 | - | ||
26 | - | let idxPoolAddress = 1 | |
27 | - | ||
28 | - | let idxPoolStatus = 2 | |
29 | - | ||
30 | - | let idxPoolLPAssetId = 3 | |
31 | - | ||
32 | - | let idxAmtAssetId = 4 | |
33 | - | ||
34 | - | let idxPriceAssetId = 5 | |
35 | - | ||
36 | - | let idxAmtAssetDcm = 6 | |
37 | - | ||
38 | - | let idxPriceAssetDcm = 7 | |
39 | - | ||
40 | - | let idxIAmtAssetId = 8 | |
41 | - | ||
42 | - | let idxIPriceAssetId = 9 | |
43 | - | ||
44 | - | let idxLPAssetDcm = 10 | |
45 | - | ||
46 | - | let idxPoolAmtAssetAmt = 1 | |
47 | - | ||
48 | - | let idxPoolPriceAssetAmt = 2 | |
49 | - | ||
50 | - | let idxPoolLPAssetAmt = 3 | |
51 | - | ||
52 | - | let idxFactoryStakingContract = 1 | |
53 | - | ||
54 | - | let idxFactorySlippageContract = 7 | |
55 | - | ||
56 | - | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
8 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
57 | 9 | ||
58 | 10 | ||
59 | - | func | |
11 | + | func getBooleanOrFail (key) = valueOrErrorMessage(getBoolean(this, key), ("No data for this.key=" + key)) | |
60 | 12 | ||
61 | 13 | ||
62 | - | func | |
14 | + | func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
63 | 15 | ||
64 | 16 | ||
65 | - | func abs (val) = if ((zeroBigInt > val)) | |
66 | - | then -(val) | |
67 | - | else val | |
17 | + | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
68 | 18 | ||
69 | 19 | ||
70 | - | func | |
20 | + | func failExecuteGet (msg,baseAssetStr,userAddressStr,getTxIdStr) = throw(((((((msg + ": baseAssetStr=") + baseAssetStr) + " userAddressStr=") + userAddressStr) + " getTxIdStr=") + getTxIdStr)) | |
71 | 21 | ||
72 | 22 | ||
73 | - | func | |
23 | + | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], SEP) | |
74 | 24 | ||
75 | 25 | ||
76 | - | func | |
26 | + | func keyAssetCfg (baseAssetStr) = ("%s%s%s__config__asset__" + baseAssetStr) | |
77 | 27 | ||
78 | 28 | ||
79 | - | func | |
29 | + | func keyProxyAddress (assetId) = makeString(["%s%s", "proxyAddress", assetId], SEP) | |
80 | 30 | ||
81 | 31 | ||
82 | - | func | |
32 | + | func keyBalance (assetId) = makeString(["%s%s", "balance", assetId], SEP) | |
83 | 33 | ||
84 | 34 | ||
85 | - | func | |
35 | + | func keyNextInternalAssetId () = "%s__nextInternalAssetId" | |
86 | 36 | ||
87 | 37 | ||
88 | - | func | |
38 | + | func keyPriceLast (internalBasetAssetStr) = ("%s%s%d__price__last__" + internalBasetAssetStr) | |
89 | 39 | ||
90 | 40 | ||
91 | - | func | |
41 | + | func keyTopUpLastHeight (internalBasetAssetStr,sender) = makeString(["%s%s%s%d%s__topup__last__height", internalBasetAssetStr, sender], SEP) | |
92 | 42 | ||
93 | 43 | ||
94 | - | func | |
44 | + | func keyPriceHistory (internalBasetAssetStr,h,timestamp) = makeString(["%s%s%d%d%d__price__history", internalBasetAssetStr, toString(h), toString(timestamp)], SEP) | |
95 | 45 | ||
96 | 46 | ||
97 | - | func | |
47 | + | func keyTotalLocked (internalBasetAssetStr) = ("%s%s%d__total__locked__" + internalBasetAssetStr) | |
98 | 48 | ||
99 | 49 | ||
100 | - | func | |
50 | + | func keyTotalLockedByUser (internalBaseAssetStr,userAddressStr) = makeString(["%s%s%d%s__total__locked", internalBaseAssetStr, userAddressStr], SEP) | |
101 | 51 | ||
102 | 52 | ||
103 | - | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
104 | - | ||
105 | - | ||
106 | - | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
53 | + | func keyMappingsInternal2baseAssetId (internalBaseAsset) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(internalBaseAsset)) | |
107 | 54 | ||
108 | 55 | ||
109 | 56 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
110 | 57 | ||
111 | 58 | ||
112 | - | func | |
59 | + | func keyMappingsShare2baseAssetId (shareAssetStr) = ("%s%s%s__mappings__share2baseAssetId__" + shareAssetStr) | |
113 | 60 | ||
114 | 61 | ||
115 | - | func | |
62 | + | func keyMappingsBaseAsset2shareId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2shareId__" + baseAssetStr) | |
116 | 63 | ||
117 | 64 | ||
118 | - | func | |
65 | + | func keyShutdownPutOperation (internalBaseAssetStr) = ("%s%s%d__shutdown__put__" + internalBaseAssetStr) | |
119 | 66 | ||
120 | 67 | ||
121 | - | func | |
68 | + | func keyShutdownManager (internalBaseAssetStr) = ("%s%s%d__shutdown__manager__" + internalBaseAssetStr) | |
122 | 69 | ||
123 | 70 | ||
124 | - | func | |
71 | + | func assetsStoreContract () = addressFromStringValue(value(getString(keyAssetsStoreContract()))) | |
125 | 72 | ||
126 | 73 | ||
127 | - | let | |
74 | + | let IdxCfgShareAssetId = 1 | |
128 | 75 | ||
129 | - | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
76 | + | let IdxCfgInternalBaseAsset = 2 | |
77 | + | ||
78 | + | let IdxCfgDecimalsMultBothAssets = 3 | |
79 | + | ||
80 | + | let IdxCfgDecimalsMultPrice = 4 | |
81 | + | ||
82 | + | let IdxCfgGetDelayBlocks = 5 | |
83 | + | ||
84 | + | func dataAssetCfg (shareAssetStr,internalBaseAssetStr,decimalsMultBothAssets,decimalsMultPrice,getDelayInBlocks) = makeString(["%s%d%d%d%d", shareAssetStr, internalBaseAssetStr, toString(decimalsMultBothAssets), toString(decimalsMultPrice), toString(getDelayInBlocks)], SEP) | |
130 | 85 | ||
131 | 86 | ||
132 | - | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
87 | + | let IdxTotalLockedShare = 1 | |
88 | + | ||
89 | + | let IdxTotalLockedBase = 2 | |
90 | + | ||
91 | + | func dataTotalLocked (shareAssetAmount,baseAssetAmount) = makeString(["%d%d", toString(shareAssetAmount), toString(baseAssetAmount)], SEP) | |
133 | 92 | ||
134 | 93 | ||
135 | - | func getPoolConfig () = { | |
136 | - | let amtAsset = getStringOrFail(this, keyAmtAsset()) | |
137 | - | let priceAsset = getStringOrFail(this, keyPriceAsset()) | |
138 | - | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
139 | - | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
140 | - | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
94 | + | func readTotalLocked (key) = { | |
95 | + | let totalLockedArray = split(valueOrElse(getString(this, key), dataTotalLocked(0, 0)), SEP) | |
96 | + | [-1, parseIntValue(totalLockedArray[IdxTotalLockedShare]), parseIntValue(totalLockedArray[IdxTotalLockedBase])] | |
141 | 97 | } | |
142 | 98 | ||
143 | 99 | ||
144 | - | func | |
100 | + | func keyOperation (operationType,internalBaseAssetStr,userAddress,txId) = makeString(["%s%d%s%s", operationType, internalBaseAssetStr, userAddress, txId], SEP) | |
145 | 101 | ||
146 | 102 | ||
147 | - | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
103 | + | let IdxOperStatus = 1 | |
104 | + | ||
105 | + | let IdxOperInAmount = 2 | |
106 | + | ||
107 | + | let IdxOperPrice = 3 | |
108 | + | ||
109 | + | let IdxOperOutAmount = 4 | |
110 | + | ||
111 | + | let IdxOperStartHeight = 5 | |
112 | + | ||
113 | + | let IdxOperStartTimestamp = 6 | |
114 | + | ||
115 | + | let IdxOperEndHeight = 7 | |
116 | + | ||
117 | + | let IdxOperEndTimestamp = 8 | |
118 | + | ||
119 | + | func privateDataOperationAllStrings (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = makeString(["%s%d%d%d%d%d%d%d", status, inAssetAmount, price, outAssetAmount, startHeight, startTimestamp, endHeight, endTimestamp], SEP) | |
148 | 120 | ||
149 | 121 | ||
150 | - | func | |
122 | + | func dataOperation (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = privateDataOperationAllStrings(status, toString(inAssetAmount), toString(price), toString(outAssetAmount), toString(startHeight), toString(startTimestamp), toString(endHeight), toString(endTimestamp)) | |
151 | 123 | ||
152 | 124 | ||
153 | - | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
154 | - | then wavesBalance(this).available | |
155 | - | else assetBalance(this, fromBase58String(assetId)) | |
125 | + | func dataOperationExecutionUpdate (currOperArray,newStatus,newEndTimestamp) = privateDataOperationAllStrings(newStatus, currOperArray[IdxOperInAmount], currOperArray[IdxOperPrice], currOperArray[IdxOperOutAmount], currOperArray[IdxOperStartHeight], currOperArray[IdxOperStartTimestamp], currOperArray[IdxOperEndHeight], toString(newEndTimestamp)) | |
156 | 126 | ||
157 | 127 | ||
158 | - | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
159 | - | ||
160 | - | ||
161 | - | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
162 | - | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
163 | - | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
164 | - | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
128 | + | func readAssetCfgOrFail (baseAssetStr) = { | |
129 | + | let key = keyAssetCfg(baseAssetStr) | |
130 | + | split(getStringOrFail(key), SEP) | |
165 | 131 | } | |
166 | 132 | ||
167 | 133 | ||
168 | - | func calcPrices (amAmt,prAmt,lpAmt) = { | |
169 | - | let cfg = getPoolConfig() | |
170 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
171 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
172 | - | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
173 | - | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
174 | - | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
175 | - | let lpAmtX18 = toX18(lpAmt, scale8) | |
176 | - | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
177 | - | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
178 | - | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
134 | + | func incrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
135 | + | let dataArray = readTotalLocked(key) | |
136 | + | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] + shareAssetAmount), (dataArray[IdxTotalLockedBase] + baseAssetAmount))) | |
179 | 137 | } | |
180 | 138 | ||
181 | 139 | ||
182 | - | func | |
183 | - | let | |
184 | - | ||
140 | + | func decrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
141 | + | let dataArray = readTotalLocked(key) | |
142 | + | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] - shareAssetAmount), (dataArray[IdxTotalLockedBase] - baseAssetAmount))) | |
185 | 143 | } | |
186 | - | ||
187 | - | ||
188 | - | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
189 | - | let cfg = getPoolConfig() | |
190 | - | let lpAssetId = cfg[idxPoolLPAssetId] | |
191 | - | let amAssetId = cfg[idxAmtAssetId] | |
192 | - | let prAssetId = cfg[idxPriceAssetId] | |
193 | - | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
194 | - | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
195 | - | let poolStatus = cfg[idxPoolStatus] | |
196 | - | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
197 | - | if ((lpAssetId != pmtAssetId)) | |
198 | - | then throw("Invalid asset passed.") | |
199 | - | else { | |
200 | - | let amBalance = getAccBalance(amAssetId) | |
201 | - | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
202 | - | let prBalance = getAccBalance(prAssetId) | |
203 | - | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
204 | - | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
205 | - | let curPrice = fromX18(curPriceX18, scale8) | |
206 | - | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
207 | - | let lpEmissionX18 = toX18(lpEmission, scale8) | |
208 | - | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
209 | - | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
210 | - | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
211 | - | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
212 | - | let state = if ((txId58 == "")) | |
213 | - | then nil | |
214 | - | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
215 | - | then unit | |
216 | - | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
217 | - | then unit | |
218 | - | else fromBase58String(prAssetId)), StringEntry(keyGetActionByUser(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(keyPriceLast(), curPrice), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), curPrice)] | |
219 | - | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
220 | - | } | |
221 | - | } | |
222 | - | ||
223 | - | ||
224 | - | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
225 | - | let cfg = getPoolConfig() | |
226 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
227 | - | let amAssetIdStr = cfg[idxAmtAssetId] | |
228 | - | let prAssetIdStr = cfg[idxPriceAssetId] | |
229 | - | let iAmtAssetId = cfg[idxIAmtAssetId] | |
230 | - | let iPriceAssetId = cfg[idxIPriceAssetId] | |
231 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
232 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
233 | - | let poolStatus = cfg[idxPoolStatus] | |
234 | - | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
235 | - | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
236 | - | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
237 | - | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
238 | - | then true | |
239 | - | else (prAssetIdStr != inPrAssetIdStr)) | |
240 | - | then throw("Invalid amt or price asset passed.") | |
241 | - | else { | |
242 | - | let amBalance = if (isEvaluate) | |
243 | - | then getAccBalance(amAssetIdStr) | |
244 | - | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
245 | - | let prBalance = if (isEvaluate) | |
246 | - | then getAccBalance(prAssetIdStr) | |
247 | - | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
248 | - | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
249 | - | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
250 | - | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
251 | - | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
252 | - | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
253 | - | let res = if ((lpEmission == 0)) | |
254 | - | then { | |
255 | - | let curPriceX18 = zeroBigInt | |
256 | - | let slippageX18 = zeroBigInt | |
257 | - | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
258 | - | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
259 | - | } | |
260 | - | else { | |
261 | - | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
262 | - | let slippageX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
263 | - | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
264 | - | if (if ((curPriceX18 != zeroBigInt)) | |
265 | - | then (slippageX18 > slippageToleranceX18) | |
266 | - | else false) | |
267 | - | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
268 | - | else { | |
269 | - | let lpEmissionX18 = toX18(lpEmission, scale8) | |
270 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
271 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
272 | - | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
273 | - | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
274 | - | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
275 | - | let expAmtAssetAmtX18 = expectedAmts._1 | |
276 | - | let expPriceAssetAmtX18 = expectedAmts._2 | |
277 | - | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
278 | - | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
279 | - | } | |
280 | - | } | |
281 | - | let calcLpAmt = res._1 | |
282 | - | let calcAmAssetPmt = res._2 | |
283 | - | let calcPrAssetPmt = res._3 | |
284 | - | let curPrice = fromX18(res._4, scale8) | |
285 | - | let slippageCalc = fromX18(res._5, scale8) | |
286 | - | if ((0 >= calcLpAmt)) | |
287 | - | then throw("Invalid calculations. LP calculated is less than zero.") | |
288 | - | else { | |
289 | - | let emitLpAmt = if (!(emitLp)) | |
290 | - | then 0 | |
291 | - | else calcLpAmt | |
292 | - | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
293 | - | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
294 | - | let commonState = [IntegerEntry(keyPriceLast(), curPrice), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), curPrice), StringEntry(keyPutActionByUser(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
295 | - | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
296 | - | } | |
297 | - | } | |
298 | - | } | |
299 | - | ||
300 | - | ||
301 | - | func validateMatcherOrderAllowed (order) = { | |
302 | - | let cfg = getPoolConfig() | |
303 | - | let amtAssetId = cfg[idxAmtAssetId] | |
304 | - | let priceAssetId = cfg[idxPriceAssetId] | |
305 | - | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
306 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
307 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
308 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
309 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
310 | - | let curPriceX18 = if ((order.orderType == Buy)) | |
311 | - | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
312 | - | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
313 | - | let curPrice = fromX18(curPriceX18, scale8) | |
314 | - | if (if (if (isGlobalShutdown()) | |
315 | - | then true | |
316 | - | else (poolStatus == PoolMatcherDisabled)) | |
317 | - | then true | |
318 | - | else (poolStatus == PoolShutdown)) | |
319 | - | then throw("Exchange operations disabled") | |
320 | - | else { | |
321 | - | let orderAmtAsset = order.assetPair.amountAsset | |
322 | - | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
323 | - | then "WAVES" | |
324 | - | else toBase58String(value(orderAmtAsset)) | |
325 | - | let orderPriceAsset = order.assetPair.priceAsset | |
326 | - | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
327 | - | then "WAVES" | |
328 | - | else toBase58String(value(orderPriceAsset)) | |
329 | - | if (if ((orderAmtAssetStr != amtAssetId)) | |
330 | - | then true | |
331 | - | else (orderPriceAssetStr != priceAssetId)) | |
332 | - | then throw("Wrong order assets.") | |
333 | - | else { | |
334 | - | let orderPrice = order.price | |
335 | - | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
336 | - | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
337 | - | let isOrderPriceValid = if ((order.orderType == Buy)) | |
338 | - | then (curPrice >= castedOrderPrice) | |
339 | - | else (castedOrderPrice >= curPrice) | |
340 | - | true | |
341 | - | } | |
342 | - | } | |
343 | - | } | |
344 | - | ||
345 | - | ||
346 | - | func commonGet (i) = if ((size(i.payments) != 1)) | |
347 | - | then throw("exactly 1 payment is expected") | |
348 | - | else { | |
349 | - | let pmt = value(i.payments[0]) | |
350 | - | let pmtAssetId = value(pmt.assetId) | |
351 | - | let pmtAmt = pmt.amount | |
352 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
353 | - | let outAmAmt = res._1 | |
354 | - | let outPrAmt = res._2 | |
355 | - | let poolStatus = parseIntValue(res._9) | |
356 | - | let state = res._10 | |
357 | - | if (if (isGlobalShutdown()) | |
358 | - | then true | |
359 | - | else (poolStatus == PoolShutdown)) | |
360 | - | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
361 | - | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
362 | - | } | |
363 | - | ||
364 | - | ||
365 | - | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
366 | - | then throw("exactly 2 payments are expected") | |
367 | - | else { | |
368 | - | let amAssetPmt = value(i.payments[0]) | |
369 | - | let prAssetPmt = value(i.payments[1]) | |
370 | - | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
371 | - | let poolStatus = parseIntValue(estPut._8) | |
372 | - | if (if (if (isGlobalShutdown()) | |
373 | - | then true | |
374 | - | else (poolStatus == PoolPutDisabled)) | |
375 | - | then true | |
376 | - | else (poolStatus == PoolShutdown)) | |
377 | - | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
378 | - | else estPut | |
379 | - | } | |
380 | 144 | ||
381 | 145 | ||
382 | 146 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
389 | 153 | } | |
390 | 154 | ||
391 | 155 | ||
156 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
157 | + | case s: String => | |
158 | + | fromBase58String(s) | |
159 | + | case _: Unit => | |
160 | + | unit | |
161 | + | case _ => | |
162 | + | throw("Match error") | |
163 | + | } | |
164 | + | ||
165 | + | ||
166 | + | func balanceOrZero (assetId) = valueOrElse(getInteger(keyBalance(assetId)), 0) | |
167 | + | ||
168 | + | ||
169 | + | func genericCalcPrice (balance,internalBaseAssetStr,baseAssetId,topUpBaseAmount,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = { | |
170 | + | let totalLockedArray = readTotalLocked(keyTotalLocked(internalBaseAssetStr)) | |
171 | + | let totalLockedBaseAmount = totalLockedArray[IdxTotalLockedBase] | |
172 | + | let baseAssetBalance = balance | |
173 | + | let baseAssetBalanceConsideringLock = ((baseAssetBalance - totalLockedBaseAmount) + topUpBaseAmount) | |
174 | + | if ((0 > baseAssetBalanceConsideringLock)) | |
175 | + | then throw(((("baseAssetBalanceConsideringLock < 0: baseAssetBalance=" + toString(baseAssetBalance)) + " baseAssetBalanceConsideringLock=") + toString(baseAssetBalanceConsideringLock))) | |
176 | + | else { | |
177 | + | let shareEmission = value(assetInfo(shareAssetId)).quantity | |
178 | + | let price = if ((shareEmission == 0)) | |
179 | + | then (1 * decimalsMultPrice) | |
180 | + | else fraction(baseAssetBalanceConsideringLock, decimalsMultPrice, shareEmission) | |
181 | + | $Tuple5(price, baseAssetBalance, totalLockedBaseAmount, baseAssetBalanceConsideringLock, shareEmission) | |
182 | + | } | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | func calcPrice (balance,internalBaseAssetStr,baseAssetId,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = genericCalcPrice(balance, internalBaseAssetStr, baseAssetId, 0, shareAssetId, decimalsMultBothAssets, decimalsMultPrice) | |
187 | + | ||
188 | + | ||
189 | + | func privateCurrentSysParamsREST (baseAssetStr) = { | |
190 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
191 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
192 | + | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
193 | + | let shareAssetId = fromBase58String(shareAssetStr) | |
194 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
195 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
196 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
197 | + | let sysState = calcPrice(balanceOrZero(baseAssetStr), internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice) | |
198 | + | $Tuple6(IntegerEntry("price", sysState._1), IntegerEntry("decimalsMultPrice", decimalsMultPrice), IntegerEntry("baseAssetBalance", sysState._2), IntegerEntry("totalLockedBaseAmount", sysState._3), IntegerEntry("baseAssetBalanceConsideringLock", sysState._4), IntegerEntry("shareEmission", sysState._5)) | |
199 | + | } | |
200 | + | ||
201 | + | ||
392 | 202 | func mustManager (i) = { | |
393 | - | let pd = throw(" | |
203 | + | let pd = throw("permission denied") | |
394 | 204 | match managerPublicKeyOrUnit() { | |
395 | 205 | case pk: ByteVector => | |
396 | 206 | if ((i.callerPublicKey == pk)) | |
406 | 216 | } | |
407 | 217 | ||
408 | 218 | ||
219 | + | func mustProxyAddress (i,assetId) = { | |
220 | + | let isProxy = (toString(i.caller) == valueOrElse(getString(keyProxyAddress(assetId)), EMPTY)) | |
221 | + | if (isProxy) | |
222 | + | then true | |
223 | + | else { | |
224 | + | let checkCaller = mustManager(i) | |
225 | + | if ((checkCaller == checkCaller)) | |
226 | + | then true | |
227 | + | else throw("Strict value is not equal to itself.") | |
228 | + | } | |
229 | + | } | |
230 | + | ||
231 | + | ||
409 | 232 | @Callable(i) | |
410 | - | func constructor ( | |
233 | + | func constructor (assetsStoreContract) = { | |
411 | 234 | let checkCaller = mustManager(i) | |
412 | 235 | if ((checkCaller == checkCaller)) | |
413 | - | then [StringEntry( | |
236 | + | then [StringEntry(keyAssetsStoreContract(), assetsStoreContract)] | |
414 | 237 | else throw("Strict value is not equal to itself.") | |
415 | 238 | } | |
416 | 239 | ||
417 | 240 | ||
418 | 241 | ||
419 | 242 | @Callable(i) | |
420 | - | func setManager (managerPublicKey) = { | |
243 | + | func adminRegisterAsset (baseAssetStr,shareAssetName,shareAssetDescr,shareAssetLogo,getDelayinBlocks,shutdownManagerAddress,proxyAddress) = { | |
244 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
245 | + | let decimals = value(assetInfo(baseAssetId)).decimals | |
246 | + | let check = mustManager(i) | |
247 | + | if ((check == check)) | |
248 | + | then if ((toString(addressFromStringValue(shutdownManagerAddress)) != shutdownManagerAddress)) | |
249 | + | then throw("invalid shutdownManagerAddress") | |
250 | + | else if ((0 > getDelayinBlocks)) | |
251 | + | then throw(("invalid getDelayinBlocks=" + toString(getDelayinBlocks))) | |
252 | + | else { | |
253 | + | let shareAssetIssueAction = Issue(shareAssetName, shareAssetDescr, 1, decimals, true) | |
254 | + | let shareAssetId = calculateAssetId(shareAssetIssueAction) | |
255 | + | let shareAssetStr = toBase58String(shareAssetId) | |
256 | + | let decimalsMultPrice = ((100 * 1000) * 1000) | |
257 | + | let decimalsMultBothAssets = pow(10, 0, decimals, 0, 0, DOWN) | |
258 | + | let startPrice = (1 * decimalsMultPrice) | |
259 | + | let internalBaseAssettId = valueOrElse(getInteger(this, keyNextInternalAssetId()), 0) | |
260 | + | let internalBaseAssetStr = toString(internalBaseAssettId) | |
261 | + | let createOrUpdate = invoke(assetsStoreContract(), "createOrUpdate", [shareAssetStr, shareAssetLogo, false], nil) | |
262 | + | if ((createOrUpdate == createOrUpdate)) | |
263 | + | then { | |
264 | + | let addLabel = invoke(assetsStoreContract(), "addLabel", [shareAssetStr, "DEFI"], nil) | |
265 | + | if ((addLabel == addLabel)) | |
266 | + | then [StringEntry(keyAssetCfg(baseAssetStr), dataAssetCfg(shareAssetStr, internalBaseAssetStr, decimalsMultBothAssets, decimalsMultPrice, getDelayinBlocks)), StringEntry(keyMappingsInternal2baseAssetId(internalBaseAssettId), baseAssetStr), StringEntry(keyMappingsBaseAsset2internalId(baseAssetStr), internalBaseAssetStr), StringEntry(keyMappingsShare2baseAssetId(shareAssetStr), baseAssetStr), StringEntry(keyMappingsBaseAsset2shareId(baseAssetStr), shareAssetStr), BooleanEntry(keyShutdownPutOperation(internalBaseAssetStr), false), StringEntry(keyShutdownManager(internalBaseAssetStr), shutdownManagerAddress), IntegerEntry(keyNextInternalAssetId(), (internalBaseAssettId + 1)), IntegerEntry(keyPriceLast(internalBaseAssetStr), startPrice), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), startPrice), shareAssetIssueAction, Burn(shareAssetId, 1), StringEntry(keyProxyAddress(baseAssetStr), proxyAddress)] | |
267 | + | else throw("Strict value is not equal to itself.") | |
268 | + | } | |
269 | + | else throw("Strict value is not equal to itself.") | |
270 | + | } | |
271 | + | else throw("Strict value is not equal to itself.") | |
272 | + | } | |
273 | + | ||
274 | + | ||
275 | + | ||
276 | + | @Callable(i) | |
277 | + | func shutdownPut (internalBaseAssetId) = { | |
278 | + | let internalBaseAssetIdStr = toString(internalBaseAssetId) | |
279 | + | let baseAssetIdStr = getStringOrFail(keyMappingsInternal2baseAssetId(internalBaseAssetId)) | |
280 | + | let shutdownManagerAddress = getStringOrFail(keyShutdownManager(internalBaseAssetIdStr)) | |
281 | + | if ((1 > size(baseAssetIdStr))) | |
282 | + | then throw("invalid internalBaseAssetId") | |
283 | + | else if ((toString(i.caller) != shutdownManagerAddress)) | |
284 | + | then throw("access denied") | |
285 | + | else [BooleanEntry(keyShutdownPutOperation(toString(internalBaseAssetId)), true)] | |
286 | + | } | |
287 | + | ||
288 | + | ||
289 | + | ||
290 | + | @Callable(i) | |
291 | + | func put () = { | |
292 | + | let pmt = value(i.payments[0]) | |
293 | + | let baseAssetId = value(pmt.assetId) | |
294 | + | let baseAssetStr = toBase58String(baseAssetId) | |
295 | + | let userAddressStr = toString(i.caller) | |
296 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
297 | + | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
298 | + | let shareAssetId = fromBase58String(shareAssetStr) | |
299 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
300 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
301 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
302 | + | let isPutBlocked = getBooleanOrFail(keyShutdownPutOperation(internalBaseAssetStr)) | |
303 | + | if (isPutBlocked) | |
304 | + | then throw("put operation is blocked") | |
305 | + | else { | |
306 | + | let balance = (balanceOrZero(baseAssetStr) + pmt.amount) | |
307 | + | let price = calcPrice(balance, internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
308 | + | let shareAssetAmount = fraction(pmt.amount, decimalsMultPrice, price) | |
309 | + | [Reissue(shareAssetId, shareAssetAmount, true), ScriptTransfer(i.caller, shareAssetAmount, shareAssetId), StringEntry(keyOperation("P", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)), dataOperation("FINISHED", pmt.amount, price, shareAssetAmount, height, lastBlock.timestamp, height, lastBlock.timestamp)), ScriptTransfer(addressFromStringValue(value(getString(keyProxyAddress(baseAssetStr)))), pmt.amount, baseAssetId), IntegerEntry(keyBalance(baseAssetStr), balance)] | |
310 | + | } | |
311 | + | } | |
312 | + | ||
313 | + | ||
314 | + | ||
315 | + | @Callable(i) | |
316 | + | func submitGetRequest () = { | |
317 | + | let pmt = value(i.payments[0]) | |
318 | + | let shareAssetId = value(pmt.assetId) | |
319 | + | let shareAssetStr = toBase58String(shareAssetId) | |
320 | + | let callerPubStr = toBase58String(i.callerPublicKey) | |
321 | + | let userAddress = i.caller | |
322 | + | let userAddressStr = toString(userAddress) | |
323 | + | let shareAssetAmount = pmt.amount | |
324 | + | let baseAssetStr = getStringOrFail(keyMappingsShare2baseAssetId(shareAssetStr)) | |
325 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
326 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
327 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
328 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
329 | + | let getDelayBlocks = parseIntValue(cfgArray[IdxCfgGetDelayBlocks]) | |
330 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
331 | + | let price = calcPrice(balanceOrZero(baseAssetStr), internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
332 | + | let baseAssetAmount = fraction(shareAssetAmount, price, decimalsMultPrice) | |
333 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)) | |
334 | + | let operationData = dataOperation("PENDING", shareAssetAmount, price, baseAssetAmount, height, lastBlock.timestamp, (height + getDelayBlocks), 0) | |
335 | + | let balance = balanceOrZero(baseAssetStr) | |
336 | + | [Burn(shareAssetId, shareAssetAmount), StringEntry(operationKey, operationData), incrementTotalLocked(keyTotalLocked(internalBaseAssetStr), shareAssetAmount, baseAssetAmount), incrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), shareAssetAmount, baseAssetAmount)] | |
337 | + | } | |
338 | + | ||
339 | + | ||
340 | + | ||
341 | + | @Callable(i) | |
342 | + | func executeGetRequest (baseAssetStr,userAddressStr,getTxIdStr) = { | |
343 | + | let userAddress = addressFromStringValue(userAddressStr) | |
344 | + | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
345 | + | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
346 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
347 | + | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
348 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, getTxIdStr) | |
349 | + | let operationArray = split(getStringOrFail(operationKey), SEP) | |
350 | + | let status = operationArray[IdxOperStatus] | |
351 | + | let endHeight = parseIntValue(operationArray[IdxOperEndHeight]) | |
352 | + | let inShareAmount = parseIntValue(operationArray[IdxOperInAmount]) | |
353 | + | let outBaseAmount = parseIntValue(operationArray[IdxOperOutAmount]) | |
354 | + | if ((status != "PENDING")) | |
355 | + | then failExecuteGet("Status is not PENDING", baseAssetStr, userAddressStr, getTxIdStr) | |
356 | + | else if ((endHeight > height)) | |
357 | + | then failExecuteGet(((("EndHeight[" + toString(endHeight)) + "] > ") + toString(height)), baseAssetStr, userAddressStr, getTxIdStr) | |
358 | + | else [ScriptTransfer(userAddress, outBaseAmount, baseAssetId), StringEntry(operationKey, dataOperationExecutionUpdate(operationArray, "FINISHED", lastBlock.timestamp)), decrementTotalLocked(keyTotalLocked(internalBaseAssetStr), inShareAmount, outBaseAmount), decrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), inShareAmount, outBaseAmount), IntegerEntry(keyBalance(baseAssetStr), (balanceOrZero(baseAssetStr) - outBaseAmount))] | |
359 | + | } | |
360 | + | ||
361 | + | ||
362 | + | ||
363 | + | @Callable(i) | |
364 | + | func topUpBalance (baseAssetStr,delta) = { | |
365 | + | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
366 | + | let pmt = value(i.payments[0]) | |
367 | + | let pmtAssetId = value(pmt.assetId) | |
368 | + | let pmtAssetStr = toBase58String(pmtAssetId) | |
369 | + | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
370 | + | let decimalsMultBothAssets = parseIntValue(assetCfgArray[IdxCfgDecimalsMultBothAssets]) | |
371 | + | let decimalsMultPrice = parseIntValue(assetCfgArray[IdxCfgDecimalsMultPrice]) | |
372 | + | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
373 | + | let topUpLastHeightKEY = keyTopUpLastHeight(internalBaseAssetStr, toString(i.caller)) | |
374 | + | let topUpLastHeight = valueOrElse(getInteger(this, topUpLastHeightKEY), 0) | |
375 | + | let checks = [mustProxyAddress(i, baseAssetStr), if ((topUpLastHeight != height)) | |
376 | + | then true | |
377 | + | else throw("only one topUp per block is allowed")] | |
378 | + | if ((checks == checks)) | |
379 | + | then if ((baseAssetStr != pmtAssetStr)) | |
380 | + | then throw("attached payment's asset id is NOT matched passed baseAssetStr") | |
381 | + | else if ((size(i.payments) > 1)) | |
382 | + | then throw("only one payment can be attached") | |
383 | + | else { | |
384 | + | let newBalance = (balanceOrZero(pmtAssetStr) + delta) | |
385 | + | let price = genericCalcPrice(newBalance, internalBaseAssetStr, pmtAssetId, pmt.amount, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
386 | + | [IntegerEntry(keyPriceLast(internalBaseAssetStr), price), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), price), IntegerEntry(topUpLastHeightKEY, height), IntegerEntry(keyBalance(pmtAssetStr), newBalance)] | |
387 | + | } | |
388 | + | else throw("Strict value is not equal to itself.") | |
389 | + | } | |
390 | + | ||
391 | + | ||
392 | + | ||
393 | + | @Callable(i) | |
394 | + | func currentSysParamsREST (baseAssetStr) = { | |
395 | + | let sysStateTuple = privateCurrentSysParamsREST(baseAssetStr) | |
396 | + | let price = sysStateTuple._1.value | |
397 | + | let decimalsMultPrice = sysStateTuple._2.value | |
398 | + | let baseAssetBalance = sysStateTuple._3.value | |
399 | + | let totalLockedBaseAmount = sysStateTuple._4.value | |
400 | + | let baseAssetBalanceConsideringLock = sysStateTuple._5.value | |
401 | + | let shareEmission = sysStateTuple._6.value | |
402 | + | let restData = makeString(["startCurrentSysParamsREST", toString(price), toString(decimalsMultPrice), toString(baseAssetBalance), toString(totalLockedBaseAmount), toString(baseAssetBalanceConsideringLock), toString(shareEmission), "endCurrentSysParamsREST"], SEP) | |
403 | + | throw(restData) | |
404 | + | } | |
405 | + | ||
406 | + | ||
407 | + | ||
408 | + | @Callable(i) | |
409 | + | func setManager (pendingManagerPublicKey) = { | |
421 | 410 | let checkCaller = mustManager(i) | |
422 | 411 | if ((checkCaller == checkCaller)) | |
423 | 412 | then { | |
424 | - | let checkManagerPublicKey = fromBase58String( | |
413 | + | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
425 | 414 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
426 | - | then [StringEntry( | |
415 | + | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
427 | 416 | else throw("Strict value is not equal to itself.") | |
428 | 417 | } | |
429 | 418 | else throw("Strict value is not equal to itself.") | |
432 | 421 | ||
433 | 422 | ||
434 | 423 | @Callable(i) | |
435 | - | func put (slippageTolerance,shouldAutoStake) = { | |
436 | - | let factoryCfg = getFactoryConfig() | |
437 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.") | |
438 | - | let slippageContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactorySlippageContract]), "Error. Incorrect slippage contract address.") | |
439 | - | if ((0 > slippageTolerance)) | |
440 | - | then throw("Invalid slippageTolerance passed") | |
441 | - | else { | |
442 | - | let estPut = commonPut(i, slippageTolerance, true) | |
443 | - | let emitLpAmt = estPut._2 | |
444 | - | let lpAssetId = estPut._7 | |
445 | - | let state = estPut._9 | |
446 | - | let amDiff = estPut._10 | |
447 | - | let prDiff = estPut._11 | |
448 | - | let amId = estPut._12 | |
449 | - | let prId = estPut._13 | |
450 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
451 | - | if ((emitInv == emitInv)) | |
452 | - | then { | |
453 | - | let emitInvLegacy = match emitInv { | |
454 | - | case legacyFactoryContract: Address => | |
455 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
456 | - | case _ => | |
457 | - | unit | |
458 | - | } | |
459 | - | if ((emitInvLegacy == emitInvLegacy)) | |
460 | - | then { | |
461 | - | let slippageAInv = if ((amDiff > 0)) | |
462 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
463 | - | else nil | |
464 | - | if ((slippageAInv == slippageAInv)) | |
465 | - | then { | |
466 | - | let slippagePInv = if ((prDiff > 0)) | |
467 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
468 | - | else nil | |
469 | - | if ((slippagePInv == slippagePInv)) | |
470 | - | then { | |
471 | - | let lpTransfer = if (shouldAutoStake) | |
472 | - | then { | |
473 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
474 | - | if ((slpStakeInv == slpStakeInv)) | |
475 | - | then nil | |
476 | - | else throw("Strict value is not equal to itself.") | |
477 | - | } | |
478 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
479 | - | (state ++ lpTransfer) | |
480 | - | } | |
481 | - | else throw("Strict value is not equal to itself.") | |
482 | - | } | |
483 | - | else throw("Strict value is not equal to itself.") | |
484 | - | } | |
485 | - | else throw("Strict value is not equal to itself.") | |
486 | - | } | |
487 | - | else throw("Strict value is not equal to itself.") | |
488 | - | } | |
489 | - | } | |
490 | - | ||
491 | - | ||
492 | - | ||
493 | - | @Callable(i) | |
494 | - | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
495 | - | then throw("Invalid value passed") | |
496 | - | else { | |
497 | - | let estPut = commonPut(i, maxSlippage, false) | |
498 | - | estPut._9 | |
499 | - | } | |
500 | - | ||
501 | - | ||
502 | - | ||
503 | - | @Callable(i) | |
504 | - | func get () = { | |
505 | - | let res = commonGet(i) | |
506 | - | let outAmtAmt = res._1 | |
507 | - | let outPrAmt = res._2 | |
508 | - | let pmtAmt = res._3 | |
509 | - | let pmtAssetId = res._4 | |
510 | - | let state = res._5 | |
511 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
512 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
513 | - | then state | |
514 | - | else throw("Strict value is not equal to itself.") | |
515 | - | } | |
516 | - | ||
517 | - | ||
518 | - | ||
519 | - | @Callable(i) | |
520 | - | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
521 | - | let res = commonGet(i) | |
522 | - | let outAmAmt = res._1 | |
523 | - | let outPrAmt = res._2 | |
524 | - | let pmtAmt = res._3 | |
525 | - | let pmtAssetId = res._4 | |
526 | - | let state = res._5 | |
527 | - | if ((noLessThenAmtAsset > outAmAmt)) | |
528 | - | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
529 | - | else if ((noLessThenPriceAsset > outPrAmt)) | |
530 | - | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
531 | - | else { | |
532 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
533 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
534 | - | then state | |
535 | - | else throw("Strict value is not equal to itself.") | |
536 | - | } | |
537 | - | } | |
538 | - | ||
539 | - | ||
540 | - | ||
541 | - | @Callable(i) | |
542 | - | func unstakeAndGet (amount) = { | |
543 | - | let checkPayments = if ((size(i.payments) != 0)) | |
544 | - | then throw("No payments are expected") | |
545 | - | else true | |
546 | - | if ((checkPayments == checkPayments)) | |
424 | + | func confirmManager () = { | |
425 | + | let pm = pendingManagerPublicKeyOrUnit() | |
426 | + | let hasPM = if (isDefined(pm)) | |
427 | + | then true | |
428 | + | else throw("no pending manager") | |
429 | + | if ((hasPM == hasPM)) | |
547 | 430 | then { | |
548 | - | let cfg = getPoolConfig() | |
549 | - | let factoryCfg = getFactoryConfig() | |
550 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
551 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.") | |
552 | - | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
553 | - | if ((unstakeInv == unstakeInv)) | |
554 | - | then { | |
555 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
556 | - | let poolStatus = parseIntValue(res._9) | |
557 | - | let state = res._10 | |
558 | - | let checkPoolStatus = if (if (isGlobalShutdown()) | |
559 | - | then true | |
560 | - | else (poolStatus == PoolShutdown)) | |
561 | - | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
562 | - | else true | |
563 | - | if ((checkPoolStatus == checkPoolStatus)) | |
564 | - | then { | |
565 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
566 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
567 | - | then state | |
568 | - | else throw("Strict value is not equal to itself.") | |
569 | - | } | |
570 | - | else throw("Strict value is not equal to itself.") | |
571 | - | } | |
431 | + | let checkPM = if ((i.callerPublicKey == value(pm))) | |
432 | + | then true | |
433 | + | else throw("you are not pending manager") | |
434 | + | if ((checkPM == checkPM)) | |
435 | + | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
572 | 436 | else throw("Strict value is not equal to itself.") | |
573 | 437 | } | |
574 | 438 | else throw("Strict value is not equal to itself.") | |
575 | 439 | } | |
576 | 440 | ||
577 | 441 | ||
578 | - | ||
579 | - | @Callable(i) | |
580 | - | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
581 | - | then throw("permissions denied") | |
582 | - | else $Tuple2([StringEntry(keyAmtAsset(), amtAssetStr), StringEntry(keyPriceAsset(), priceAssetStr)], "success") | |
583 | - | ||
584 | - | ||
585 | - | ||
586 | - | @Callable(i) | |
587 | - | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
588 | - | ||
589 | - | ||
590 | - | ||
591 | - | @Callable(i) | |
592 | - | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
593 | - | ||
594 | - | ||
595 | - | ||
596 | - | @Callable(i) | |
597 | - | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
598 | - | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
599 | - | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
442 | + | @Verifier(tx) | |
443 | + | func verify () = { | |
444 | + | let targetPublicKey = match managerPublicKeyOrUnit() { | |
445 | + | case pk: ByteVector => | |
446 | + | pk | |
447 | + | case _: Unit => | |
448 | + | tx.senderPublicKey | |
449 | + | case _ => | |
450 | + | throw("Match error") | |
600 | 451 | } | |
601 | - | ||
602 | - | ||
603 | - | ||
604 | - | @Callable(i) | |
605 | - | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
606 | - | ||
607 | - | ||
608 | - | ||
609 | - | @Callable(i) | |
610 | - | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
611 | - | ||
612 | - | ||
613 | - | ||
614 | - | @Callable(i) | |
615 | - | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
616 | - | ||
617 | - | ||
618 | - | ||
619 | - | @Callable(i) | |
620 | - | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
621 | - | ||
622 | - | ||
623 | - | ||
624 | - | @Callable(i) | |
625 | - | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
626 | - | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
627 | - | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
452 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
628 | 453 | } | |
629 | - | ||
630 | - | ||
631 | - | ||
632 | - | @Callable(i) | |
633 | - | func statsREADONLY () = { | |
634 | - | let cfg = getPoolConfig() | |
635 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
636 | - | let amtAssetId = cfg[idxAmtAssetId] | |
637 | - | let priceAssetId = cfg[idxPriceAssetId] | |
638 | - | let iAmtAssetId = cfg[idxIAmtAssetId] | |
639 | - | let iPriceAssetId = cfg[idxIPriceAssetId] | |
640 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
641 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
642 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
643 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
644 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
645 | - | let pricesList = if ((poolLPBalance == 0)) | |
646 | - | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
647 | - | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
648 | - | let curPrice = 0 | |
649 | - | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
650 | - | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
651 | - | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
652 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP)) | |
653 | - | } | |
654 | - | ||
655 | - | ||
656 | - | ||
657 | - | @Callable(i) | |
658 | - | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
659 | - | let cfg = getPoolConfig() | |
660 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
661 | - | let amAssetIdStr = cfg[idxAmtAssetId] | |
662 | - | let amAssetId = fromBase58String(amAssetIdStr) | |
663 | - | let prAssetIdStr = cfg[idxPriceAssetId] | |
664 | - | let prAssetId = fromBase58String(prAssetIdStr) | |
665 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
666 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
667 | - | let poolStatus = cfg[idxPoolStatus] | |
668 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
669 | - | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
670 | - | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
671 | - | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
672 | - | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
673 | - | let curPriceX18 = if ((poolLPBalance == 0)) | |
674 | - | then zeroBigInt | |
675 | - | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
676 | - | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
677 | - | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
678 | - | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
679 | - | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
680 | - | let calcLpAmt = estPut._1 | |
681 | - | let curPriceCalc = estPut._3 | |
682 | - | let amBalance = estPut._4 | |
683 | - | let prBalance = estPut._5 | |
684 | - | let lpEmission = estPut._6 | |
685 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
686 | - | } | |
687 | - | ||
688 | - | ||
689 | - | ||
690 | - | @Callable(i) | |
691 | - | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
692 | - | let cfg = getPoolConfig() | |
693 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
694 | - | let amAssetIdStr = cfg[idxAmtAssetId] | |
695 | - | let amAssetId = fromBase58String(amAssetIdStr) | |
696 | - | let prAssetIdStr = cfg[idxPriceAssetId] | |
697 | - | let prAssetId = fromBase58String(prAssetIdStr) | |
698 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
699 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
700 | - | let poolStatus = cfg[idxPoolStatus] | |
701 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
702 | - | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
703 | - | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
704 | - | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
705 | - | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
706 | - | let curPriceX18 = if ((poolLPBalance == 0)) | |
707 | - | then zeroBigInt | |
708 | - | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
709 | - | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
710 | - | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
711 | - | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
712 | - | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
713 | - | let calcLpAmt = estPut._1 | |
714 | - | let curPriceCalc = estPut._3 | |
715 | - | let amBalance = estPut._4 | |
716 | - | let prBalance = estPut._5 | |
717 | - | let lpEmission = estPut._6 | |
718 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
719 | - | } | |
720 | - | ||
721 | - | ||
722 | - | ||
723 | - | @Callable(i) | |
724 | - | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
725 | - | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
726 | - | let outAmAmt = res._1 | |
727 | - | let outPrAmt = res._2 | |
728 | - | let amBalance = res._5 | |
729 | - | let prBalance = res._6 | |
730 | - | let lpEmission = res._7 | |
731 | - | let curPrice = res._8 | |
732 | - | let poolStatus = parseIntValue(res._9) | |
733 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), toString(curPrice), toString(poolStatus)], SEP)) | |
734 | - | } | |
735 | - | ||
736 | - | ||
737 | - | @Verifier(tx) | |
738 | - | func verify () = match tx { | |
739 | - | case order: Order => | |
740 | - | let matcherPub = getMatcherPubOrFail() | |
741 | - | let orderValid = validateMatcherOrderAllowed(order) | |
742 | - | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
743 | - | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
744 | - | if (if (if (orderValid) | |
745 | - | then senderValid | |
746 | - | else false) | |
747 | - | then matcherValid | |
748 | - | else false) | |
749 | - | then true | |
750 | - | else throwOrderError(orderValid, senderValid, matcherValid) | |
751 | - | case _ => | |
752 | - | let targetPublicKey = match managerPublicKeyOrUnit() { | |
753 | - | case pk: ByteVector => | |
754 | - | pk | |
755 | - | case _: Unit => | |
756 | - | tx.senderPublicKey | |
757 | - | case _ => | |
758 | - | throw("Match error") | |
759 | - | } | |
760 | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
761 | - | } | |
762 | 454 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let lPdecimals = 8 | |
5 | - | ||
6 | - | let scale8 = 100000000 | |
7 | - | ||
8 | - | let scale8BigInt = toBigInt(100000000) | |
9 | - | ||
10 | - | let scale18 = toBigInt(1000000000000000000) | |
11 | - | ||
12 | - | let zeroBigInt = toBigInt(0) | |
13 | - | ||
14 | 4 | let SEP = "__" | |
15 | 5 | ||
16 | 6 | let EMPTY = "" | |
17 | 7 | ||
18 | - | let PoolActive = 1 | |
19 | - | ||
20 | - | let PoolPutDisabled = 2 | |
21 | - | ||
22 | - | let PoolMatcherDisabled = 3 | |
23 | - | ||
24 | - | let PoolShutdown = 4 | |
25 | - | ||
26 | - | let idxPoolAddress = 1 | |
27 | - | ||
28 | - | let idxPoolStatus = 2 | |
29 | - | ||
30 | - | let idxPoolLPAssetId = 3 | |
31 | - | ||
32 | - | let idxAmtAssetId = 4 | |
33 | - | ||
34 | - | let idxPriceAssetId = 5 | |
35 | - | ||
36 | - | let idxAmtAssetDcm = 6 | |
37 | - | ||
38 | - | let idxPriceAssetDcm = 7 | |
39 | - | ||
40 | - | let idxIAmtAssetId = 8 | |
41 | - | ||
42 | - | let idxIPriceAssetId = 9 | |
43 | - | ||
44 | - | let idxLPAssetDcm = 10 | |
45 | - | ||
46 | - | let idxPoolAmtAssetAmt = 1 | |
47 | - | ||
48 | - | let idxPoolPriceAssetAmt = 2 | |
49 | - | ||
50 | - | let idxPoolLPAssetAmt = 3 | |
51 | - | ||
52 | - | let idxFactoryStakingContract = 1 | |
53 | - | ||
54 | - | let idxFactorySlippageContract = 7 | |
55 | - | ||
56 | - | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
8 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
57 | 9 | ||
58 | 10 | ||
59 | - | func | |
11 | + | func getBooleanOrFail (key) = valueOrErrorMessage(getBoolean(this, key), ("No data for this.key=" + key)) | |
60 | 12 | ||
61 | 13 | ||
62 | - | func | |
14 | + | func keyManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
63 | 15 | ||
64 | 16 | ||
65 | - | func abs (val) = if ((zeroBigInt > val)) | |
66 | - | then -(val) | |
67 | - | else val | |
17 | + | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
68 | 18 | ||
69 | 19 | ||
70 | - | func | |
20 | + | func failExecuteGet (msg,baseAssetStr,userAddressStr,getTxIdStr) = throw(((((((msg + ": baseAssetStr=") + baseAssetStr) + " userAddressStr=") + userAddressStr) + " getTxIdStr=") + getTxIdStr)) | |
71 | 21 | ||
72 | 22 | ||
73 | - | func | |
23 | + | func keyAssetsStoreContract () = makeString(["%s", "assetsStoreContract"], SEP) | |
74 | 24 | ||
75 | 25 | ||
76 | - | func | |
26 | + | func keyAssetCfg (baseAssetStr) = ("%s%s%s__config__asset__" + baseAssetStr) | |
77 | 27 | ||
78 | 28 | ||
79 | - | func | |
29 | + | func keyProxyAddress (assetId) = makeString(["%s%s", "proxyAddress", assetId], SEP) | |
80 | 30 | ||
81 | 31 | ||
82 | - | func | |
32 | + | func keyBalance (assetId) = makeString(["%s%s", "balance", assetId], SEP) | |
83 | 33 | ||
84 | 34 | ||
85 | - | func | |
35 | + | func keyNextInternalAssetId () = "%s__nextInternalAssetId" | |
86 | 36 | ||
87 | 37 | ||
88 | - | func | |
38 | + | func keyPriceLast (internalBasetAssetStr) = ("%s%s%d__price__last__" + internalBasetAssetStr) | |
89 | 39 | ||
90 | 40 | ||
91 | - | func | |
41 | + | func keyTopUpLastHeight (internalBasetAssetStr,sender) = makeString(["%s%s%s%d%s__topup__last__height", internalBasetAssetStr, sender], SEP) | |
92 | 42 | ||
93 | 43 | ||
94 | - | func | |
44 | + | func keyPriceHistory (internalBasetAssetStr,h,timestamp) = makeString(["%s%s%d%d%d__price__history", internalBasetAssetStr, toString(h), toString(timestamp)], SEP) | |
95 | 45 | ||
96 | 46 | ||
97 | - | func | |
47 | + | func keyTotalLocked (internalBasetAssetStr) = ("%s%s%d__total__locked__" + internalBasetAssetStr) | |
98 | 48 | ||
99 | 49 | ||
100 | - | func | |
50 | + | func keyTotalLockedByUser (internalBaseAssetStr,userAddressStr) = makeString(["%s%s%d%s__total__locked", internalBaseAssetStr, userAddressStr], SEP) | |
101 | 51 | ||
102 | 52 | ||
103 | - | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
104 | - | ||
105 | - | ||
106 | - | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
53 | + | func keyMappingsInternal2baseAssetId (internalBaseAsset) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(internalBaseAsset)) | |
107 | 54 | ||
108 | 55 | ||
109 | 56 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
110 | 57 | ||
111 | 58 | ||
112 | - | func | |
59 | + | func keyMappingsShare2baseAssetId (shareAssetStr) = ("%s%s%s__mappings__share2baseAssetId__" + shareAssetStr) | |
113 | 60 | ||
114 | 61 | ||
115 | - | func | |
62 | + | func keyMappingsBaseAsset2shareId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2shareId__" + baseAssetStr) | |
116 | 63 | ||
117 | 64 | ||
118 | - | func | |
65 | + | func keyShutdownPutOperation (internalBaseAssetStr) = ("%s%s%d__shutdown__put__" + internalBaseAssetStr) | |
119 | 66 | ||
120 | 67 | ||
121 | - | func | |
68 | + | func keyShutdownManager (internalBaseAssetStr) = ("%s%s%d__shutdown__manager__" + internalBaseAssetStr) | |
122 | 69 | ||
123 | 70 | ||
124 | - | func | |
71 | + | func assetsStoreContract () = addressFromStringValue(value(getString(keyAssetsStoreContract()))) | |
125 | 72 | ||
126 | 73 | ||
127 | - | let | |
74 | + | let IdxCfgShareAssetId = 1 | |
128 | 75 | ||
129 | - | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
76 | + | let IdxCfgInternalBaseAsset = 2 | |
77 | + | ||
78 | + | let IdxCfgDecimalsMultBothAssets = 3 | |
79 | + | ||
80 | + | let IdxCfgDecimalsMultPrice = 4 | |
81 | + | ||
82 | + | let IdxCfgGetDelayBlocks = 5 | |
83 | + | ||
84 | + | func dataAssetCfg (shareAssetStr,internalBaseAssetStr,decimalsMultBothAssets,decimalsMultPrice,getDelayInBlocks) = makeString(["%s%d%d%d%d", shareAssetStr, internalBaseAssetStr, toString(decimalsMultBothAssets), toString(decimalsMultPrice), toString(getDelayInBlocks)], SEP) | |
130 | 85 | ||
131 | 86 | ||
132 | - | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
87 | + | let IdxTotalLockedShare = 1 | |
88 | + | ||
89 | + | let IdxTotalLockedBase = 2 | |
90 | + | ||
91 | + | func dataTotalLocked (shareAssetAmount,baseAssetAmount) = makeString(["%d%d", toString(shareAssetAmount), toString(baseAssetAmount)], SEP) | |
133 | 92 | ||
134 | 93 | ||
135 | - | func getPoolConfig () = { | |
136 | - | let amtAsset = getStringOrFail(this, keyAmtAsset()) | |
137 | - | let priceAsset = getStringOrFail(this, keyPriceAsset()) | |
138 | - | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
139 | - | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
140 | - | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
94 | + | func readTotalLocked (key) = { | |
95 | + | let totalLockedArray = split(valueOrElse(getString(this, key), dataTotalLocked(0, 0)), SEP) | |
96 | + | [-1, parseIntValue(totalLockedArray[IdxTotalLockedShare]), parseIntValue(totalLockedArray[IdxTotalLockedBase])] | |
141 | 97 | } | |
142 | 98 | ||
143 | 99 | ||
144 | - | func | |
100 | + | func keyOperation (operationType,internalBaseAssetStr,userAddress,txId) = makeString(["%s%d%s%s", operationType, internalBaseAssetStr, userAddress, txId], SEP) | |
145 | 101 | ||
146 | 102 | ||
147 | - | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
103 | + | let IdxOperStatus = 1 | |
104 | + | ||
105 | + | let IdxOperInAmount = 2 | |
106 | + | ||
107 | + | let IdxOperPrice = 3 | |
108 | + | ||
109 | + | let IdxOperOutAmount = 4 | |
110 | + | ||
111 | + | let IdxOperStartHeight = 5 | |
112 | + | ||
113 | + | let IdxOperStartTimestamp = 6 | |
114 | + | ||
115 | + | let IdxOperEndHeight = 7 | |
116 | + | ||
117 | + | let IdxOperEndTimestamp = 8 | |
118 | + | ||
119 | + | func privateDataOperationAllStrings (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = makeString(["%s%d%d%d%d%d%d%d", status, inAssetAmount, price, outAssetAmount, startHeight, startTimestamp, endHeight, endTimestamp], SEP) | |
148 | 120 | ||
149 | 121 | ||
150 | - | func | |
122 | + | func dataOperation (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = privateDataOperationAllStrings(status, toString(inAssetAmount), toString(price), toString(outAssetAmount), toString(startHeight), toString(startTimestamp), toString(endHeight), toString(endTimestamp)) | |
151 | 123 | ||
152 | 124 | ||
153 | - | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
154 | - | then wavesBalance(this).available | |
155 | - | else assetBalance(this, fromBase58String(assetId)) | |
125 | + | func dataOperationExecutionUpdate (currOperArray,newStatus,newEndTimestamp) = privateDataOperationAllStrings(newStatus, currOperArray[IdxOperInAmount], currOperArray[IdxOperPrice], currOperArray[IdxOperOutAmount], currOperArray[IdxOperStartHeight], currOperArray[IdxOperStartTimestamp], currOperArray[IdxOperEndHeight], toString(newEndTimestamp)) | |
156 | 126 | ||
157 | 127 | ||
158 | - | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
159 | - | ||
160 | - | ||
161 | - | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
162 | - | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
163 | - | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
164 | - | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
128 | + | func readAssetCfgOrFail (baseAssetStr) = { | |
129 | + | let key = keyAssetCfg(baseAssetStr) | |
130 | + | split(getStringOrFail(key), SEP) | |
165 | 131 | } | |
166 | 132 | ||
167 | 133 | ||
168 | - | func calcPrices (amAmt,prAmt,lpAmt) = { | |
169 | - | let cfg = getPoolConfig() | |
170 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
171 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
172 | - | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
173 | - | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
174 | - | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
175 | - | let lpAmtX18 = toX18(lpAmt, scale8) | |
176 | - | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
177 | - | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
178 | - | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
134 | + | func incrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
135 | + | let dataArray = readTotalLocked(key) | |
136 | + | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] + shareAssetAmount), (dataArray[IdxTotalLockedBase] + baseAssetAmount))) | |
179 | 137 | } | |
180 | 138 | ||
181 | 139 | ||
182 | - | func | |
183 | - | let | |
184 | - | ||
140 | + | func decrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
141 | + | let dataArray = readTotalLocked(key) | |
142 | + | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] - shareAssetAmount), (dataArray[IdxTotalLockedBase] - baseAssetAmount))) | |
185 | 143 | } | |
186 | - | ||
187 | - | ||
188 | - | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
189 | - | let cfg = getPoolConfig() | |
190 | - | let lpAssetId = cfg[idxPoolLPAssetId] | |
191 | - | let amAssetId = cfg[idxAmtAssetId] | |
192 | - | let prAssetId = cfg[idxPriceAssetId] | |
193 | - | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
194 | - | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
195 | - | let poolStatus = cfg[idxPoolStatus] | |
196 | - | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
197 | - | if ((lpAssetId != pmtAssetId)) | |
198 | - | then throw("Invalid asset passed.") | |
199 | - | else { | |
200 | - | let amBalance = getAccBalance(amAssetId) | |
201 | - | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
202 | - | let prBalance = getAccBalance(prAssetId) | |
203 | - | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
204 | - | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
205 | - | let curPrice = fromX18(curPriceX18, scale8) | |
206 | - | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
207 | - | let lpEmissionX18 = toX18(lpEmission, scale8) | |
208 | - | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
209 | - | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
210 | - | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
211 | - | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
212 | - | let state = if ((txId58 == "")) | |
213 | - | then nil | |
214 | - | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
215 | - | then unit | |
216 | - | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
217 | - | then unit | |
218 | - | else fromBase58String(prAssetId)), StringEntry(keyGetActionByUser(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(keyPriceLast(), curPrice), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), curPrice)] | |
219 | - | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
220 | - | } | |
221 | - | } | |
222 | - | ||
223 | - | ||
224 | - | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
225 | - | let cfg = getPoolConfig() | |
226 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
227 | - | let amAssetIdStr = cfg[idxAmtAssetId] | |
228 | - | let prAssetIdStr = cfg[idxPriceAssetId] | |
229 | - | let iAmtAssetId = cfg[idxIAmtAssetId] | |
230 | - | let iPriceAssetId = cfg[idxIPriceAssetId] | |
231 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
232 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
233 | - | let poolStatus = cfg[idxPoolStatus] | |
234 | - | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
235 | - | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
236 | - | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
237 | - | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
238 | - | then true | |
239 | - | else (prAssetIdStr != inPrAssetIdStr)) | |
240 | - | then throw("Invalid amt or price asset passed.") | |
241 | - | else { | |
242 | - | let amBalance = if (isEvaluate) | |
243 | - | then getAccBalance(amAssetIdStr) | |
244 | - | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
245 | - | let prBalance = if (isEvaluate) | |
246 | - | then getAccBalance(prAssetIdStr) | |
247 | - | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
248 | - | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
249 | - | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
250 | - | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
251 | - | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
252 | - | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
253 | - | let res = if ((lpEmission == 0)) | |
254 | - | then { | |
255 | - | let curPriceX18 = zeroBigInt | |
256 | - | let slippageX18 = zeroBigInt | |
257 | - | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
258 | - | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
259 | - | } | |
260 | - | else { | |
261 | - | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
262 | - | let slippageX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
263 | - | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
264 | - | if (if ((curPriceX18 != zeroBigInt)) | |
265 | - | then (slippageX18 > slippageToleranceX18) | |
266 | - | else false) | |
267 | - | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
268 | - | else { | |
269 | - | let lpEmissionX18 = toX18(lpEmission, scale8) | |
270 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
271 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
272 | - | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
273 | - | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
274 | - | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
275 | - | let expAmtAssetAmtX18 = expectedAmts._1 | |
276 | - | let expPriceAssetAmtX18 = expectedAmts._2 | |
277 | - | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
278 | - | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
279 | - | } | |
280 | - | } | |
281 | - | let calcLpAmt = res._1 | |
282 | - | let calcAmAssetPmt = res._2 | |
283 | - | let calcPrAssetPmt = res._3 | |
284 | - | let curPrice = fromX18(res._4, scale8) | |
285 | - | let slippageCalc = fromX18(res._5, scale8) | |
286 | - | if ((0 >= calcLpAmt)) | |
287 | - | then throw("Invalid calculations. LP calculated is less than zero.") | |
288 | - | else { | |
289 | - | let emitLpAmt = if (!(emitLp)) | |
290 | - | then 0 | |
291 | - | else calcLpAmt | |
292 | - | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
293 | - | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
294 | - | let commonState = [IntegerEntry(keyPriceLast(), curPrice), IntegerEntry(keyPriceHistory(height, lastBlock.timestamp), curPrice), StringEntry(keyPutActionByUser(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
295 | - | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
296 | - | } | |
297 | - | } | |
298 | - | } | |
299 | - | ||
300 | - | ||
301 | - | func validateMatcherOrderAllowed (order) = { | |
302 | - | let cfg = getPoolConfig() | |
303 | - | let amtAssetId = cfg[idxAmtAssetId] | |
304 | - | let priceAssetId = cfg[idxPriceAssetId] | |
305 | - | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
306 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
307 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
308 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
309 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
310 | - | let curPriceX18 = if ((order.orderType == Buy)) | |
311 | - | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
312 | - | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
313 | - | let curPrice = fromX18(curPriceX18, scale8) | |
314 | - | if (if (if (isGlobalShutdown()) | |
315 | - | then true | |
316 | - | else (poolStatus == PoolMatcherDisabled)) | |
317 | - | then true | |
318 | - | else (poolStatus == PoolShutdown)) | |
319 | - | then throw("Exchange operations disabled") | |
320 | - | else { | |
321 | - | let orderAmtAsset = order.assetPair.amountAsset | |
322 | - | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
323 | - | then "WAVES" | |
324 | - | else toBase58String(value(orderAmtAsset)) | |
325 | - | let orderPriceAsset = order.assetPair.priceAsset | |
326 | - | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
327 | - | then "WAVES" | |
328 | - | else toBase58String(value(orderPriceAsset)) | |
329 | - | if (if ((orderAmtAssetStr != amtAssetId)) | |
330 | - | then true | |
331 | - | else (orderPriceAssetStr != priceAssetId)) | |
332 | - | then throw("Wrong order assets.") | |
333 | - | else { | |
334 | - | let orderPrice = order.price | |
335 | - | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
336 | - | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
337 | - | let isOrderPriceValid = if ((order.orderType == Buy)) | |
338 | - | then (curPrice >= castedOrderPrice) | |
339 | - | else (castedOrderPrice >= curPrice) | |
340 | - | true | |
341 | - | } | |
342 | - | } | |
343 | - | } | |
344 | - | ||
345 | - | ||
346 | - | func commonGet (i) = if ((size(i.payments) != 1)) | |
347 | - | then throw("exactly 1 payment is expected") | |
348 | - | else { | |
349 | - | let pmt = value(i.payments[0]) | |
350 | - | let pmtAssetId = value(pmt.assetId) | |
351 | - | let pmtAmt = pmt.amount | |
352 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
353 | - | let outAmAmt = res._1 | |
354 | - | let outPrAmt = res._2 | |
355 | - | let poolStatus = parseIntValue(res._9) | |
356 | - | let state = res._10 | |
357 | - | if (if (isGlobalShutdown()) | |
358 | - | then true | |
359 | - | else (poolStatus == PoolShutdown)) | |
360 | - | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
361 | - | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
362 | - | } | |
363 | - | ||
364 | - | ||
365 | - | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
366 | - | then throw("exactly 2 payments are expected") | |
367 | - | else { | |
368 | - | let amAssetPmt = value(i.payments[0]) | |
369 | - | let prAssetPmt = value(i.payments[1]) | |
370 | - | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
371 | - | let poolStatus = parseIntValue(estPut._8) | |
372 | - | if (if (if (isGlobalShutdown()) | |
373 | - | then true | |
374 | - | else (poolStatus == PoolPutDisabled)) | |
375 | - | then true | |
376 | - | else (poolStatus == PoolShutdown)) | |
377 | - | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
378 | - | else estPut | |
379 | - | } | |
380 | 144 | ||
381 | 145 | ||
382 | 146 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
383 | 147 | case s: String => | |
384 | 148 | fromBase58String(s) | |
385 | 149 | case _: Unit => | |
386 | 150 | unit | |
387 | 151 | case _ => | |
388 | 152 | throw("Match error") | |
389 | 153 | } | |
390 | 154 | ||
391 | 155 | ||
156 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
157 | + | case s: String => | |
158 | + | fromBase58String(s) | |
159 | + | case _: Unit => | |
160 | + | unit | |
161 | + | case _ => | |
162 | + | throw("Match error") | |
163 | + | } | |
164 | + | ||
165 | + | ||
166 | + | func balanceOrZero (assetId) = valueOrElse(getInteger(keyBalance(assetId)), 0) | |
167 | + | ||
168 | + | ||
169 | + | func genericCalcPrice (balance,internalBaseAssetStr,baseAssetId,topUpBaseAmount,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = { | |
170 | + | let totalLockedArray = readTotalLocked(keyTotalLocked(internalBaseAssetStr)) | |
171 | + | let totalLockedBaseAmount = totalLockedArray[IdxTotalLockedBase] | |
172 | + | let baseAssetBalance = balance | |
173 | + | let baseAssetBalanceConsideringLock = ((baseAssetBalance - totalLockedBaseAmount) + topUpBaseAmount) | |
174 | + | if ((0 > baseAssetBalanceConsideringLock)) | |
175 | + | then throw(((("baseAssetBalanceConsideringLock < 0: baseAssetBalance=" + toString(baseAssetBalance)) + " baseAssetBalanceConsideringLock=") + toString(baseAssetBalanceConsideringLock))) | |
176 | + | else { | |
177 | + | let shareEmission = value(assetInfo(shareAssetId)).quantity | |
178 | + | let price = if ((shareEmission == 0)) | |
179 | + | then (1 * decimalsMultPrice) | |
180 | + | else fraction(baseAssetBalanceConsideringLock, decimalsMultPrice, shareEmission) | |
181 | + | $Tuple5(price, baseAssetBalance, totalLockedBaseAmount, baseAssetBalanceConsideringLock, shareEmission) | |
182 | + | } | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | func calcPrice (balance,internalBaseAssetStr,baseAssetId,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = genericCalcPrice(balance, internalBaseAssetStr, baseAssetId, 0, shareAssetId, decimalsMultBothAssets, decimalsMultPrice) | |
187 | + | ||
188 | + | ||
189 | + | func privateCurrentSysParamsREST (baseAssetStr) = { | |
190 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
191 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
192 | + | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
193 | + | let shareAssetId = fromBase58String(shareAssetStr) | |
194 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
195 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
196 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
197 | + | let sysState = calcPrice(balanceOrZero(baseAssetStr), internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice) | |
198 | + | $Tuple6(IntegerEntry("price", sysState._1), IntegerEntry("decimalsMultPrice", decimalsMultPrice), IntegerEntry("baseAssetBalance", sysState._2), IntegerEntry("totalLockedBaseAmount", sysState._3), IntegerEntry("baseAssetBalanceConsideringLock", sysState._4), IntegerEntry("shareEmission", sysState._5)) | |
199 | + | } | |
200 | + | ||
201 | + | ||
392 | 202 | func mustManager (i) = { | |
393 | - | let pd = throw(" | |
203 | + | let pd = throw("permission denied") | |
394 | 204 | match managerPublicKeyOrUnit() { | |
395 | 205 | case pk: ByteVector => | |
396 | 206 | if ((i.callerPublicKey == pk)) | |
397 | 207 | then true | |
398 | 208 | else pd | |
399 | 209 | case _: Unit => | |
400 | 210 | if ((i.caller == this)) | |
401 | 211 | then true | |
402 | 212 | else pd | |
403 | 213 | case _ => | |
404 | 214 | throw("Match error") | |
405 | 215 | } | |
406 | 216 | } | |
407 | 217 | ||
408 | 218 | ||
219 | + | func mustProxyAddress (i,assetId) = { | |
220 | + | let isProxy = (toString(i.caller) == valueOrElse(getString(keyProxyAddress(assetId)), EMPTY)) | |
221 | + | if (isProxy) | |
222 | + | then true | |
223 | + | else { | |
224 | + | let checkCaller = mustManager(i) | |
225 | + | if ((checkCaller == checkCaller)) | |
226 | + | then true | |
227 | + | else throw("Strict value is not equal to itself.") | |
228 | + | } | |
229 | + | } | |
230 | + | ||
231 | + | ||
409 | 232 | @Callable(i) | |
410 | - | func constructor ( | |
233 | + | func constructor (assetsStoreContract) = { | |
411 | 234 | let checkCaller = mustManager(i) | |
412 | 235 | if ((checkCaller == checkCaller)) | |
413 | - | then [StringEntry( | |
236 | + | then [StringEntry(keyAssetsStoreContract(), assetsStoreContract)] | |
414 | 237 | else throw("Strict value is not equal to itself.") | |
415 | 238 | } | |
416 | 239 | ||
417 | 240 | ||
418 | 241 | ||
419 | 242 | @Callable(i) | |
420 | - | func setManager (managerPublicKey) = { | |
243 | + | func adminRegisterAsset (baseAssetStr,shareAssetName,shareAssetDescr,shareAssetLogo,getDelayinBlocks,shutdownManagerAddress,proxyAddress) = { | |
244 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
245 | + | let decimals = value(assetInfo(baseAssetId)).decimals | |
246 | + | let check = mustManager(i) | |
247 | + | if ((check == check)) | |
248 | + | then if ((toString(addressFromStringValue(shutdownManagerAddress)) != shutdownManagerAddress)) | |
249 | + | then throw("invalid shutdownManagerAddress") | |
250 | + | else if ((0 > getDelayinBlocks)) | |
251 | + | then throw(("invalid getDelayinBlocks=" + toString(getDelayinBlocks))) | |
252 | + | else { | |
253 | + | let shareAssetIssueAction = Issue(shareAssetName, shareAssetDescr, 1, decimals, true) | |
254 | + | let shareAssetId = calculateAssetId(shareAssetIssueAction) | |
255 | + | let shareAssetStr = toBase58String(shareAssetId) | |
256 | + | let decimalsMultPrice = ((100 * 1000) * 1000) | |
257 | + | let decimalsMultBothAssets = pow(10, 0, decimals, 0, 0, DOWN) | |
258 | + | let startPrice = (1 * decimalsMultPrice) | |
259 | + | let internalBaseAssettId = valueOrElse(getInteger(this, keyNextInternalAssetId()), 0) | |
260 | + | let internalBaseAssetStr = toString(internalBaseAssettId) | |
261 | + | let createOrUpdate = invoke(assetsStoreContract(), "createOrUpdate", [shareAssetStr, shareAssetLogo, false], nil) | |
262 | + | if ((createOrUpdate == createOrUpdate)) | |
263 | + | then { | |
264 | + | let addLabel = invoke(assetsStoreContract(), "addLabel", [shareAssetStr, "DEFI"], nil) | |
265 | + | if ((addLabel == addLabel)) | |
266 | + | then [StringEntry(keyAssetCfg(baseAssetStr), dataAssetCfg(shareAssetStr, internalBaseAssetStr, decimalsMultBothAssets, decimalsMultPrice, getDelayinBlocks)), StringEntry(keyMappingsInternal2baseAssetId(internalBaseAssettId), baseAssetStr), StringEntry(keyMappingsBaseAsset2internalId(baseAssetStr), internalBaseAssetStr), StringEntry(keyMappingsShare2baseAssetId(shareAssetStr), baseAssetStr), StringEntry(keyMappingsBaseAsset2shareId(baseAssetStr), shareAssetStr), BooleanEntry(keyShutdownPutOperation(internalBaseAssetStr), false), StringEntry(keyShutdownManager(internalBaseAssetStr), shutdownManagerAddress), IntegerEntry(keyNextInternalAssetId(), (internalBaseAssettId + 1)), IntegerEntry(keyPriceLast(internalBaseAssetStr), startPrice), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), startPrice), shareAssetIssueAction, Burn(shareAssetId, 1), StringEntry(keyProxyAddress(baseAssetStr), proxyAddress)] | |
267 | + | else throw("Strict value is not equal to itself.") | |
268 | + | } | |
269 | + | else throw("Strict value is not equal to itself.") | |
270 | + | } | |
271 | + | else throw("Strict value is not equal to itself.") | |
272 | + | } | |
273 | + | ||
274 | + | ||
275 | + | ||
276 | + | @Callable(i) | |
277 | + | func shutdownPut (internalBaseAssetId) = { | |
278 | + | let internalBaseAssetIdStr = toString(internalBaseAssetId) | |
279 | + | let baseAssetIdStr = getStringOrFail(keyMappingsInternal2baseAssetId(internalBaseAssetId)) | |
280 | + | let shutdownManagerAddress = getStringOrFail(keyShutdownManager(internalBaseAssetIdStr)) | |
281 | + | if ((1 > size(baseAssetIdStr))) | |
282 | + | then throw("invalid internalBaseAssetId") | |
283 | + | else if ((toString(i.caller) != shutdownManagerAddress)) | |
284 | + | then throw("access denied") | |
285 | + | else [BooleanEntry(keyShutdownPutOperation(toString(internalBaseAssetId)), true)] | |
286 | + | } | |
287 | + | ||
288 | + | ||
289 | + | ||
290 | + | @Callable(i) | |
291 | + | func put () = { | |
292 | + | let pmt = value(i.payments[0]) | |
293 | + | let baseAssetId = value(pmt.assetId) | |
294 | + | let baseAssetStr = toBase58String(baseAssetId) | |
295 | + | let userAddressStr = toString(i.caller) | |
296 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
297 | + | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
298 | + | let shareAssetId = fromBase58String(shareAssetStr) | |
299 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
300 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
301 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
302 | + | let isPutBlocked = getBooleanOrFail(keyShutdownPutOperation(internalBaseAssetStr)) | |
303 | + | if (isPutBlocked) | |
304 | + | then throw("put operation is blocked") | |
305 | + | else { | |
306 | + | let balance = (balanceOrZero(baseAssetStr) + pmt.amount) | |
307 | + | let price = calcPrice(balance, internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
308 | + | let shareAssetAmount = fraction(pmt.amount, decimalsMultPrice, price) | |
309 | + | [Reissue(shareAssetId, shareAssetAmount, true), ScriptTransfer(i.caller, shareAssetAmount, shareAssetId), StringEntry(keyOperation("P", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)), dataOperation("FINISHED", pmt.amount, price, shareAssetAmount, height, lastBlock.timestamp, height, lastBlock.timestamp)), ScriptTransfer(addressFromStringValue(value(getString(keyProxyAddress(baseAssetStr)))), pmt.amount, baseAssetId), IntegerEntry(keyBalance(baseAssetStr), balance)] | |
310 | + | } | |
311 | + | } | |
312 | + | ||
313 | + | ||
314 | + | ||
315 | + | @Callable(i) | |
316 | + | func submitGetRequest () = { | |
317 | + | let pmt = value(i.payments[0]) | |
318 | + | let shareAssetId = value(pmt.assetId) | |
319 | + | let shareAssetStr = toBase58String(shareAssetId) | |
320 | + | let callerPubStr = toBase58String(i.callerPublicKey) | |
321 | + | let userAddress = i.caller | |
322 | + | let userAddressStr = toString(userAddress) | |
323 | + | let shareAssetAmount = pmt.amount | |
324 | + | let baseAssetStr = getStringOrFail(keyMappingsShare2baseAssetId(shareAssetStr)) | |
325 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
326 | + | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
327 | + | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
328 | + | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
329 | + | let getDelayBlocks = parseIntValue(cfgArray[IdxCfgGetDelayBlocks]) | |
330 | + | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
331 | + | let price = calcPrice(balanceOrZero(baseAssetStr), internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
332 | + | let baseAssetAmount = fraction(shareAssetAmount, price, decimalsMultPrice) | |
333 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)) | |
334 | + | let operationData = dataOperation("PENDING", shareAssetAmount, price, baseAssetAmount, height, lastBlock.timestamp, (height + getDelayBlocks), 0) | |
335 | + | let balance = balanceOrZero(baseAssetStr) | |
336 | + | [Burn(shareAssetId, shareAssetAmount), StringEntry(operationKey, operationData), incrementTotalLocked(keyTotalLocked(internalBaseAssetStr), shareAssetAmount, baseAssetAmount), incrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), shareAssetAmount, baseAssetAmount)] | |
337 | + | } | |
338 | + | ||
339 | + | ||
340 | + | ||
341 | + | @Callable(i) | |
342 | + | func executeGetRequest (baseAssetStr,userAddressStr,getTxIdStr) = { | |
343 | + | let userAddress = addressFromStringValue(userAddressStr) | |
344 | + | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
345 | + | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
346 | + | let baseAssetId = fromBase58String(baseAssetStr) | |
347 | + | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
348 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, getTxIdStr) | |
349 | + | let operationArray = split(getStringOrFail(operationKey), SEP) | |
350 | + | let status = operationArray[IdxOperStatus] | |
351 | + | let endHeight = parseIntValue(operationArray[IdxOperEndHeight]) | |
352 | + | let inShareAmount = parseIntValue(operationArray[IdxOperInAmount]) | |
353 | + | let outBaseAmount = parseIntValue(operationArray[IdxOperOutAmount]) | |
354 | + | if ((status != "PENDING")) | |
355 | + | then failExecuteGet("Status is not PENDING", baseAssetStr, userAddressStr, getTxIdStr) | |
356 | + | else if ((endHeight > height)) | |
357 | + | then failExecuteGet(((("EndHeight[" + toString(endHeight)) + "] > ") + toString(height)), baseAssetStr, userAddressStr, getTxIdStr) | |
358 | + | else [ScriptTransfer(userAddress, outBaseAmount, baseAssetId), StringEntry(operationKey, dataOperationExecutionUpdate(operationArray, "FINISHED", lastBlock.timestamp)), decrementTotalLocked(keyTotalLocked(internalBaseAssetStr), inShareAmount, outBaseAmount), decrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), inShareAmount, outBaseAmount), IntegerEntry(keyBalance(baseAssetStr), (balanceOrZero(baseAssetStr) - outBaseAmount))] | |
359 | + | } | |
360 | + | ||
361 | + | ||
362 | + | ||
363 | + | @Callable(i) | |
364 | + | func topUpBalance (baseAssetStr,delta) = { | |
365 | + | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
366 | + | let pmt = value(i.payments[0]) | |
367 | + | let pmtAssetId = value(pmt.assetId) | |
368 | + | let pmtAssetStr = toBase58String(pmtAssetId) | |
369 | + | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
370 | + | let decimalsMultBothAssets = parseIntValue(assetCfgArray[IdxCfgDecimalsMultBothAssets]) | |
371 | + | let decimalsMultPrice = parseIntValue(assetCfgArray[IdxCfgDecimalsMultPrice]) | |
372 | + | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
373 | + | let topUpLastHeightKEY = keyTopUpLastHeight(internalBaseAssetStr, toString(i.caller)) | |
374 | + | let topUpLastHeight = valueOrElse(getInteger(this, topUpLastHeightKEY), 0) | |
375 | + | let checks = [mustProxyAddress(i, baseAssetStr), if ((topUpLastHeight != height)) | |
376 | + | then true | |
377 | + | else throw("only one topUp per block is allowed")] | |
378 | + | if ((checks == checks)) | |
379 | + | then if ((baseAssetStr != pmtAssetStr)) | |
380 | + | then throw("attached payment's asset id is NOT matched passed baseAssetStr") | |
381 | + | else if ((size(i.payments) > 1)) | |
382 | + | then throw("only one payment can be attached") | |
383 | + | else { | |
384 | + | let newBalance = (balanceOrZero(pmtAssetStr) + delta) | |
385 | + | let price = genericCalcPrice(newBalance, internalBaseAssetStr, pmtAssetId, pmt.amount, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
386 | + | [IntegerEntry(keyPriceLast(internalBaseAssetStr), price), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), price), IntegerEntry(topUpLastHeightKEY, height), IntegerEntry(keyBalance(pmtAssetStr), newBalance)] | |
387 | + | } | |
388 | + | else throw("Strict value is not equal to itself.") | |
389 | + | } | |
390 | + | ||
391 | + | ||
392 | + | ||
393 | + | @Callable(i) | |
394 | + | func currentSysParamsREST (baseAssetStr) = { | |
395 | + | let sysStateTuple = privateCurrentSysParamsREST(baseAssetStr) | |
396 | + | let price = sysStateTuple._1.value | |
397 | + | let decimalsMultPrice = sysStateTuple._2.value | |
398 | + | let baseAssetBalance = sysStateTuple._3.value | |
399 | + | let totalLockedBaseAmount = sysStateTuple._4.value | |
400 | + | let baseAssetBalanceConsideringLock = sysStateTuple._5.value | |
401 | + | let shareEmission = sysStateTuple._6.value | |
402 | + | let restData = makeString(["startCurrentSysParamsREST", toString(price), toString(decimalsMultPrice), toString(baseAssetBalance), toString(totalLockedBaseAmount), toString(baseAssetBalanceConsideringLock), toString(shareEmission), "endCurrentSysParamsREST"], SEP) | |
403 | + | throw(restData) | |
404 | + | } | |
405 | + | ||
406 | + | ||
407 | + | ||
408 | + | @Callable(i) | |
409 | + | func setManager (pendingManagerPublicKey) = { | |
421 | 410 | let checkCaller = mustManager(i) | |
422 | 411 | if ((checkCaller == checkCaller)) | |
423 | 412 | then { | |
424 | - | let checkManagerPublicKey = fromBase58String( | |
413 | + | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
425 | 414 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
426 | - | then [StringEntry( | |
415 | + | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
427 | 416 | else throw("Strict value is not equal to itself.") | |
428 | 417 | } | |
429 | 418 | else throw("Strict value is not equal to itself.") | |
430 | 419 | } | |
431 | 420 | ||
432 | 421 | ||
433 | 422 | ||
434 | 423 | @Callable(i) | |
435 | - | func put (slippageTolerance,shouldAutoStake) = { | |
436 | - | let factoryCfg = getFactoryConfig() | |
437 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.") | |
438 | - | let slippageContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactorySlippageContract]), "Error. Incorrect slippage contract address.") | |
439 | - | if ((0 > slippageTolerance)) | |
440 | - | then throw("Invalid slippageTolerance passed") | |
441 | - | else { | |
442 | - | let estPut = commonPut(i, slippageTolerance, true) | |
443 | - | let emitLpAmt = estPut._2 | |
444 | - | let lpAssetId = estPut._7 | |
445 | - | let state = estPut._9 | |
446 | - | let amDiff = estPut._10 | |
447 | - | let prDiff = estPut._11 | |
448 | - | let amId = estPut._12 | |
449 | - | let prId = estPut._13 | |
450 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
451 | - | if ((emitInv == emitInv)) | |
452 | - | then { | |
453 | - | let emitInvLegacy = match emitInv { | |
454 | - | case legacyFactoryContract: Address => | |
455 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
456 | - | case _ => | |
457 | - | unit | |
458 | - | } | |
459 | - | if ((emitInvLegacy == emitInvLegacy)) | |
460 | - | then { | |
461 | - | let slippageAInv = if ((amDiff > 0)) | |
462 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
463 | - | else nil | |
464 | - | if ((slippageAInv == slippageAInv)) | |
465 | - | then { | |
466 | - | let slippagePInv = if ((prDiff > 0)) | |
467 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
468 | - | else nil | |
469 | - | if ((slippagePInv == slippagePInv)) | |
470 | - | then { | |
471 | - | let lpTransfer = if (shouldAutoStake) | |
472 | - | then { | |
473 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
474 | - | if ((slpStakeInv == slpStakeInv)) | |
475 | - | then nil | |
476 | - | else throw("Strict value is not equal to itself.") | |
477 | - | } | |
478 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
479 | - | (state ++ lpTransfer) | |
480 | - | } | |
481 | - | else throw("Strict value is not equal to itself.") | |
482 | - | } | |
483 | - | else throw("Strict value is not equal to itself.") | |
484 | - | } | |
485 | - | else throw("Strict value is not equal to itself.") | |
486 | - | } | |
487 | - | else throw("Strict value is not equal to itself.") | |
488 | - | } | |
489 | - | } | |
490 | - | ||
491 | - | ||
492 | - | ||
493 | - | @Callable(i) | |
494 | - | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
495 | - | then throw("Invalid value passed") | |
496 | - | else { | |
497 | - | let estPut = commonPut(i, maxSlippage, false) | |
498 | - | estPut._9 | |
499 | - | } | |
500 | - | ||
501 | - | ||
502 | - | ||
503 | - | @Callable(i) | |
504 | - | func get () = { | |
505 | - | let res = commonGet(i) | |
506 | - | let outAmtAmt = res._1 | |
507 | - | let outPrAmt = res._2 | |
508 | - | let pmtAmt = res._3 | |
509 | - | let pmtAssetId = res._4 | |
510 | - | let state = res._5 | |
511 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
512 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
513 | - | then state | |
514 | - | else throw("Strict value is not equal to itself.") | |
515 | - | } | |
516 | - | ||
517 | - | ||
518 | - | ||
519 | - | @Callable(i) | |
520 | - | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
521 | - | let res = commonGet(i) | |
522 | - | let outAmAmt = res._1 | |
523 | - | let outPrAmt = res._2 | |
524 | - | let pmtAmt = res._3 | |
525 | - | let pmtAssetId = res._4 | |
526 | - | let state = res._5 | |
527 | - | if ((noLessThenAmtAsset > outAmAmt)) | |
528 | - | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
529 | - | else if ((noLessThenPriceAsset > outPrAmt)) | |
530 | - | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
531 | - | else { | |
532 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
533 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
534 | - | then state | |
535 | - | else throw("Strict value is not equal to itself.") | |
536 | - | } | |
537 | - | } | |
538 | - | ||
539 | - | ||
540 | - | ||
541 | - | @Callable(i) | |
542 | - | func unstakeAndGet (amount) = { | |
543 | - | let checkPayments = if ((size(i.payments) != 0)) | |
544 | - | then throw("No payments are expected") | |
545 | - | else true | |
546 | - | if ((checkPayments == checkPayments)) | |
424 | + | func confirmManager () = { | |
425 | + | let pm = pendingManagerPublicKeyOrUnit() | |
426 | + | let hasPM = if (isDefined(pm)) | |
427 | + | then true | |
428 | + | else throw("no pending manager") | |
429 | + | if ((hasPM == hasPM)) | |
547 | 430 | then { | |
548 | - | let cfg = getPoolConfig() | |
549 | - | let factoryCfg = getFactoryConfig() | |
550 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
551 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.") | |
552 | - | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
553 | - | if ((unstakeInv == unstakeInv)) | |
554 | - | then { | |
555 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
556 | - | let poolStatus = parseIntValue(res._9) | |
557 | - | let state = res._10 | |
558 | - | let checkPoolStatus = if (if (isGlobalShutdown()) | |
559 | - | then true | |
560 | - | else (poolStatus == PoolShutdown)) | |
561 | - | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
562 | - | else true | |
563 | - | if ((checkPoolStatus == checkPoolStatus)) | |
564 | - | then { | |
565 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
566 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
567 | - | then state | |
568 | - | else throw("Strict value is not equal to itself.") | |
569 | - | } | |
570 | - | else throw("Strict value is not equal to itself.") | |
571 | - | } | |
431 | + | let checkPM = if ((i.callerPublicKey == value(pm))) | |
432 | + | then true | |
433 | + | else throw("you are not pending manager") | |
434 | + | if ((checkPM == checkPM)) | |
435 | + | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
572 | 436 | else throw("Strict value is not equal to itself.") | |
573 | 437 | } | |
574 | 438 | else throw("Strict value is not equal to itself.") | |
575 | 439 | } | |
576 | 440 | ||
577 | 441 | ||
578 | - | ||
579 | - | @Callable(i) | |
580 | - | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
581 | - | then throw("permissions denied") | |
582 | - | else $Tuple2([StringEntry(keyAmtAsset(), amtAssetStr), StringEntry(keyPriceAsset(), priceAssetStr)], "success") | |
583 | - | ||
584 | - | ||
585 | - | ||
586 | - | @Callable(i) | |
587 | - | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
588 | - | ||
589 | - | ||
590 | - | ||
591 | - | @Callable(i) | |
592 | - | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
593 | - | ||
594 | - | ||
595 | - | ||
596 | - | @Callable(i) | |
597 | - | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
598 | - | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
599 | - | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
442 | + | @Verifier(tx) | |
443 | + | func verify () = { | |
444 | + | let targetPublicKey = match managerPublicKeyOrUnit() { | |
445 | + | case pk: ByteVector => | |
446 | + | pk | |
447 | + | case _: Unit => | |
448 | + | tx.senderPublicKey | |
449 | + | case _ => | |
450 | + | throw("Match error") | |
600 | 451 | } | |
601 | - | ||
602 | - | ||
603 | - | ||
604 | - | @Callable(i) | |
605 | - | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
606 | - | ||
607 | - | ||
608 | - | ||
609 | - | @Callable(i) | |
610 | - | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
611 | - | ||
612 | - | ||
613 | - | ||
614 | - | @Callable(i) | |
615 | - | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
616 | - | ||
617 | - | ||
618 | - | ||
619 | - | @Callable(i) | |
620 | - | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
621 | - | ||
622 | - | ||
623 | - | ||
624 | - | @Callable(i) | |
625 | - | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
626 | - | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
627 | - | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
452 | + | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
628 | 453 | } | |
629 | - | ||
630 | - | ||
631 | - | ||
632 | - | @Callable(i) | |
633 | - | func statsREADONLY () = { | |
634 | - | let cfg = getPoolConfig() | |
635 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
636 | - | let amtAssetId = cfg[idxAmtAssetId] | |
637 | - | let priceAssetId = cfg[idxPriceAssetId] | |
638 | - | let iAmtAssetId = cfg[idxIAmtAssetId] | |
639 | - | let iPriceAssetId = cfg[idxIPriceAssetId] | |
640 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
641 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
642 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
643 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
644 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
645 | - | let pricesList = if ((poolLPBalance == 0)) | |
646 | - | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
647 | - | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
648 | - | let curPrice = 0 | |
649 | - | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
650 | - | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
651 | - | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
652 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP)) | |
653 | - | } | |
654 | - | ||
655 | - | ||
656 | - | ||
657 | - | @Callable(i) | |
658 | - | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
659 | - | let cfg = getPoolConfig() | |
660 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
661 | - | let amAssetIdStr = cfg[idxAmtAssetId] | |
662 | - | let amAssetId = fromBase58String(amAssetIdStr) | |
663 | - | let prAssetIdStr = cfg[idxPriceAssetId] | |
664 | - | let prAssetId = fromBase58String(prAssetIdStr) | |
665 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
666 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
667 | - | let poolStatus = cfg[idxPoolStatus] | |
668 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
669 | - | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
670 | - | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
671 | - | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
672 | - | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
673 | - | let curPriceX18 = if ((poolLPBalance == 0)) | |
674 | - | then zeroBigInt | |
675 | - | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
676 | - | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
677 | - | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
678 | - | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
679 | - | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
680 | - | let calcLpAmt = estPut._1 | |
681 | - | let curPriceCalc = estPut._3 | |
682 | - | let amBalance = estPut._4 | |
683 | - | let prBalance = estPut._5 | |
684 | - | let lpEmission = estPut._6 | |
685 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
686 | - | } | |
687 | - | ||
688 | - | ||
689 | - | ||
690 | - | @Callable(i) | |
691 | - | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
692 | - | let cfg = getPoolConfig() | |
693 | - | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
694 | - | let amAssetIdStr = cfg[idxAmtAssetId] | |
695 | - | let amAssetId = fromBase58String(amAssetIdStr) | |
696 | - | let prAssetIdStr = cfg[idxPriceAssetId] | |
697 | - | let prAssetId = fromBase58String(prAssetIdStr) | |
698 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
699 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
700 | - | let poolStatus = cfg[idxPoolStatus] | |
701 | - | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
702 | - | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
703 | - | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
704 | - | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
705 | - | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
706 | - | let curPriceX18 = if ((poolLPBalance == 0)) | |
707 | - | then zeroBigInt | |
708 | - | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
709 | - | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
710 | - | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
711 | - | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
712 | - | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
713 | - | let calcLpAmt = estPut._1 | |
714 | - | let curPriceCalc = estPut._3 | |
715 | - | let amBalance = estPut._4 | |
716 | - | let prBalance = estPut._5 | |
717 | - | let lpEmission = estPut._6 | |
718 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
719 | - | } | |
720 | - | ||
721 | - | ||
722 | - | ||
723 | - | @Callable(i) | |
724 | - | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
725 | - | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
726 | - | let outAmAmt = res._1 | |
727 | - | let outPrAmt = res._2 | |
728 | - | let amBalance = res._5 | |
729 | - | let prBalance = res._6 | |
730 | - | let lpEmission = res._7 | |
731 | - | let curPrice = res._8 | |
732 | - | let poolStatus = parseIntValue(res._9) | |
733 | - | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), toString(curPrice), toString(poolStatus)], SEP)) | |
734 | - | } | |
735 | - | ||
736 | - | ||
737 | - | @Verifier(tx) | |
738 | - | func verify () = match tx { | |
739 | - | case order: Order => | |
740 | - | let matcherPub = getMatcherPubOrFail() | |
741 | - | let orderValid = validateMatcherOrderAllowed(order) | |
742 | - | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
743 | - | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
744 | - | if (if (if (orderValid) | |
745 | - | then senderValid | |
746 | - | else false) | |
747 | - | then matcherValid | |
748 | - | else false) | |
749 | - | then true | |
750 | - | else throwOrderError(orderValid, senderValid, matcherValid) | |
751 | - | case _ => | |
752 | - | let targetPublicKey = match managerPublicKeyOrUnit() { | |
753 | - | case pk: ByteVector => | |
754 | - | pk | |
755 | - | case _: Unit => | |
756 | - | tx.senderPublicKey | |
757 | - | case _ => | |
758 | - | throw("Match error") | |
759 | - | } | |
760 | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
761 | - | } | |
762 | 454 |
github/deemru/w8io/169f3d6 101.53 ms ◑