-
Notifications
You must be signed in to change notification settings - Fork 308
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
Transfer SEPS: deprecate refunded
boolean, add refunds
object to transaction records
#1128
Conversation
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.
👏🏻 Thanks for progressing this discussion to a PR. I have started a few conversations inline.
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.
Looks good to me. I think we should get weigh in from a variety of folks before merging.
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.
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
#### 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`. | ||
|
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.
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?
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.
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.
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.
Sure, I can add a fee
attribute. Shouldn't we have a total_fee
attribute or something similar alongside amount_refunded
then?
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.
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?
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.
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"
}
]
}
}
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.
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. |
---|
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.
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.
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.
Yes thats right. In fact I think those formulas are worth including in the specifications.
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.
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.
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 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.
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
Co-authored-by: Leigh McCulloch <[email protected]>
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 |
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.
@JakeUrban revisiting this just for clarification: does it mean the user is paying for the fees related to the refunds?
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.
Yes, if the anchor charges fees for processing a refund.
@JakeUrban FYI the PR title still says "refund" instead of "refunds" |
Same for the PR description |
refunded
boolean, add refund
object to transaction recordsrefunded
boolean, add refunds
object to transaction records
resolves #1122
Deprecates the
refunded
attribute included in objects returned fromGET /transaction(s)
endpoints for SEP-6, 24, & 31 in favor of adding arefund
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).