Skip to content

Commit

Permalink
chore: fix address issue in stake and unstake
Browse files Browse the repository at this point in the history
  • Loading branch information
kenta-elys committed Nov 30, 2023
1 parent 4016d0e commit c1725e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions x/commitment/types/message_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const TypeMsgStake = "stake"

var _ sdk.Msg = &MsgStake{}

func NewMsgStake(creator string, amount sdk.Int, asset string, validatorAddress string) *MsgStake {
func NewMsgStake(address string, amount sdk.Int, asset string, validatorAddress string) *MsgStake {
return &MsgStake{
Creator: creator,
Creator: address,
Address: address,
Amount: amount,
Asset: asset,
ValidatorAddress: validatorAddress,
Expand Down
5 changes: 3 additions & 2 deletions x/commitment/types/message_unstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ const TypeMsgUnstake = "unstake"

var _ sdk.Msg = &MsgUnstake{}

func NewMsgUnstake(creator string, amount sdk.Int, asset string, validatorAddress string) *MsgUnstake {
func NewMsgUnstake(address string, amount sdk.Int, asset string, validatorAddress string) *MsgUnstake {
return &MsgUnstake{
Creator: creator,
Creator: address,
Address: address,
Amount: amount,
Asset: asset,
ValidatorAddress: validatorAddress,
Expand Down
7 changes: 5 additions & 2 deletions x/incentive/keeper/apr.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (sdk

// Calc Eden price in usdc
// We put Elys as denom as Eden won't be avaialble in amm pool and has the same value as Elys
edenPrice := k.EstimatePrice(ctx, sdk.NewCoin(ptypes.Elys, sdk.NewInt(10)), baseCurrency)
edenPrice := k.EstimatePrice(ctx, sdk.NewCoin(ptypes.Elys, sdk.NewInt(1000000)), baseCurrency)
if edenPrice.IsZero() {
return sdk.ZeroInt(), nil
}

// Update total committed states
k.UpdateTotalCommitmentInfo(ctx, baseCurrency)
Expand All @@ -131,7 +134,7 @@ func (k Keeper) CalculateApr(ctx sdk.Context, query *types.QueryAprRequest) (sdk

// Usdc apr for elys staking = (24 hour dex rewards in USDC generated for stakers) * 365*100/ {price ( elys/usdc)*( sum of (elys staked, Eden committed, Eden boost committed))}
// we multiply 10 as we have use 10elys as input in the price estimation
apr := amtDexRewardPerDay.MulInt(sdk.NewInt(ptypes.DaysPerYear)).MulInt(sdk.NewInt(100)).MulInt(sdk.NewInt(10)).QuoInt(edenPrice).QuoInt(totalStakedSnapshot)
apr := amtDexRewardPerDay.MulInt(sdk.NewInt(ptypes.DaysPerYear)).MulInt(sdk.NewInt(100)).MulInt(sdk.NewInt(1000000)).QuoInt(edenPrice).QuoInt(totalStakedSnapshot)

return apr.TruncateInt(), nil
}
Expand Down

0 comments on commit c1725e6

Please sign in to comment.