-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(iro): scale the bonding curve (#1247)
- Loading branch information
Showing
25 changed files
with
896 additions
and
560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/dymensionxyz/dymension/v3/testutil/sample" | ||
"github.com/dymensionxyz/dymension/v3/x/iro/types" | ||
) | ||
|
||
func (s *KeeperTestSuite) TestClaim() { | ||
rollappId := s.CreateDefaultRollapp() | ||
k := s.App.IROKeeper | ||
curve := types.DefaultBondingCurve() | ||
incentives := types.DefaultIncentivePlanParams() | ||
rollappDenom := "dasdasdasdasdsa" | ||
|
||
startTime := time.Now() | ||
amt := sdk.NewInt(1_000_000).MulRaw(1e18) | ||
|
||
rollapp, _ := s.App.RollappKeeper.GetRollapp(s.Ctx, rollappId) | ||
planId, err := k.CreatePlan(s.Ctx, amt, startTime, startTime.Add(time.Hour), rollapp, curve, incentives) | ||
s.Require().NoError(err) | ||
planDenom := k.MustGetPlan(s.Ctx, planId).TotalAllocation.Denom | ||
balance := s.App.BankKeeper.GetBalance(s.Ctx, k.AK.GetModuleAddress(types.ModuleName), planDenom) | ||
s.Require().Equal(amt, balance.Amount) | ||
|
||
claimer := sample.Acc() | ||
// buy some tokens | ||
s.Ctx = s.Ctx.WithBlockTime(startTime.Add(time.Minute)) | ||
soldAmt := sdk.NewInt(1_000).MulRaw(1e18) | ||
s.BuySomeTokens(planId, claimer, soldAmt) | ||
|
||
// claim should fail as not settled | ||
err = k.Claim(s.Ctx, planId, claimer) | ||
s.Require().Error(err) | ||
|
||
// settle | ||
s.FundModuleAcc(types.ModuleName, sdk.NewCoins(sdk.NewCoin(rollappDenom, amt))) | ||
err = k.Settle(s.Ctx, rollappId, rollappDenom) | ||
s.Require().NoError(err) | ||
|
||
// claim should fail as no balance available (random address) | ||
err = k.Claim(s.Ctx, planId, sample.Acc()) | ||
s.Require().Error(err) | ||
|
||
// fund. claim should succeed | ||
err = k.Claim(s.Ctx, planId, claimer) | ||
s.Require().NoError(err) | ||
|
||
// assert claimed amt | ||
balance = s.App.BankKeeper.GetBalance(s.Ctx, k.AK.GetModuleAddress(types.ModuleName), planDenom) | ||
s.Require().True(balance.IsZero()) | ||
balance = s.App.BankKeeper.GetBalance(s.Ctx, claimer, rollappDenom) | ||
s.Require().Equal(soldAmt, balance.Amount) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.