Skip to content

Commit

Permalink
feat: emit event on asset take rate deduction
Browse files Browse the repository at this point in the history
  • Loading branch information
madrezaz committed Jun 29, 2023
1 parent 16f8f5b commit 25cca86
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 34 deletions.
16 changes: 16 additions & 0 deletions docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

- [alliance/events.proto](#alliance/events.proto)
- [ClaimAllianceRewardsEvent](#alliance.ClaimAllianceRewardsEvent)
- [DeductAllianceAssetsEvent](#alliance.DeductAllianceAssetsEvent)
- [DelegateAllianceEvent](#alliance.DelegateAllianceEvent)
- [RedelegateAllianceEvent](#alliance.RedelegateAllianceEvent)
- [UndelegateAllianceEvent](#alliance.UndelegateAllianceEvent)
Expand Down Expand Up @@ -324,6 +325,21 @@ key: denom value: AllianceAsset



<a name="alliance.DeductAllianceAssetsEvent"></a>

### DeductAllianceAssetsEvent



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `coins` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | |






<a name="alliance.DelegateAllianceEvent"></a>

### DelegateAllianceEvent
Expand Down
7 changes: 7 additions & 0 deletions proto/alliance/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,11 @@ message ClaimAllianceRewardsEvent {
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
}

message DeductAllianceAssetsEvent {
repeated cosmos.base.v1beta1.Coin coins = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
1 change: 1 addition & 0 deletions x/alliance/keeper/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func (k Keeper) DeductAssetsWithTakeRate(ctx sdk.Context, lastClaim time.Time, a
}
// Only update if there was a token transfer to prevent < 1 amounts to be ignored
k.SetLastRewardClaimTime(ctx, lastClaim.Add(rewardClaimInterval*time.Duration(intervalsSinceLastClaim)))
_ = ctx.EventManager().EmitTypedEvent(&types.DeductAllianceAssetsEvent{Coins: coins})
}
return coins, nil
}
Expand Down
251 changes: 217 additions & 34 deletions x/alliance/types/events.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25cca86

Please sign in to comment.