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

feat: add liquidfarming module #332

Merged
merged 157 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
84d4b3d
chore: scaffold liquidfarming module
jaybxyz Jun 28, 2022
36f6e69
Merge commit '42e024d800964d99e87b7c0b257d7c31951ce6fb' into kogisin/…
jaybxyz Jul 4, 2022
55a4442
chore: apply updated spec
jaybxyz Jul 4, 2022
faf1782
feat: adding handlers for both msgs and proposal
jaybxyz Jul 4, 2022
5c37013
feat: adding keeper logics
jaybxyz Jul 4, 2022
0ba1f2f
chore: fix proto numbering and add msg server boilerplate
jaybxyz Jul 5, 2022
19a2a04
feat: add keys and proposal handler
jaybxyz Jul 5, 2022
3ca8b5a
feat: add params and genesis
jaybxyz Jul 5, 2022
88ed943
feat: add more getter and setter stores
jaybxyz Jul 5, 2022
2b23c2b
chore: update store and add cli boilerplate
jaybxyz Jul 5, 2022
be89af0
feat: follow naming convention
jaybxyz Jul 6, 2022
552b9b9
chore: apply updated spec and add keeper test suite boilerplate
jaybxyz Jul 6, 2022
501d6e9
feat: add winner bid id
jaybxyz Jul 6, 2022
626331e
feat: update proto files
jaybxyz Jul 7, 2022
7cce89f
feat: register liquid farming in app
jaybxyz Jul 7, 2022
758f689
feat: implement deposit, cancel, and withdraw
jaybxyz Jul 7, 2022
21e23e5
feat: add transaction commands
jaybxyz Jul 7, 2022
5f376a6
docs: add spec docs
jaybxyz Jul 7, 2022
a2bad66
docs: update README.md
jaybxyz Jul 7, 2022
57273af
chore: fix indentation, add farming keeper, and add helper and short-…
jaybxyz Jul 7, 2022
f7ce6f6
feat: apply updated specs
jaybxyz Jul 8, 2022
49ea29b
feat: add liquidfarms and liquidfarm grpc queries
jaybxyz Jul 8, 2022
497050b
feat: imposing deposit gas fee for deposit request
jaybxyz Jul 8, 2022
ff2e825
feat: add logic to impose more gas as there are more number of deposi…
jaybxyz Jul 11, 2022
aa903dc
feat: add AfterAllocateRewardsHook for the farming module
jaybxyz Jul 11, 2022
1985fee
docs: add hooks
jaybxyz Jul 11, 2022
a0f2340
feat: apply suggestions from the review
jaybxyz Jul 11, 2022
b7271a8
feat: work in progress
jaybxyz Jul 11, 2022
0964fd1
feat: update names
jaybxyz Jul 11, 2022
d7c2149
Merge branch 'kogisin/329-add-farming-hooks' into kogisin/scaffold-li…
jaybxyz Jul 11, 2022
c996886
feat: apply updated spec
jaybxyz Jul 12, 2022
b42a5c2
feat: clean up keeper and add missing logics
jaybxyz Jul 12, 2022
3b15459
feat: add AfterStaked hook in the farming module
jaybxyz Jul 12, 2022
a894758
feat: set hooks in app
jaybxyz Jul 12, 2022
9ccc711
chore: add queued farming, update params to meet naming convention, a…
jaybxyz Jul 12, 2022
eb76a2d
test: adding store to cancel queued farming
jaybxyz Jul 12, 2022
936c607
chore: fix farm and cancel queued farming logic and add test cases
jaybxyz Jul 13, 2022
515d80a
Merge branch 'main' into kogisin/scaffold-liquidfarm
jaybxyz Jul 13, 2022
7f0e8e1
feat: mint LFCoin in hook
jaybxyz Jul 13, 2022
4b9b91a
chore: add test cases to verify farm, unfarm, cancel
jaybxyz Jul 14, 2022
77b8737
feat: set time nullable false and add create rewards auction function
jaybxyz Jul 14, 2022
a7772ee
fix: add unsafe hooks to fix the case
jaybxyz Jul 14, 2022
b35e5e0
WIP: adding PlaceBid
jaybxyz Jul 14, 2022
1450b9b
WIP: apply updated spec
jaybxyz Jul 15, 2022
856f679
feat: rename some fields and add bid stores
jaybxyz Jul 15, 2022
a00d652
chore: apply updated spec, fix bugs, and add test cases
jaybxyz Jul 15, 2022
1326584
chore: update deposit to farm and add refund bid test case
jaybxyz Jul 18, 2022
9899086
WIP: adding after allocate rewards hook
jaybxyz Jul 18, 2022
39a9c56
Merge commit '7ae07d34994b4f4842dae1828699f703a5dd1522' into kogisin/…
jaybxyz Jul 19, 2022
41f422a
chore: add CreateRewardsAuction, AfterAllocateRewards hook, and remov…
jaybxyz Jul 19, 2022
b55b46c
feat: adding gRPC queries
jaybxyz Jul 19, 2022
29849fe
WIP: fixing registerservices and adding test case
jaybxyz Jul 20, 2022
9632501
feat: terminate rewards auction and create new one, add logic for aut…
jaybxyz Jul 20, 2022
f9bb195
chore: organize codes and inline comments
jaybxyz Jul 20, 2022
720fafc
feat: remove end blocker
jaybxyz Jul 20, 2022
040b45d
test: add liquidfarms and liquifarm grpc queries
jaybxyz Jul 20, 2022
d8e21f6
feat: add refund bid cmd
jaybxyz Jul 20, 2022
d0b27a0
feat: update grpc queries endpoints
jaybxyz Jul 20, 2022
66f880a
test: add msgs and params test cases
jaybxyz Jul 25, 2022
992af3b
chore: remove selling reserve address in rewards auction, add grpc qu…
jaybxyz Jul 25, 2022
256d725
WIP: adding query commands
jaybxyz Jul 25, 2022
6fb3f44
feat: add query commands
jaybxyz Jul 26, 2022
3e14bf1
feat: add genesis import and export
jaybxyz Jul 26, 2022
3bdf9f6
chore: add genesis test case, clean up codes
jaybxyz Jul 27, 2022
8b1511b
refactor: make error handling consistent, follow naming convention, a…
jaybxyz Jul 27, 2022
64f6b9a
feat: adding unfarm and withdraw msg server
jaybxyz Jul 27, 2022
abd80a9
feat: remove unused codes
jaybxyz Jul 27, 2022
2b9c4cb
feat: add UnfarmAndWithdraw and remove liquid farm exist validation f…
jaybxyz Jul 29, 2022
5af2a1a
test: add test case for UnfarmAndWithdraw
jaybxyz Jul 29, 2022
371d017
chore: fix broken test cases and refactor hook
jaybxyz Aug 1, 2022
7470618
Merge commit '1ce813826bc59066ccf04e81984dbf9e71a691bc' into kogisin/…
jaybxyz Aug 1, 2022
2a402ab
WIP: fixing bug
jaybxyz Aug 1, 2022
389c8c4
feat: update AdvancedEpoch
jaybxyz Aug 1, 2022
5f80906
refactor: add necessary comments
jaybxyz Aug 2, 2022
577ce77
chore: remove LiquidFarmCreationFee and add test cases for types
jaybxyz Aug 2, 2022
96046cf
test: add more tests
jaybxyz Aug 2, 2022
61edf26
fix: remove pointer
jaybxyz Aug 3, 2022
8e3ea8f
fix: typo in query endpoints
jaybxyz Aug 4, 2022
fe14363
fix: rename lfCoin to UnfarmingCoin and add validation check for the …
jaybxyz Aug 4, 2022
9ebe946
chore: fix RewardsAuctions query command, apply updated spec to store…
jaybxyz Aug 5, 2022
6347f1d
fix: rename reward-auction to rewards-auction query command
jaybxyz Aug 5, 2022
7f91cfe
chore: apply updated spec and adding test cases
jaybxyz Aug 8, 2022
59113d4
test: adding test case
jaybxyz Aug 8, 2022
d8d4c31
chore: add unfarm fee rate param, add more test cases, organize codebase
jaybxyz Aug 9, 2022
b4fdad6
fix: broken tests
jaybxyz Aug 9, 2022
8632cfd
feat: make liquidFarmSet map deterministic
jaybxyz Aug 9, 2022
e9c6542
feat: `liquidfarming` module apply changed spec (#345)
jaybxyz Aug 11, 2022
38b9372
feat: add edge test case
jaybxyz Aug 11, 2022
fd468e7
feat: add stakedCoins zero validation before unstake
jaybxyz Aug 11, 2022
2a4f0a0
feat: organize events
jaybxyz Aug 11, 2022
4342601
docs: add drafts of specs for liquidfarming module (#343)
jeonghoyeo7 Aug 11, 2022
556e858
review: applying almost all suggestions
jaybxyz Aug 11, 2022
c5bf6f8
review: refund previous bid if exists in PlaceBid
jaybxyz Aug 12, 2022
93ec42a
review: apply the rest suggestions
jaybxyz Aug 12, 2022
2272519
chore: rename minimum to min for convention and fix broken test cases
jaybxyz Aug 12, 2022
190e146
test: add tx query integration tests
jaybxyz Aug 12, 2022
978dfcd
fix: fix daed links in spec docs
jaybxyz Aug 12, 2022
4827f5f
fix: move denom verification to message level
jaybxyz Aug 16, 2022
59e96bb
fix: add bidding coin denom verification and winning bid verification…
jaybxyz Aug 16, 2022
1d09ead
test: add integration tests
jaybxyz Aug 16, 2022
c91f0ba
docs: update cli docs
jaybxyz Aug 16, 2022
7be782a
test: add boilerplate for simulation tests
jaybxyz Aug 16, 2022
070d190
feat: rename UnfarmFeeRate to FeeRate and move it inside LiquidFarm
jaybxyz Aug 18, 2022
b8fd87a
feat: add deduct fees logic
jaybxyz Aug 18, 2022
4764caa
feat: add mint/burn rate queries
jaybxyz Aug 18, 2022
222463b
fix: fix genesis validation test
jaybxyz Aug 18, 2022
077aa22
test: add tests for mint/burn rates grpc queries
jaybxyz Aug 19, 2022
0195552
fix: fix simulation params
jaybxyz Aug 19, 2022
e6e2b84
test: add param test for simulation
jaybxyz Aug 19, 2022
66ae4a5
chore: add liquidfarming in labeler workflow and remove mistakenly ad…
jaybxyz Sep 16, 2022
c12b4f7
Merge commit '5fbcd22561a3427f1689374377cc23f64fcbf1e7' into kogisin/…
jaybxyz Sep 20, 2022
1f63323
feat: remove hooks in farming and liquidfarming modules as they are n…
jaybxyz Sep 20, 2022
4adbae0
feat: change names from Farm and Unfarm to LiquidFarm and LiquidUnfarm
jaybxyz Sep 20, 2022
9e71200
feat: switch farming module to farm module and update with new functions
jaybxyz Sep 20, 2022
78f18f0
feat: add auction period hours
jaybxyz Sep 20, 2022
afecccd
feat: updating RewardsAuction creation
jaybxyz Sep 21, 2022
45837f1
feat: complete BeginBlocker logics
jaybxyz Sep 22, 2022
d0f21b8
Merge commit '2de5a71b3d0756f75fd1dc78387b2bc118074e56' into kogisin/…
jaybxyz Sep 22, 2022
09f8a38
feat: add NewLiquidUnfarmAndWithdrawCmd CLI command
jaybxyz Sep 22, 2022
b2deec2
feat: rename BurningCoin to UnfarmingCoin
jaybxyz Sep 22, 2022
9eb9d22
test: add more test cases for types
jaybxyz Sep 22, 2022
b47a0ce
feat: add TODO comments and use Rewards
jaybxyz Sep 22, 2022
16dc8bc
test: fixing test case
jaybxyz Sep 22, 2022
47fcc6e
fix: SetRewardsAuctionEndTime
jaybxyz Sep 22, 2022
762e264
test: updating test cases
jaybxyz Sep 22, 2022
9b7bff4
test: resolve TODO comments
jaybxyz Sep 23, 2022
f84d9ce
Merge commit '1be39d977fbd72e8d70b6af8a99bce95156483db' into kogisin/…
jaybxyz Sep 23, 2022
10fdb16
test: update more test cases
jaybxyz Sep 23, 2022
aa0930d
test: update all keeper and type test cases for the farm module
jaybxyz Sep 26, 2022
c111d34
Merge commit '41e4143f12b9dc14565e411648e836b9231ab023' into kogisin/…
jaybxyz Sep 26, 2022
6bee2a5
fix: fix broken test cases due to relying on the farming module
jaybxyz Sep 26, 2022
d15e7de
test: add missing param in simulation test
jaybxyz Sep 27, 2022
95c8ac6
test: update simulation tests and fix golangci-lint issues
jaybxyz Sep 27, 2022
dd45f37
Merge commit '6f3de7ce219b9ddbdcefdb75d51d9fc189dfc961' into kogisin/…
jaybxyz Sep 27, 2022
095f298
fix: fix params test
jaybxyz Sep 27, 2022
58b58ee
chore: update api and cli docs
jaybxyz Sep 27, 2022
e25ae00
Merge commit 'c3a4ff184baab88e2d1d27765a0cb8145adcd969' into kogisin/…
jaybxyz Sep 27, 2022
8b044bf
docs: updating spec docs with the latest version
jaybxyz Sep 27, 2022
7cddb42
test: update test cases
jaybxyz Sep 27, 2022
930a6cc
chore: update comments, clean up, update docs
jaybxyz Sep 27, 2022
156561b
feat: remove typo
jaybxyz Sep 27, 2022
5c72ad9
feat: apply suggestions from the review
jaybxyz Oct 4, 2022
f98896f
chore: fix broken integration test and add test cases
jaybxyz Oct 4, 2022
04d6186
fix: fix error messages
jaybxyz Oct 4, 2022
713f88b
revert: revert incorrectly fixed error message
jaybxyz Oct 4, 2022
6620d07
Merge commit '643182a32564a7b64e8629c11fa79683fd7ccc8f' into kogisin/…
jaybxyz Oct 4, 2022
8a52540
docs: update spec docs
jaybxyz Oct 5, 2022
ccde80c
Merge commit '5585f1e530b2d48160387d8a2868315fcd212848' into kogisin/…
jaybxyz Oct 5, 2022
9db8fa3
feat: resolve TODO comments
jaybxyz Oct 5, 2022
cc0b721
fix: add includeWinningBid when refunding all bids to fix an edge case
jaybxyz Oct 5, 2022
7130ca6
fix: simulation halted due to position
jaybxyz Oct 5, 2022
4b4f9a8
feat: add auction id as param for PlaceBid and RefundBid, add Winning…
jaybxyz Oct 5, 2022
ba9a58d
fix: test cases by applying the previous commit
jaybxyz Oct 5, 2022
07de1b6
docs: update spec docs
jaybxyz Oct 5, 2022
8aaae9e
Merge commit '8ec2d0fbef7c726941a7a31153d7152e0ca868f4' into kogisin/…
jaybxyz Oct 5, 2022
ebb5835
docs: update CHANGELOG.md
jaybxyz Oct 5, 2022
c0464ef
env: add farm and liquidfarming modules in c-sync labeler.yml
jaybxyz Oct 5, 2022
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
4 changes: 2 additions & 2 deletions x/liquidfarming/keeper/auction.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ func (k Keeper) PlaceBid(ctx sdk.Context, poolId uint64, bidder sdk.AccAddress,
}

if biddingCoin.Amount.LT(liquidFarm.MinBidAmount) {
return types.Bid{}, sdkerrors.Wrapf(types.ErrSmallerThanMinimumAmount, "%s is smaller than %s", biddingCoin.Amount, liquidFarm.MinBidAmount)
return types.Bid{}, sdkerrors.Wrapf(types.ErrNotBiggerThanMinimumAmount, "%s is not bigger than %s", biddingCoin.Amount, liquidFarm.MinBidAmount)
jaybxyz marked this conversation as resolved.
Show resolved Hide resolved
}

winningBid, found := k.GetWinningBid(ctx, poolId, auctionId)
if found {
if biddingCoin.Amount.LTE(winningBid.Amount.Amount) {
return types.Bid{}, sdkerrors.Wrapf(types.ErrSmallerThanWinningBidAmount, "%s is smaller than %s", biddingCoin.Amount, winningBid.Amount.Amount)
return types.Bid{}, sdkerrors.Wrapf(types.ErrNotBiggerThanWinningBidAmount, "%s is not bigger than %s", biddingCoin.Amount, winningBid.Amount.Amount)
}
}

Expand Down
4 changes: 2 additions & 2 deletions x/liquidfarming/keeper/auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s *KeeperTestSuite) TestPlaceBid_Validation() {
sdk.NewInt64Coin(pool.PoolCoinDenom, 100),
),
nil,
"100 is smaller than 1000000: smaller than minimum amount",
"100 is not bigger than 1000000: not bigger than the minimum amount",
},
} {
s.Run(tc.name, func() {
Expand Down Expand Up @@ -129,7 +129,7 @@ func (s *KeeperTestSuite) TestPlaceBid() {

// Place a bid with less than the winning bid amount
_, err = s.keeper.PlaceBid(s.ctx, pool.Id, bidderAddr2, sdk.NewInt64Coin(pool.PoolCoinDenom, 90_000_000))
s.Require().EqualError(err, "90000000 is smaller than 150000000: smaller than winning bid amount")
s.Require().EqualError(err, "90000000 is not bigger than 150000000: not bigger than the winning bid amount")
}

func (s *KeeperTestSuite) TestRefundBid() {
Expand Down
2 changes: 1 addition & 1 deletion x/liquidfarming/keeper/liquidfarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (k Keeper) LiquidFarm(ctx sdk.Context, poolId uint64, farmer sdk.AccAddress
}

if farmingCoin.Amount.LT(liquidFarm.MinFarmAmount) {
return sdkerrors.Wrapf(types.ErrSmallerThanMinimumAmount, "%s is smaller than %s", farmingCoin.Amount, liquidFarm.MinFarmAmount)
return sdkerrors.Wrapf(types.ErrNotBiggerThanMinimumAmount, "%s is not bigger than %s", farmingCoin.Amount, liquidFarm.MinFarmAmount)
}

reserveAddr := types.LiquidFarmReserveAddress(pool.Id)
Expand Down
18 changes: 9 additions & 9 deletions x/liquidfarming/keeper/liquidfarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/cosmosquad-labs/squad/v3/x/liquidfarming/types"
)

func (s *KeeperTestSuite) TestFarm_Validation() {
func (s *KeeperTestSuite) TestLiquidFarm_Validation() {
err := s.keeper.LiquidFarm(s.ctx, 1, s.addr(0), utils.ParseCoin("100_000_000pool1"))
s.Require().EqualError(err, "pool 1 not found: not found")

Expand Down Expand Up @@ -50,7 +50,7 @@ func (s *KeeperTestSuite) TestFarm_Validation() {
sdk.NewInt64Coin(pool.PoolCoinDenom, 100),
),
nil,
"100 is smaller than 100000000: smaller than minimum amount",
"100 is not bigger than 100000000: not bigger than the minimum amount",
},
{
"insufficient funds",
Expand All @@ -77,7 +77,7 @@ func (s *KeeperTestSuite) TestFarm_Validation() {
}
}

func (s *KeeperTestSuite) TestFarm() {
func (s *KeeperTestSuite) TestLiquidFarm() {
pair := s.createPair(s.addr(0), "denom1", "denom2")
pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"))

Expand Down Expand Up @@ -109,7 +109,7 @@ func (s *KeeperTestSuite) TestFarm() {
s.Require().Equal(amount1.Add(amount2).Add(amount3), position.FarmingAmount)
}

func (s *KeeperTestSuite) TestUnfarm_Validation() {
func (s *KeeperTestSuite) TestLiquidUnfarm_Validation() {
_, err := s.keeper.LiquidUnfarm(s.ctx, 1, s.addr(0), utils.ParseCoin("100_000_000pool1"))
s.Require().EqualError(err, "pool 1 not found: not found")

Expand Down Expand Up @@ -162,7 +162,7 @@ func (s *KeeperTestSuite) TestUnfarm_Validation() {
}
}

func (s *KeeperTestSuite) TestUnfarm_All() {
func (s *KeeperTestSuite) TestLiquidUnfarm_All() {
pair := s.createPair(s.addr(0), "denom1", "denom2")
pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"))

Expand Down Expand Up @@ -200,7 +200,7 @@ func (s *KeeperTestSuite) TestUnfarm_All() {
s.Require().True(supply.IsZero())
}

func (s *KeeperTestSuite) TestUnfarm_Partial() {
func (s *KeeperTestSuite) TestLiquidUnfarm_Partial() {
pair := s.createPair(s.addr(0), "denom1", "denom2")
pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"))

Expand Down Expand Up @@ -263,7 +263,7 @@ func (s *KeeperTestSuite) TestUnfarm_Partial() {
s.Require().Equal(amount1, s.app.BankKeeper.GetSupply(s.ctx, lfCoinDenom).Amount)
}

func (s *KeeperTestSuite) TestUnfarm_RemoveLiquidFarm() {
func (s *KeeperTestSuite) TestLiquidUnfarm_RemoveLiquidFarm() {
pair := s.createPair(s.addr(0), "denom1", "denom2")
pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"))

Expand All @@ -278,7 +278,7 @@ func (s *KeeperTestSuite) TestUnfarm_RemoveLiquidFarm() {
s.nextBlock()
}

func (s *KeeperTestSuite) TestUnfarm_Complex_WithRewards() {
func (s *KeeperTestSuite) TestLiquidUnfarm_Complex_WithRewards() {
pair := s.createPairWithLastPrice(s.addr(0), "denom1", "denom2", sdk.NewDec(1))
pool := s.createPool(s.addr(0), pair.Id, utils.ParseCoins("100_000_000denom1, 100_000_000denom2"))

Expand Down Expand Up @@ -382,7 +382,7 @@ func (s *KeeperTestSuite) TestUnfarm_Complex_WithRewards() {
s.Require().Equal(sdk.ZeroInt(), s.app.BankKeeper.GetSupply(s.ctx, lfCoinDenom).Amount)
}

func (s *KeeperTestSuite) TestUnfarmAndWithdraw() {
func (s *KeeperTestSuite) TestLiquidUnfarmAndWithdraw() {
depositCoins := utils.ParseCoins("100_000_000denom1, 100_000_000denom2")
pair := s.createPair(s.addr(0), "denom1", "denom2")
pool := s.createPool(s.addr(0), pair.Id, depositCoins)
Expand Down
4 changes: 2 additions & 2 deletions x/liquidfarming/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import (

// x/liquidfarming module sentinel errors
var (
ErrSmallerThanMinimumAmount = sdkerrors.Register(ModuleName, 2, "smaller than minimum amount")
ErrSmallerThanWinningBidAmount = sdkerrors.Register(ModuleName, 3, "smaller than winning bid amount")
ErrNotBiggerThanMinimumAmount = sdkerrors.Register(ModuleName, 2, "not bigger than the minimum amount")
ErrNotBiggerThanWinningBidAmount = sdkerrors.Register(ModuleName, 3, "not bigger than the winning bid amount")
)