diff --git a/internal/orders/services/order.go b/internal/orders/services/order.go index 6d6e555..61805ed 100644 --- a/internal/orders/services/order.go +++ b/internal/orders/services/order.go @@ -43,6 +43,8 @@ type CreateOrderBody struct { Amount string `json:"amount" validate:"numeric,gt=0"` TwapTotalTime *int32 `json:"twapTotalTime" validate:"omitempty,gt=0"` Slippage float64 `json:"slippage" validate:"gte=0"` + Signature string `json:"signature" validate:"max=130"` + Paths string `json:"paths" validate:"max=256"` } func CreateOrder(ctx context.Context, body CreateOrderBody) (*db.Order, error) { @@ -102,7 +104,6 @@ func FillPartialOrder(ctx context.Context, parent db.Order, price, amount string } func MatchOrder(ctx context.Context, price *big.Float) (*db.Order, error) { - numericPrice, err := utils.BigFloatToNumeric(price) if err != nil { return nil, err diff --git a/pkg/db/migration/000001_init.up.sql b/pkg/db/migration/000001_init.up.sql index e07289b..9309f0a 100644 --- a/pkg/db/migration/000001_init.up.sql +++ b/pkg/db/migration/000001_init.up.sql @@ -61,7 +61,7 @@ CREATE TABLE IF NOT EXISTS orders ( amount NUMERIC(78,18) NOT NULL, slippage DOUBLE PRECISION, signature VARCHAR(130), -- 0x + 64 bytes for r, 64 bytes for s, 2 bytes for v - nonce BIGINT NOT NULL, + nonce BIGSERIAL NOT NULL, parent_id BIGINT, twap_interval_seconds INT, diff --git a/pkg/db/orders.sql.go b/pkg/db/orders.sql.go index 5792718..c46d3af 100644 --- a/pkg/db/orders.sql.go +++ b/pkg/db/orders.sql.go @@ -172,13 +172,15 @@ INSERT INTO orders ( price, amount, slippage, twap_interval_seconds, twap_executed_times, twap_current_executed_times, twap_min_price, twap_max_price, deadline, + signature, paths, partial_filled_at, filled_at, rejected_at, cancelled_at, created_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, - $17, $18, $19, $20) + $17, $18, $19, $20, + $21, $22) RETURNING id, pool_ids, paths, wallet, status, side, type, price, amount, slippage, signature, nonce, parent_id, twap_interval_seconds, twap_executed_times, twap_current_executed_times, twap_min_price, twap_max_price, deadline, partial_filled_at, filled_at, rejected_at, cancelled_at, created_at ` @@ -198,6 +200,8 @@ type InsertOrderParams struct { TwapMinPrice pgtype.Numeric `json:"twap_min_price"` TwapMaxPrice pgtype.Numeric `json:"twap_max_price"` Deadline pgtype.Timestamp `json:"deadline"` + Signature pgtype.Text `json:"signature"` + Paths string `json:"paths"` PartialFilledAt pgtype.Timestamp `json:"partial_filled_at"` FilledAt pgtype.Timestamp `json:"filled_at"` RejectedAt pgtype.Timestamp `json:"rejected_at"` @@ -222,6 +226,8 @@ func (q *Queries) InsertOrder(ctx context.Context, arg InsertOrderParams) (Order arg.TwapMinPrice, arg.TwapMaxPrice, arg.Deadline, + arg.Signature, + arg.Paths, arg.PartialFilledAt, arg.FilledAt, arg.RejectedAt, diff --git a/pkg/db/query/orders.sql b/pkg/db/query/orders.sql index 72908f2..f047000 100644 --- a/pkg/db/query/orders.sql +++ b/pkg/db/query/orders.sql @@ -4,13 +4,15 @@ INSERT INTO orders ( price, amount, slippage, twap_interval_seconds, twap_executed_times, twap_current_executed_times, twap_min_price, twap_max_price, deadline, + signature, paths, partial_filled_at, filled_at, rejected_at, cancelled_at, created_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, - $17, $18, $19, $20) + $17, $18, $19, $20, + $21, $22) RETURNING *; -- name: GetOrdersByWallet :many