1 | | - | {-# STDLIB_VERSION 6 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let SCALE8 = 8 |
---|
5 | | - | |
---|
6 | | - | let MULT8 = 100000000 |
---|
7 | | - | |
---|
8 | | - | let SCALE18 = 18 |
---|
9 | | - | |
---|
10 | | - | let MULT18 = toBigInt(1000000000000000000) |
---|
11 | | - | |
---|
12 | | - | let POOLWEIGHTMULT = MULT8 |
---|
13 | | - | |
---|
14 | | - | let GWXvirtualPOOL = "GWXvirtualPOOL" |
---|
15 | | - | |
---|
16 | | - | let labelPoolsLp = "POOLS_LP" |
---|
17 | | - | |
---|
18 | | - | let defaultSpread = 2000000 |
---|
19 | | - | |
---|
20 | | - | let wavesString = "WAVES" |
---|
21 | | - | |
---|
22 | | - | let decimalsMultPrice = ((100 * 1000) * 1000) |
---|
23 | | - | |
---|
24 | | - | let SEP = "__" |
---|
25 | | - | |
---|
26 | | - | let EMPTY = "" |
---|
27 | | - | |
---|
28 | | - | let PoolActive = 1 |
---|
29 | | - | |
---|
30 | | - | let PoolPutDisabled = 2 |
---|
31 | | - | |
---|
32 | | - | let PoolMatcherDisabled = 3 |
---|
33 | | - | |
---|
34 | | - | let PoolShutdown = 4 |
---|
35 | | - | |
---|
36 | | - | let idxInternalAssetId = 1 |
---|
37 | | - | |
---|
38 | | - | let idxResutActions = 2 |
---|
39 | | - | |
---|
40 | | - | let idxIfAssetIdCalculationPerformed = 3 |
---|
41 | | - | |
---|
42 | | - | let idxPoolAddress = 1 |
---|
43 | | - | |
---|
44 | | - | let idxPoolStatus = 2 |
---|
45 | | - | |
---|
46 | | - | let idxPoolLPAssetId = 3 |
---|
47 | | - | |
---|
48 | | - | let idxAmtAssetId = 4 |
---|
49 | | - | |
---|
50 | | - | let idxPriceAssetId = 5 |
---|
51 | | - | |
---|
52 | | - | let idxAmtAssetDcm = 6 |
---|
53 | | - | |
---|
54 | | - | let idxPriceAssetDcm = 7 |
---|
55 | | - | |
---|
56 | | - | let idxIAmtAssetId = 8 |
---|
57 | | - | |
---|
58 | | - | let idxIPriceAssetId = 9 |
---|
59 | | - | |
---|
60 | | - | let idxLPAssetDcm = 10 |
---|
61 | | - | |
---|
62 | | - | let idxPoolType = 11 |
---|
63 | | - | |
---|
64 | | - | let poolLabelWxEmission = "WX_EMISSION" |
---|
65 | | - | |
---|
66 | | - | let validPoolLabels = [poolLabelWxEmission] |
---|
67 | | - | |
---|
68 | | - | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" |
---|
69 | | - | |
---|
70 | | - | |
---|
71 | | - | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" |
---|
72 | | - | |
---|
73 | | - | |
---|
74 | | - | func keyAllowedLpStableAddonScriptHash () = "%s__allowedLpStableAddonScriptHash" |
---|
75 | | - | |
---|
76 | | - | |
---|
77 | | - | func swapContract () = "%s__swapContract" |
---|
78 | | - | |
---|
79 | | - | |
---|
80 | | - | func keyFactoryConfig () = "%s__factoryConfig" |
---|
81 | | - | |
---|
82 | | - | |
---|
83 | | - | func keyLpTokensList () = "%s__lpTokensList" |
---|
84 | | - | |
---|
85 | | - | |
---|
86 | | - | func keyPoolScriptHash () = "%s%s__pool__scriptHash" |
---|
87 | | - | |
---|
88 | | - | |
---|
89 | | - | func keyMatcherPub () = "%s%s__matcher__publicKey" |
---|
90 | | - | |
---|
91 | | - | |
---|
92 | | - | func keyLegacyFactoryContract () = "%s__legacyFactoryContract" |
---|
93 | | - | |
---|
94 | | - | |
---|
95 | | - | func keyLegacyPools () = "%s__legacyPools" |
---|
96 | | - | |
---|
97 | | - | |
---|
98 | | - | func keyManagerPublicKey () = "%s__managerPublicKey" |
---|
99 | | - | |
---|
100 | | - | |
---|
101 | | - | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" |
---|
102 | | - | |
---|
103 | | - | |
---|
104 | | - | func keyAdminPubKeys () = "%s__adminPubKeys" |
---|
105 | | - | |
---|
106 | | - | |
---|
107 | | - | func keyAssetsStoreContract () = "%s__assetsStoreContract" |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | func keyVotingEmissionContract () = "%s__votingEmissionContract" |
---|
111 | | - | |
---|
112 | | - | |
---|
113 | | - | func keyPriceAssets () = makeString(["%s", "priceAssets"], SEP) |
---|
114 | | - | |
---|
115 | | - | |
---|
116 | | - | func keyPriceDecimals () = "%s__priceDecimals" |
---|
117 | | - | |
---|
118 | | - | |
---|
119 | | - | func keyAllPoolsShutdown () = "%s__shutdown" |
---|
120 | | - | |
---|
121 | | - | |
---|
122 | | - | func keyNextInternalAssetId () = "%s__nextInternalAssetId" |
---|
123 | | - | |
---|
124 | | - | |
---|
125 | | - | func keyPoolToWeight (poolAddress) = ("%s%s__poolWeight__" + poolAddress) |
---|
126 | | - | |
---|
127 | | - | |
---|
128 | | - | func keyPoolToWeightHistory (poolAddress,num) = ((("%s%s__poolWeight__" + poolAddress) + "__") + toString(num)) |
---|
129 | | - | |
---|
130 | | - | |
---|
131 | | - | func keyMappingsInternal2baseAssetId (internalBaseAsset) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(internalBaseAsset)) |
---|
132 | | - | |
---|
133 | | - | |
---|
134 | | - | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) |
---|
135 | | - | |
---|
136 | | - | |
---|
137 | | - | func keyPoolConfig (amountAssetInternal,priceAssetInternal) = (((("%d%d%s__" + amountAssetInternal) + "__") + priceAssetInternal) + "__config") |
---|
138 | | - | |
---|
139 | | - | |
---|
140 | | - | func keyPoolOneTokenOperationsDisabled (assetsInternal) = { |
---|
141 | | - | let $t038253887 = assetsInternal |
---|
142 | | - | let amountAssetInternal = $t038253887._1 |
---|
143 | | - | let priceAssetInternal = $t038253887._2 |
---|
144 | | - | makeString(["%d%d%s", toString(amountAssetInternal), toString(priceAssetInternal), "oneTokenOperationsDisabled"], SEP) |
---|
145 | | - | } |
---|
146 | | - | |
---|
147 | | - | |
---|
148 | | - | func keyAllPoolsOneTokenOperationsDisabled () = makeString(["%s", "oneTokenOperationsDisabled"], SEP) |
---|
149 | | - | |
---|
150 | | - | |
---|
151 | | - | func keyMappingLpAssetToPoolAssets (lpAssetStr) = (("%s%s%s__" + lpAssetStr) + "__mappings__lpAsset2Pool") |
---|
152 | | - | |
---|
153 | | - | |
---|
154 | | - | func keyMappingPoolAssetsToLpasset (internalAmountAssetIdStr,internalPriceAssetIdStr) = (((("%d%d%s%s__" + internalAmountAssetIdStr) + "__") + internalPriceAssetIdStr) + "__mappings__PoolAssets2LpAsset") |
---|
155 | | - | |
---|
156 | | - | |
---|
157 | | - | func keyPoolSpread (poolAddress) = ("%s%s__spread__" + poolAddress) |
---|
158 | | - | |
---|
159 | | - | |
---|
160 | | - | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2PoolAssets") |
---|
161 | | - | |
---|
162 | | - | |
---|
163 | | - | func keyMappingPoolAssetsToPoolContractAddress (internalAmountAssetIdStr,internalPriceAssetIdStr) = (((("%d%d%s%s__" + toString(internalAmountAssetIdStr)) + "__") + toString(internalPriceAssetIdStr)) + "__mappings__poolAssets2PoolContract") |
---|
164 | | - | |
---|
165 | | - | |
---|
166 | | - | func keyMappingPoolContractToLPAsset (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") |
---|
167 | | - | |
---|
168 | | - | |
---|
169 | | - | func keyMappingPoolLPAssetToPoolContractAddress (lpAssetStr) = (("%s%s%s__" + lpAssetStr) + "__mappings__lpAsset2PoolContract") |
---|
170 | | - | |
---|
171 | | - | |
---|
172 | | - | func keyWxEmission (amountAssetId,priceAssetId) = ((("%s%s%s__wxEmission__" + amountAssetId) + "__") + priceAssetId) |
---|
173 | | - | |
---|
174 | | - | |
---|
175 | | - | func keyInFee (poolAddress) = ("%s%s__inFee__" + poolAddress) |
---|
176 | | - | |
---|
177 | | - | |
---|
178 | | - | func keyInFeeDefault () = "%s__inFeeDefault" |
---|
179 | | - | |
---|
180 | | - | |
---|
181 | | - | func keyOutFee (poolAddress) = ("%s%s__outFee__" + poolAddress) |
---|
182 | | - | |
---|
183 | | - | |
---|
184 | | - | func keyOutFeeDefault () = "%s__outFeeDefault" |
---|
185 | | - | |
---|
186 | | - | |
---|
187 | | - | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) |
---|
188 | | - | |
---|
189 | | - | |
---|
190 | | - | func getBooleanOrFail (key) = valueOrErrorMessage(getBoolean(this, key), ("No data for this.key=" + key)) |
---|
191 | | - | |
---|
192 | | - | |
---|
193 | | - | func getIntOrFail (key) = valueOrErrorMessage(getInteger(this, key), ("No data for this.key=" + key)) |
---|
194 | | - | |
---|
195 | | - | |
---|
196 | | - | func parseAssetId (input) = if ((input == wavesString)) |
---|
197 | | - | then unit |
---|
198 | | - | else fromBase58String(input) |
---|
199 | | - | |
---|
200 | | - | |
---|
201 | | - | let IdxFactoryCfgStakingDapp = 1 |
---|
202 | | - | |
---|
203 | | - | let IdxFactoryCfgBoostingDapp = 2 |
---|
204 | | - | |
---|
205 | | - | let IdxFactoryCfgIdoDapp = 3 |
---|
206 | | - | |
---|
207 | | - | let IdxFactoryCfgTeamDapp = 4 |
---|
208 | | - | |
---|
209 | | - | let IdxFactoryCfgEmissionDapp = 5 |
---|
210 | | - | |
---|
211 | | - | let IdxFactoryCfgRestDapp = 6 |
---|
212 | | - | |
---|
213 | | - | let IdxFactoryCfgSlippageDapp = 7 |
---|
214 | | - | |
---|
215 | | - | let IdxFactoryCfgDaoDapp = 8 |
---|
216 | | - | |
---|
217 | | - | let IdxFactoryCfgMarketingDapp = 9 |
---|
218 | | - | |
---|
219 | | - | let IdxFactoryCfgGwxRewardDapp = 10 |
---|
220 | | - | |
---|
221 | | - | let IdxFactoryCfgBirdsDapp = 11 |
---|
222 | | - | |
---|
223 | | - | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) |
---|
224 | | - | |
---|
225 | | - | |
---|
226 | | - | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) |
---|
227 | | - | |
---|
228 | | - | |
---|
229 | | - | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) |
---|
230 | | - | |
---|
231 | | - | |
---|
232 | | - | func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp]) |
---|
233 | | - | |
---|
234 | | - | |
---|
235 | | - | func getPriceAssets () = match getString(keyPriceAssets()) { |
---|
236 | | - | case s: String => |
---|
237 | | - | if ((size(s) == 0)) |
---|
238 | | - | then nil |
---|
239 | | - | else split(s, SEP) |
---|
240 | | - | case _ => |
---|
241 | | - | nil |
---|
242 | | - | } |
---|
243 | | - | |
---|
244 | | - | |
---|
245 | | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { |
---|
246 | | - | case s: String => |
---|
247 | | - | fromBase58String(s) |
---|
248 | | - | case _: Unit => |
---|
249 | | - | unit |
---|
250 | | - | case _ => |
---|
251 | | - | throw("Match error") |
---|
252 | | - | } |
---|
253 | | - | |
---|
254 | | - | |
---|
255 | | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { |
---|
256 | | - | case s: String => |
---|
257 | | - | fromBase58String(s) |
---|
258 | | - | case _: Unit => |
---|
259 | | - | unit |
---|
260 | | - | case _ => |
---|
261 | | - | throw("Match error") |
---|
262 | | - | } |
---|
263 | | - | |
---|
264 | | - | |
---|
265 | | - | let permissionDeniedError = throw("Permission denied") |
---|
266 | | - | |
---|
267 | | - | let testError = throw("Test error here") |
---|
268 | | - | |
---|
269 | | - | func mustThis (i) = if ((i.caller == this)) |
---|
270 | | - | then true |
---|
271 | | - | else permissionDeniedError |
---|
272 | | - | |
---|
273 | | - | |
---|
274 | | - | func mustManager (i) = match managerPublicKeyOrUnit() { |
---|
275 | | - | case pk: ByteVector => |
---|
276 | | - | if ((i.callerPublicKey == pk)) |
---|
277 | | - | then true |
---|
278 | | - | else permissionDeniedError |
---|
279 | | - | case _: Unit => |
---|
280 | | - | mustThis(i) |
---|
281 | | - | case _ => |
---|
282 | | - | throw("Match error") |
---|
283 | | - | } |
---|
284 | | - | |
---|
285 | | - | |
---|
286 | | - | func dataFactoryCfgV3 (stakingAddress,boostingAddress,idoContract,teamContract,emissionContract,restContract,slippageContract,daoContract,marketingContract,gwxRewardsContract,birdsContract) = makeString(["%s%s%s%s%s%s%s%s%s%s%s", stakingAddress, boostingAddress, idoContract, teamContract, emissionContract, restContract, slippageContract, daoContract, marketingContract, gwxRewardsContract, birdsContract], SEP) |
---|
287 | | - | |
---|
288 | | - | |
---|
289 | | - | func dataFactoryCfg (stakingAddress,boostingAddress,idoContract,teamContract,emissionContract,restContract,slippageContract) = makeString(["%s%s%s%s%s%s", stakingAddress, boostingAddress, idoContract, teamContract, emissionContract, restContract, slippageContract], SEP) |
---|
290 | | - | |
---|
291 | | - | |
---|
292 | | - | func dataPoolCfg (poolAddress,poolStatus,lpAssetId,amountAssetStr,priceAssetStr,amountAssetDecimals,priceAssetDecimals,amountAssetInternalId,priceAssetInternalId,lpAssetDecimals,poolType) = makeString(["%s%d%s%s%s%d%d%d%d%d%s", poolAddress, poolStatus, lpAssetId, amountAssetStr, priceAssetStr, toString(amountAssetDecimals), toString(priceAssetDecimals), toString(amountAssetInternalId), toString(priceAssetInternalId), toString(lpAssetDecimals), poolType], SEP) |
---|
293 | | - | |
---|
294 | | - | |
---|
295 | | - | func dataMappingPoolAssets (internalAmountAssetStr,internalPriceAssetStr) = makeString(["%d%d", toString(internalAmountAssetStr), toString(internalPriceAssetStr)], SEP) |
---|
296 | | - | |
---|
297 | | - | |
---|
298 | | - | func getPoolConfig (poolAddress) = { |
---|
299 | | - | let poolAssets = split(getStringOrFail(keyMappingPoolContractAddressToPoolAssets(poolAddress)), SEP) |
---|
300 | | - | let amountAssetInternal = poolAssets[1] |
---|
301 | | - | let priceAssetInternal = poolAssets[2] |
---|
302 | | - | split(getStringOrFail(keyPoolConfig(amountAssetInternal, priceAssetInternal)), SEP) |
---|
303 | | - | } |
---|
304 | | - | |
---|
305 | | - | |
---|
306 | | - | func getInternalAssetIdOrCreate (assetIdStr,incrementor) = { |
---|
307 | | - | let internalAssetId = valueOrElse(getInteger(this, keyMappingsBaseAsset2internalId(assetIdStr)), 0) |
---|
308 | | - | let currentIndexOfInternalId = valueOrElse(getInteger(this, keyNextInternalAssetId()), 0) |
---|
309 | | - | let result = if ((internalAssetId == 0)) |
---|
310 | | - | then { |
---|
311 | | - | let newInternalAssetId = (currentIndexOfInternalId + incrementor) |
---|
312 | | - | $Tuple3(newInternalAssetId, [IntegerEntry(keyNextInternalAssetId(), newInternalAssetId), IntegerEntry(keyMappingsBaseAsset2internalId(assetIdStr), newInternalAssetId), StringEntry(keyMappingsInternal2baseAssetId(newInternalAssetId), assetIdStr)], true) |
---|
313 | | - | } |
---|
314 | | - | else $Tuple3(internalAssetId, nil, false) |
---|
315 | | - | result |
---|
316 | | - | } |
---|
317 | | - | |
---|
318 | | - | |
---|
319 | | - | func mustAdmin (i) = { |
---|
320 | | - | let adminPKs = split(valueOrElse(getString(keyAdminPubKeys()), EMPTY), SEP) |
---|
321 | | - | if (containsElement(adminPKs, toBase58String(i.callerPublicKey))) |
---|
322 | | - | then true |
---|
323 | | - | else { |
---|
324 | | - | let isManager = mustManager(i) |
---|
325 | | - | if ((isManager == isManager)) |
---|
326 | | - | then true |
---|
327 | | - | else throw("Strict value is not equal to itself.") |
---|
328 | | - | } |
---|
329 | | - | } |
---|
330 | | - | |
---|
331 | | - | |
---|
332 | | - | func intOrDefaultOrFallback (key,keyDefault,valueFallback) = valueOrElse(getInteger(this, key), valueOrElse(getInteger(this, keyDefault), valueFallback)) |
---|
333 | | - | |
---|
334 | | - | |
---|
335 | | - | func poolExistsInternal (amountAssetId,priceAssetId) = { |
---|
336 | | - | let amountAssetInternal = getInteger(keyMappingsBaseAsset2internalId(amountAssetId)) |
---|
337 | | - | let priceAssetInternal = getInteger(keyMappingsBaseAsset2internalId(priceAssetId)) |
---|
338 | | - | if (if ((amountAssetInternal == unit)) |
---|
339 | | - | then true |
---|
340 | | - | else (priceAssetInternal == unit)) |
---|
341 | | - | then false |
---|
342 | | - | else { |
---|
343 | | - | let amAs = toString(value(amountAssetInternal)) |
---|
344 | | - | let prAs = toString(value(priceAssetInternal)) |
---|
345 | | - | let cfg = getString(keyPoolConfig(amAs, prAs)) |
---|
346 | | - | let cfgReverse = getString(keyPoolConfig(prAs, amAs)) |
---|
347 | | - | let exists = if ((cfg != unit)) |
---|
348 | | - | then true |
---|
349 | | - | else (cfgReverse != unit) |
---|
350 | | - | exists |
---|
351 | | - | } |
---|
352 | | - | } |
---|
353 | | - | |
---|
354 | | - | |
---|
355 | | - | @Callable(i) |
---|
356 | | - | func getSwapContractREADONLY () = $Tuple2(nil, getStringOrFail(swapContract())) |
---|
357 | | - | |
---|
358 | | - | |
---|
359 | | - | |
---|
360 | | - | @Callable(i) |
---|
361 | | - | func getLpAssetFromPoolAssetsREADONLY (asset1,asset2) = if (if ((asset1 == "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS")) |
---|
362 | | - | then (asset2 == "WAVES") |
---|
363 | | - | else false) |
---|
364 | | - | then $Tuple2(nil, unit) |
---|
365 | | - | else { |
---|
366 | | - | let assetNum1 = value(getInteger(this, keyMappingsBaseAsset2internalId(asset1))) |
---|
367 | | - | let assetNum2 = value(getInteger(this, keyMappingsBaseAsset2internalId(asset2))) |
---|
368 | | - | let ee = getString(this, keyMappingPoolAssetsToLpasset(toString(assetNum1), toString(assetNum2))) |
---|
369 | | - | let res = if ((ee == unit)) |
---|
370 | | - | then unit |
---|
371 | | - | else drop(value(ee), 4) |
---|
372 | | - | $Tuple2(nil, res) |
---|
373 | | - | } |
---|
374 | | - | |
---|
375 | | - | |
---|
376 | | - | |
---|
377 | | - | @Callable(i) |
---|
378 | | - | func getPoolAddressFromLpAssetREADONLY (lp) = $Tuple2(nil, valueOrElse(getString(this, keyMappingPoolLPAssetToPoolContractAddress(lp)), "")) |
---|
379 | | - | |
---|
380 | | - | |
---|
381 | | - | |
---|
382 | | - | @Callable(i) |
---|
383 | | - | func constructor (stakingContract,boostingContract,idoContract,teamContract,emissionContract,restContract,slpipageContract,priceDecimals) = { |
---|
384 | | - | let checkCaller = mustManager(i) |
---|
385 | | - | if ((checkCaller == checkCaller)) |
---|
386 | | - | then [StringEntry(keyFactoryConfig(), dataFactoryCfg(stakingContract, boostingContract, idoContract, teamContract, emissionContract, restContract, slpipageContract)), IntegerEntry(keyPriceDecimals(), priceDecimals)] |
---|
387 | | - | else throw("Strict value is not equal to itself.") |
---|
388 | | - | } |
---|
389 | | - | |
---|
390 | | - | |
---|
391 | | - | |
---|
392 | | - | @Callable(i) |
---|
393 | | - | func constructorV2 (mathcherPub58Str) = { |
---|
394 | | - | let checkCaller = mustManager(i) |
---|
395 | | - | if ((checkCaller == checkCaller)) |
---|
396 | | - | then { |
---|
397 | | - | let mathcerPub = addressFromPublicKey(fromBase58String(mathcherPub58Str)) |
---|
398 | | - | if ((mathcerPub == mathcerPub)) |
---|
399 | | - | then [StringEntry(keyMatcherPub(), mathcherPub58Str)] |
---|
400 | | - | else throw("Strict value is not equal to itself.") |
---|
401 | | - | } |
---|
402 | | - | else throw("Strict value is not equal to itself.") |
---|
403 | | - | } |
---|
404 | | - | |
---|
405 | | - | |
---|
406 | | - | |
---|
407 | | - | @Callable(i) |
---|
408 | | - | func constructorV3 (daoContract,marketingContract,gwxRewardsContract,birdsContract) = { |
---|
409 | | - | let checkCaller = mustManager(i) |
---|
410 | | - | if ((checkCaller == checkCaller)) |
---|
411 | | - | then { |
---|
412 | | - | let factoryCfg = split(getStringOrFail(keyFactoryConfig()), SEP) |
---|
413 | | - | [StringEntry(keyFactoryConfig(), dataFactoryCfgV3(factoryCfg[1], factoryCfg[2], factoryCfg[3], factoryCfg[4], factoryCfg[5], factoryCfg[6], factoryCfg[7], daoContract, marketingContract, gwxRewardsContract, birdsContract))] |
---|
414 | | - | } |
---|
415 | | - | else throw("Strict value is not equal to itself.") |
---|
416 | | - | } |
---|
417 | | - | |
---|
418 | | - | |
---|
419 | | - | |
---|
420 | | - | @Callable(i) |
---|
421 | | - | func constructorV4 (legacyFactoryContract,legacyPools) = { |
---|
422 | | - | let checkCaller = mustManager(i) |
---|
423 | | - | if ((checkCaller == checkCaller)) |
---|
424 | | - | then [StringEntry(keyLegacyFactoryContract(), legacyFactoryContract), StringEntry(keyLegacyPools(), makeString(legacyPools, SEP))] |
---|
425 | | - | else throw("Strict value is not equal to itself.") |
---|
426 | | - | } |
---|
427 | | - | |
---|
428 | | - | |
---|
429 | | - | |
---|
430 | | - | @Callable(i) |
---|
431 | | - | func constructorV5 (assetsStoreContract) = { |
---|
432 | | - | let checkCaller = mustManager(i) |
---|
433 | | - | if ((checkCaller == checkCaller)) |
---|
434 | | - | then [StringEntry(keyAssetsStoreContract(), assetsStoreContract)] |
---|
435 | | - | else throw("Strict value is not equal to itself.") |
---|
436 | | - | } |
---|
437 | | - | |
---|
438 | | - | |
---|
439 | | - | |
---|
440 | | - | @Callable(i) |
---|
441 | | - | func constructorV6 (votingEmissionContract,priceAssets) = { |
---|
442 | | - | let cheks = [mustManager(i), if ((addressFromString(votingEmissionContract) != unit)) |
---|
443 | | - | then true |
---|
444 | | - | else "invalid voting emission contract address"] |
---|
445 | | - | if ((cheks == cheks)) |
---|
446 | | - | then [StringEntry(keyVotingEmissionContract(), votingEmissionContract), StringEntry(keyPriceAssets(), makeString(priceAssets, SEP))] |
---|
447 | | - | else throw("Strict value is not equal to itself.") |
---|
448 | | - | } |
---|
449 | | - | |
---|
450 | | - | |
---|
451 | | - | |
---|
452 | | - | @Callable(i) |
---|
453 | | - | func setManager (pendingManagerPublicKey) = { |
---|
454 | | - | let checkCaller = mustManager(i) |
---|
455 | | - | if ((checkCaller == checkCaller)) |
---|
456 | | - | then { |
---|
457 | | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) |
---|
458 | | - | if ((checkManagerPublicKey == checkManagerPublicKey)) |
---|
459 | | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] |
---|
460 | | - | else throw("Strict value is not equal to itself.") |
---|
461 | | - | } |
---|
462 | | - | else throw("Strict value is not equal to itself.") |
---|
463 | | - | } |
---|
464 | | - | |
---|
465 | | - | |
---|
466 | | - | |
---|
467 | | - | @Callable(i) |
---|
468 | | - | func confirmManager () = { |
---|
469 | | - | let pm = pendingManagerPublicKeyOrUnit() |
---|
470 | | - | let hasPM = if (isDefined(pm)) |
---|
471 | | - | then true |
---|
472 | | - | else throw("No pending manager") |
---|
473 | | - | if ((hasPM == hasPM)) |
---|
474 | | - | then { |
---|
475 | | - | let checkPM = if ((i.callerPublicKey == value(pm))) |
---|
476 | | - | then true |
---|
477 | | - | else throw("You are not pending manager") |
---|
478 | | - | if ((checkPM == checkPM)) |
---|
479 | | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] |
---|
480 | | - | else throw("Strict value is not equal to itself.") |
---|
481 | | - | } |
---|
482 | | - | else throw("Strict value is not equal to itself.") |
---|
483 | | - | } |
---|
484 | | - | |
---|
485 | | - | |
---|
486 | | - | |
---|
487 | | - | @Callable(i) |
---|
488 | | - | func setAdmins (adminPubKeys) = { |
---|
489 | | - | let checkCaller = mustManager(i) |
---|
490 | | - | if ((checkCaller == checkCaller)) |
---|
491 | | - | then [StringEntry(keyAdminPubKeys(), makeString(adminPubKeys, SEP))] |
---|
492 | | - | else throw("Strict value is not equal to itself.") |
---|
493 | | - | } |
---|
494 | | - | |
---|
495 | | - | |
---|
496 | | - | |
---|
497 | | - | @Callable(i) |
---|
498 | | - | func activateNewPool (poolAddress,amountAssetStr,priceAssetStr,lpAssetName,lpAssetDescr,poolWeight,poolType,logo) = { |
---|
499 | | - | let checkCaller = mustAdmin(i) |
---|
500 | | - | if ((checkCaller == checkCaller)) |
---|
501 | | - | then if (isDefined(getString(keyMappingPoolContractAddressToPoolAssets(poolAddress)))) |
---|
502 | | - | then throw((("Pool address " + poolAddress) + " already registered.")) |
---|
503 | | - | else { |
---|
504 | | - | let internalAmountAssetData = getInternalAssetIdOrCreate(amountAssetStr, 1) |
---|
505 | | - | let internalAmountAssetId = internalAmountAssetData._1 |
---|
506 | | - | let internalPriceAssetData = getInternalAssetIdOrCreate(priceAssetStr, if (internalAmountAssetData._3) |
---|
507 | | - | then 2 |
---|
508 | | - | else 1) |
---|
509 | | - | let internalPriceAssetId = internalPriceAssetData._1 |
---|
510 | | - | let poolAccountScriptHash = valueOrErrorMessage(scriptHash(addressFromStringValue(poolAddress)), ("No script has been found on pool account " + poolAddress)) |
---|
511 | | - | let ethalonPoolAccountScriptHash = getBinaryValue(keyPoolScriptHash()) |
---|
512 | | - | let poolExists = poolExistsInternal(amountAssetStr, priceAssetStr) |
---|
513 | | - | if (poolExists) |
---|
514 | | - | then throw((((("Pool " + amountAssetStr) + "/") + priceAssetStr) + " has already been activated.")) |
---|
515 | | - | else { |
---|
516 | | - | let poolConfigValue = value(getString(this, keyPoolConfig(toString(internalAmountAssetId), toString(internalPriceAssetId)))) |
---|
517 | | - | let amountAssetsDecimals = if ((amountAssetStr == "WAVES")) |
---|
518 | | - | then decimalsMultPrice |
---|
519 | | - | else pow(10, 0, value(assetInfo(fromBase58String(amountAssetStr))).decimals, 0, 0, DOWN) |
---|
520 | | - | let priceAssetsDecimals = if ((priceAssetStr == "WAVES")) |
---|
521 | | - | then decimalsMultPrice |
---|
522 | | - | else pow(10, 0, value(assetInfo(fromBase58String(priceAssetStr))).decimals, 0, 0, DOWN) |
---|
523 | | - | let lpAssetIssueAction = Issue(lpAssetName, lpAssetDescr, 1, 8, true) |
---|
524 | | - | let lpAssetId = calculateAssetId(lpAssetIssueAction) |
---|
525 | | - | let lpAssetIdStr = toBase58String(lpAssetId) |
---|
526 | | - | let poolActivateInvokeResult = invoke(addressFromStringValue(poolAddress), "activate", [amountAssetStr, priceAssetStr], nil) |
---|
527 | | - | if ((poolActivateInvokeResult == poolActivateInvokeResult)) |
---|
528 | | - | then if ((poolActivateInvokeResult != "success")) |
---|
529 | | - | then throw("Pool initialisation error happened.") |
---|
530 | | - | else { |
---|
531 | | - | let assetsStoreContract = addressFromStringValue(getStringOrFail(keyAssetsStoreContract())) |
---|
532 | | - | let createOrUpdateLpAssetInv = invoke(assetsStoreContract, "createOrUpdate", [lpAssetIdStr, lpAssetName, false], nil) |
---|
533 | | - | if ((createOrUpdateLpAssetInv == createOrUpdateLpAssetInv)) |
---|
534 | | - | then { |
---|
535 | | - | let addPoolsLpLabelInv = invoke(assetsStoreContract, "addLabel", [lpAssetIdStr, labelPoolsLp], nil) |
---|
536 | | - | if ((addPoolsLpLabelInv == addPoolsLpLabelInv)) |
---|
537 | | - | then { |
---|
538 | | - | let setLogoInv = invoke(assetsStoreContract, "setLogo", [lpAssetIdStr, logo], nil) |
---|
539 | | - | if ((setLogoInv == setLogoInv)) |
---|
540 | | - | then { |
---|
541 | | - | let addAssetsLinkInv = invoke(assetsStoreContract, "addAssetsLink", [amountAssetStr, priceAssetStr, lpAssetIdStr], nil) |
---|
542 | | - | if ((addAssetsLinkInv == addAssetsLinkInv)) |
---|
543 | | - | then { |
---|
544 | | - | let increaseAssetPoolsNumberInv = invoke(assetsStoreContract, "increaseAssetPoolsNumber", [amountAssetStr], nil) |
---|
545 | | - | if ((increaseAssetPoolsNumberInv == increaseAssetPoolsNumberInv)) |
---|
546 | | - | then $Tuple2(((internalAmountAssetData._2 ++ internalPriceAssetData._2) ++ [lpAssetIssueAction, Burn(lpAssetId, 1), StringEntry(keyPoolConfig(toString(internalAmountAssetId), toString(internalPriceAssetId)), dataPoolCfg(poolAddress, toString(PoolActive), lpAssetIdStr, amountAssetStr, priceAssetStr, amountAssetsDecimals, priceAssetsDecimals, internalAmountAssetId, internalPriceAssetId, decimalsMultPrice, poolType)), StringEntry(keyMappingLpAssetToPoolAssets(lpAssetIdStr), dataMappingPoolAssets(internalAmountAssetId, internalPriceAssetId)), StringEntry(keyMappingPoolAssetsToLpasset(toString(internalAmountAssetId), toString(internalPriceAssetId)), ("%s__" + lpAssetIdStr)), StringEntry(keyMappingPoolContractAddressToPoolAssets(poolAddress), dataMappingPoolAssets(internalAmountAssetId, internalPriceAssetId)), StringEntry(keyMappingPoolAssetsToPoolContractAddress(internalAmountAssetId, internalPriceAssetId), poolAddress), StringEntry(keyMappingPoolLPAssetToPoolContractAddress(lpAssetIdStr), poolAddress), StringEntry(keyMappingPoolContractToLPAsset(poolAddress), lpAssetIdStr), IntegerEntry(keyPoolToWeight(poolAddress), poolWeight), IntegerEntry(keyPoolSpread(poolAddress), defaultSpread)]), lpAssetIdStr) |
---|
547 | | - | else throw("Strict value is not equal to itself.") |
---|
548 | | - | } |
---|
549 | | - | else throw("Strict value is not equal to itself.") |
---|
550 | | - | } |
---|
551 | | - | else throw("Strict value is not equal to itself.") |
---|
552 | | - | } |
---|
553 | | - | else throw("Strict value is not equal to itself.") |
---|
554 | | - | } |
---|
555 | | - | else throw("Strict value is not equal to itself.") |
---|
556 | | - | } |
---|
557 | | - | else throw("Strict value is not equal to itself.") |
---|
558 | | - | } |
---|
559 | | - | } |
---|
560 | | - | else throw("Strict value is not equal to itself.") |
---|
561 | | - | } |
---|
562 | | - | |
---|
563 | | - | |
---|
564 | | - | |
---|
565 | | - | @Callable(i) |
---|
566 | | - | func managePool (poolAddress,newStatus) = { |
---|
567 | | - | let checkCaller = mustManager(i) |
---|
568 | | - | if ((checkCaller == checkCaller)) |
---|
569 | | - | then { |
---|
570 | | - | let poolConfig = getPoolConfig(poolAddress) |
---|
571 | | - | let poolStatus = poolConfig[idxPoolStatus] |
---|
572 | | - | let lpAssetIdStr = poolConfig[idxPoolLPAssetId] |
---|
573 | | - | let amountAssetStr = poolConfig[idxAmtAssetId] |
---|
574 | | - | let priceAssetStr = poolConfig[idxPriceAssetId] |
---|
575 | | - | let amountAssetsDecimals = parseIntValue(poolConfig[idxAmtAssetDcm]) |
---|
576 | | - | let priceAssetsDecimals = parseIntValue(poolConfig[idxPriceAssetDcm]) |
---|
577 | | - | let internalAmountAssetId = parseIntValue(poolConfig[idxIAmtAssetId]) |
---|
578 | | - | let internalPriceAssetId = parseIntValue(poolConfig[idxIPriceAssetId]) |
---|
579 | | - | let lpAssetDcm = parseIntValue(poolConfig[idxLPAssetDcm]) |
---|
580 | | - | let poolType = poolConfig[idxPoolType] |
---|
581 | | - | [StringEntry(keyPoolConfig(toString(internalAmountAssetId), toString(internalPriceAssetId)), dataPoolCfg(poolAddress, toString(newStatus), lpAssetIdStr, amountAssetStr, priceAssetStr, amountAssetsDecimals, priceAssetsDecimals, internalAmountAssetId, internalPriceAssetId, lpAssetDcm, poolType))] |
---|
582 | | - | } |
---|
583 | | - | else throw("Strict value is not equal to itself.") |
---|
584 | | - | } |
---|
585 | | - | |
---|
586 | | - | |
---|
587 | | - | |
---|
588 | | - | @Callable(i) |
---|
589 | | - | func emit (amountToEmit) = { |
---|
590 | | - | let caller = i.caller |
---|
591 | | - | let originCaller = i.originCaller |
---|
592 | | - | let lpAssetRequested = valueOrErrorMessage(getString(keyMappingPoolContractToLPAsset(toString(caller))), "Invalid LP address called me.") |
---|
593 | | - | let lpAsset = fromBase58String(lpAssetRequested) |
---|
594 | | - | let legacyPools = split(valueOrElse(getString(keyLegacyPools()), EMPTY), SEP) |
---|
595 | | - | let legacyFactoryContract = addressFromStringValue(valueOrErrorMessage(getString(keyLegacyFactoryContract()), "Legacy factory contract does not exists.")) |
---|
596 | | - | if ((0 >= amountToEmit)) |
---|
597 | | - | then nil |
---|
598 | | - | else if (containsElement(legacyPools, toString(caller))) |
---|
599 | | - | then $Tuple2(nil, legacyFactoryContract) |
---|
600 | | - | else $Tuple2([Reissue(lpAsset, amountToEmit, true), ScriptTransfer(i.caller, amountToEmit, lpAsset)], "success") |
---|
601 | | - | } |
---|
602 | | - | |
---|
603 | | - | |
---|
604 | | - | |
---|
605 | | - | @Callable(i) |
---|
606 | | - | func burn (amountToBurn) = { |
---|
607 | | - | let caller = i.caller |
---|
608 | | - | let originCaller = i.originCaller |
---|
609 | | - | let payment = value(i.payments[0]) |
---|
610 | | - | let paymentAmount = value(payment.amount) |
---|
611 | | - | let inAmountAssetId = toBase58String(value(payment.assetId)) |
---|
612 | | - | let lpAssetRequestedForBurning = valueOrErrorMessage(getString(keyMappingPoolContractToLPAsset(toString(caller))), "Invalid LP address called me.") |
---|
613 | | - | if ((inAmountAssetId != lpAssetRequestedForBurning)) |
---|
614 | | - | then throw("Invalid asset passed.") |
---|
615 | | - | else if ((amountToBurn != paymentAmount)) |
---|
616 | | - | then throw("Invalid amount passed.") |
---|
617 | | - | else { |
---|
618 | | - | let lpAsset = fromBase58String(lpAssetRequestedForBurning) |
---|
619 | | - | $Tuple2([Burn(lpAsset, amountToBurn)], "success") |
---|
620 | | - | } |
---|
621 | | - | } |
---|
622 | | - | |
---|
623 | | - | |
---|
624 | | - | |
---|
625 | | - | @Callable(i) |
---|
626 | | - | func modifyWeight (lpAssetId,share) = { |
---|
627 | | - | let checkCaller = if ((toBase58String(i.caller.bytes) == valueOrElse(getString(this, keyVotingEmissionContract()), ""))) |
---|
628 | | - | then true |
---|
629 | | - | else mustManager(i) |
---|
630 | | - | if ((checkCaller == checkCaller)) |
---|
631 | | - | then { |
---|
632 | | - | let poolContractAddress = getStringOrFail(keyMappingPoolLPAssetToPoolContractAddress(lpAssetId)) |
---|
633 | | - | let poolWeightKey = keyPoolToWeight(poolContractAddress) |
---|
634 | | - | let gwxWeightKey = keyPoolToWeight(GWXvirtualPOOL) |
---|
635 | | - | let gwxWeight = valueOrElse(getInteger(gwxWeightKey), 0) |
---|
636 | | - | let poolWeight = valueOrElse(getInteger(poolWeightKey), 0) |
---|
637 | | - | let poolWeightNew = share |
---|
638 | | - | let factoryCfg = split(getStringOrFail(keyFactoryConfig()), SEP) |
---|
639 | | - | let stakingContract = getStakingAddressOrFail(factoryCfg) |
---|
640 | | - | let onModifyWeightInv = invoke(stakingContract, "onModifyWeight", [lpAssetId, poolContractAddress], nil) |
---|
641 | | - | if ((onModifyWeightInv == onModifyWeightInv)) |
---|
642 | | - | then { |
---|
643 | | - | let gwxVirtualPoolActions = if ((gwxWeight == 0)) |
---|
644 | | - | then nil |
---|
645 | | - | else [IntegerEntry(gwxWeightKey, 0)] |
---|
646 | | - | let poolWeightHistoryKey = keyPoolToWeightHistory(poolContractAddress, 0) |
---|
647 | | - | let poolWeightHistoryOrUnit = getInteger(poolWeightHistoryKey) |
---|
648 | | - | let poolWeightHistoryActions = if ((poolWeightHistoryOrUnit == unit)) |
---|
649 | | - | then nil |
---|
650 | | - | else [DeleteEntry(poolWeightHistoryKey)] |
---|
651 | | - | (([IntegerEntry(poolWeightKey, poolWeightNew)] ++ gwxVirtualPoolActions) ++ poolWeightHistoryActions) |
---|
652 | | - | } |
---|
653 | | - | else throw("Strict value is not equal to itself.") |
---|
654 | | - | } |
---|
655 | | - | else throw("Strict value is not equal to itself.") |
---|
656 | | - | } |
---|
657 | | - | |
---|
658 | | - | |
---|
659 | | - | |
---|
660 | | - | @Callable(i) |
---|
661 | | - | func modifyWeights (btcPoolAddress,ethPoolAddress,ethBtcPoolAddress,usdcUsdtPoolAddress) = { |
---|
662 | | - | let checkCaller = mustManager(i) |
---|
663 | | - | if ((checkCaller == checkCaller)) |
---|
664 | | - | then { |
---|
665 | | - | let ethBtcWeightNew = ((5 * POOLWEIGHTMULT) / 100) |
---|
666 | | - | let usdcUsdtWeightNew = ((5 * POOLWEIGHTMULT) / 100) |
---|
667 | | - | let weightDecrement = ((5 * POOLWEIGHTMULT) / 100) |
---|
668 | | - | let factoryCfg = split(getStringOrFail(keyFactoryConfig()), SEP) |
---|
669 | | - | let stakingDapp = getStakingAddressOrFail(factoryCfg) |
---|
670 | | - | let gwxRewardDapp = getGwxRewardAddressOrFail(factoryCfg) |
---|
671 | | - | let btcWeightKEY = keyPoolToWeight(btcPoolAddress) |
---|
672 | | - | let ethWeightKEY = keyPoolToWeight(ethPoolAddress) |
---|
673 | | - | let ethBtcWeightKEY = keyPoolToWeight(ethBtcPoolAddress) |
---|
674 | | - | let usdcUsdtWeightKEY = keyPoolToWeight(usdcUsdtPoolAddress) |
---|
675 | | - | let btcWeight = getIntOrFail(btcWeightKEY) |
---|
676 | | - | let ethWeight = getIntOrFail(ethWeightKEY) |
---|
677 | | - | let btcWeightNew = (btcWeight - weightDecrement) |
---|
678 | | - | let ethWeightNew = (ethWeight - weightDecrement) |
---|
679 | | - | if ((0 >= btcWeightNew)) |
---|
680 | | - | then throw(("invalid btcWeightNew: " + toString(btcWeightNew))) |
---|
681 | | - | else if ((0 >= ethWeightNew)) |
---|
682 | | - | then throw(("invalid ethWeightNew: " + toString(ethWeightNew))) |
---|
683 | | - | else { |
---|
684 | | - | let btcLpAssetIdStr = getStringOrFail(keyMappingPoolContractToLPAsset(btcPoolAddress)) |
---|
685 | | - | let ethLpAssetIdStr = getStringOrFail(keyMappingPoolContractToLPAsset(ethPoolAddress)) |
---|
686 | | - | let ethBtcLpAssetIdStr = getStringOrFail(keyMappingPoolContractToLPAsset(ethBtcPoolAddress)) |
---|
687 | | - | let usdcUsdtLpAssetIdStr = getStringOrFail(keyMappingPoolContractToLPAsset(usdcUsdtPoolAddress)) |
---|
688 | | - | let onModifyWeightBtc = invoke(stakingDapp, "onModifyWeight", [btcLpAssetIdStr, btcPoolAddress], nil) |
---|
689 | | - | if ((onModifyWeightBtc == onModifyWeightBtc)) |
---|
690 | | - | then { |
---|
691 | | - | let onModifyWeightEth = invoke(stakingDapp, "onModifyWeight", [ethLpAssetIdStr, ethPoolAddress], nil) |
---|
692 | | - | if ((onModifyWeightEth == onModifyWeightEth)) |
---|
693 | | - | then { |
---|
694 | | - | let onModifyWeightEthBtc = invoke(stakingDapp, "onModifyWeight", [ethBtcLpAssetIdStr, ethBtcPoolAddress], nil) |
---|
695 | | - | if ((onModifyWeightEthBtc == onModifyWeightEthBtc)) |
---|
696 | | - | then { |
---|
697 | | - | let onModifyWeightUsdcUsdt = invoke(stakingDapp, "onModifyWeight", [usdcUsdtLpAssetIdStr, usdcUsdtPoolAddress], nil) |
---|
698 | | - | if ((onModifyWeightUsdcUsdt == onModifyWeightUsdcUsdt)) |
---|
699 | | - | then [IntegerEntry(btcWeightKEY, btcWeightNew), IntegerEntry(ethWeightKEY, ethWeightNew), IntegerEntry(ethBtcWeightKEY, ethBtcWeightNew), IntegerEntry(usdcUsdtWeightKEY, usdcUsdtWeightNew), IntegerEntry(keyPoolToWeightHistory(btcPoolAddress, 0), btcWeight), IntegerEntry(keyPoolToWeightHistory(ethPoolAddress, 0), ethWeight), IntegerEntry(keyPoolToWeightHistory(ethBtcPoolAddress, 0), ethBtcWeightNew), IntegerEntry(keyPoolToWeightHistory(usdcUsdtPoolAddress, 0), usdcUsdtWeightNew)] |
---|
700 | | - | else throw("Strict value is not equal to itself.") |
---|
701 | | - | } |
---|
702 | | - | else throw("Strict value is not equal to itself.") |
---|
703 | | - | } |
---|
704 | | - | else throw("Strict value is not equal to itself.") |
---|
705 | | - | } |
---|
706 | | - | else throw("Strict value is not equal to itself.") |
---|
707 | | - | } |
---|
708 | | - | } |
---|
709 | | - | else throw("Strict value is not equal to itself.") |
---|
710 | | - | } |
---|
711 | | - | |
---|
712 | | - | |
---|
713 | | - | |
---|
714 | | - | @Callable(i) |
---|
715 | | - | func checkWxEmissionPoolLabel (amountAssetId,priceAssetId) = { |
---|
716 | | - | let haveLabel = match getBoolean(keyWxEmission(amountAssetId, priceAssetId)) { |
---|
717 | | - | case b: Boolean => |
---|
718 | | - | b |
---|
719 | | - | case _ => |
---|
720 | | - | false |
---|
721 | | - | } |
---|
722 | | - | $Tuple2(nil, haveLabel) |
---|
723 | | - | } |
---|
724 | | - | |
---|
725 | | - | |
---|
726 | | - | |
---|
727 | | - | @Callable(i) |
---|
728 | | - | func setWxEmissionPoolLabel (amountAssetId,priceAssetId) = { |
---|
729 | | - | let checkCaller = mustAdmin(i) |
---|
730 | | - | if ((checkCaller == checkCaller)) |
---|
731 | | - | then $Tuple2([BooleanEntry(keyWxEmission(amountAssetId, priceAssetId), true)], unit) |
---|
732 | | - | else throw("Strict value is not equal to itself.") |
---|
733 | | - | } |
---|
734 | | - | |
---|
735 | | - | |
---|
736 | | - | |
---|
737 | | - | @Callable(i) |
---|
738 | | - | func deleteWxEmissionPoolLabel (amountAssetId,priceAssetId) = { |
---|
739 | | - | let checkCaller = if (mustThis(i)) |
---|
740 | | - | then true |
---|
741 | | - | else mustAdmin(i) |
---|
742 | | - | if ((checkCaller == checkCaller)) |
---|
743 | | - | then $Tuple2([DeleteEntry(keyWxEmission(amountAssetId, priceAssetId))], unit) |
---|
744 | | - | else throw("Strict value is not equal to itself.") |
---|
745 | | - | } |
---|
746 | | - | |
---|
747 | | - | |
---|
748 | | - | |
---|
749 | | - | @Callable(i) |
---|
750 | | - | func onVerificationLoss (assetId) = { |
---|
751 | | - | let checkCaller = if ((toBase58String(i.caller.bytes) == valueOrElse(getString(this, keyAssetsStoreContract()), ""))) |
---|
752 | | - | then true |
---|
753 | | - | else mustManager(i) |
---|
754 | | - | if ((checkCaller == checkCaller)) |
---|
755 | | - | then { |
---|
756 | | - | let priceAssets = getPriceAssets() |
---|
757 | | - | let checkPriceAssetsSize = if ((size(priceAssets) > 0)) |
---|
758 | | - | then true |
---|
759 | | - | else throw("invalid price assets") |
---|
760 | | - | if ((checkPriceAssetsSize == checkPriceAssetsSize)) |
---|
761 | | - | then { |
---|
762 | | - | func cb (acc,priceAsset) = { |
---|
763 | | - | let r = invoke(this, "deleteWxEmissionPoolLabel", [assetId, priceAsset], nil) |
---|
764 | | - | if ((r == r)) |
---|
765 | | - | then unit |
---|
766 | | - | else throw("Strict value is not equal to itself.") |
---|
767 | | - | } |
---|
768 | | - | |
---|
769 | | - | let actions = { |
---|
770 | | - | let $l = priceAssets |
---|
771 | | - | let $s = size($l) |
---|
772 | | - | let $acc0 = unit |
---|
773 | | - | func $f0_1 ($a,$i) = if (($i >= $s)) |
---|
774 | | - | then $a |
---|
775 | | - | else cb($a, $l[$i]) |
---|
776 | | - | |
---|
777 | | - | func $f0_2 ($a,$i) = if (($i >= $s)) |
---|
778 | | - | then $a |
---|
779 | | - | else throw("List size exceeds 2") |
---|
780 | | - | |
---|
781 | | - | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) |
---|
782 | | - | } |
---|
783 | | - | if ((actions == actions)) |
---|
784 | | - | then $Tuple2(nil, unit) |
---|
785 | | - | else throw("Strict value is not equal to itself.") |
---|
786 | | - | } |
---|
787 | | - | else throw("Strict value is not equal to itself.") |
---|
788 | | - | } |
---|
789 | | - | else throw("Strict value is not equal to itself.") |
---|
790 | | - | } |
---|
791 | | - | |
---|
792 | | - | |
---|
793 | | - | |
---|
794 | | - | @Callable(i) |
---|
795 | | - | func isPoolOneTokenOperationsDisabledREADONLY (poolAddress) = { |
---|
796 | | - | let poolConfig = getPoolConfig(poolAddress) |
---|
797 | | - | let assetsInternal = $Tuple2(parseIntValue(poolConfig[idxIAmtAssetId]), parseIntValue(poolConfig[idxIPriceAssetId])) |
---|
798 | | - | let poolOneTokenOperationsDisabled = valueOrElse(getBoolean(keyPoolOneTokenOperationsDisabled(assetsInternal)), false) |
---|
799 | | - | let allPoolsOneTokenOperationsDisabled = valueOrElse(getBoolean(keyAllPoolsOneTokenOperationsDisabled()), false) |
---|
800 | | - | $Tuple2(nil, if (allPoolsOneTokenOperationsDisabled) |
---|
801 | | - | then true |
---|
802 | | - | else poolOneTokenOperationsDisabled) |
---|
803 | | - | } |
---|
804 | | - | |
---|
805 | | - | |
---|
806 | | - | |
---|
807 | | - | @Callable(i) |
---|
808 | | - | func getInFeeREADONLY (poolAddress) = { |
---|
809 | | - | let fee = intOrDefaultOrFallback(keyInFee(poolAddress), keyInFeeDefault(), 0) |
---|
810 | | - | $Tuple2(nil, fee) |
---|
811 | | - | } |
---|
812 | | - | |
---|
813 | | - | |
---|
814 | | - | |
---|
815 | | - | @Callable(i) |
---|
816 | | - | func getOutFeeREADONLY (poolAddress) = { |
---|
817 | | - | let fee = intOrDefaultOrFallback(keyOutFee(poolAddress), keyOutFeeDefault(), fraction(10, MULT8, 10000)) |
---|
818 | | - | $Tuple2(nil, fee) |
---|
819 | | - | } |
---|
820 | | - | |
---|
821 | | - | |
---|
822 | | - | |
---|
823 | | - | @Callable(i) |
---|
824 | | - | func poolInfoREADONLY (amountAssetIdStr,priceAssetIdStr) = { |
---|
825 | | - | let amountAssetInternalIdOption = getInteger(this, keyMappingsBaseAsset2internalId(amountAssetIdStr)) |
---|
826 | | - | let priceAssetInternalIdOption = getInteger(this, keyMappingsBaseAsset2internalId(priceAssetIdStr)) |
---|
827 | | - | let poolContractAddressOption = getString(this, keyMappingPoolAssetsToPoolContractAddress(value(amountAssetInternalIdOption), value(priceAssetInternalIdOption))) |
---|
828 | | - | let lpAssetIdOption = getString(this, keyMappingPoolContractToLPAsset(value(poolContractAddressOption))) |
---|
829 | | - | let poolExists = if (if (isDefined(amountAssetInternalIdOption)) |
---|
830 | | - | then isDefined(priceAssetInternalIdOption) |
---|
831 | | - | else false) |
---|
832 | | - | then isDefined(poolContractAddressOption) |
---|
833 | | - | else false |
---|
834 | | - | let poolInfo = if (poolExists) |
---|
835 | | - | then $Tuple2(addressFromStringValue(value(poolContractAddressOption)), parseAssetId(value(lpAssetIdOption))) |
---|
836 | | - | else unit |
---|
837 | | - | $Tuple2(nil, poolInfo) |
---|
838 | | - | } |
---|
839 | | - | |
---|
840 | | - | |
---|
841 | | - | |
---|
842 | | - | @Callable(i) |
---|
843 | | - | func getPoolStatusREADONLY (poolAddress) = { |
---|
844 | | - | let poolAssets = split(getStringOrFail(keyMappingPoolContractAddressToPoolAssets(poolAddress)), SEP) |
---|
845 | | - | let amountAssetInternal = poolAssets[1] |
---|
846 | | - | let priceAssetInternal = poolAssets[2] |
---|
847 | | - | let cfg = split(getStringOrFail(keyPoolConfig(amountAssetInternal, priceAssetInternal)), SEP) |
---|
848 | | - | $Tuple2(nil, parseIntValue(cfg[idxPoolStatus])) |
---|
849 | | - | } |
---|
850 | | - | |
---|
851 | | - | |
---|
852 | | - | |
---|
853 | | - | @Callable(i) |
---|
854 | | - | func getPoolConfigREADONLY (poolAddress) = { |
---|
855 | | - | let poolAssets = split(getStringOrFail(keyMappingPoolContractAddressToPoolAssets(poolAddress)), SEP) |
---|
856 | | - | let amountAssetInternal = poolAssets[1] |
---|
857 | | - | let priceAssetInternal = poolAssets[2] |
---|
858 | | - | let cfg = split(getStringOrFail(keyPoolConfig(amountAssetInternal, priceAssetInternal)), SEP) |
---|
859 | | - | $Tuple2(nil, cfg) |
---|
860 | | - | } |
---|
861 | | - | |
---|
862 | | - | |
---|
863 | | - | |
---|
864 | | - | @Callable(i) |
---|
865 | | - | func poolExistsREADONLY (amountAssetId,priceAssetId) = $Tuple2(nil, poolExistsInternal(amountAssetId, priceAssetId)) |
---|
866 | | - | |
---|
867 | | - | |
---|
868 | | - | @Verifier(tx) |
---|
869 | | - | func verify () = { |
---|
870 | | - | let targetPublicKey = match managerPublicKeyOrUnit() { |
---|
871 | | - | case pk: ByteVector => |
---|
872 | | - | pk |
---|
873 | | - | case _: Unit => |
---|
874 | | - | tx.senderPublicKey |
---|
875 | | - | case _ => |
---|
876 | | - | throw("Match error") |
---|
877 | | - | } |
---|
878 | | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) |
---|
879 | | - | } |
---|
880 | | - | |
---|
| 1 | + | # no script |
---|