1 | 1 | | {-# STDLIB_VERSION 6 #-} |
---|
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 SEP = "__" |
---|
13 | 13 | | |
---|
14 | 14 | | let POOLWEIGHTMULT = MULT8 |
---|
15 | 15 | | |
---|
16 | 16 | | let zeroBigInt = toBigInt(0) |
---|
17 | 17 | | |
---|
18 | 18 | | let idxPoolAddress = 1 |
---|
19 | 19 | | |
---|
20 | 20 | | let idxPoolStatus = 2 |
---|
21 | 21 | | |
---|
22 | 22 | | let idxPoolLPAssetId = 3 |
---|
23 | 23 | | |
---|
24 | 24 | | let idxAmtAssetId = 4 |
---|
25 | 25 | | |
---|
26 | 26 | | let idxPriceAssetId = 5 |
---|
27 | 27 | | |
---|
28 | 28 | | let idxAmtAssetDcm = 6 |
---|
29 | 29 | | |
---|
30 | 30 | | let idxPriceAssetDcm = 7 |
---|
31 | 31 | | |
---|
32 | 32 | | let idxIAmtAssetId = 8 |
---|
33 | 33 | | |
---|
34 | 34 | | let idxIPriceAssetId = 9 |
---|
35 | 35 | | |
---|
36 | 36 | | let idxLPAssetDcm = 10 |
---|
37 | 37 | | |
---|
38 | 38 | | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) |
---|
39 | 39 | | |
---|
40 | 40 | | |
---|
41 | 41 | | func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) |
---|
42 | 42 | | |
---|
43 | 43 | | |
---|
44 | 44 | | func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0) |
---|
45 | 45 | | |
---|
46 | 46 | | |
---|
47 | 47 | | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) |
---|
48 | 48 | | |
---|
49 | 49 | | |
---|
50 | 50 | | func asAnyList (val) = match val { |
---|
51 | 51 | | case valAnyLyst: List[Any] => |
---|
52 | 52 | | valAnyLyst |
---|
53 | 53 | | case _ => |
---|
54 | 54 | | throw("fail to cast into List[Any]") |
---|
55 | 55 | | } |
---|
56 | 56 | | |
---|
57 | 57 | | |
---|
58 | 58 | | func asInt (val) = match val { |
---|
59 | 59 | | case valInt: Int => |
---|
60 | 60 | | valInt |
---|
61 | 61 | | case _ => |
---|
62 | 62 | | throw("fail to cast into Int") |
---|
63 | 63 | | } |
---|
64 | 64 | | |
---|
65 | 65 | | |
---|
66 | 66 | | func asString (val) = match val { |
---|
67 | 67 | | case valStr: String => |
---|
68 | 68 | | valStr |
---|
69 | 69 | | case _ => |
---|
70 | 70 | | throw("fail to cast into String") |
---|
71 | 71 | | } |
---|
72 | 72 | | |
---|
73 | 73 | | |
---|
74 | 74 | | func keyFactoryAddress () = "%s%s__config__factoryAddress" |
---|
75 | 75 | | |
---|
76 | 76 | | |
---|
77 | 77 | | func keyManagerPublicKey () = "%s__managerPublicKey" |
---|
78 | 78 | | |
---|
79 | 79 | | |
---|
80 | 80 | | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" |
---|
81 | 81 | | |
---|
82 | 82 | | |
---|
83 | 83 | | let IdxFactoryCfgStakingDapp = 1 |
---|
84 | 84 | | |
---|
85 | 85 | | let IdxFactoryCfgBoostingDapp = 2 |
---|
86 | 86 | | |
---|
87 | 87 | | let IdxFactoryCfgIdoDapp = 3 |
---|
88 | 88 | | |
---|
89 | 89 | | let IdxFactoryCfgTeamDapp = 4 |
---|
90 | 90 | | |
---|
91 | 91 | | let IdxFactoryCfgEmissionDapp = 5 |
---|
92 | 92 | | |
---|
93 | 93 | | let IdxFactoryCfgRestDapp = 6 |
---|
94 | 94 | | |
---|
95 | 95 | | let IdxFactoryCfgSlippageDapp = 7 |
---|
96 | 96 | | |
---|
97 | 97 | | let IdxFactoryCfgGwxRewardDapp = 8 |
---|
98 | 98 | | |
---|
99 | 99 | | func keyFactoryCfg () = "%s__factoryConfig" |
---|
100 | 100 | | |
---|
101 | 101 | | |
---|
102 | 102 | | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) |
---|
103 | 103 | | |
---|
104 | 104 | | |
---|
105 | 105 | | func keyFactoryLpList () = "%s__lpTokensList" |
---|
106 | 106 | | |
---|
107 | 107 | | |
---|
108 | 108 | | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) |
---|
109 | 109 | | |
---|
110 | 110 | | |
---|
111 | 111 | | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) |
---|
112 | 112 | | |
---|
113 | 113 | | |
---|
114 | 114 | | func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(keyFactoryAddress())) |
---|
115 | 115 | | |
---|
116 | 116 | | |
---|
117 | 117 | | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) |
---|
118 | 118 | | |
---|
119 | 119 | | |
---|
120 | 120 | | func readFactoryCfgOrFail (factory) = split(getStringByAddressOrFail(factory, keyFactoryCfg()), SEP) |
---|
121 | 121 | | |
---|
122 | 122 | | |
---|
123 | 123 | | func getBoostingAddressOrFail (fCfg) = addressFromStringValue(fCfg[IdxFactoryCfgBoostingDapp]) |
---|
124 | 124 | | |
---|
125 | 125 | | |
---|
126 | 126 | | func getEmissionAddressOrFail (fCfg) = addressFromStringValue(fCfg[IdxFactoryCfgEmissionDapp]) |
---|
127 | 127 | | |
---|
128 | 128 | | |
---|
129 | 129 | | func getStakingAddressOrFail (fCfg) = addressFromStringValue(fCfg[IdxFactoryCfgStakingDapp]) |
---|
130 | 130 | | |
---|
131 | 131 | | |
---|
132 | 132 | | func getGwxRewardAddressOrFail (fCfg) = addressFromStringValue(fCfg[IdxFactoryCfgGwxRewardDapp]) |
---|
133 | 133 | | |
---|
134 | 134 | | |
---|
135 | 135 | | func keyBoostCfg () = "%s__config" |
---|
136 | 136 | | |
---|
137 | 137 | | |
---|
138 | 138 | | func keyBoostingLockParamTotalAmount () = "%s%s__stats__activeTotalLocked" |
---|
139 | 139 | | |
---|
140 | 140 | | |
---|
141 | 141 | | func keyBoostingStatsLocksDurationSumInBlocks () = "%s%s__stats__locksDurationSumInBlocks" |
---|
142 | 142 | | |
---|
143 | 143 | | |
---|
144 | 144 | | func keyBoostingStatsLocksCount () = "%s%s__stats__locksCount" |
---|
145 | 145 | | |
---|
146 | 146 | | |
---|
147 | 147 | | func keyBoostingStatsUsersCount () = "%s%s__stats__activeUsersCount" |
---|
148 | 148 | | |
---|
149 | 149 | | |
---|
150 | 150 | | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", userAddress], SEP) |
---|
151 | 151 | | |
---|
152 | 152 | | |
---|
153 | 153 | | func keyNum2UserMapping (num) = makeString(["%s%s%s__mapping__num2user", num], SEP) |
---|
154 | 154 | | |
---|
155 | 155 | | |
---|
156 | 156 | | func keyLockParamUserAmount (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "amount"], SEP) |
---|
157 | 157 | | |
---|
158 | 158 | | |
---|
159 | 159 | | func keyLockParamStartBlock (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "start"], SEP) |
---|
160 | 160 | | |
---|
161 | 161 | | |
---|
162 | 162 | | func keyLockParamDuration (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "duration"], SEP) |
---|
163 | 163 | | |
---|
164 | 164 | | |
---|
165 | 165 | | func keyLockParamK (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "k"], SEP) |
---|
166 | 166 | | |
---|
167 | 167 | | |
---|
168 | 168 | | func keyLockParamB (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "b"], SEP) |
---|
169 | 169 | | |
---|
170 | 170 | | |
---|
171 | 171 | | func keyLockParamByPeriodK (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "k", period], SEP) |
---|
172 | 172 | | |
---|
173 | 173 | | |
---|
174 | 174 | | func keyLockParamByPeriodB (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "b", period], SEP) |
---|
175 | 175 | | |
---|
176 | 176 | | |
---|
177 | 177 | | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastInt", userNum], SEP) |
---|
178 | 178 | | |
---|
179 | 179 | | |
---|
180 | 180 | | func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", userNum], SEP) |
---|
181 | 181 | | |
---|
182 | 182 | | |
---|
183 | 183 | | func keyTotalMaxBoostINTEGRAL () = "%s%s__maxBoostInt__total" |
---|
184 | 184 | | |
---|
185 | 185 | | |
---|
186 | 186 | | func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", userNum], SEP) |
---|
187 | 187 | | |
---|
188 | 188 | | |
---|
189 | 189 | | func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", userNum], SEP) |
---|
190 | 190 | | |
---|
191 | 191 | | |
---|
192 | 192 | | func keyTotalCachedGwx () = "%s%s__gwxCached__total" |
---|
193 | 193 | | |
---|
194 | 194 | | |
---|
195 | 195 | | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP) |
---|
196 | 196 | | |
---|
197 | 197 | | |
---|
198 | 198 | | func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr) |
---|
199 | 199 | | |
---|
200 | 200 | | |
---|
201 | 201 | | func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP) |
---|
202 | 202 | | |
---|
203 | 203 | | |
---|
204 | 204 | | func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP) |
---|
205 | 205 | | |
---|
206 | 206 | | |
---|
207 | 207 | | func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP) |
---|
208 | 208 | | |
---|
209 | 209 | | |
---|
210 | 210 | | func readStaked (stakingDapp,key) = valueOrElse(getInteger(stakingDapp, key), 0) |
---|
211 | 211 | | |
---|
212 | 212 | | |
---|
213 | 213 | | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" |
---|
214 | 214 | | |
---|
215 | 215 | | |
---|
216 | 216 | | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" |
---|
217 | 217 | | |
---|
218 | 218 | | |
---|
219 | 219 | | func keyEmissionStartBlock () = "%s%s__emission__startBlock" |
---|
220 | 220 | | |
---|
221 | 221 | | |
---|
222 | 222 | | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" |
---|
223 | 223 | | |
---|
224 | 224 | | |
---|
225 | 225 | | func keyEmissionEndBlock () = "%s%s__emission__endBlock" |
---|
226 | 226 | | |
---|
227 | 227 | | |
---|
228 | 228 | | func keyAddonAddr () = "%s__addonAddr" |
---|
229 | 229 | | |
---|
230 | 230 | | |
---|
231 | 231 | | func getPoolFee (poolAddress) = { |
---|
232 | 232 | | let feeDefault = fraction(5, MULT8, 10000) |
---|
233 | 233 | | let keyFee = "%s__fee" |
---|
234 | 234 | | valueOrElse(getInteger(poolAddress, keyFee), feeDefault) |
---|
235 | 235 | | } |
---|
236 | 236 | | |
---|
237 | 237 | | |
---|
238 | 238 | | let factoryDapp = readFactoryAddressOrFail() |
---|
239 | 239 | | |
---|
240 | 240 | | let factoryCfg = readFactoryCfgOrFail(factoryDapp) |
---|
241 | 241 | | |
---|
242 | 242 | | let emissionDapp = getEmissionAddressOrFail(factoryCfg) |
---|
243 | 243 | | |
---|
244 | 244 | | let stakingDapp = getStakingAddressOrFail(factoryCfg) |
---|
245 | 245 | | |
---|
246 | 246 | | let gwxRewardDapp = getGwxRewardAddressOrFail(factoryCfg) |
---|
247 | 247 | | |
---|
248 | 248 | | let boostingDapp = getBoostingAddressOrFail(factoryCfg) |
---|
249 | 249 | | |
---|
250 | 250 | | func internalCurrentRewardRate (lpAssetId) = { |
---|
251 | 251 | | let poolAddressStr = getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAssetId)) |
---|
252 | 252 | | let poolWeightMult = MULT8 |
---|
253 | 253 | | let poolWeight = getIntegerValue(factoryDapp, keyFactoryPoolWeight(poolAddressStr)) |
---|
254 | 254 | | let wxEmissionPerBlock = getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) |
---|
255 | 255 | | let wxEmissionPerBlockMax = getIntOrFail(emissionDapp, keyEmissionRatePerBlockMaxCurrent()) |
---|
256 | 256 | | let boostMaxCoeff = 3 |
---|
257 | 257 | | let poolWxEmissionPerBlock = (fraction(wxEmissionPerBlock, poolWeight, poolWeightMult) / boostMaxCoeff) |
---|
258 | 258 | | let poolWxEmissionPerBlockMax = fraction(wxEmissionPerBlockMax, poolWeight, poolWeightMult) |
---|
259 | 259 | | let maxFactor = (boostMaxCoeff * MULT8) |
---|
260 | 260 | | let totalLpStaked = getIntOrZero(stakingDapp, keyStakedTotal(lpAssetId)) |
---|
261 | 261 | | [poolWxEmissionPerBlock, maxFactor, totalLpStaked] |
---|
262 | 262 | | } |
---|
263 | 263 | | |
---|
264 | 264 | | |
---|
265 | 265 | | func calcGwxAmountStartREADONLY (lockAmount,lockDuration,maxLockDuration) = { |
---|
266 | 266 | | let coeffX8 = fraction(lockDuration, MULT8, maxLockDuration) |
---|
267 | 267 | | let gWxAmountStart = fraction(lockAmount, coeffX8, MULT8) |
---|
268 | 268 | | [gWxAmountStart] |
---|
269 | 269 | | } |
---|
270 | 270 | | |
---|
271 | 271 | | |
---|
272 | 272 | | func getKey (addr,key,type) = if ((type == "string")) |
---|
273 | 273 | | then getStringValue(addr, key) |
---|
274 | 274 | | else if ((type == "integer")) |
---|
275 | 275 | | then toString(getIntegerValue(addr, key)) |
---|
276 | 276 | | else if ((type == "boolean")) |
---|
277 | 277 | | then toString(getBooleanValue(addr, key)) |
---|
278 | 278 | | else throw("unknown type. expected string/integer/boolean") |
---|
279 | 279 | | |
---|
280 | 280 | | |
---|
281 | 281 | | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { |
---|
282 | 282 | | case s: String => |
---|
283 | 283 | | fromBase58String(s) |
---|
284 | 284 | | case _: Unit => |
---|
285 | 285 | | unit |
---|
286 | 286 | | case _ => |
---|
287 | 287 | | throw("Match error") |
---|
288 | 288 | | } |
---|
289 | 289 | | |
---|
290 | 290 | | |
---|
291 | 291 | | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { |
---|
292 | 292 | | case s: String => |
---|
293 | 293 | | fromBase58String(s) |
---|
294 | 294 | | case _: Unit => |
---|
295 | 295 | | unit |
---|
296 | 296 | | case _ => |
---|
297 | 297 | | throw("Match error") |
---|
298 | 298 | | } |
---|
299 | 299 | | |
---|
300 | 300 | | |
---|
301 | 301 | | func mustManager (i) = { |
---|
302 | 302 | | let pd = throw("Permission denied") |
---|
303 | 303 | | match managerPublicKeyOrUnit() { |
---|
304 | 304 | | case pk: ByteVector => |
---|
305 | 305 | | if ((i.callerPublicKey == pk)) |
---|
306 | 306 | | then true |
---|
307 | 307 | | else pd |
---|
308 | 308 | | case _: Unit => |
---|
309 | 309 | | if ((i.caller == this)) |
---|
310 | 310 | | then true |
---|
311 | 311 | | else pd |
---|
312 | 312 | | case _ => |
---|
313 | 313 | | throw("Match error") |
---|
314 | 314 | | } |
---|
315 | 315 | | } |
---|
316 | 316 | | |
---|
317 | 317 | | |
---|
318 | 318 | | @Callable(i) |
---|
319 | 319 | | func constructor (factoryAddress) = { |
---|
320 | 320 | | let checkCaller = mustManager(i) |
---|
321 | 321 | | if ((checkCaller == checkCaller)) |
---|
322 | 322 | | then [StringEntry(keyFactoryAddress(), factoryAddress)] |
---|
323 | 323 | | else throw("Strict value is not equal to itself.") |
---|
324 | 324 | | } |
---|
325 | 325 | | |
---|
326 | 326 | | |
---|
327 | 327 | | |
---|
328 | 328 | | @Callable(i) |
---|
329 | 329 | | func currentRewardRateREADONLY (lpAssetId) = { |
---|
330 | 330 | | let rewardData = internalCurrentRewardRate(lpAssetId) |
---|
331 | 331 | | let wxEmissionPerBlock = rewardData[0] |
---|
332 | 332 | | let maxFactor = rewardData[1] |
---|
333 | 333 | | let totalLpStaked = rewardData[2] |
---|
334 | 334 | | $Tuple2(nil, makeString(["%d%d%d", toString(wxEmissionPerBlock), toString(maxFactor), toString(totalLpStaked)], SEP)) |
---|
335 | 335 | | } |
---|
336 | 336 | | |
---|
337 | 337 | | |
---|
338 | 338 | | |
---|
339 | 339 | | @Callable(i) |
---|
340 | 340 | | func currentUserRewardRateREADONLY (lpAssetId,userAddress) = { |
---|
341 | 341 | | let rewardData = internalCurrentRewardRate(lpAssetId) |
---|
342 | 342 | | let wxEmissionPerBlock = rewardData[0] |
---|
343 | 343 | | let maxFactor = rewardData[1] |
---|
344 | 344 | | let totalLpStaked = rewardData[2] |
---|
345 | 345 | | let lpStakedByUser = getIntOrZero(stakingDapp, keyStakedByUser(userAddress, lpAssetId)) |
---|
346 | 346 | | let userClaimInfo = split(asString(invoke(stakingDapp, "claimWxREADONLY", [lpAssetId, userAddress], nil)), SEP) |
---|
347 | 347 | | let minRewardPart = valueOrErrorMessage(parseInt(userClaimInfo[5]), "couldn't parse minRewardPart") |
---|
348 | 348 | | let boostRewardPart = valueOrErrorMessage(parseInt(userClaimInfo[6]), "couldn't parse boostRewardPart") |
---|
349 | 349 | | let debug = userClaimInfo[7] |
---|
350 | 350 | | let boostingPower = if ((boostRewardPart == 0)) |
---|
351 | 351 | | then (1 * MULT8) |
---|
352 | 352 | | else fraction((minRewardPart + boostRewardPart), MULT8, minRewardPart) |
---|
353 | 353 | | $Tuple2(nil, makeString(["%d%d%d%d%d%s", toString(wxEmissionPerBlock), toString(maxFactor), toString(totalLpStaked), toString(lpStakedByUser), toString(boostingPower), debug], SEP)) |
---|
354 | 354 | | } |
---|
355 | 355 | | |
---|
356 | 356 | | |
---|
357 | 357 | | |
---|
358 | 358 | | @Callable(i) |
---|
359 | 359 | | func calcBoostBulkInternalREADONLY (currentIter,deltaWxAmountBulk,deltaLockPeriodInBlocksBulk,deltaLpAmountBulk,lpAssetIdOptBulk,userAddressOpt,resAcc) = if ((currentIter == size(deltaWxAmountBulk))) |
---|
360 | 360 | | then $Tuple2(nil, resAcc) |
---|
361 | 361 | | else { |
---|
362 | 362 | | let deltaWxAmount = deltaWxAmountBulk[currentIter] |
---|
363 | 363 | | let deltaLockPeriodInBlocks = deltaLockPeriodInBlocksBulk[currentIter] |
---|
364 | 364 | | let deltaLpAmount = deltaLpAmountBulk[currentIter] |
---|
365 | 365 | | let lpAssetIdOpt = lpAssetIdOptBulk[currentIter] |
---|
366 | 366 | | let info = { |
---|
367 | 367 | | let @ = invoke(this, "calcBoostREADONLY", [deltaWxAmount, deltaLockPeriodInBlocks, deltaLpAmount, lpAssetIdOpt, userAddressOpt], nil) |
---|
368 | 368 | | if ($isInstanceOf(@, "String")) |
---|
369 | 369 | | then @ |
---|
370 | 370 | | else throw(($getType(@) + " couldn't be cast to String")) |
---|
371 | 371 | | } |
---|
372 | 372 | | let res = (resAcc :+ info) |
---|
373 | 373 | | let inv = { |
---|
374 | 374 | | let @ = invoke(this, "calcBoostBulkInternalREADONLY", [(currentIter + 1), deltaWxAmountBulk, deltaLockPeriodInBlocksBulk, deltaLpAmountBulk, lpAssetIdOptBulk, userAddressOpt, res], nil) |
---|
375 | 375 | | if ($isInstanceOf(@, "List[Any]")) |
---|
376 | 376 | | then @ |
---|
377 | 377 | | else throw(($getType(@) + " couldn't be cast to List[Any]")) |
---|
378 | 378 | | } |
---|
379 | 379 | | if ((inv == inv)) |
---|
380 | 380 | | then $Tuple2(nil, inv) |
---|
381 | 381 | | else throw("Strict value is not equal to itself.") |
---|
382 | 382 | | } |
---|
383 | 383 | | |
---|
384 | 384 | | |
---|
385 | 385 | | |
---|
386 | 386 | | @Callable(i) |
---|
387 | 387 | | func calcBoostBulkREADONLY (deltaWxAmount,deltaLockPeriodInBlocks,deltaLpAmount,lpAssetIdOpt,userAddressOpt) = { |
---|
388 | 388 | | let res = invoke(this, "calcBoostBulkInternalREADONLY", [0, deltaWxAmount, deltaLockPeriodInBlocks, deltaLpAmount, lpAssetIdOpt, userAddressOpt, nil], nil) |
---|
389 | 389 | | $Tuple2(nil, res) |
---|
390 | 390 | | } |
---|
391 | 391 | | |
---|
392 | 392 | | |
---|
393 | 393 | | |
---|
394 | 394 | | @Callable(i) |
---|
395 | 395 | | func calcBoostREADONLY (deltaWxAmount,deltaLockPeriodInBlocks,deltaLpAmount,lpAssetIdOpt,userAddressOpt) = { |
---|
396 | 396 | | let mathDapp = gwxRewardDapp |
---|
397 | 397 | | let EMPTYSTR = "empty" |
---|
398 | 398 | | let maxLockDurationInBlocks = parseIntValue(split(getStringByAddressOrFail(boostingDapp, keyBoostCfg()), SEP)[4]) |
---|
399 | 399 | | let lpAssetIdStr = if ((lpAssetIdOpt == "")) |
---|
400 | 400 | | then EMPTYSTR |
---|
401 | 401 | | else lpAssetIdOpt |
---|
402 | 402 | | let userAddressStr = if ((userAddressOpt == "")) |
---|
403 | 403 | | then EMPTYSTR |
---|
404 | 404 | | else userAddressOpt |
---|
405 | 405 | | let userNumStr = valueOrElse(getString(boostingDapp, keyUser2NumMapping(userAddressOpt)), EMPTYSTR) |
---|
406 | 406 | | let userAmount = valueOrElse(getInteger(boostingDapp, keyLockParamUserAmount(userNumStr)), 0) |
---|
407 | 407 | | let lockStart = valueOrElse(getInteger(boostingDapp, keyLockParamStartBlock(userNumStr)), height) |
---|
408 | 408 | | let lockDuration = valueOrElse(getInteger(boostingDapp, keyLockParamDuration(userNumStr)), 0) |
---|
409 | 409 | | let lockEnd = (lockStart + lockDuration) |
---|
410 | 410 | | let remainingDuration = max([(lockEnd - height), 0]) |
---|
411 | 411 | | let userAmountNew = (userAmount + deltaWxAmount) |
---|
412 | 412 | | let lockDurationNew = min([(remainingDuration + deltaLockPeriodInBlocks), maxLockDurationInBlocks]) |
---|
413 | 413 | | let userCurrgWxAmount = asInt(asAnyList(invoke(boostingDapp, "gwxUserInfoREADONLY", [userAddressStr], nil))[0]) |
---|
414 | 414 | | let gWxAmountStartNew = calcGwxAmountStartREADONLY(userAmountNew, lockDurationNew, maxLockDurationInBlocks)[0] |
---|
415 | 415 | | let gWxParamsResultList = asAnyList(invoke(mathDapp, "calcGwxParamsREADONLY", [gWxAmountStartNew, height, lockDurationNew], nil)) |
---|
416 | 416 | | let gWxAmountDiff = (gWxAmountStartNew - userCurrgWxAmount) |
---|
417 | 417 | | let k = asInt(gWxParamsResultList[0]) |
---|
418 | 418 | | let b = asInt(gWxParamsResultList[1]) |
---|
419 | 419 | | let period = toString(asInt(gWxParamsResultList[2])) |
---|
420 | 420 | | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() |
---|
421 | 421 | | let totalCachedGwxKEY = keyTotalCachedGwx() |
---|
422 | 422 | | let userMaxBoostIntNew = ((gWxAmountStartNew * lockDurationNew) / 2) |
---|
423 | 423 | | let totalMaxBoostInt = getIntOrZero(boostingDapp, totalMaxBoostIntegralKEY) |
---|
424 | 424 | | let totalCachedGwx = valueOrElse(getInteger(boostingDapp, totalCachedGwxKEY), 0) |
---|
425 | 425 | | let MULT3 = 1000 |
---|
426 | 426 | | let wxEmissionPerBlockX3 = (getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) * MULT3) |
---|
427 | 427 | | let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr) |
---|
428 | 428 | | let stakedTotalKEY = keyStakedTotal(lpAssetIdStr) |
---|
429 | 429 | | let stakedByUser = readStaked(stakingDapp, stakedByUserKEY) |
---|
430 | 430 | | let stakedTotal = readStaked(stakingDapp, stakedTotalKEY) |
---|
431 | 431 | | let stakedByUserNew = (stakedByUser + deltaLpAmount) |
---|
432 | 432 | | let stakedTotalNew = (stakedTotal + deltaLpAmount) |
---|
433 | 433 | | let poolWeight = if ((lpAssetIdStr != EMPTYSTR)) |
---|
434 | 434 | | then { |
---|
435 | 435 | | let poolAddressStr = valueOrErrorMessage(getString(factoryDapp, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) |
---|
436 | 436 | | getIntegerValue(factoryDapp, keyFactoryPoolWeight(poolAddressStr)) |
---|
437 | 437 | | } |
---|
438 | 438 | | else 0 |
---|
439 | 439 | | let poolWxEmissionPerBlockX3 = fraction(wxEmissionPerBlockX3, poolWeight, (POOLWEIGHTMULT * 3)) |
---|
440 | 440 | | let wxPerLpX3 = if ((stakedTotalNew != 0)) |
---|
441 | 441 | | then fraction(poolWxEmissionPerBlockX3, MULT8, stakedTotalNew) |
---|
442 | 442 | | else 0 |
---|
443 | 443 | | let userWxPerBlockX3 = fraction(wxPerLpX3, stakedByUserNew, MULT8) |
---|
444 | 444 | | let boostEmissionPerBlockX3 = (poolWxEmissionPerBlockX3 * 2) |
---|
445 | 445 | | let tmpUserBoostPerBlockX3 = fraction(gWxAmountStartNew, boostEmissionPerBlockX3, (totalCachedGwx + gWxAmountDiff)) |
---|
446 | 446 | | let userBoostPerBlockX3 = min([tmpUserBoostPerBlockX3, (userWxPerBlockX3 * 2)]) |
---|
447 | 447 | | let boostCoeff = if ((userWxPerBlockX3 == 0)) |
---|
448 | 448 | | then (1 * MULT8) |
---|
449 | 449 | | else fraction((userBoostPerBlockX3 + userWxPerBlockX3), MULT8, userWxPerBlockX3) |
---|
450 | 450 | | $Tuple2(nil, makeString(["%d%d%s", toString(gWxAmountStartNew), toString(boostCoeff), "d"], SEP)) |
---|
451 | 451 | | } |
---|
452 | 452 | | |
---|
453 | 453 | | |
---|
454 | 454 | | |
---|
455 | 455 | | @Callable(i) |
---|
456 | 456 | | func wxEmissionStatsREADONLY () = { |
---|
457 | 457 | | let ONEMULT = toString(MULT8) |
---|
458 | 458 | | let ONE = "1" |
---|
459 | 459 | | let wxEmissionPerBlock = getIntOrFail(emissionDapp, keyEmissionRatePerBlockCurrent()) |
---|
460 | 460 | | let emissionStartBlock = getIntOrFail(emissionDapp, keyEmissionStartBlock()) |
---|
461 | 461 | | let passedBlocks = if ((emissionStartBlock > height)) |
---|
462 | 462 | | then 0 |
---|
463 | 463 | | else (height - emissionStartBlock) |
---|
464 | 464 | | let teamEmDuration = (1440 * 365) |
---|
465 | 465 | | let teamEmMax = (201000000 * MULT8) |
---|
466 | 466 | | let teamEm = if ((passedBlocks > teamEmDuration)) |
---|
467 | 467 | | then teamEmMax |
---|
468 | 468 | | else fraction(teamEmMax, passedBlocks, teamEmDuration) |
---|
469 | 469 | | let totalWxReleased = ((wxEmissionPerBlock * passedBlocks) + teamEm) |
---|
470 | 470 | | let totalWxLocked = getIntOrZero(boostingDapp, keyBoostingLockParamTotalAmount()) |
---|
471 | 471 | | let locksDurationSumInBlocks = getIntOrZero(boostingDapp, keyBoostingStatsLocksDurationSumInBlocks()) |
---|
472 | 472 | | let locksCount = getIntOrZero(boostingDapp, keyBoostingStatsLocksCount()) |
---|
473 | 473 | | $Tuple2(nil, makeString(["%d%d%d%d", toString(totalWxReleased), toString(totalWxLocked), toString(locksDurationSumInBlocks), toString(locksCount)], SEP)) |
---|
474 | 474 | | } |
---|
475 | 475 | | |
---|
476 | 476 | | |
---|
477 | 477 | | |
---|
478 | 478 | | @Callable(i) |
---|
479 | 479 | | func poolStatsREADONLY (lpAsset) = { |
---|
480 | 480 | | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) |
---|
481 | 481 | | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) |
---|
482 | 482 | | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) |
---|
483 | 483 | | let amtAssetId = asString(cfg[idxAmtAssetId]) |
---|
484 | 484 | | let priceAssetId = asString(cfg[idxPriceAssetId]) |
---|
485 | 485 | | let iAmtAssetId = asString(cfg[idxIAmtAssetId]) |
---|
486 | 486 | | let iPriceAssetId = asString(cfg[idxIPriceAssetId]) |
---|
487 | 487 | | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) |
---|
488 | 488 | | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) |
---|
489 | 489 | | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity |
---|
490 | 490 | | let accAmtAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amtAssetId], nil)) |
---|
491 | 491 | | let accPriceAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [priceAssetId], nil)) |
---|
492 | 492 | | let pricesList = if ((poolLPBalance == 0)) |
---|
493 | 493 | | then [toString(zeroBigInt), toString(zeroBigInt), toString(zeroBigInt)] |
---|
494 | 494 | | else asAnyList(invoke(poolAddress, "calcPricesWrapperREADONLY", [accAmtAssetBalance, accPriceAssetBalance, poolLPBalance], nil)) |
---|
495 | 495 | | let curPrice = 0 |
---|
496 | 496 | | let lpAmtAssetShare = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [pricesList[1], MULT8], nil)) |
---|
497 | 497 | | let lpPriceAssetShare = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [pricesList[2], MULT8], nil)) |
---|
498 | 498 | | let poolWeight = getIntegerValue(factoryDapp, keyFactoryPoolWeight(toString(poolAddress))) |
---|
499 | 499 | | let fee = getPoolFee(poolAddress) |
---|
500 | 500 | | let poolOneTokenOperationsDisabled = { |
---|
501 | 501 | | let @ = invoke(factoryDapp, "isPoolOneTokenOperationsDisabledREADONLY", [toString(poolAddress)], nil) |
---|
502 | 502 | | if ($isInstanceOf(@, "Boolean")) |
---|
503 | 503 | | then @ |
---|
504 | 504 | | else throw(($getType(@) + " couldn't be cast to Boolean")) |
---|
505 | 505 | | } |
---|
506 | 506 | | let poolOneTokenOperationsEnabled = !(poolOneTokenOperationsDisabled) |
---|
507 | 507 | | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d%s", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight), toString(fee), toString(poolOneTokenOperationsEnabled)], SEP)) |
---|
508 | 508 | | } |
---|
509 | 509 | | |
---|
510 | 510 | | |
---|
511 | 511 | | |
---|
512 | 512 | | @Callable(i) |
---|
513 | 513 | | func poolEvaluatePutByAmountAssetREADONLY (lpAsset,inAmAssetAmt) = { |
---|
514 | 514 | | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) |
---|
515 | 515 | | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) |
---|
516 | 516 | | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) |
---|
517 | 517 | | let amAssetIdStr = asString(cfg[idxAmtAssetId]) |
---|
518 | 518 | | let amAssetId = fromBase58String(amAssetIdStr) |
---|
519 | 519 | | let prAssetIdStr = asString(cfg[idxPriceAssetId]) |
---|
520 | 520 | | let prAssetId = fromBase58String(prAssetIdStr) |
---|
521 | 521 | | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) |
---|
522 | 522 | | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) |
---|
523 | 523 | | let poolStatus = asString(cfg[idxPoolStatus]) |
---|
524 | 524 | | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity |
---|
525 | 525 | | let accAmtAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amAssetIdStr], nil)) |
---|
526 | 526 | | let accPriceAssetBalance = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [prAssetIdStr], nil)) |
---|
527 | 527 | | let amtAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [accAmtAssetBalance, amtAssetDcm], nil))) |
---|
528 | 528 | | let priceAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [accPriceAssetBalance, priceAssetDcm], nil))) |
---|
529 | 529 | | let curPriceX18 = if ((poolLPBalance == 0)) |
---|
530 | 530 | | then zeroBigInt |
---|
531 | 531 | | else parseBigIntValue(asString(invoke(poolAddress, "calcPriceBigIntWrapperREADONLY", [toString(priceAssetAmtX18), toString(amtAssetAmtX18)], nil))) |
---|
532 | 532 | | let curPrice = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(curPriceX18), MULT8], nil)) |
---|
533 | 533 | | let inAmAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [inAmAssetAmt, amtAssetDcm], nil))) |
---|
534 | 534 | | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, MULT18) |
---|
535 | 535 | | let inPrAssetAmt = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(inPrAssetAmtX18), priceAssetDcm], nil)) |
---|
536 | 536 | | let res = invoke(poolAddress, "estimatePutOperationWrapperREADONLY", ["", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false], nil) |
---|
537 | 537 | | let $t02269923052 = match res { |
---|
538 | 538 | | case _ => |
---|
539 | 539 | | if (if (if ($isInstanceOf($match0._1, "Int")) |
---|
540 | 540 | | then if ($isInstanceOf($match0._3, "Int")) |
---|
541 | 541 | | then if ($isInstanceOf($match0._4, "Int")) |
---|
542 | 542 | | then if ($isInstanceOf($match0._5, "Int")) |
---|
543 | 543 | | then $isInstanceOf($match0._6, "Int") |
---|
544 | 544 | | else false |
---|
545 | 545 | | else false |
---|
546 | 546 | | else false |
---|
547 | 547 | | else false) |
---|
548 | 548 | | then (size($match0) == 13) |
---|
549 | 549 | | else false) |
---|
550 | 550 | | then { |
---|
551 | 551 | | let calcLpAmt = $match0._1 |
---|
552 | 552 | | let curPriceCalc = $match0._3 |
---|
553 | 553 | | let amBalance = $match0._4 |
---|
554 | 554 | | let prBalance = $match0._5 |
---|
555 | 555 | | let lpEmission = $match0._6 |
---|
556 | 556 | | $Tuple5(calcLpAmt, curPriceCalc, amBalance, prBalance, lpEmission) |
---|
557 | 557 | | } |
---|
558 | 558 | | else throw("Couldn't cast types") |
---|
559 | 559 | | } |
---|
560 | 560 | | let calcLpAmt = $t02269923052._1 |
---|
561 | 561 | | let curPriceCalc = $t02269923052._2 |
---|
562 | 562 | | let amBalance = $t02269923052._3 |
---|
563 | 563 | | let prBalance = $t02269923052._4 |
---|
564 | 564 | | let lpEmission = $t02269923052._5 |
---|
565 | 565 | | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(curPrice), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) |
---|
566 | 566 | | } |
---|
567 | 567 | | |
---|
568 | 568 | | |
---|
569 | 569 | | |
---|
570 | 570 | | @Callable(i) |
---|
571 | 571 | | func poolEvaluatePutByPriceAssetREADONLY (lpAsset,inPrAssetAmt) = { |
---|
572 | 572 | | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(lpAsset))) |
---|
573 | 573 | | let cfg = asAnyList(invoke(poolAddress, "getPoolConfigWrapperREADONLY", nil, nil)) |
---|
574 | 574 | | let lpAssetId = fromBase58String(asString(cfg[idxPoolLPAssetId])) |
---|
575 | 575 | | let amAssetIdStr = asString(cfg[idxAmtAssetId]) |
---|
576 | 576 | | let amAssetId = fromBase58String(amAssetIdStr) |
---|
577 | 577 | | let prAssetIdStr = asString(cfg[idxPriceAssetId]) |
---|
578 | 578 | | let prAssetId = fromBase58String(prAssetIdStr) |
---|
579 | 579 | | let amtAssetDcm = parseIntValue(asString(cfg[idxAmtAssetDcm])) |
---|
580 | 580 | | let priceAssetDcm = parseIntValue(asString(cfg[idxPriceAssetDcm])) |
---|
581 | 581 | | let poolStatus = asString(cfg[idxPoolStatus]) |
---|
582 | 582 | | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity |
---|
583 | 583 | | let amBalanceRaw = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [amAssetIdStr], nil)) |
---|
584 | 584 | | let prBalanceRaw = asInt(invoke(poolAddress, "getAccBalanceWrapperREADONLY", [prAssetIdStr], nil)) |
---|
585 | 585 | | let amBalanceRawX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [amBalanceRaw, amtAssetDcm], nil))) |
---|
586 | 586 | | let prBalanceRawX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [prBalanceRaw, priceAssetDcm], nil))) |
---|
587 | 587 | | let curPriceX18 = if ((poolLPBalance == 0)) |
---|
588 | 588 | | then zeroBigInt |
---|
589 | 589 | | else parseBigIntValue(asString(invoke(poolAddress, "calcPriceBigIntWrapperREADONLY", [toString(prBalanceRawX18), toString(amBalanceRawX18)], nil))) |
---|
590 | 590 | | let curPrice = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(curPriceX18), MULT8], nil)) |
---|
591 | 591 | | let inPrAssetAmtX18 = parseBigIntValue(asString(invoke(poolAddress, "toX18WrapperREADONLY", [inPrAssetAmt, priceAssetDcm], nil))) |
---|
592 | 592 | | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, MULT18, curPriceX18) |
---|
593 | 593 | | let inAmAssetAmt = asInt(invoke(poolAddress, "fromX18WrapperREADONLY", [toString(inAmAssetAmtX18), amtAssetDcm], nil)) |
---|
594 | 594 | | let res = invoke(poolAddress, "estimatePutOperationWrapperREADONLY", ["", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false], nil) |
---|
595 | 595 | | let $t02562525978 = match res { |
---|
596 | 596 | | case _ => |
---|
597 | 597 | | if (if (if ($isInstanceOf($match0._1, "Int")) |
---|
598 | 598 | | then if ($isInstanceOf($match0._3, "Int")) |
---|
599 | 599 | | then if ($isInstanceOf($match0._4, "Int")) |
---|
600 | 600 | | then if ($isInstanceOf($match0._5, "Int")) |
---|
601 | 601 | | then $isInstanceOf($match0._6, "Int") |
---|
602 | 602 | | else false |
---|
603 | 603 | | else false |
---|
604 | 604 | | else false |
---|
605 | 605 | | else false) |
---|
606 | 606 | | then (size($match0) == 13) |
---|
607 | 607 | | else false) |
---|
608 | 608 | | then { |
---|
609 | 609 | | let calcLpAmt = $match0._1 |
---|
610 | 610 | | let curPriceCalc = $match0._3 |
---|
611 | 611 | | let amBalance = $match0._4 |
---|
612 | 612 | | let prBalance = $match0._5 |
---|
613 | 613 | | let lpEmission = $match0._6 |
---|
614 | 614 | | $Tuple5(calcLpAmt, curPriceCalc, amBalance, prBalance, lpEmission) |
---|
615 | 615 | | } |
---|
616 | 616 | | else throw("Couldn't cast types") |
---|
617 | 617 | | } |
---|
618 | 618 | | let calcLpAmt = $t02562525978._1 |
---|
619 | 619 | | let curPriceCalc = $t02562525978._2 |
---|
620 | 620 | | let amBalance = $t02562525978._3 |
---|
621 | 621 | | let prBalance = $t02562525978._4 |
---|
622 | 622 | | let lpEmission = $t02562525978._5 |
---|
623 | 623 | | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(curPrice), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) |
---|
624 | 624 | | } |
---|
625 | 625 | | |
---|
626 | 626 | | |
---|
627 | 627 | | |
---|
628 | 628 | | @Callable(i) |
---|
629 | 629 | | func poolEvaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { |
---|
630 | 630 | | let poolAddress = addressFromStringValue(getStringByAddressOrFail(factoryDapp, keyFactoryLpAssetToPoolContractAddress(paymentLpAssetId))) |
---|
631 | 631 | | let res = invoke(poolAddress, "estimateGetOperationWrapperREADONLY", ["", paymentLpAssetId, paymentLpAmt, toString(poolAddress)], nil) |
---|
632 | 632 | | let $t02667327090 = match res { |
---|
633 | 633 | | case _ => |
---|
634 | 634 | | if (if (if ($isInstanceOf($match0._1, "Int")) |
---|
635 | 635 | | then if ($isInstanceOf($match0._2, "Int")) |
---|
636 | 636 | | then if ($isInstanceOf($match0._5, "Int")) |
---|
637 | 637 | | then if ($isInstanceOf($match0._6, "Int")) |
---|
638 | 638 | | then if ($isInstanceOf($match0._7, "Int")) |
---|
639 | 639 | | then if ($isInstanceOf($match0._8, "String")) |
---|
640 | 640 | | then $isInstanceOf($match0._9, "String") |
---|
641 | 641 | | else false |
---|
642 | 642 | | else false |
---|
643 | 643 | | else false |
---|
644 | 644 | | else false |
---|
645 | 645 | | else false |
---|
646 | 646 | | else false) |
---|
647 | 647 | | then (size($match0) == 10) |
---|
648 | 648 | | else false) |
---|
649 | 649 | | then { |
---|
650 | 650 | | let outAmAmt = $match0._1 |
---|
651 | 651 | | let outPrAmt = $match0._2 |
---|
652 | 652 | | let amBalance = $match0._5 |
---|
653 | 653 | | let prBalance = $match0._6 |
---|
654 | 654 | | let lpEmission = $match0._7 |
---|
655 | 655 | | let curPrice = $match0._8 |
---|
656 | 656 | | let poolStatus = $match0._9 |
---|
657 | 657 | | $Tuple7(outAmAmt, outPrAmt, amBalance, prBalance, lpEmission, curPrice, poolStatus) |
---|
658 | 658 | | } |
---|
659 | 659 | | else throw("Couldn't cast types") |
---|
660 | 660 | | } |
---|
661 | 661 | | let outAmAmt = $t02667327090._1 |
---|
662 | 662 | | let outPrAmt = $t02667327090._2 |
---|
663 | 663 | | let amBalance = $t02667327090._3 |
---|
664 | 664 | | let prBalance = $t02667327090._4 |
---|
665 | 665 | | let lpEmission = $t02667327090._5 |
---|
666 | 666 | | let curPrice = $t02667327090._6 |
---|
667 | 667 | | let poolStatus = $t02667327090._7 |
---|
668 | 668 | | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), curPrice, poolStatus], SEP)) |
---|
669 | 669 | | } |
---|
670 | 670 | | |
---|
671 | 671 | | |
---|
672 | 672 | | |
---|
673 | 673 | | @Callable(i) |
---|
674 | 674 | | func gwxUserInfoREADONLY (userAddress) = { |
---|
675 | 675 | | let gwxUserInfoLIST = asAnyList(invoke(boostingDapp, "gwxUserInfoREADONLY", [userAddress], nil)) |
---|
676 | 676 | | let gwxAmount = asInt(gwxUserInfoLIST[0]) |
---|
677 | 677 | | $Tuple2(nil, makeString(["%d", toString(gwxAmount)], SEP)) |
---|
678 | 678 | | } |
---|
679 | 679 | | |
---|
680 | 680 | | |
---|
681 | 681 | | |
---|
682 | 682 | | @Callable(i) |
---|
683 | 683 | | func getKeysBulkInternal (currentIter,keys,resAcc) = if ((currentIter == size(keys))) |
---|
684 | 684 | | then $Tuple2(nil, resAcc) |
---|
685 | 685 | | else { |
---|