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

Transfer SEPS: deprecate refunded boolean, add refunds object to transaction records #1128

Merged
merged 26 commits into from
Feb 17, 2022

Conversation

JakeUrban
Copy link
Contributor

@JakeUrban JakeUrban commented Feb 15, 2022

resolves #1122

Deprecates the refunded attribute included in objects returned from GET /transaction(s) endpoints for SEP-6, 24, & 31 in favor of adding a refund object.

This refund object contains information about the type of refund, total amount refunded, and the individual payments made back to the sender / user.

Note that SEP-31 refunds are assumed to be made via Stellar (since funds are always delivered to receiving anchors via Stellar).

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

👏🏻 Thanks for progressing this discussion to a PR. I have started a few conversations inline.

ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
leighmcculloch
leighmcculloch previously approved these changes Feb 16, 2022
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

Looks good to me. I think we should get weigh in from a variety of folks before merging.

Copy link
Contributor

@marcelosalloum marcelosalloum left a comment

Choose a reason for hiding this comment

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

It's looking good! Could you add a changelog section to these SEPs as (recently) suggested in the SEP template? https://github.com/stellar/stellar-protocol/blob/master/sep-template.md#changelog.

No need to include previous versions there, tracking this and future changes is great to start with.

ecosystem/sep-0006.md Outdated Show resolved Hide resolved
Comment on lines 1022 to 1029
#### Refund Transactions Object Schema

Name | Type | Description
-----|------|------------
`id` | string | The payment ID that can be used to identify the refund payment. This is either a Stellar transaction hash or an off-chain payment identifier, such as a reference number provided to the user when the refund was initiated.
`id_type` | string | `stellar` or `external`.
`amount` | string | The amount sent back to the user for the payment identified by `id`.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's common for exchanges to charge a refund fee in case something goes wrong with the transaction. Shouldn't we include some kind of fee field as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

For Stellar network payments, the anchor could add 2 transactions, one for the refund and the other for the refund fee, but that may not be practical for bank transfers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can add a fee attribute. Shouldn't we have a total_fee attribute or something similar alongside amount_refunded then?

Copy link
Member

@leighmcculloch leighmcculloch Feb 16, 2022

Choose a reason for hiding this comment

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

Is the idea with the fee attribute that this would represented an amount that the user no longer has a right to, but was not included in the refund transaction? How would this affect the amount refunded?

For example:

  • Original deposit $100.
  • Anchor needs to refund $25, charges $5 per refund.
  • Amount refunded = $25? or $20?
  • Refunds includes a single refund with id and amount.
  • What value does the refunds.payments[0].amount field hold? Is it $25, or $20?

Copy link
Contributor Author

@JakeUrban JakeUrban Feb 16, 2022

Choose a reason for hiding this comment

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

My understanding is that it would look like this:

  • Original deposit $100
  • Anchor needs to refund $25, and charges $5 per refund
  • Lets say that anchor charges a $5 flat fee for transactions (regardless of refund)
  • 100 (amount in) - 25 (refund) - 5 (tx fee) - 5 (refund fee) = 65 (amount out)

So:

{
  ...
  "amount_in": "100",
  "amount_out": "65",
  "amount_fee": "5",
  "refunded": false,
  "refunds": {
    "amount_refunded": "25",
    "total_fee": "5",
    "payments": [
      {
        "id": "<stellar hash>"
        "id_type": "stellar",
        "amount": "25",
        "fee": "5"
      }
    ]
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense to me too, since it's consistent with the amount_in description:

amount_in string (optional) Amount received by anchor at start of transaction as a string with up to 7 decimals. Excludes any fees charged before the anchor received the funds.

Copy link
Member

@leighmcculloch leighmcculloch Feb 16, 2022

Choose a reason for hiding this comment

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

Got it, so is it correct that this formula should balance to zero?

amount_in
– amount_out
– amount_fee
– refunds.amount_refunded
– refunds.total_fee

And:

refunds.amount_refunded = sum(refunds.payments[].amount
refunds.total_fee = sum(refunds.payments[].fee)

refunds.total_fee should be named refunds.amount_fee I think for consistency with other amount fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes thats right. In fact I think those formulas are worth including in the specifications.

Copy link
Member

Choose a reason for hiding this comment

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

Amount received by anchor at start of transaction as a string with up to 7 decimals. Excludes any fees charged before the anchor received the funds.

The excludes statement is ambiguous to me. When I read it I can't tell if it means the amount_in has already had fees excluded, i.e. I'm depositing $100, but amount_in will be $95 because it excludes the fee I paid.

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 agree, the amount_in definitions statement about "fees charged before the anchor received the funds" is nonsensical. I'd rather not remove that text in this PR though. I think the formulas make it clear, which I've added.

ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0024.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0024.md Outdated Show resolved Hide resolved
ecosystem/sep-0031.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Show resolved Hide resolved
ecosystem/sep-0024.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Outdated Show resolved Hide resolved
ecosystem/sep-0006.md Show resolved Hide resolved
ecosystem/sep-0024.md Show resolved Hide resolved
ecosystem/sep-0031.md Show resolved Hide resolved
The following should hold true for all transaction records, assuming `amount_in_asset` and `amount_out_asset` are the same. If they are different, the following should still hold true after converting all amounts to units of one of the assets.

```
amount_out = amount_in - amount_fee - refunds.amount_refunded - refunds.amount_fee
Copy link
Contributor

Choose a reason for hiding this comment

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

@JakeUrban revisiting this just for clarification: does it mean the user is paying for the fees related to the refunds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, if the anchor charges fees for processing a refund.

ecosystem/sep-0006.md Outdated Show resolved Hide resolved
@CassioMG
Copy link
Contributor

@JakeUrban FYI the PR title still says "refund" instead of "refunds"

@CassioMG
Copy link
Contributor

@JakeUrban FYI the PR title still says "refund" instead of "refunds"

Same for the PR description

@JakeUrban JakeUrban changed the title Transfer SEPS: deprecate refunded boolean, add refund object to transaction records Transfer SEPS: deprecate refunded boolean, add refunds object to transaction records Feb 17, 2022
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.

SEP-24: Withdraw transaction refund handling.
6 participants