I need to know how to find the acmount of

asset id that one will receive when calls claimsreward. I get this is calculated here, can anyone confirm if the equivalent in XTN (was USDN) is saved in datafields and the transfered assetIDs are just calcualted on runtime before transfer and NOT saved in any data field?

func handler (accum,assetId) = {
let assetIdStr = getAssetString(assetId)
let aBalance = tryGetInteger((("global_" + getAssetString(assetId)) + "_balance"))
let tokenEarningsLastCheck = tryGetInteger((("global_lastCheck_" + assetIdStr) + "_earnings"))
let currentTokenInterest = calculateCurrentAssetInterest(assetId, assetIdStr, aBalance, tokenEarningsLastCheck)
let currentTokenEarnings = max([tokenEarningsLastCheck, (getTokenBalance(assetId) - aBalance)])
let rewardAmount = fraction(puzzleAmount, (currentTokenInterest - tryGetInteger((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"))), Scale8)
let transfer = if ((rewardAmount == 0))
then nil
else [ScriptTransfer(address, rewardAmount, assetId)]
$Tuple2(((accum._1 ++ transfer) ++ [IntegerEntry((("global_lastCheck_" + assetIdStr) + "_earnings"), (currentTokenEarnings - rewardAmount)), IntegerEntry((("global_lastCheck_" + assetIdStr) + "_interest"), currentTokenInterest), IntegerEntry((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"), currentTokenInterest)]), (accum._2 + calculateUsdnValue(assetId, rewardAmount, aBalance, unit)))
}

2 ответов

64 просмотра

there is a special func for it

what are you cooking sir

Похожие вопросы

Обсуждают сегодня

Карта сайта