Last active
March 17, 2019 23:59
-
-
Save adrake33/f8877156a5d2a703ff2dd0d6a7ef2fb9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface GetOrdersResults { | |
[marketId: string]: { | |
[outcome: number]: { | |
[orderType: string]: { | |
[orderId: string]: Order; | |
}; | |
}; | |
}; | |
} | |
export interface Order { | |
amount: string, // fullPrecisionAmount (rounded) | |
creationBlockNumber: number, // Block number of OrderCreated event | |
creationTime: number, // Block timestamp of OrderCreated event | |
fullPrecisionAmount: string, // Not sure what the best way to get this is? | |
fullPrecisionPrice: string, // Not sure what the best way to get this is? | |
logIndex: // Block log index of OrderCreated event | |
orderId: OrderId, // OrderCreated.orderId | |
orderState: OrderState, // Not sure what the best way to get this is? | |
originalAmount: string, // OrderCreated.amount (rounded) | |
originalFullPrecisionAmount: string, // OrderCreated.amount | |
originalSharesEscrowed: string, // OrderCreated.sharesEscrowed | |
originalTokensEscrowed: string, // OrderCreated.moneyEscrowed | |
owner: Address, // OrderCreated.creator | |
price: string, // fullPrecisionPrice (rounded) | |
shareToken: Address, // OrderCreated.shareToken | |
sharesEscrowed: string, // OrderCreated.sharesEscrowed | |
tokensEscrowed: string, // OrderCreated.moneyEscrowed | |
transactionHash: TransactionHash, // Block transaction hash of OrderCreated event | |
} |
This getter can be used in either situation. (There is an optional creator
parameter, and either a universe
or market
address must be specified.) We can retrieve/calculate the full precision amounts depending on whether the creator
is specified. We can also rename the "full precision" values to something else and get rid of the order state.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this used to get a user's open orders or the orders for a market?
If its to get orders for a market we're going to just get this off chain instead of via logs and processing.
If its to get a user's orders:
The full precision amounts can be calculated in the getter (and please god can we rename them to something else since they actually involve a loss of precision...).
The order state can probably be removed. There are no orphaned orders in v2 so the only states that can exist are:
where Filled/Canceled mean the order won't show up in either case and Open == amount > 0