Skip to content

Commit

Permalink
Merge pull request #9796 from vegaprotocol/referral-timestamps
Browse files Browse the repository at this point in the history
fix: referral api timestamp consistency
  • Loading branch information
jeremyletang authored Oct 16, 2023
2 parents 0854b6c + 332db47 commit 8c52215
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
- [8729](https://github.com/vegaprotocol/vega/issues/8729) - Stop order direction not set in datanode
- [8545](https://github.com/vegaprotocol/vega/issues/8545) - Block Explorer pagination does not order correctly.
- [8748](https://github.com/vegaprotocol/vega/issues/8748) - `ListSuccessorMarkets` does not return results.
- [9784](https://github.com/vegaprotocol/vega/issues/9784) - Referral timestamp consistency
- [8749](https://github.com/vegaprotocol/vega/issues/8749) - Ensure stop order expiry is in the future
- [9337](https://github.com/vegaprotocol/vega/issues/9337) - Non deterministic ordering of vesting ledger events
- [8773](https://github.com/vegaprotocol/vega/issues/8773) - Fix panic with stop orders
Expand Down
42 changes: 14 additions & 28 deletions datanode/gateway/graphql/generated.go

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

6 changes: 0 additions & 6 deletions datanode/gateway/graphql/referral_program_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"context"
"errors"
"math"
"time"

v2 "code.vegaprotocol.io/vega/protos/data-node/api/v2"

Expand All @@ -44,11 +43,6 @@ func (r *referralProgramResolver) WindowLength(ctx context.Context, obj *vega.Re
return int(obj.WindowLength), nil
}

func (r *referralProgramResolver) EndOfProgramTimestamp(ctx context.Context, obj *vega.ReferralProgram) (string, error) {
endTime := time.Unix(obj.EndOfProgramTimestamp, 0)
return endTime.Format(time.RFC3339), nil
}

type currentReferralProgramResolver VegaResolverRoot

func (r *currentReferralProgramResolver) Version(ctx context.Context, obj *v2.ReferralProgram) (int, error) {
Expand Down
14 changes: 7 additions & 7 deletions datanode/gateway/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4339,8 +4339,8 @@ type UpdateMarketState {
type UpdateReferralProgram {
"Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc."
benefitTiers: [BenefitTier!]!
"Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled."
endOfProgramTimestamp: String!
"Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the program will end and benefits will be disabled."
endOfProgramTimestamp: Timestamp!
"Number of epochs over which to evaluate a referral set's running volume."
windowLength: Int!
"""
Expand Down Expand Up @@ -4372,7 +4372,7 @@ type StakingTier {
type UpdateVolumeDiscountProgram {
"The benefit tiers for the program"
benefitTiers: [VolumeBenefitTier!]!
"The end time of the program"
"Timestamp as Unix time in nanoseconds, after which program ends."
endOfProgramTimestamp: Timestamp!
"The window length to consider for the volume discount program"
windowLength: Int!
Expand Down Expand Up @@ -5996,8 +5996,8 @@ type ReferralProgram {
version: Int!
"Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc."
benefitTiers: [BenefitTier!]!
"Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled."
endOfProgramTimestamp: String!
"Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the program will end and benefits will be disabled."
endOfProgramTimestamp: Timestamp!
"Number of epochs over which to evaluate a referral set's running volume."
windowLength: Int!
"""
Expand All @@ -6016,7 +6016,7 @@ type CurrentReferralProgram {
version: Int!
"Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc."
benefitTiers: [BenefitTier!]!
"Timestamp as RFC3339Nano, after which when the current epoch ends, the program will end and benefits will be disabled."
"Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the program will end and benefits will be disabled."
endOfProgramTimestamp: Timestamp!
"Number of epochs over which to evaluate a referral set's running volume."
windowLength: Int!
Expand Down Expand Up @@ -6269,7 +6269,7 @@ type VolumeDiscountProgram {
version: Int!
"Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc."
benefitTiers: [VolumeBenefitTier!]!
"Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the programs will end and benefits will be disabled."
"Timestamp as Unix time in nanoseconds, after which when the current epoch ends, the program will end and benefits will be disabled."
endOfProgramTimestamp: Timestamp!
"Number of epochs over which to evaluate parties' running volume."
windowLength: Int!
Expand Down
5 changes: 3 additions & 2 deletions datanode/gateway/graphql/update_referral_program_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ func (u updateReferralProgramResolver) BenefitTiers(_ context.Context, obj *vega
return obj.Changes.BenefitTiers, nil
}

func (u updateReferralProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *vega.UpdateReferralProgram) (string, error) {
return time.Unix(obj.Changes.EndOfProgramTimestamp, 0).String(), nil
func (u updateReferralProgramResolver) EndOfProgramTimestamp(_ context.Context, obj *vega.UpdateReferralProgram) (int64, error) {
endTime := time.Unix(obj.Changes.EndOfProgramTimestamp, 0)
return endTime.UnixNano(), nil
}

func (u updateReferralProgramResolver) WindowLength(_ context.Context, obj *vega.UpdateReferralProgram) (int, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package gql

import (
"context"
"time"

"code.vegaprotocol.io/vega/protos/vega"
)
Expand All @@ -32,7 +33,8 @@ func (r *updateVolumeDiscountProgramResolver) BenefitTiers(
func (r *updateVolumeDiscountProgramResolver) EndOfProgramTimestamp(
_ context.Context, obj *vega.UpdateVolumeDiscountProgram,
) (int64, error) {
return obj.Changes.EndOfProgramTimestamp, nil
endTime := time.Unix(obj.Changes.EndOfProgramTimestamp, 0)
return endTime.UnixNano(), nil
}

func (r *updateVolumeDiscountProgramResolver) WindowLength(
Expand Down

0 comments on commit 8c52215

Please sign in to comment.