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

Feature / Deposit message fee amount #306

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions x/house/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ func (k Keeper) GetAllDeposits(ctx sdk.Context) (list []types.Deposit, err error
// Deposit performs a deposit transaction and stores a new deposit in store.
func (k Keeper) Deposit(ctx sdk.Context, creator, depositor string,
marketUID string, amount sdkmath.Int,
) (participationIndex uint64, err error) {
) (participationIndex uint64, feeAmount sdkmath.Int, err error) {
// Create the deposit object
deposit := types.NewDeposit(creator, depositor, marketUID, amount, sdk.ZeroInt(), 0)

feeAmount := deposit.CalcHouseParticipationFeeAmount(k.GetHouseParticipationFee(ctx))
feeAmount = deposit.CalcHouseParticipationFeeAmount(k.GetHouseParticipationFee(ctx))

depositorAddr, err := sdk.AccAddressFromBech32(depositor)
if err != nil {
Expand All @@ -79,5 +79,5 @@ func (k Keeper) Deposit(ctx sdk.Context, creator, depositor string,

k.SetDeposit(ctx, deposit)

return participationIndex, err
return participationIndex, feeAmount, err
}
4 changes: 2 additions & 2 deletions x/house/keeper/msg_server_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (k msgServer) Deposit(goCtx context.Context,
return nil, sdkerrors.Wrapf(types.ErrInTicketPayloadValidation, "%s", err)
}

participationIndex, err := k.Keeper.Deposit(
participationIndex, feeAmount, err := k.Keeper.Deposit(
ctx,
msg.Creator,
depositorAddr,
Expand All @@ -48,7 +48,7 @@ func (k msgServer) Deposit(goCtx context.Context,
return nil, sdkerrors.Wrap(err, "failed to deposit")
}

msg.EmitEvent(&ctx, depositorAddr, participationIndex)
msg.EmitEvent(&ctx, depositorAddr, participationIndex, feeAmount)

return &types.MsgDepositResponse{
MarketUID: msg.MarketUID,
Expand Down
1 change: 1 addition & 0 deletions x/house/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (

attributeKeyCreator = "creator"
attributeKeyDepositor = "depositor"
attributeKeyDepositFee = "deposit_fee"
attributeKeyWithdrawalID = "withdrawal_id"
attributeKeyDepositMarketUIDParticipantIndex = "deposit_market_index"
attributeKeyWithdrawMarketUIDParticipantIndex = "withdraw_market_index"
Expand Down
3 changes: 2 additions & 1 deletion x/house/types/message_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ func (msg MsgDeposit) ValidateSanity(_ sdk.Context, p *Params) error {
}

// EmitEvent emits the event for the message success.
func (msg *MsgDeposit) EmitEvent(ctx *sdk.Context, depositor string, participationIndex uint64) {
func (msg *MsgDeposit) EmitEvent(ctx *sdk.Context, depositor string, participationIndex uint64, feeAmount sdkmath.Int) {
emitter := utils.NewEventEmitter(ctx, attributeValueCategory)
emitter.AddMsg(typeMsgDeposit, msg.Creator,
sdk.NewAttribute(attributeKeyCreator, msg.Creator),
sdk.NewAttribute(attributeKeyDepositor, depositor),
sdk.NewAttribute(attributeKeyDepositFee, feeAmount.String()),
sdk.NewAttribute(attributeKeyDepositMarketUIDParticipantIndex,
strings.Join([]string{msg.MarketUID, cast.ToString(participationIndex)}, "#"),
),
Expand Down
8 changes: 4 additions & 4 deletions x/orderbook/keeper/bet_wager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (ts *testBetSuite) placeBetsAndTest() ([]bettypes.Bet, sdk.Dec, sdk.Dec) {
require.NoError(ts.t, err)

found := false
participationIndex, err := ts.tApp.HouseKeeper.Deposit(
participationIndex, _, err := ts.tApp.HouseKeeper.Deposit(
ts.ctx,
ts.deposits[0].DepositorAddress,
ts.deposits[0].DepositorAddress,
Expand All @@ -108,7 +108,7 @@ func (ts *testBetSuite) placeBetsAndTest() ([]bettypes.Bet, sdk.Dec, sdk.Dec) {
)
require.True(ts.t, found)

participationIndex, err = ts.tApp.HouseKeeper.Deposit(
participationIndex, _, err = ts.tApp.HouseKeeper.Deposit(
ts.ctx,
ts.deposits[1].DepositorAddress,
ts.deposits[1].DepositorAddress,
Expand All @@ -130,7 +130,7 @@ func (ts *testBetSuite) placeBetsAndTest() ([]bettypes.Bet, sdk.Dec, sdk.Dec) {
)
require.True(ts.t, found)

participationIndex, err = ts.tApp.HouseKeeper.Deposit(
participationIndex, _, err = ts.tApp.HouseKeeper.Deposit(
ts.ctx,
ts.deposits[2].DepositorAddress,
ts.deposits[2].DepositorAddress,
Expand Down Expand Up @@ -418,7 +418,7 @@ func (ts *testBetSuite) bulkDepositPlaceBetsAndTest() {

for i := 0; i < len(ts.deposits); i++ {
found := false
participationIndex, err := ts.tApp.HouseKeeper.Deposit(
participationIndex, _, err := ts.tApp.HouseKeeper.Deposit(
ts.ctx,
ts.deposits[i].DepositorAddress,
ts.deposits[i].DepositorAddress,
Expand Down
Loading