tx · H4UieFtjxW84a33dSYCZzxCZRZe1j9Sw94ZiXSK9qPN9

3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz:  -0.01000000 Waves

2021.11.25 18:20 [1806741] smart account 3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz > SELF 0.00000000 Waves

{ "type": 13, "id": "H4UieFtjxW84a33dSYCZzxCZRZe1j9Sw94ZiXSK9qPN9", "fee": 1000000, "feeAssetId": null, "timestamp": 1637853731233, "version": 1, "sender": "3Mx3zmXrMcLFCafMuPtXAzR4ZPVeZYb6qLz", "senderPublicKey": "D28XoueZWsMfm8Y5pa6C5ZFuYoWgre2Wm8tzJANJgMnq", "proofs": [ "2Joahxg13o1NQSguBhMyK6fV8vdHx5vcRsJWzvcUuRMqzQrhyd69gzoKeSD28vQDPhWJ5eLFnCz4CCiHsneL1uoz" ], "script": "base64:AAIFAAAAAAAAABoIAhIDCgEIEgASBAoCCAESAwoBCBIECgIICAAAACcAAAAABlNDQUxFOAAAAAAAAAAACAAAAAAFTVVMVDgAAAAAAAX14QAAAAAAB1NDQUxFMTgAAAAAAAAAABIAAAAABk1VTFQxOAkAATYAAAABAA3gtrOnZAAAAAAAAANTRVACAAAAAl9fAQAAAA9nZXRTdHJpbmdPckZhaWwAAAABAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEIgAAAAEFAAAAA2tleQkAASwAAAACCQABLAAAAAICAAAAD21hbmRhdG9yeSB0aGlzLgUAAAADa2V5AgAAAA8gaXMgbm90IGRlZmluZWQBAAAAGGdldFN0cmluZ0J5QWRkcmVzc09yRmFpbAAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAKbWFuZGF0b3J5IAkABCUAAAABBQAAAAdhZG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sBQAAAANTRVAAAAAAWCZNQg==", "chainId": 84, "height": 1806741, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GYN5ZtiJqKHpg3ovB1k6Qm5iB7Jtd3y6PuGHnG1tS4Mz Next: 7DXFhDCR1ms35XKCKEzcEdJbMTyuy3mMFKUL2z8HXS2k Diff:
OldNewDifferences
1111
1212 let SEP = "__"
1313
14-let POOLWEIGHTMULT = MULT8
15-
16-func asAnyList (val) = match val {
17- case valAnyLyst: List[Any] =>
18- valAnyLyst
19- case _ =>
20- throw("fail to cast into List[Any]")
21-}
22-
23-
24-func asInt (val) = match val {
25- case valInt: Int =>
26- valInt
27- case _ =>
28- throw("fail to cast into Int")
29-}
30-
31-
32-func asByteVector (val) = match val {
33- case valBin: ByteVector =>
34- valBin
35- case _ =>
36- throw("fail to cast into Int")
37-}
38-
39-
4014 func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined"))
4115
4216
4620 func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0)
4721
4822
49-func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal)
50-
51-
5223 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined"))
53-
54-
55-func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), MULT18, toBigInt(origScaleMult))
56-
57-
58-func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), MULT18))
5924
6025
6126 func keyFactoryAddress () = "%s%s__config__factoryAddress"
12994 func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr)
13095
13196
132-func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP)
133-
134-
135-func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP)
136-
137-
138-func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP)
139-
140-
141-func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed", "total", lpAssetIdStr], SEP)
142-
143-
14497 func readStaked (key) = valueOrElse(getInteger(this, key), 0)
145-
146-
147-func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP)
148-
149-
150-func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP)
151-
152-
153-func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP)
154-
155-
156-func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP)
157-
158-
159-func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP)
160-
161-
162-func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP)
163-
164-
165-func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP)
166-
167-
168-func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP)
169-
170-
171-func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP)
172-
173-
174-func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP)
175-
176-
177-func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP)
178-
179-
180-func keyWxPerLpX18 (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLpX18"], SEP)
181-
182-
183-func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP)
18498
18599
186100 func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP)
192106 func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount))
193107
194108
195-let factoryContract = readFactoryAddressOrFail()
196-
197-let factoryCfg = readFactoryCfgOrFail(factoryContract)
198-
199-let emissionContract = getEmissionAddressOrFail(factoryCfg)
200-
201-let boostingContract = getBoostingAddressOrFail(factoryCfg)
202-
203-func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == 0))
204- then (stakedByUser > 0)
205- else false)
206- then 0
207- else if ((stakedByUser == 0))
208- then wxPerLpIntegralNew
209- else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > 0))
210- then (stakedByUser > 0)
211- else false)
212- then getIntOrFail(this, wxPerLpIntegralUserLastKEY)
213- else throw("calcWxPerLpIntegralUserLast: unexpected state")
214-
215-
216-func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = {
217- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
218- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
219- let stakedByUser = readStaked(stakedByUserKEY)
220- let stakedTotal = readStaked(stakedTotalKEY)
221- let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
222- let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock())
223- let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent())
224- let poolWxEmissionPerBlock = fraction(wxEmissionPerBlock, poolWeight, (POOLWEIGHTMULT * 3))
225- let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr)
226- let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr)
227- let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr)
228- let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr)
229- let wxPerLpKEY = keyWxPerLp(lpAssetIdStr)
230- let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr)
231- let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock)
232- let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY)
233- let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY)
234- let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY)
235- let wxPerLpOrZeroX8 = getIntOrZero(this, wxPerLpKEY)
236- let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0])
237- let wxPerLpX8 = if ((wxPerLpOrZeroX8 != 0))
238- then wxPerLpOrZeroX8
239- else fraction(poolWxEmissionPerBlock, MULT8, stakedTotal)
240- let stakedTotalNew = (stakedTotal + lpDeltaAmount)
241- let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLpX8 * dh))
242- let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(stakedByUser, wxPerLpIntegralUserLastUpdHeightOrZero, wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY)
243- let wxToClaimUserNew = (wxToClaimUser + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), stakedByUser, MULT8))
244- let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew
245- let wxPerLpNewX8 = (poolWxEmissionPerBlock / stakedTotalNew)
246- let wxPerLpIntegralLastUpdHeightNew = height
247- let wxPerLpIntegralUserLastUpdHeightNew = height
248- let debug = makeString([toString(wxToClaimUserNew), toString(wxPerLpIntegralNew), toString(wxPerLpIntegralUserLast), toString(stakedByUser), toString(dh), toString(wxPerLpX8), toString(stakedTotal), toString(poolWxEmissionPerBlock), toString(wxEmissionPerBlock), toString(poolWeight), toString(height)], "::")
249- $Tuple3(wxToClaimUserNew, [IntegerEntry(wxPerLpIntegralKEY, wxPerLpIntegralNew), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), IntegerEntry(wxToClaimUserKEY, wxToClaimUserNew), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), IntegerEntry(wxPerLpKEY, wxPerLpNewX8), IntegerEntry(wxPerLpIntegralUserLastKEY, wxPerLpIntegralUserLastNew)], debug)
250- }
251-
252-
253109 @Callable(i)
254110 func constructor (factoryAddressStr) = if ((i.caller != this))
255111 then throw("not authorized")
258114
259115
260116 @Callable(i)
261-func stake () = if ((size(i.payments) != 1))
262- then throw("invalid payment - exact one payment must be attached")
263- else {
264- let pmt = i.payments[0]
265- let lpAssetId = value(pmt.assetId)
266- let lpAssetIdStr = toBase58String(lpAssetId)
267- let amount = pmt.amount
268- let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
269- let callerStr = toString(i.caller)
270- let userAddressStr = if ((callerStr == poolAddressStr))
271- then toString(i.originCaller)
272- else callerStr
273- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
274- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
275- let stakedByUser = readStaked(stakedByUserKEY)
276- let stakedTotal = readStaked(stakedTotalKEY)
277- let $t01242712544 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount)
278- let wxToClaimUserNew = $t01242712544._1
279- let integralSTATE = $t01242712544._2
280- let debug = $t01242712544._3
281- ([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE)
282- }
283-
284-
285-
286-@Callable(i)
287-func unstake (lpAssetIdStr,amount) = {
288- let userAddressStr = toString(i.caller)
289- let lpAssetId = fromBase58String(lpAssetIdStr)
290- let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
291- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
292- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
293- let stakedByUser = readStaked(stakedByUserKEY)
294- let stakedTotal = readStaked(stakedTotalKEY)
295- let $t01336113479 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount))
296- let wxToClaimUserNew = $t01336113479._1
297- let integralSTATE = $t01336113479._2
298- let debug = $t01336113479._3
299- if ((amount > stakedByUser))
300- then throw("passed amount is less then available")
301- else ([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE)
302- }
303-
304-
305-
306-@Callable(i)
307-func claimWx (lpAssetIdStr) = {
308- let userAddress = i.caller
309- let userAddressStr = toString(i.caller)
310- let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr))
311- let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr)
312- let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr)
313- let claimedByUserMinRewardKEY = keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr)
314- let claimedByUserBoostRewardKEY = keyClaimedByUserBoostReward(lpAssetIdStr, userAddressStr)
315- let claimedByUser = getIntOrZero(this, claimedByUserKEY)
316- let claimedByUserMinReward = getIntOrZero(this, claimedByUserMinRewardKEY)
317- let claimedByUserBoostReward = getIntOrZero(this, claimedByUserBoostRewardKEY)
318- let claimedTotal = getIntOrZero(this, claimedTotalKEY)
319- let $t01467114783 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0)
320- let wxToClaimUserNew = $t01467114783._1
321- let integralSTATE = $t01467114783._2
322- let debug = $t01467114783._3
323- let availableToClaim = (wxToClaimUserNew - claimedByUser)
324- if ((0 >= availableToClaim))
325- then throw("nothing to claim")
117+func stake () = {
118+ let factory = readFactoryAddressOrFail()
119+ if ((size(i.payments) != 1))
120+ then throw("invalid payment - exact one payment must be attached")
326121 else {
327- let wxAmountBoostTotal = asInt(asAnyList(invoke(boostingContract, "claimWxBoost", [userAddressStr], nil))[0])
328- let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
329- let boostRewardPartTMP = fraction(wxAmountBoostTotal, poolWeight, POOLWEIGHTMULT)
330- let minRewardPart = availableToClaim
331- let boostRewardPart = min([(minRewardPart * 2), boostRewardPartTMP])
332- let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [minRewardPart], nil))[0])
333- let emitBoost = asAnyList(invoke(emissionContract, "emit", [boostRewardPart], nil))
334- if ((emitBoost == emitBoost))
335- then [IntegerEntry(claimedByUserKEY, (claimedByUser + availableToClaim)), IntegerEntry(claimedByUserMinRewardKEY, (claimedByUserMinReward + minRewardPart)), IntegerEntry(claimedByUserBoostRewardKEY, (claimedByUserBoostReward + boostRewardPart)), IntegerEntry(claimedTotalKEY, (claimedTotal + availableToClaim)), ScriptTransfer(userAddress, minRewardPart, wxAssetId), ScriptTransfer(userAddress, boostRewardPart, wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, availableToClaim, i.transactionId)]
336- else throw("Strict value is not equal to itself.")
122+ let pmt = i.payments[0]
123+ let lpAssetId = value(pmt.assetId)
124+ let lpAssetIdStr = toBase58String(lpAssetId)
125+ let amount = pmt.amount
126+ let lpDappStr = valueOrErrorMessage(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
127+ let callerStr = toString(i.caller)
128+ let userAddressStr = if ((callerStr == lpDappStr))
129+ then toString(i.originCaller)
130+ else callerStr
131+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
132+ let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
133+ let stakedByUser = readStaked(stakedByUserKEY)
134+ let stakedTotal = readStaked(stakedTotalKEY)
135+[IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
337136 }
338137 }
339138
340139
341140
342141 @Callable(i)
343-func claimWxREADONLY (lpAssetIdStr,userAddressStr) = {
344- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
142+func unstake (lpAssetIdStr,amount) = {
143+ let factory = readFactoryAddressOrFail()
144+ let userAddressStr = toString(i.caller)
145+ let lpAssetId = fromBase58String(lpAssetIdStr)
146+ if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)))))
147+ then throw(("unsupported lp asset " + lpAssetIdStr))
148+ else {
149+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
150+ let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
151+ let stakedByUser = readStaked(stakedByUserKEY)
152+ let stakedTotal = readStaked(stakedTotalKEY)
153+ if ((amount > stakedByUser))
154+ then throw("passed amount is less then available")
155+ else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
156+ }
157+ }
158+
159+
160+
161+@Callable(i)
162+func claimWx (lpAssetIdStr) = throw("temorary disabled")
163+
164+
165+
166+@Callable(i)
167+func claimWxREADONLY (lpAssetIdStr,userAddress) = {
168+ let factoryContract = readFactoryAddressOrFail()
169+ let factoryCfg = readFactoryCfgOrFail(factoryContract)
170+ let emissionContract = getEmissionAddressOrFail(factoryCfg)
171+ let stakedByUserKEY = keyStakedByUser(userAddress, lpAssetIdStr)
345172 let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
346- let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr)
347173 let stakedByUser = readStaked(stakedByUserKEY)
348174 let stakedTotal = readStaked(stakedTotalKEY)
349- let claimedByUser = getIntOrZero(this, claimedByUserKEY)
350175 let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr))
351176 let poolWeightMult = MULT8
352177 let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
357182 else (height - emissionStartBlock)
358183 let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, poolWeightMult)
359184 let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal)
360- let $t01720517317 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0)
361- let wxToClaimUserNew = $t01720517317._1
362- let integralSTATE = $t01720517317._2
363- let debug = $t01720517317._3
364- let availableToClaim = (wxToClaimUserNew - claimedByUser)
365- let wxAmountBoostTotal = asInt(asAnyList(invoke(boostingContract, "claimWxBoostREADONLY", [userAddressStr], nil))[0])
366- let boostRewardPartTMP = fraction(wxAmountBoostTotal, poolWeight, POOLWEIGHTMULT)
367- let minRewardPart = availableToClaim
368- let boostRewardPart = min([(minRewardPart * 2), boostRewardPartTMP])
369- let totalReward = (minRewardPart + boostRewardPart)
370- $Tuple2(nil, makeString(["%s%s%d%d%d%d%s", lpAssetIdStr, userAddressStr, toString(totalReward), toString(claimedByUser), toString(minRewardPart), toString(boostRewardPart), ((debug + "::") + toString(userWxReward))], SEP))
185+ $Tuple2(nil, makeString(["%s%s%d", lpAssetIdStr, userAddress, toString(userWxReward)], SEP))
371186 }
372187
373188
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SCALE8 = 8
55
66 let MULT8 = 100000000
77
88 let SCALE18 = 18
99
1010 let MULT18 = toBigInt(1000000000000000000)
1111
1212 let SEP = "__"
1313
14-let POOLWEIGHTMULT = MULT8
15-
16-func asAnyList (val) = match val {
17- case valAnyLyst: List[Any] =>
18- valAnyLyst
19- case _ =>
20- throw("fail to cast into List[Any]")
21-}
22-
23-
24-func asInt (val) = match val {
25- case valInt: Int =>
26- valInt
27- case _ =>
28- throw("fail to cast into Int")
29-}
30-
31-
32-func asByteVector (val) = match val {
33- case valBin: ByteVector =>
34- valBin
35- case _ =>
36- throw("fail to cast into Int")
37-}
38-
39-
4014 func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined"))
4115
4216
4317 func getStringByAddressOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
4418
4519
4620 func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0)
4721
4822
49-func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal)
50-
51-
5223 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined"))
53-
54-
55-func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), MULT18, toBigInt(origScaleMult))
56-
57-
58-func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), MULT18))
5924
6025
6126 func keyFactoryAddress () = "%s%s__config__factoryAddress"
6227
6328
6429 let IdxFactoryCfgStakingDapp = 1
6530
6631 let IdxFactoryCfgBoostingDapp = 2
6732
6833 let IdxFactoryCfgIdoDapp = 3
6934
7035 let IdxFactoryCfgTeamDapp = 4
7136
7237 let IdxFactoryCfgEmissionDapp = 5
7338
7439 let IdxFactoryCfgRestDapp = 6
7540
7641 let IdxFactoryCfgSlippageDapp = 7
7742
7843 func keyFactoryCfg () = "%s__factoryConfig"
7944
8045
8146 func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP)
8247
8348
8449 func keyFactoryLpList () = "%s__lpTokensList"
8550
8651
8752 func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP)
8853
8954
9055 func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP)
9156
9257
9358 func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(keyFactoryAddress()))
9459
9560
9661 func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP)
9762
9863
9964 func readFactoryCfgOrFail (factory) = split(getStringByAddressOrFail(factory, keyFactoryCfg()), SEP)
10065
10166
10267 func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp])
10368
10469
10570 func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp])
10671
10772
10873 func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp])
10974
11075
11176 func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current"
11277
11378
11479 func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current"
11580
11681
11782 func keyEmissionStartBlock () = "%s%s__emission__startBlock"
11883
11984
12085 func keyEmissionDurationInBlocks () = "%s%s__emission__duration"
12186
12287
12388 func keyEmissionEndBlock () = "%s%s__emission__endBlock"
12489
12590
12691 func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s__staked", userAddressStr, lpAssetIdStr], SEP)
12792
12893
12994 func keyStakedTotal (lpAssetIdStr) = ("%s%s%s__staked__total__" + lpAssetIdStr)
13095
13196
132-func keyClaimedByUser (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimed", userAddressStr, lpAssetIdStr], SEP)
133-
134-
135-func keyClaimedByUserMinReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedMinReward", userAddressStr, lpAssetIdStr], SEP)
136-
137-
138-func keyClaimedByUserBoostReward (lpAssetIdStr,userAddressStr) = makeString(["%s%s%s__claimedBoostReward", userAddressStr, lpAssetIdStr], SEP)
139-
140-
141-func keyClaimedTotal (lpAssetIdStr) = makeString(["%s%s%s__claimed", "total", lpAssetIdStr], SEP)
142-
143-
14497 func readStaked (key) = valueOrElse(getInteger(this, key), 0)
145-
146-
147-func keyLastTotalLpBalance (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "bal"], SEP)
148-
149-
150-func keyLastUserLpBalance (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "bal"], SEP)
151-
152-
153-func keyTotalLpBalanceIntegral (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "balINT"], SEP)
154-
155-
156-func keyUserLpBalanceIntegral (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "balINT"], SEP)
157-
158-
159-func keyTotalLpBalanceIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s", lpAssetId, "total", "lastUpd"], SEP)
160-
161-
162-func keyUserLpBalanceIntegralLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s", lpAssetId, userAddress, "lastUpd"], SEP)
163-
164-
165-func keyWxPerLpIntegral (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpInt"], SEP)
166-
167-
168-func keyWxPerLpIntegralLastUpdHeight (lpAssetId) = makeString(["%s%s%s%s", lpAssetId, "common", "lpIntH"], SEP)
169-
170-
171-func keyWxToClaimUser (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpInt"], SEP)
172-
173-
174-func keyWxPerLpIntegralUserLastUpdHeight (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "lpIntH"], SEP)
175-
176-
177-func keyWxPerLp (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLp"], SEP)
178-
179-
180-func keyWxPerLpX18 (lpAssetId) = makeString(["%s", lpAssetId, "wxPerLpX18"], SEP)
181-
182-
183-func keyWxPerLpIntegralUserLast (lpAssetId,userAddress) = makeString(["%s%s%s%s", lpAssetId, userAddress, "uIntL"], SEP)
18498
18599
186100 func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP)
187101
188102
189103 func formatHistoryRecord (userAddress,lpAssetId,type,amount) = makeString(["%s%s%s%d%d%d", userAddress, lpAssetId, type, toString(height), toString(lastBlock.timestamp), toString(amount)], SEP)
190104
191105
192106 func OperationHistoryEntry (type,userAddress,lpAssetId,amount,txId) = StringEntry(keyOperationHistoryRecord(type, userAddress, toBase58String(txId)), formatHistoryRecord(userAddress, lpAssetId, type, amount))
193107
194108
195-let factoryContract = readFactoryAddressOrFail()
196-
197-let factoryCfg = readFactoryCfgOrFail(factoryContract)
198-
199-let emissionContract = getEmissionAddressOrFail(factoryCfg)
200-
201-let boostingContract = getBoostingAddressOrFail(factoryCfg)
202-
203-func calcWxPerLpIntegralUserLast (stakedByUser,wxPerLpIntegralUserLastUpdHeightOrZero,wxPerLpIntegralNew,wxPerLpIntegralUserLastKEY) = if (if ((wxPerLpIntegralUserLastUpdHeightOrZero == 0))
204- then (stakedByUser > 0)
205- else false)
206- then 0
207- else if ((stakedByUser == 0))
208- then wxPerLpIntegralNew
209- else if (if ((wxPerLpIntegralUserLastUpdHeightOrZero > 0))
210- then (stakedByUser > 0)
211- else false)
212- then getIntOrFail(this, wxPerLpIntegralUserLastKEY)
213- else throw("calcWxPerLpIntegralUserLast: unexpected state")
214-
215-
216-func refreshINTEGRALS (lpAssetIdStr,userAddressStr,poolAddressStr,lpDeltaAmount) = {
217- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
218- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
219- let stakedByUser = readStaked(stakedByUserKEY)
220- let stakedTotal = readStaked(stakedTotalKEY)
221- let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
222- let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock())
223- let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent())
224- let poolWxEmissionPerBlock = fraction(wxEmissionPerBlock, poolWeight, (POOLWEIGHTMULT * 3))
225- let wxPerLpIntegralKEY = keyWxPerLpIntegral(lpAssetIdStr)
226- let wxPerLpIntegralLastUpdHeightKEY = keyWxPerLpIntegralLastUpdHeight(lpAssetIdStr)
227- let wxToClaimUserKEY = keyWxToClaimUser(lpAssetIdStr, userAddressStr)
228- let wxPerLpIntegralUserLastUpdHeightKEY = keyWxPerLpIntegralUserLastUpdHeight(lpAssetIdStr, userAddressStr)
229- let wxPerLpKEY = keyWxPerLp(lpAssetIdStr)
230- let wxPerLpIntegralUserLastKEY = keyWxPerLpIntegralUserLast(lpAssetIdStr, userAddressStr)
231- let wxPerLpIntegralLastUpdHeight = getIntOrDefault(this, wxPerLpIntegralLastUpdHeightKEY, emissionStartBlock)
232- let wxPerLpIntegral = getIntOrZero(this, wxPerLpIntegralKEY)
233- let wxToClaimUser = getIntOrZero(this, wxToClaimUserKEY)
234- let wxPerLpIntegralUserLastUpdHeightOrZero = getIntOrZero(this, wxPerLpIntegralUserLastUpdHeightKEY)
235- let wxPerLpOrZeroX8 = getIntOrZero(this, wxPerLpKEY)
236- let dh = max([(height - wxPerLpIntegralLastUpdHeight), 0])
237- let wxPerLpX8 = if ((wxPerLpOrZeroX8 != 0))
238- then wxPerLpOrZeroX8
239- else fraction(poolWxEmissionPerBlock, MULT8, stakedTotal)
240- let stakedTotalNew = (stakedTotal + lpDeltaAmount)
241- let wxPerLpIntegralNew = (wxPerLpIntegral + (wxPerLpX8 * dh))
242- let wxPerLpIntegralUserLast = calcWxPerLpIntegralUserLast(stakedByUser, wxPerLpIntegralUserLastUpdHeightOrZero, wxPerLpIntegralNew, wxPerLpIntegralUserLastKEY)
243- let wxToClaimUserNew = (wxToClaimUser + fraction((wxPerLpIntegralNew - wxPerLpIntegralUserLast), stakedByUser, MULT8))
244- let wxPerLpIntegralUserLastNew = wxPerLpIntegralNew
245- let wxPerLpNewX8 = (poolWxEmissionPerBlock / stakedTotalNew)
246- let wxPerLpIntegralLastUpdHeightNew = height
247- let wxPerLpIntegralUserLastUpdHeightNew = height
248- let debug = makeString([toString(wxToClaimUserNew), toString(wxPerLpIntegralNew), toString(wxPerLpIntegralUserLast), toString(stakedByUser), toString(dh), toString(wxPerLpX8), toString(stakedTotal), toString(poolWxEmissionPerBlock), toString(wxEmissionPerBlock), toString(poolWeight), toString(height)], "::")
249- $Tuple3(wxToClaimUserNew, [IntegerEntry(wxPerLpIntegralKEY, wxPerLpIntegralNew), IntegerEntry(wxPerLpIntegralLastUpdHeightKEY, wxPerLpIntegralLastUpdHeightNew), IntegerEntry(wxToClaimUserKEY, wxToClaimUserNew), IntegerEntry(wxPerLpIntegralUserLastUpdHeightKEY, wxPerLpIntegralUserLastUpdHeightNew), IntegerEntry(wxPerLpKEY, wxPerLpNewX8), IntegerEntry(wxPerLpIntegralUserLastKEY, wxPerLpIntegralUserLastNew)], debug)
250- }
251-
252-
253109 @Callable(i)
254110 func constructor (factoryAddressStr) = if ((i.caller != this))
255111 then throw("not authorized")
256112 else [StringEntry(keyFactoryAddress(), factoryAddressStr)]
257113
258114
259115
260116 @Callable(i)
261-func stake () = if ((size(i.payments) != 1))
262- then throw("invalid payment - exact one payment must be attached")
263- else {
264- let pmt = i.payments[0]
265- let lpAssetId = value(pmt.assetId)
266- let lpAssetIdStr = toBase58String(lpAssetId)
267- let amount = pmt.amount
268- let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
269- let callerStr = toString(i.caller)
270- let userAddressStr = if ((callerStr == poolAddressStr))
271- then toString(i.originCaller)
272- else callerStr
273- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
274- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
275- let stakedByUser = readStaked(stakedByUserKEY)
276- let stakedTotal = readStaked(stakedTotalKEY)
277- let $t01242712544 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, amount)
278- let wxToClaimUserNew = $t01242712544._1
279- let integralSTATE = $t01242712544._2
280- let debug = $t01242712544._3
281- ([IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE)
282- }
283-
284-
285-
286-@Callable(i)
287-func unstake (lpAssetIdStr,amount) = {
288- let userAddressStr = toString(i.caller)
289- let lpAssetId = fromBase58String(lpAssetIdStr)
290- let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
291- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
292- let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
293- let stakedByUser = readStaked(stakedByUserKEY)
294- let stakedTotal = readStaked(stakedTotalKEY)
295- let $t01336113479 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, -(amount))
296- let wxToClaimUserNew = $t01336113479._1
297- let integralSTATE = $t01336113479._2
298- let debug = $t01336113479._3
299- if ((amount > stakedByUser))
300- then throw("passed amount is less then available")
301- else ([IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)] ++ integralSTATE)
302- }
303-
304-
305-
306-@Callable(i)
307-func claimWx (lpAssetIdStr) = {
308- let userAddress = i.caller
309- let userAddressStr = toString(i.caller)
310- let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr))
311- let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr)
312- let claimedTotalKEY = keyClaimedTotal(lpAssetIdStr)
313- let claimedByUserMinRewardKEY = keyClaimedByUserMinReward(lpAssetIdStr, userAddressStr)
314- let claimedByUserBoostRewardKEY = keyClaimedByUserBoostReward(lpAssetIdStr, userAddressStr)
315- let claimedByUser = getIntOrZero(this, claimedByUserKEY)
316- let claimedByUserMinReward = getIntOrZero(this, claimedByUserMinRewardKEY)
317- let claimedByUserBoostReward = getIntOrZero(this, claimedByUserBoostRewardKEY)
318- let claimedTotal = getIntOrZero(this, claimedTotalKEY)
319- let $t01467114783 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0)
320- let wxToClaimUserNew = $t01467114783._1
321- let integralSTATE = $t01467114783._2
322- let debug = $t01467114783._3
323- let availableToClaim = (wxToClaimUserNew - claimedByUser)
324- if ((0 >= availableToClaim))
325- then throw("nothing to claim")
117+func stake () = {
118+ let factory = readFactoryAddressOrFail()
119+ if ((size(i.payments) != 1))
120+ then throw("invalid payment - exact one payment must be attached")
326121 else {
327- let wxAmountBoostTotal = asInt(asAnyList(invoke(boostingContract, "claimWxBoost", [userAddressStr], nil))[0])
328- let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
329- let boostRewardPartTMP = fraction(wxAmountBoostTotal, poolWeight, POOLWEIGHTMULT)
330- let minRewardPart = availableToClaim
331- let boostRewardPart = min([(minRewardPart * 2), boostRewardPartTMP])
332- let wxAssetId = asByteVector(asAnyList(invoke(emissionContract, "emit", [minRewardPart], nil))[0])
333- let emitBoost = asAnyList(invoke(emissionContract, "emit", [boostRewardPart], nil))
334- if ((emitBoost == emitBoost))
335- then [IntegerEntry(claimedByUserKEY, (claimedByUser + availableToClaim)), IntegerEntry(claimedByUserMinRewardKEY, (claimedByUserMinReward + minRewardPart)), IntegerEntry(claimedByUserBoostRewardKEY, (claimedByUserBoostReward + boostRewardPart)), IntegerEntry(claimedTotalKEY, (claimedTotal + availableToClaim)), ScriptTransfer(userAddress, minRewardPart, wxAssetId), ScriptTransfer(userAddress, boostRewardPart, wxAssetId), OperationHistoryEntry("claim", userAddressStr, lpAssetIdStr, availableToClaim, i.transactionId)]
336- else throw("Strict value is not equal to itself.")
122+ let pmt = i.payments[0]
123+ let lpAssetId = value(pmt.assetId)
124+ let lpAssetIdStr = toBase58String(lpAssetId)
125+ let amount = pmt.amount
126+ let lpDappStr = valueOrErrorMessage(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr))
127+ let callerStr = toString(i.caller)
128+ let userAddressStr = if ((callerStr == lpDappStr))
129+ then toString(i.originCaller)
130+ else callerStr
131+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
132+ let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
133+ let stakedByUser = readStaked(stakedByUserKEY)
134+ let stakedTotal = readStaked(stakedTotalKEY)
135+[IntegerEntry(stakedByUserKEY, (stakedByUser + amount)), IntegerEntry(stakedTotalKEY, (stakedTotal + amount)), OperationHistoryEntry("stake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
337136 }
338137 }
339138
340139
341140
342141 @Callable(i)
343-func claimWxREADONLY (lpAssetIdStr,userAddressStr) = {
344- let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
142+func unstake (lpAssetIdStr,amount) = {
143+ let factory = readFactoryAddressOrFail()
144+ let userAddressStr = toString(i.caller)
145+ let lpAssetId = fromBase58String(lpAssetIdStr)
146+ if (!(isDefined(getString(factory, keyFactoryLp2AssetsMapping(lpAssetIdStr)))))
147+ then throw(("unsupported lp asset " + lpAssetIdStr))
148+ else {
149+ let stakedByUserKEY = keyStakedByUser(userAddressStr, lpAssetIdStr)
150+ let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
151+ let stakedByUser = readStaked(stakedByUserKEY)
152+ let stakedTotal = readStaked(stakedTotalKEY)
153+ if ((amount > stakedByUser))
154+ then throw("passed amount is less then available")
155+ else [IntegerEntry(stakedByUserKEY, (stakedByUser - amount)), IntegerEntry(stakedTotalKEY, (stakedTotal - amount)), ScriptTransfer(i.caller, amount, lpAssetId), OperationHistoryEntry("unstake", userAddressStr, lpAssetIdStr, amount, i.transactionId)]
156+ }
157+ }
158+
159+
160+
161+@Callable(i)
162+func claimWx (lpAssetIdStr) = throw("temorary disabled")
163+
164+
165+
166+@Callable(i)
167+func claimWxREADONLY (lpAssetIdStr,userAddress) = {
168+ let factoryContract = readFactoryAddressOrFail()
169+ let factoryCfg = readFactoryCfgOrFail(factoryContract)
170+ let emissionContract = getEmissionAddressOrFail(factoryCfg)
171+ let stakedByUserKEY = keyStakedByUser(userAddress, lpAssetIdStr)
345172 let stakedTotalKEY = keyStakedTotal(lpAssetIdStr)
346- let claimedByUserKEY = keyClaimedByUser(lpAssetIdStr, userAddressStr)
347173 let stakedByUser = readStaked(stakedByUserKEY)
348174 let stakedTotal = readStaked(stakedTotalKEY)
349- let claimedByUser = getIntOrZero(this, claimedByUserKEY)
350175 let poolAddressStr = getStringByAddressOrFail(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr))
351176 let poolWeightMult = MULT8
352177 let poolWeight = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
353178 let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent())
354179 let emissionStartBlock = getIntOrFail(emissionContract, keyEmissionStartBlock())
355180 let passedBlocks = if ((emissionStartBlock > height))
356181 then 0
357182 else (height - emissionStartBlock)
358183 let poolWxEmission = fraction((wxEmissionPerBlock * passedBlocks), poolWeight, poolWeightMult)
359184 let userWxReward = fraction(poolWxEmission, stakedByUser, stakedTotal)
360- let $t01720517317 = refreshINTEGRALS(lpAssetIdStr, userAddressStr, poolAddressStr, 0)
361- let wxToClaimUserNew = $t01720517317._1
362- let integralSTATE = $t01720517317._2
363- let debug = $t01720517317._3
364- let availableToClaim = (wxToClaimUserNew - claimedByUser)
365- let wxAmountBoostTotal = asInt(asAnyList(invoke(boostingContract, "claimWxBoostREADONLY", [userAddressStr], nil))[0])
366- let boostRewardPartTMP = fraction(wxAmountBoostTotal, poolWeight, POOLWEIGHTMULT)
367- let minRewardPart = availableToClaim
368- let boostRewardPart = min([(minRewardPart * 2), boostRewardPartTMP])
369- let totalReward = (minRewardPart + boostRewardPart)
370- $Tuple2(nil, makeString(["%s%s%d%d%d%d%s", lpAssetIdStr, userAddressStr, toString(totalReward), toString(claimedByUser), toString(minRewardPart), toString(boostRewardPart), ((debug + "::") + toString(userWxReward))], SEP))
185+ $Tuple2(nil, makeString(["%s%s%d", lpAssetIdStr, userAddress, toString(userWxReward)], SEP))
371186 }
372187
373188

github/deemru/w8io/169f3d6 
40.82 ms