From fa945b65e7fa86be7d97f0c31de33cabbe1e5d15 Mon Sep 17 00:00:00 2001 From: King Date: Wed, 30 Aug 2023 20:18:40 +0900 Subject: [PATCH] refactor: rename lashare to sb(snowball) --- x/liquidamm/keeper/auction_test.go | 38 +++++++++++----------- x/liquidamm/keeper/grpc_query.go | 2 +- x/liquidamm/keeper/grpc_query_test.go | 4 +-- x/liquidamm/keeper/public_position_test.go | 26 +++++++-------- x/liquidamm/types/auction_test.go | 12 +++---- x/liquidamm/types/msgs_test.go | 20 ++++++------ x/liquidamm/types/public_position.go | 4 +-- x/liquidamm/types/public_position_test.go | 16 ++++----- 8 files changed, 61 insertions(+), 61 deletions(-) diff --git a/x/liquidamm/keeper/auction_test.go b/x/liquidamm/keeper/auction_test.go index f99c851e..cde693b2 100644 --- a/x/liquidamm/keeper/auction_test.go +++ b/x/liquidamm/keeper/auction_test.go @@ -22,18 +22,18 @@ func (s *KeeperTestSuite) TestPlaceBid() { bidderAddr1 := utils.TestAddress(2) s.MintShare(bidderAddr1, publicPosition.Id, utils.ParseCoins("100_000000ucre,500_000000uusd"), true) - s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000lashare1")) + s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000sb1")) s.NextBlock() s.AdvanceRewardsAuctions() auction, _ = s.keeper.GetLastRewardsAuction(s.Ctx, publicPosition.Id) - s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000lashare1")) + s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000sb1")) bidderAddr2 := utils.TestAddress(3) s.MintShare(bidderAddr2, publicPosition.Id, utils.ParseCoins("100_000000ucre,500_000000uusd"), true) - s.PlaceBid(bidderAddr2, publicPosition.Id, auction.Id, utils.ParseCoin("200000lashare1")) + s.PlaceBid(bidderAddr2, publicPosition.Id, auction.Id, utils.ParseCoin("200000sb1")) s.NextBlock() s.Require().Len(s.keeper.GetAllBids(s.Ctx), 2) @@ -49,25 +49,25 @@ func (s *KeeperTestSuite) TestPlaceBid() { { "happy case", types.NewMsgPlaceBid( - bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("300000lashare1")), + bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("300000sb1")), "", }, { "minimum bid amount", types.NewMsgPlaceBid( - bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("100lashare1")), + bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("100sb1")), "share amount must not be smaller than 10000: invalid request", }, { "smaller than winning bid", types.NewMsgPlaceBid( - bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("150000lashare1")), + bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("150000sb1")), "share amount must be greater than winning bid's share 200000: insufficient bid amount", }, { "finished auction", types.NewMsgPlaceBid( - bidderAddr3, publicPosition.Id, auction.Id-1, utils.ParseCoin("300000lashare1")), + bidderAddr3, publicPosition.Id, auction.Id-1, utils.ParseCoin("300000sb1")), "rewards auction is not started: invalid request", }, } { @@ -146,14 +146,14 @@ func (s *KeeperTestSuite) TestPlaceBid_Refund() { auction, found := s.keeper.GetLastRewardsAuction(s.Ctx, publicPosition.Id) s.Require().True(found) - s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000lashare1")) + s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000sb1")) s.NextBlock() balancesBefore := s.GetAllBalances(bidderAddr1) - s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("200000lashare1")) + s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("200000sb1")) s.NextBlock() balancesAfter := s.GetAllBalances(bidderAddr1) - s.Require().Equal("100000lashare1", balancesBefore.Sub(balancesAfter).String()) + s.Require().Equal("100000sb1", balancesBefore.Sub(balancesAfter).String()) } func (s *KeeperTestSuite) TestAfterRewardsAllocated() { @@ -177,18 +177,18 @@ func (s *KeeperTestSuite) TestAfterRewardsAllocated() { s.MintShare(bidderAddr2, publicPosition.Id, utils.ParseCoins("100_000000ucre,500_000000uusd"), true) s.MintShare(bidderAddr3, publicPosition.Id, utils.ParseCoins("100_000000ucre,500_000000uusd"), true) // Previous share balance - s.Require().Equal("4357388321lashare1", s.GetBalance(bidderAddr1, "lashare1").String()) - s.Require().Equal("4357388321lashare1", s.GetBalance(bidderAddr2, "lashare1").String()) - s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000lashare1")) - s.PlaceBid(bidderAddr2, publicPosition.Id, auction.Id, utils.ParseCoin("200000lashare1")) - s.PlaceBid(bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("300000lashare1")) + s.Require().Equal("4357388321sb1", s.GetBalance(bidderAddr1, "sb1").String()) + s.Require().Equal("4357388321sb1", s.GetBalance(bidderAddr2, "sb1").String()) + s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000sb1")) + s.PlaceBid(bidderAddr2, publicPosition.Id, auction.Id, utils.ParseCoin("200000sb1")) + s.PlaceBid(bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("300000sb1")) s.NextBlock() s.AdvanceRewardsAuctions() // Ensure that two bidders got their shares back to their balances - s.Require().Equal("4357388321lashare1", s.GetBalance(bidderAddr1, "lashare1").String()) - s.Require().Equal("4357388321lashare1", s.GetBalance(bidderAddr2, "lashare1").String()) + s.Require().Equal("4357388321sb1", s.GetBalance(bidderAddr1, "sb1").String()) + s.Require().Equal("4357388321sb1", s.GetBalance(bidderAddr2, "sb1").String()) s.Require().True(s.GetBalance(bidderAddr3, "uatom").Amount.GT(sdk.NewInt(1))) // One more epoch should be advanced @@ -196,7 +196,7 @@ func (s *KeeperTestSuite) TestAfterRewardsAllocated() { s.AdvanceRewardsAuctions() // Ensure liquidity per share increased due to the auction result - removedLiquidity, _, _ := s.BurnShare(minterAddr, publicPosition.Id, s.GetBalance(minterAddr, "lashare1")) + removedLiquidity, _, _ := s.BurnShare(minterAddr, publicPosition.Id, s.GetBalance(minterAddr, "sb1")) s.Require().True(removedLiquidity.GT(liquidity)) } @@ -233,7 +233,7 @@ func (s *KeeperTestSuite) TestRewardsAuction_RewardsAndFees() { bidderAddr1 := utils.TestAddress(2) s.MintShare(bidderAddr1, publicPosition.Id, utils.ParseCoins("100_000000ucre,500_000000uusd"), true) auction, _ := s.keeper.GetLastRewardsAuction(s.Ctx, publicPosition.Id) - s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000lashare1")) + s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000sb1")) s.NextBlock() position := s.keeper.MustGetAMMPosition(s.Ctx, publicPosition) diff --git a/x/liquidamm/keeper/grpc_query.go b/x/liquidamm/keeper/grpc_query.go index 90e7fc96..4766d450 100644 --- a/x/liquidamm/keeper/grpc_query.go +++ b/x/liquidamm/keeper/grpc_query.go @@ -266,7 +266,7 @@ func (k Querier) Rewards(c context.Context, req *types.QueryRewardsRequest) (*ty return &types.QueryRewardsResponse{Rewards: rewards}, nil } -// ExchangeRate queries exchange rate, such as mint rate and burn rate per 1 lashare. +// ExchangeRate queries exchange rate, such as mint rate and burn rate per 1 sb. func (k Querier) ExchangeRate(c context.Context, req *types.QueryExchangeRateRequest) (*types.QueryExchangeRateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") diff --git a/x/liquidamm/keeper/grpc_query_test.go b/x/liquidamm/keeper/grpc_query_test.go index c3287057..52ef4897 100644 --- a/x/liquidamm/keeper/grpc_query_test.go +++ b/x/liquidamm/keeper/grpc_query_test.go @@ -192,11 +192,11 @@ func (s *KeeperTestSuite) TestQueryRewardsAuctions() { auction := resp.RewardsAuctions[0] s.Require().EqualValues(1, auction.Id) s.Require().Equal(types.AuctionStatusFinished, auction.Status) - s.Require().Equal(utils.ParseCoin("1307216496lashare1"), auction.WinningBid.Share) + s.Require().Equal(utils.ParseCoin("1307216496sb1"), auction.WinningBid.Share) auction = resp.RewardsAuctions[1] s.Require().EqualValues(2, auction.Id) s.Require().Equal(types.AuctionStatusStarted, auction.Status) - s.Require().Equal(utils.ParseCoin("814642164lashare1"), auction.WinningBid.Share) + s.Require().Equal(utils.ParseCoin("814642164sb1"), auction.WinningBid.Share) }, }, { diff --git a/x/liquidamm/keeper/public_position_test.go b/x/liquidamm/keeper/public_position_test.go index 3d4bdbb4..20c0bcf6 100644 --- a/x/liquidamm/keeper/public_position_test.go +++ b/x/liquidamm/keeper/public_position_test.go @@ -38,7 +38,7 @@ func (s *KeeperTestSuite) TestMintShare() { utils.ParseCoins("100_000000ucre,500_000000uusd"), ), func(resp *types.MsgMintShareResponse) { - s.Require().Equal(utils.ParseCoin("4357388321lashare1"), resp.MintedShare) + s.Require().Equal(utils.ParseCoin("4357388321sb1"), resp.MintedShare) s.Require().Equal(sdk.NewInt(4357388321), resp.Liquidity) s.Require().Equal(utils.ParseCoins("90686676ucre,500000000uusd"), resp.Amount) }, @@ -104,7 +104,7 @@ func (s *KeeperTestSuite) TestBurnShare() { }{ { "happy case", - types.NewMsgBurnShare(minterAddr, publicPosition.Id, utils.ParseCoin("100000lashare1")), + types.NewMsgBurnShare(minterAddr, publicPosition.Id, utils.ParseCoin("100000sb1")), func(resp *types.MsgBurnShareResponse) { s.Require().Equal(sdk.NewInt(100000), resp.RemovedLiquidity) s.Require().Equal(utils.ParseCoins("2081ucre,11474uusd"), resp.Amount) @@ -116,7 +116,7 @@ func (s *KeeperTestSuite) TestBurnShare() { types.NewMsgBurnShare( minterAddr, 2, - utils.ParseCoin("100000lashare2"), + utils.ParseCoin("100000sb2"), ), nil, "public position not found: not found", @@ -149,8 +149,8 @@ func (s *KeeperTestSuite) TestBurnShare_Complex_WithRewards() { s.NextBlock() // Ensure that the minters have received the minted share - s.Require().Equal("4357388321lashare1", s.GetBalance(minterAddr1, "lashare1").String()) - s.Require().Equal("8714776642lashare1", s.GetBalance(minterAddr2, "lashare1").String()) + s.Require().Equal("4357388321sb1", s.GetBalance(minterAddr1, "sb1").String()) + s.Require().Equal("8714776642sb1", s.GetBalance(minterAddr2, "sb1").String()) s.AdvanceRewardsAuctions() @@ -162,8 +162,8 @@ func (s *KeeperTestSuite) TestBurnShare_Complex_WithRewards() { bidderAddr2 := utils.TestAddress(4) s.MintShare(bidderAddr1, publicPosition.Id, utils.ParseCoins("100_000000ucre,500_000000uusd"), true) s.MintShare(bidderAddr2, publicPosition.Id, utils.ParseCoins("200_000000ucre,1000_000000uusd"), true) - s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000lashare1")) - s.PlaceBid(bidderAddr2, publicPosition.Id, auction.Id, utils.ParseCoin("200000lashare1")) + s.PlaceBid(bidderAddr1, publicPosition.Id, auction.Id, utils.ParseCoin("100000sb1")) + s.PlaceBid(bidderAddr2, publicPosition.Id, auction.Id, utils.ParseCoin("200000sb1")) s.NextBlock() s.AdvanceRewardsAuctions() @@ -172,7 +172,7 @@ func (s *KeeperTestSuite) TestBurnShare_Complex_WithRewards() { publicPosition, _ = s.keeper.GetPublicPosition(s.Ctx, publicPosition.Id) auction, found = s.keeper.GetPreviousRewardsAuction(s.Ctx, publicPosition) s.Require().True(found) - s.Require().Equal("200000lashare1", auction.WinningBid.Share.String()) + s.Require().Equal("200000sb1", auction.WinningBid.Share.String()) // Ensure bidderAddr2 has received rewards s.Require().True(s.GetBalance(bidderAddr2, "uatom").Amount.GT(sdk.NewInt(1))) @@ -185,8 +185,8 @@ func (s *KeeperTestSuite) TestBurnShare_Complex_WithRewards() { auction, _ = s.keeper.GetLastRewardsAuction(s.Ctx, publicPosition.Id) s.MintShare(bidderAddr3, publicPosition.Id, utils.ParseCoins("100_000000ucre,500_000000uusd"), true) s.MintShare(bidderAddr4, publicPosition.Id, utils.ParseCoins("300_000000ucre,1500_000000uusd"), true) - s.PlaceBid(bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("100000lashare1")) - s.PlaceBid(bidderAddr4, publicPosition.Id, auction.Id, utils.ParseCoin("300000lashare1")) + s.PlaceBid(bidderAddr3, publicPosition.Id, auction.Id, utils.ParseCoin("100000sb1")) + s.PlaceBid(bidderAddr4, publicPosition.Id, auction.Id, utils.ParseCoin("300000sb1")) s.AdvanceRewardsAuctions() @@ -194,12 +194,12 @@ func (s *KeeperTestSuite) TestBurnShare_Complex_WithRewards() { publicPosition, _ = s.keeper.GetPublicPosition(s.Ctx, publicPosition.Id) auction, found = s.keeper.GetPreviousRewardsAuction(s.Ctx, publicPosition) s.Require().True(found) - s.Require().Equal("300000lashare1", auction.WinningBid.Share.String()) + s.Require().Equal("300000sb1", auction.WinningBid.Share.String()) // Ensure bidderAddr4 has received farming rewards s.Require().True(s.GetBalance(bidderAddr4, "uatom").Amount.GT(sdk.NewInt(1))) // Burn all shares - s.BurnShare(minterAddr1, publicPosition.Id, s.GetBalance(minterAddr1, "lashare1")) - s.BurnShare(minterAddr2, publicPosition.Id, s.GetBalance(minterAddr2, "lashare1")) + s.BurnShare(minterAddr1, publicPosition.Id, s.GetBalance(minterAddr1, "sb1")) + s.BurnShare(minterAddr2, publicPosition.Id, s.GetBalance(minterAddr2, "sb1")) } diff --git a/x/liquidamm/types/auction_test.go b/x/liquidamm/types/auction_test.go index f4d0909d..a4b0c59d 100644 --- a/x/liquidamm/types/auction_test.go +++ b/x/liquidamm/types/auction_test.go @@ -82,7 +82,7 @@ func TestRewardsAuction_Validate(t *testing.T) { auction := types.NewRewardsAuction( 1, 2, utils.ParseTime("2023-05-01T00:00:00Z"), utils.ParseTime("2023-05-01T01:00:00Z"), types.AuctionStatusStarted) - winningBid := types.NewBid(1, 2, utils.TestAddress(1), utils.ParseCoin("10000lashare1")) + winningBid := types.NewBid(1, 2, utils.TestAddress(1), utils.ParseCoin("10000sb1")) auction.SetWinningBid(&winningBid) auction.SetRewards(utils.ParseCoins("100000uatom")) auction.SetFees(utils.ParseCoins("300uatom")) @@ -132,20 +132,20 @@ func TestBidValidate(t *testing.T) { { "invalid share", func(bid *types.Bid) { - bid.Share = utils.ParseCoin("0lashare1") + bid.Share = utils.ParseCoin("0sb1") }, - "share amount must be positive: 0lashare1", + "share amount must be positive: 0sb1", }, { "invalid share denom", func(bid *types.Bid) { - bid.Share = utils.ParseCoin("10000lashare2") + bid.Share = utils.ParseCoin("10000sb2") }, - "share denom must be lashare1", + "share denom must be sb1", }, } { t.Run(tc.name, func(t *testing.T) { - bid := types.NewBid(1, 2, utils.TestAddress(1), utils.ParseCoin("10000lashare1")) + bid := types.NewBid(1, 2, utils.TestAddress(1), utils.ParseCoin("10000sb1")) tc.malleate(&bid) err := bid.Validate() if tc.expectedErr == "" { diff --git a/x/liquidamm/types/msgs_test.go b/x/liquidamm/types/msgs_test.go index 1baa4043..208367f5 100644 --- a/x/liquidamm/types/msgs_test.go +++ b/x/liquidamm/types/msgs_test.go @@ -112,20 +112,20 @@ func TestMsgBurnShare(t *testing.T) { { "invalid share", func(msg *types.MsgBurnShare) { - msg.Share = utils.ParseCoin("0lashare1") + msg.Share = utils.ParseCoin("0sb1") }, - "share amount must be positive: 0lashare1: invalid request", + "share amount must be positive: 0sb1: invalid request", }, { "invalid share denom", func(msg *types.MsgBurnShare) { - msg.Share = utils.ParseCoin("10000lashare2") + msg.Share = utils.ParseCoin("10000sb2") }, - "share denom must be lashare1: invalid request", + "share denom must be sb1: invalid request", }, } { t.Run(tc.name, func(t *testing.T) { - msg := types.NewMsgBurnShare(utils.TestAddress(0), 1, utils.ParseCoin("1000000lashare1")) + msg := types.NewMsgBurnShare(utils.TestAddress(0), 1, utils.ParseCoin("1000000sb1")) tc.malleate(msg) require.Equal(t, types.TypeMsgBurnShare, msg.Type()) require.Equal(t, types.RouterKey, msg.Route()) @@ -178,20 +178,20 @@ func TestMsgPlaceBid(t *testing.T) { { "invalid share", func(msg *types.MsgPlaceBid) { - msg.Share = utils.ParseCoin("0lashare1") + msg.Share = utils.ParseCoin("0sb1") }, - "share amount must be positive: 0lashare1: invalid request", + "share amount must be positive: 0sb1: invalid request", }, { "invalid share denom", func(msg *types.MsgPlaceBid) { - msg.Share = utils.ParseCoin("10000lashare2") + msg.Share = utils.ParseCoin("10000sb2") }, - "share denom must be lashare1: invalid request", + "share denom must be sb1: invalid request", }, } { t.Run(tc.name, func(t *testing.T) { - msg := types.NewMsgPlaceBid(utils.TestAddress(0), 1, 1, utils.ParseCoin("1000000lashare1")) + msg := types.NewMsgPlaceBid(utils.TestAddress(0), 1, 1, utils.ParseCoin("1000000sb1")) tc.malleate(msg) require.Equal(t, types.TypeMsgPlaceBid, msg.Type()) require.Equal(t, types.RouterKey, msg.Route()) diff --git a/x/liquidamm/types/public_position.go b/x/liquidamm/types/public_position.go index 341525a7..e3d90e48 100644 --- a/x/liquidamm/types/public_position.go +++ b/x/liquidamm/types/public_position.go @@ -12,11 +12,11 @@ import ( ) const ( - ShareDenomPrefix = "lashare" + ShareDenomPrefix = "sb" ) var ( - shareDenomRe = regexp.MustCompile(`^lashare([1-9]\d*)$`) + shareDenomRe = regexp.MustCompile(`^sb([1-9]\d*)$`) ) // DeriveBidReserveAddress creates the reserve address for bids diff --git a/x/liquidamm/types/public_position_test.go b/x/liquidamm/types/public_position_test.go index 9afd2854..96cd8181 100644 --- a/x/liquidamm/types/public_position_test.go +++ b/x/liquidamm/types/public_position_test.go @@ -17,14 +17,14 @@ func TestShareDenom(t *testing.T) { denom string expectsErr bool }{ - {"lashare1", false}, - {"lashare10", false}, - {"lashare18446744073709551615", false}, - {"lashare18446744073709551616", true}, - {"lashareabc", true}, - {"lashare01", true}, - {"lashare-10", true}, - {"lashare+10", true}, + {"sb1", false}, + {"sb10", false}, + {"sb18446744073709551615", false}, + {"sb18446744073709551616", true}, + {"sbabc", true}, + {"sb01", true}, + {"sb-10", true}, + {"sb+10", true}, {"ucre", true}, {"denom1", true}, } {