diff --git a/.version b/.version index 090488e21..bb8e4e769 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -v0.32.2 \ No newline at end of file +v0.32.3 \ No newline at end of file diff --git a/scripts/examples/leveragelp/leveragelp.sh b/scripts/examples/leveragelp/leveragelp.sh index dd04b0148..9e5219851 100644 --- a/scripts/examples/leveragelp/leveragelp.sh +++ b/scripts/examples/leveragelp/leveragelp.sh @@ -18,15 +18,25 @@ elysd tx stablestake bond 100000000 --from=treasury --keyring-backend=test --cha elysd tx gov submit-proposal proposal.json --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 elysd tx gov vote 1 Yes --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 elysd tx gov vote 3 Yes --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 +elysd query gov proposals # Open position -elysd tx leveragelp open 5 uusdc 500000 1 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 --fees=250uelys +elysd tx leveragelp open 5.0 uusdc 500000 1 0.0 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 --fees=250uelys elysd tx leveragelp open [leverage] [collateral-asset] [collateral-amount] [amm-pool-id] [flags] # Close position elysd tx leveragelp close 1 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 elysd tx leveragelp close [position-id] [flags] +# Query rewards +elysd query leveragelp rewards $(elysd keys show -a treasury --keyring-backend=test) 1 --output=json +# {"rewards":[{"position_id":"1","reward":[{"denom":"ueden","amount":"3086835"}]}],"total_rewards":[{"denom":"ueden","amount":"3086835"}]} + +# Claim rewards +elysd tx leveragelp claim-rewards 1 --from=treasury --keyring-backend=test --chain-id=elystestnet-1 --yes --gas=1000000 + +elysd query commitment show-commitments $(elysd keys show -a treasury --keyring-backend=test) + # Testnet elysd query oracle show-price ATOM --node=https://rpc.testnet.elys.network:443 elysd query oracle show-price USDC --node=https://rpc.testnet.elys.network:443 diff --git a/x/leveragelp/keeper/msg_server_claim_rewards.go b/x/leveragelp/keeper/msg_server_claim_rewards.go index 4a0a9029f..9fb729555 100644 --- a/x/leveragelp/keeper/msg_server_claim_rewards.go +++ b/x/leveragelp/keeper/msg_server_claim_rewards.go @@ -23,17 +23,10 @@ func (k msgServer) ClaimRewards(goCtx context.Context, msg *types.MsgClaimReward if position.Address != msg.Sender { return nil, types.ErrPositionDoesNotExist } - err = k.masterchefKeeper.ClaimRewards(ctx, posAddr, []uint64{position.Id}) + err = k.masterchefKeeper.ClaimRewards(ctx, posAddr, []uint64{position.AmmPoolId}, sender) if err != nil { return nil, err } - balances := k.bankKeeper.GetAllBalances(ctx, posAddr) - if balances.IsAllPositive() { - err := k.bankKeeper.SendCoins(ctx, posAddr, sender, balances) - if err != nil { - return nil, err - } - } } return &types.MsgClaimRewardsResponse{}, nil diff --git a/x/leveragelp/keeper/query_rewards.go b/x/leveragelp/keeper/query_rewards.go index 276a7688a..74299c251 100644 --- a/x/leveragelp/keeper/query_rewards.go +++ b/x/leveragelp/keeper/query_rewards.go @@ -15,10 +15,6 @@ func (k Keeper) Rewards(goCtx context.Context, req *types.QueryRewardsRequest) ( } ctx := sdk.UnwrapSDKContext(goCtx) - addr, err := sdk.AccAddressFromBech32(req.Address) - if err != nil { - return nil, err - } totalRewards := sdk.Coins{} rewardInfos := []*types.RewardInfo{} @@ -27,7 +23,7 @@ func (k Keeper) Rewards(goCtx context.Context, req *types.QueryRewardsRequest) ( if err != nil { return &types.QueryRewardsResponse{}, nil } - coins := k.masterchefKeeper.UserPoolPendingReward(ctx, addr, position.AmmPoolId) + coins := k.masterchefKeeper.UserPoolPendingReward(ctx, position.GetPositionAddress(), position.AmmPoolId) rewardInfos = append(rewardInfos, &types.RewardInfo{ PositionId: id, Reward: coins, diff --git a/x/leveragelp/types/expected_keepers.go b/x/leveragelp/types/expected_keepers.go index ca646d2ca..939126043 100644 --- a/x/leveragelp/types/expected_keepers.go +++ b/x/leveragelp/types/expected_keepers.go @@ -76,6 +76,6 @@ type AssetProfileKeeper interface { // MasterchefKeeper defines expected interface for masterchef keeper type MasterchefKeeper interface { - ClaimRewards(ctx sdk.Context, sender sdk.AccAddress, poolIds []uint64) error + ClaimRewards(ctx sdk.Context, sender sdk.AccAddress, poolIds []uint64, recipient sdk.AccAddress) error UserPoolPendingReward(ctx sdk.Context, user sdk.AccAddress, poolId uint64) sdk.Coins } diff --git a/x/masterchef/keeper/msg_server.go b/x/masterchef/keeper/msg_server.go index c0b695056..373df7873 100644 --- a/x/masterchef/keeper/msg_server.go +++ b/x/masterchef/keeper/msg_server.go @@ -135,7 +135,7 @@ func (k msgServer) AddExternalIncentive(goCtx context.Context, msg *types.MsgAdd return &types.MsgAddExternalIncentiveResponse{}, nil } -func (k Keeper) ClaimRewards(ctx sdk.Context, sender sdk.AccAddress, poolIds []uint64) error { +func (k Keeper) ClaimRewards(ctx sdk.Context, sender sdk.AccAddress, poolIds []uint64, recipient sdk.AccAddress) error { coins := sdk.NewCoins() for _, poolId := range poolIds { k.AfterWithdraw(ctx, poolId, sender.String(), sdk.ZeroInt()) @@ -161,7 +161,7 @@ func (k Keeper) ClaimRewards(ctx sdk.Context, sender sdk.AccAddress, poolIds []u } // Transfer rewards (Eden/EdenB is transferred through commitment module) - err := k.cmk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, coins) + err := k.cmk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, recipient, coins) if err != nil { return err } @@ -180,7 +180,7 @@ func (k msgServer) ClaimRewards(goCtx context.Context, msg *types.MsgClaimReward } } - err := k.Keeper.ClaimRewards(ctx, sender, msg.PoolIds) + err := k.Keeper.ClaimRewards(ctx, sender, msg.PoolIds, sender) if err != nil { return nil, err }