-
Notifications
You must be signed in to change notification settings - Fork 103
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
tatanka/trade: add order compatibility and matching functions #3165
base: master
Are you sure you want to change the base?
Conversation
// MinFeeRate: Tatankanet does not prescribe a fee rate on an order, but it | ||
// does supply a suggested fee rate that is updated periodically. The user's | ||
// UI should ignore an order from the order book if its MinFeeRate falls | ||
// below the Tatnkanet suggested rate. | ||
MinFeeRate uint64 `json:"minFeeRate"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be part of the order. This is a dynamic quantity based on the mesh's fee rate oracle service, and only needs to be confirmed as part of the match request sent to the counterparty.
This should give us some direction for how trading will work.
1994ddf
to
83e57fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
ReasonTheirQtyTooSmall = "their order size is less than our lot size" | ||
) | ||
|
||
// OrderIsMatchable determines whether a given standling limit order is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// OrderIsMatchable determines whether a given standling limit order is | |
// OrderIsMatchable determines whether a given standing limit order is |
// ## Dividing both size by qty | ||
// 1 / lot_size < max_fee_exposure / (base_fees_per_lot + (quote_fees_per_lot / rate)) | ||
// ## Fliparoo | ||
// lot_size > (base_fees_per_lot + (quote_fees_per_lot / rate)) / max_fee_exposure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conclusion is already pretty intuitive.
// 1 / lot_size < max_fee_exposure / (base_fees_per_lot + (quote_fees_per_lot / rate)) | ||
// ## Fliparoo | ||
// lot_size > (base_fees_per_lot + (quote_fees_per_lot / rate)) / max_fee_exposure | ||
atomicRate := float64(msgRate) / calc.RateEncodingFactor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember we were discussing changing RateEncodingFactor
to be more flexible.
return blake256.Sum256(b) | ||
|
||
} | ||
|
||
func (ord *Order) Valid() error { | ||
// Check whether the lot size is a power of 2, using binary ju-jitsu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Check whether the lot size is a power of 2, using binary ju-jitsu. | |
// Check whether the lot size is a power of 2, using binary jiu-jitsu. |
if ord.Rate == 0 { | ||
return errors.New("order rate is zero") | ||
} | ||
if ord.Expiration.Equal(ord.Stamp) || ord.Expiration.Before(ord.Stamp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ord.Expiration.Equal(ord.Stamp) || ord.Expiration.Before(ord.Stamp) { | |
if !ord.Stamp.After(ord.Expiration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the match falls through will that go directly to the books? There would be stages to falling through, initially the counterparty could just say no I assume? In that case it might go the books, but if a trade started and failed after that, maybe we would get a notification and error and it doesnt go to the order book?
This should give us some direction for how trading will work.