Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

buck54321
Copy link
Member

This should give us some direction for how trading will work.

Comment on lines -27 to -31
// 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"`
Copy link
Member Author

@buck54321 buck54321 Jan 29, 2025

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.
@buck54321 buck54321 force-pushed the tanka-order-validate branch from 1994ddf to 83e57fd Compare January 29, 2025 02:20
Copy link
Collaborator

@martonp martonp left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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
Copy link
Collaborator

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
Copy link
Collaborator

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ord.Expiration.Equal(ord.Stamp) || ord.Expiration.Before(ord.Stamp) {
if !ord.Stamp.After(ord.Expiration) {

Copy link
Member

@JoeGruffins JoeGruffins left a 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants