Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StakedBalance init for lp.ride #348

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions ride/lp.ride
Original file line number Diff line number Diff line change
Expand Up @@ -1459,16 +1459,29 @@ func unstakeAndGetNoLess(unstakeAmount: Int, noLessThenAmountAsset: Int, noLessT
# 1. issue new LP token and save data in state
# 2. burn LP token
# 3. write initial price, that is used for first deposit
# 4. Init "%s%s__stakedBalance__" for aa() and pa() with 0
# arguments:
# attach:
# return:
@Callable(i)
func activate(amtAssetStr: String, priceAssetStr: String) = {
if (i.caller.toString() != factoryContract.toString()) then throw("permissions denied") else {
let amtAssetInitStakedBalance = match(this.getInteger(keyAdditionalBalance(amtAssetStr))) {
case n:Int => []
case _ => [IntegerEntry(keyAdditionalBalance(amtAssetStr), 0)]
}

let priceAssetInitStakedBalance = match(this.getInteger(keyAdditionalBalance(priceAssetStr))) {
case n:Int => []
case _ => [IntegerEntry(keyAdditionalBalance(priceAssetStr), 0)]
}

([
StringEntry(aa(),amtAssetStr),
StringEntry(pa(),priceAssetStr)
],
StringEntry(aa(),amtAssetStr),
StringEntry(pa(),priceAssetStr)
]
++ amtAssetInitStakedBalance
++ priceAssetInitStakedBalance,
"success")
}
}
Expand Down