You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to map out what information we get about trades from the new ingestion system. We also need to know what the output to BigQuery should look like. Part of #19.
Why
This issue helps us know what information about trades we can get from the ingestion system and what information may have to be reconstructed or omitted.
The text was updated successfully, but these errors were encountered:
Trades are more complicated because they can happen in a variety of different ways. Trades are effects of operations, not operations themselves. The operations that can cause a trade to occur are: OperationTypeManageBuyOffer, OperationTypeManageSellOffer, OperationTypeCreatePassiveSellOffer, OperationTypePathPaymentStrictSend, and OperationTypePathPaymentStrictReceive. We can use a LedgerTransactionReader to look through all the transactions and their operations. If one of previously listed operations is part of the transaction and it is successful, then by checking the corresponding entry in the Results field, we can get more info. The entry in Results contains types like PathPaymentStrictReceiveResult or ManageOfferResult, depending on the base type of the operation. These structs have a Success field, which has a slice of the Offers that got claimed while creating the operation. These ClaimOfferAtom structs look like
Each one represents a trade that occurred as an effect from the base operation. For a given transaction tx, we can get the transaction itself as info := tx.Envelope.V1.Tx and we can get the trade array as trades := tx.Result.Results[operationIndex].Tr.(operationType)Result.Success.Offers. In order to reconstruct the trade table we need:
order: integer - get from the offer's index in the slice
ledger_closed_at: timestamp - from ledger.LedgerHeader.ScpValue.CloseTime
offer_id: integer - get from trades[order].OfferId
base_account_id: integer - get from trades[order].SellerId
base_asset_id: integer - get from trades[order].AssetSold
base_amount: integer - get from trades[order].AmountSold
counter_account_id: integer - get from info.SourceAccount.ToAccountId()
counter_asset_id: integer - get from trades[order].AssetBought
counter_amount: integer - get from trades[order].AmountBought
base_is_seller: boolean - true
base_offer_id: integer - TODO: horizon uses synthetic ids here; figure out how to replicate
counter_offer_id: integer - TODO: horizon uses synthetic ids here; figure out how to replicate
What
We need to map out what information we get about trades from the new ingestion system. We also need to know what the output to BigQuery should look like. Part of #19.
Why
This issue helps us know what information about trades we can get from the ingestion system and what information may have to be reconstructed or omitted.
The text was updated successfully, but these errors were encountered: