-
Notifications
You must be signed in to change notification settings - Fork 39
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
Implement XRP DEX order parsing -> EdgeTxAction's #641
Conversation
3cba915
to
2d3462c
Compare
/** | ||
* Parse TakerGets or TakerPays into an EdgeAssetAmount | ||
* */ | ||
parseRippleDexTxAmount = ( |
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.
Replace most of parseRippleDexTxAmount and processRippleDexTx with getBalances to determine src/dest amounts of order fulfillments.
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 way I had it done is more accurate and complete according to xrpscan.com.
The balances object is good for including mainnet fees in the xrp amount total, but for some reason underreports the actual amounts involved in the trades (regardless of fees - token amounts are underreported). Also there's no way to tell unfilled order amounts from the Balances
obj either.
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.
Comparing against xrpscan.com shows alignment between my amounts and the summary amounts given by api queries to xrp explorers
2d3462c
to
aff0775
Compare
typeof takerAmount === 'string' | ||
? { currency: 'XRP', issuer: undefined, value: takerAmount } | ||
: takerAmount | ||
const isTakerToken = currency !== 'XRP' && issuer != null |
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.
Should be an assert case if currency !== 'XRP' && issuer == null
. Token check is just currency !== 'XRP'
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'll add the assert, but we still need to keep the entire isTakerToken
statement, or else makeTokenId
right after complains
|
||
// Parse amounts | ||
const { TakerPays, TakerGets } = tx | ||
sourceAsset = this.parseRippleDexTxAmount(TakerGets) |
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 always get the amounts from the tx
object. But in the case of a partial order fulfillment, the correct amounts are in the Nodes.
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.
We don't actually display the amounts from the GUI at this time.
This implementation is tracking 2 things consistently across all order states: the state of the order, and the posted order amount.
Fill amount is a completely separate thing and I think is a mistake to conflate into the source/destAsset
amounts described here. We also don't differentiate full and partial fills in the GUI right now, either.
If we only track fill amount, we actually are mis-reporting later down the road when the order status changes. We won't have knowledge of that unless we go back and modify related transactions as we process newer transactions. Imo, fill amount should be a completely separate field.
At this point in time, the only thing we are certain of is the total amounts of the original offer. Even if we have a partial fill immediately upon posting, we don't know if a later tx from someone else further modified the fill amount.
aff0775
to
f6a3157
Compare
f6a3157
to
08ac642
Compare
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
EdgeApp/edge-core-js#567
Description
Parse XRP DEX orders into EdgeTxActions. Supports OfferCreate and OfferCancel type order tx's