feat: add ows swap quote command via LI.FI#192
feat: add ows swap quote command via LI.FI#192Sertug17 wants to merge 1 commit intoopen-wallet-standard:mainfrom
Conversation
Part of open-wallet-standard#125 Adds ows swap quote — a dry-run cross-chain swap route lookup powered by LI.FI's aggregation API (27 bridges, 31 DEXs, 58 chains). - ows-pay: new swap.rs module with LI.FI quote client, token amount formatting, SwapParams/SwapResult types, swap_dry_run() - ows-cli: new swap subcommand with ows swap quote --wallet --from --to --amount --from-chain --to-chain --slippage --order - No signing in this PR — quote only, transaction_request returned for future signing integration - 3 unit tests for amount formatting (format_amount)
|
@Sertug17 is attempting to deploy a commit to the MoonPay Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5b1e6aa. Configure here.
| 6u32 | ||
| } else { | ||
| 18u32 | ||
| }; |
There was a problem hiding this comment.
Hardcoded decimals wrong for most token types
High Severity
The decimal heuristic only recognizes USDC and USDT as 6-decimal tokens and defaults everything else to 18. Common tokens like WBTC (8 decimals), GUSD (2 decimals), or any other non-18-decimal token will have amount_to_raw produce a wildly incorrect raw amount. For example, swapping 0.1 WBTC computes a fromAmount of 10^17 instead of 10^7 — off by a factor of 10 billion — resulting in a completely wrong quote from the LI.FI API.
Reviewed by Cursor Bugbot for commit 5b1e6aa. Configure here.
| crate::error::PayErrorCode::HttpStatus, | ||
| format!("LI.FI API error {status}: {body}"), | ||
| )); | ||
| } |
There was a problem hiding this comment.
Third-party API response body included in error
Low Severity
The full LI.FI API error response body is captured via resp.text() and embedded verbatim into the PayError message, which then propagates to the CLI and gets printed. This includes an unfiltered third-party payload in error output, violating the sensitive data logging rule that prohibits logging full HTTP response bodies or third-party payloads.
Triggered by team rule: Sensitive Data Logging Best Practices
Reviewed by Cursor Bugbot for commit 5b1e6aa. Configure here.


Part of #125
Adds
ows swap quote— a dry-run cross-chain swap route lookup powered by LI.FI's aggregation API (27 bridges, 31 DEXs, 58 chains).Usage
Changes
ows-pay: new
swap.rsmodule/v1/quoteAPI client (no SDK dependency, pure REST)SwapParams/SwapResulttypesswap_dry_run()— fetches route, formats amounts, returns resultformat_amountows-cli: new
swapsubcommandows swap quotewith flags:--wallet,--from,--to,--amount,--from-chain,--to-chain,--slippage,--orderNot included in this PR
ows bridgealias (same asows swapwith--to-chain)ows swap execute(after signing integration)max_value_usd/allowed_tokenspolicy rulesNote
Medium Risk
Introduces a new external HTTP integration (LI.FI) and new CLI surface area; while it’s quote-only (no signing), failures or parameter/amount formatting issues could impact user output and reliability.
Overview
Adds a new
ows swap quoteCLI subcommand that loads a wallet, derives an EVM address, converts the user’s amount to a raw integer string, and prints a swap/bridge route summary (min received, tool, gas estimate, duration) as a dry-run.Introduces a new
ows-payswapmodule that calls LI.FI’s/v1/quoteREST API, deserializes the response, formats token amounts by decimals, and exposesSwapParams,SwapResult, andswap_dry_run()(with unit tests forformat_amount).Reviewed by Cursor Bugbot for commit 5b1e6aa. Bugbot is set up for automated code reviews on this repo. Configure here.