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