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

[ANCHOR-749] Add SEP-38 validation documentation #943

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions openapi/anchor-platform/main-callbacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@ paths:
Either `sell_amount` or `buy_amount` will be included in requests as parameters, but never both. In the same way,
either `sell_delivery_method` and `buy_delivery_method` may be included in requests, but never both, since either
`sell_asset` or `buy_asset` is a Stellar asset.


Upon receiving the response, the Anchor Platform will validate the amount and price of the response.

If the validation fails, the Platform will respond to the client application's request with a HTTP status
code of `502 Bad Gateway`.

The `sell_mount`, `buy_amount`, `price`, and `fee` are validated as follows:
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: sell_amount


- if `rate.fee` exists,
- `rate.fee.asset` must be defined with proper `significant_decimals` in the asset configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does proper mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exists and positive.

- `rate.fee.total` must equal to the sum of `rate.fee.details.amount`.
- if the `rate.fee.asset == rate.sell_asset`, `sell_amount ~= price * buy_amount + fee` must hold true.
- if the `rate.fee.asset == rate.buy_asset`, `sell_amount ~= price * (buy_amount + fee)` must hold true.
- if `rate.fee` does not exist, `sell_amount ~= price * buy_amount` must hold true.

The `~=` is defined as equality within rounding error.
The rounding error is defined as `10^(-significant_decimals)`


tags:
- Rates
x-seps:
Expand Down
Loading