Skip to content

fix: create order #3

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

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/orders/services/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/db/migration/000001_init.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion pkg/db/orders.sql.go

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

4 changes: 3 additions & 1 deletion pkg/db/query/orders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading