Skip to content

Commit

Permalink
fix gwx burned math and unlock test
Browse files Browse the repository at this point in the history
  • Loading branch information
ridev6 committed Aug 31, 2023
1 parent 141c8d2 commit efc2e47
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 1 addition & 3 deletions ride/boosting.ride
Original file line number Diff line number Diff line change
Expand Up @@ -703,10 +703,8 @@ func unlock(txIdStr: String) = {
txIdOption
)

let gWxAmountStart = fraction(userAmount, lockDuration, maxLockDuration)

let gwxBurned = min([
fraction(t * blocksInPeriod, gWxAmountStart, maxLockDuration),
fraction(wxWithdrawable, lockDuration, maxLockDuration),
gwxAmount
])
let gwxRemaining = ensurePositive(gwxAmount - gwxBurned, "gwxRemaining")
Expand Down
4 changes: 2 additions & 2 deletions test/components/boosting/contract/boosting.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class Boosting {
}

calcGwxAmountBurned({
gwxAmountStart, gwxAmountPrev, passedPeriods,
wxWithdrawable, lockDuration, gwxAmountPrev,
}) {
const gwxBurned = Math.min(
Math.floor(
(passedPeriods * this.blocksInPeriod * gwxAmountStart) / this.maxLockDuration,
(wxWithdrawable * lockDuration) / this.maxLockDuration,
),
gwxAmountPrev,
);
Expand Down
8 changes: 3 additions & 5 deletions test/components/boosting/unlock.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ describe('boosting: unlock.mjs', /** @this {MochaSuiteModified} */() => {
lockDuration,
passedPeriods,
});
const gwxAmountStart = boosting.calcGwxAmountStart({
wxAmount: lockWxAmount,
duration: lockDuration,
});
const gwxAmountPrev = lockParamsPrev.gwxAmount;
const gwxBurned = boosting.calcGwxAmountBurned({
gwxAmountStart, gwxAmountPrev, passedPeriods,
wxWithdrawable,
lockDuration,
gwxAmountPrev,
});

expect(lockParams.wxClaimed).to.equal(wxWithdrawable, 'wxClaimed');
Expand Down

0 comments on commit efc2e47

Please sign in to comment.