Skip to content

Commit

Permalink
feat: add proposed fee to schema and API
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Van Ootegem <[email protected]>
  • Loading branch information
EVODelavega committed Jun 14, 2024
1 parent 8867cc7 commit b40d2b6
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- [11268](https://github.com/vegaprotocol/vega/issues/11268) - Include derived parties vesting stats API
- [11266](https://github.com/vegaprotocol/vega/issues/11266) - Include derived parties rewards API
- [11357](https://github.com/vegaprotocol/vega/issues/11357) - Support historical game scores
- [11023](https://github.com/vegaprotocol/vega/issues/11023) - Add proposed fees to `vAMM` data.

### 🐛 Fixes

Expand Down
13 changes: 8 additions & 5 deletions datanode/entities/amm_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func AMMPoolFromProto(pool *eventspb.AMM, vegaTime time.Time) (AMMPool, error) {
parametersBase,
commitment num.Decimal
parametersLowerBound,
parametersUpperBound *num.Decimal
parametersUpperBound, fee *num.Decimal
err error
)
partyID := PartyID(pool.PartyId)
Expand Down Expand Up @@ -118,9 +118,12 @@ func AMMPoolFromProto(pool *eventspb.AMM, vegaTime time.Time) (AMMPool, error) {
upperLeverage = &v
}

fee, err := num.DecimalFromString(pool.ProposedFee)
if err != nil {
return AMMPool{}, err
if len(pool.ProposedFee) > 0 {
fd, err := num.DecimalFromString(pool.ProposedFee)
if err != nil {
return AMMPool{}, err
}
fee = &fd
}

return AMMPool{
Expand All @@ -136,7 +139,7 @@ func AMMPoolFromProto(pool *eventspb.AMM, vegaTime time.Time) (AMMPool, error) {
ParametersUpperBound: parametersUpperBound,
ParametersLeverageAtLowerBound: lowerLeverage,
ParametersLeverageAtUpperBound: upperLeverage,
ProposedFee: &fee,
ProposedFee: fee,
CreatedAt: vegaTime,
LastUpdated: vegaTime,
}, nil
Expand Down
53 changes: 53 additions & 0 deletions datanode/gateway/graphql/generated.go

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

2 changes: 2 additions & 0 deletions datanode/gateway/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7593,6 +7593,8 @@ type AMM {
status: AMMStatus!
"Reason for status if applicable"
statusReason: AMMStatusReason!
"Proposed fee"
proposedFee: String
}

type ConcentratedLiquidityParameters {
Expand Down
12 changes: 6 additions & 6 deletions datanode/networkhistory/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,12 @@ func TestMain(t *testing.M) {
log.Infof("%s", goldenSourceHistorySegment[4000].HistorySegmentID)
log.Infof("%s", goldenSourceHistorySegment[5000].HistorySegmentID)

panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[1000].HistorySegmentID, "Qmf5QzhfokNqFE7N5Kf1oUmrzA94tTJNRWxB9ULShf1uzV", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[2000].HistorySegmentID, "QmbsusmxWeUxCHdJRznLbtcevgKhF4dkvL9yFnhpJS3wQa", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[2500].HistorySegmentID, "QmPfUnXkuBzmMjB2rcdtGMNhdd6mc3cvYMfS9rnMXjfu6L", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[3000].HistorySegmentID, "QmRwtm3pUuUYG69tmbssFkYd2DafLELBeDfxuEjqjmXct8", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[4000].HistorySegmentID, "QmQmC4xrdSJMiJ9MLgWdU1mptVv9TdSsYyosusd8dCt8A4", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[5000].HistorySegmentID, "QmU3zDAHiQYWLyeYzwwCAynoh8A7g38ZaLpdV2h5pgkuL5", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[1000].HistorySegmentID, "QmcnPQ9EtzgCBpeJ54ztxw6dkS8baWkndFqayQSAvvreYR", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[2000].HistorySegmentID, "QmNw9naAXcxgXPxiMNih6ciUoH6i6kdE4Kop42B4b5VXnH", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[2500].HistorySegmentID, "QmTn7YCSP5ZPBQNQHXroFatrKMuHshdUP8PdxRXPoLw74D", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[3000].HistorySegmentID, "QmT2KLMWgezCczmcBkc1yXn3bgs7mBZWeTBARsAtJxFAVA", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[4000].HistorySegmentID, "QmP9FKxEewC98C4YVhAmgJCxLeK49cLSPnve3Nrykz4efp", snapshots)
panicIfHistorySegmentIdsNotEqual(goldenSourceHistorySegment[5000].HistorySegmentID, "QmaPTyvUKeLBaASEXXbpFvzpkaHpZKTpiLEu6zfax1Yo8L", snapshots)
}, postgresRuntimePath, sqlFs)

if exitCode != 0 {
Expand Down
6 changes: 4 additions & 2 deletions datanode/sqlstore/amm_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ insert into amms(party_id, market_id, id, amm_party_id,
commitment, status, status_reason, parameters_base,
parameters_lower_bound, parameters_upper_bound,
parameters_leverage_at_lower_bound, parameters_leverage_at_upper_bound,
created_at, last_updated) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
created_at, last_updated, proposed_fee) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
on conflict (party_id, market_id, id, amm_party_id) do update set
commitment=excluded.commitment,
status=excluded.status,
Expand All @@ -61,7 +61,8 @@ on conflict (party_id, market_id, id, amm_party_id) do update set
parameters_upper_bound=excluded.parameters_upper_bound,
parameters_leverage_at_lower_bound=excluded.parameters_leverage_at_lower_bound,
parameters_leverage_at_upper_bound=excluded.parameters_leverage_at_upper_bound,
last_updated=excluded.last_updated;`,
last_updated=excluded.last_updated,
proposed_fee=excluded.proposed_fee;`,
pool.PartyID,
pool.MarketID,
pool.ID,
Expand All @@ -76,6 +77,7 @@ on conflict (party_id, market_id, id, amm_party_id) do update set
pool.ParametersLeverageAtUpperBound,
pool.CreatedAt,
pool.LastUpdated,
pool.ProposedFee,
); err != nil {
return fmt.Errorf("could not upsert AMM Pool: %w", err)
}
Expand Down
7 changes: 7 additions & 0 deletions datanode/sqlstore/migrations/0113_add_proposed_fee.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- +goose Up

ALTER TABLE amms ADD COLUMN IF NOT EXISTS proposed_fee numeric;

-- +goose Down

ALTER TABLE amms DROP COLUMN IF EXISTS proposed_fee;

0 comments on commit b40d2b6

Please sign in to comment.