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

Implement XRP DEX order parsing -> EdgeTxAction's #641

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Conversation

Jon-edge
Copy link
Contributor

@Jon-edge Jon-edge commented Oct 11, 2023

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

EdgeApp/edge-core-js#567

Description

Parse XRP DEX orders into EdgeTxActions. Supports OfferCreate and OfferCancel type order tx's


/**
* Parse TakerGets or TakerPays into an EdgeAssetAmount
* */
parseRippleDexTxAmount = (
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

typeof takerAmount === 'string'
? { currency: 'XRP', issuer: undefined, value: takerAmount }
: takerAmount
const isTakerToken = currency !== 'XRP' && issuer != null
Copy link
Member

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'

Copy link
Contributor Author

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)
Copy link
Member

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.

Copy link
Contributor Author

@Jon-edge Jon-edge Oct 26, 2023

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.

@Jon-edge Jon-edge enabled auto-merge October 26, 2023 00:32
@Jon-edge Jon-edge disabled auto-merge October 26, 2023 00:36
@Jon-edge Jon-edge merged commit 5b2a67f into master Oct 26, 2023
1 of 3 checks passed
@Jon-edge Jon-edge deleted the jon/xrp-txinfo branch October 26, 2023 00:36
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.

2 participants