Skip to content

Commit

Permalink
revert: test 04
Browse files Browse the repository at this point in the history
  • Loading branch information
notJoon committed Jan 15, 2025
1 parent 01f0cd0 commit a4cddf9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ func testStakeTokenPos02ToWarmUp70_Pos03ToWarmUp50_Pos04ToWarmUp30_Pos05(t *test
CollectReward(4, false) // toUser 0 (out of range)
CollectReward(5, false) // toUser 0 (out of range)

// FIXED: staker.gno CollectReward (L405~L419)
CollectReward(3, false)
// CollectReward(3, false) // toUser 331211442847 // FIXME: insufficient balance
// 테스트 실행하면 3번 포지션에 대해 유저한테 리워드 주는거까지는 통과
// 그러나 페널티를 커뮤니티 풀에 줄 때 스테이커의 GNS 잔액보다 더 높게 계산되어 있는 페널티를 전송할 때 잔액 부족 발생 중
})
}
16 changes: 1 addition & 15 deletions staker/staker.gno
Original file line number Diff line number Diff line change
Expand Up @@ -402,21 +402,7 @@ func CollectReward(tokenId uint64, unwrapResult bool) (string, string) {
toUser := handleUnstakingFee(consts.GNS_PATH, reward.Internal, true, tokenId, deposit.targetPoolPath)
println("toUser", toUser)
if toUser > 0 {
stakerBalance := gns.BalanceOf(pusers.AddressOrName(consts.STAKER_ADDR))
println("gns balance (staker) : ", stakerBalance)

// calculate total required GNS amount
totalRequired := toUser + reward.InternalPenalty

// if total required amount exceeeds staker's balance,
// adjust both user reward and penalty proportionally
if totalRequired > stakerBalance {
// adjustment ratio based on available balance
// and apply ratio to both user reward and penalty
ratio := float64(stakerBalance) / float64(totalRequired)
toUser = uint64(float64(toUser) * ratio)
reward.InternalPenalty = uint64(float64(reward.InternalPenalty) * ratio)
}
println("gns balance (staker) : ", gns.BalanceOf(pusers.AddressOrName(consts.STAKER_ADDR)))

println("sending reward", toUser, "to", deposit.owner, "// gns balance (staker) :", gns.BalanceOf(pusers.AddressOrName(consts.STAKER_ADDR)))
gns.Transfer(a2u(deposit.owner), toUser)
Expand Down

0 comments on commit a4cddf9

Please sign in to comment.