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(perp): Implemented funding payment calculation in epoch hook #616

Merged
merged 13 commits into from
Jun 23, 2022

Conversation

john-connor84
Copy link
Contributor

  • Also implemented TWAP mark price calculation

@john-connor84 john-connor84 requested a review from a team as a code owner June 16, 2022 01:07
@john-connor84 john-connor84 marked this pull request as draft June 16, 2022 01:09
@john-connor84 john-connor84 linked an issue Jun 17, 2022 that may be closed by this pull request
@john-connor84 john-connor84 changed the title Implemented funding payment calculation in epoch hook feature(perp): Implemented funding payment calculation in epoch hook Jun 17, 2022
@john-connor84 john-connor84 changed the title feature(perp): Implemented funding payment calculation in epoch hook feat(perp): Implemented funding payment calculation in epoch hook Jun 17, 2022
@john-connor84 john-connor84 marked this pull request as ready for review June 17, 2022 00:27
proto/vpool/v1/params.proto Outdated Show resolved Hide resolved
x/vpool/keeper/prices.go Outdated Show resolved Hide resolved
x/vpool/keeper/prices.go Outdated Show resolved Hide resolved
proto/perp/v1/state.proto Outdated Show resolved Hide resolved
x/perp/keeper/hooks.go Outdated Show resolved Hide resolved
x/perp/keeper/hooks.go Show resolved Hide resolved
x/vpool/keeper/prices_test.go Show resolved Hide resolved
x/perp/keeper/hooks_test.go Outdated Show resolved Hide resolved
x/perp/keeper/hooks.go Outdated Show resolved Hide resolved
x/perp/keeper/hooks.go Outdated Show resolved Hide resolved
x/perp/keeper/hooks.go Outdated Show resolved Hide resolved
@@ -11,38 +13,45 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochN
}

func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ int64) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the third parameter used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the epochNumber, I don't use it so I made it _, didn't want to remove it as the func signature is used throughout but can if you think it's better

x/pricefeed/keeper/keeper.go Outdated Show resolved Hide resolved
x/pricefeed/keeper/keeper.go Outdated Show resolved Hide resolved
@@ -347,19 +347,19 @@ func (k Keeper) updateTWAPPrice(ctx sdk.Context, pairID string) error {
currentTWAP = types.CurrentTWAP{
PairID: pairID,
Numerator: sdk.MustNewDecFromStr("0"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just do sdk.ZeroDec() here.

@john-connor84 john-connor84 merged commit 39ca8e0 into master Jun 23, 2022
@john-connor84 john-connor84 deleted the jc/fundingPayment branch June 23, 2022 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(perp): calculate latest funding payment in epoch hook
3 participants