Skip to content

Add BlindPay shadow quote for USDC↔BRLA rebalances#1258

Closed
ebma wants to merge 2 commits into
stagingfrom
feat/rebalancer-blindpay-comparison
Closed

Add BlindPay shadow quote for USDC↔BRLA rebalances#1258
ebma wants to merge 2 commits into
stagingfrom
feat/rebalancer-blindpay-comparison

Conversation

@ebma

@ebma ebma commented Jul 8, 2026

Copy link
Copy Markdown
Member

What

Adds an observational BlindPay price comparison to the `usdc-brla-usdc-base` rebalancing route, to evaluate whether BlindPay is a cheaper source of stablecoin (USDT to feed into Nabla) than the routes we already use.

On each route comparison, `compareRoutesUpfront` now fetches a BlindPay shadow quote (payin BRL → USDT/USDB) in parallel with the SquidRouter / Avenia / Nabla quotes. It's:

  • Logged in the console comparison, alongside the executed routes.
  • Surfaced in the Slack completion notification, e.g.:
    ```
    BlindPay shadow (not routed): 95.220000 USDC-eq | vs SquidRouter 95.400000: -0.180000
    ```

Not routed

The shadow quote is never added to `candidates`, so BlindPay is never actually selected/executed — this is a data-gathering feature only. It never throws, and skips cleanly when BlindPay is unconfigured or the amount is below BlindPay's 5 BRL minimum.

Implementation

  • New `apps/rebalancer/src/services/blindpay/` — a minimal client for BlindPay's lightweight payin FX-rate endpoint (`POST /instances/{id}/payin-quotes/fx`), which needs only an API key + instance ID (no receiver/KYC/blockchain-wallet setup).
  • `fetchBlindpayShadowQuoteUsdc` returns a USDC-equivalent (6dp) quote for apples-to-apples comparison.
  • Threaded through preflight quotes → rebalance state → Slack completion message.
  • Optional `BLINDPAY_*` config (documented in `.env.example`).

Config

```
BLINDPAY_API_KEY=...
BLINDPAY_INSTANCE_ID=in_...
BLINDPAY_BASE_URL=https://api.blindpay.com/v1 # optional
BLINDPAY_TOKEN=USDT # sandbox/dev instances only support USDB
```

When `BLINDPAY_API_KEY`/`BLINDPAY_INSTANCE_ID` are unset, the shadow quote is skipped and the rebalancer behaves exactly as before.

Testing

  • `tsc` clean, all 56 rebalancer tests pass.
  • Verified live against the BlindPay sandbox: 500 BRL → 95.22 USDC-eq (~0.190 USD/BRL, tracks real BRL/USD); below-minimum amounts return null; Slack line renders with the delta vs the executed route and is absent when unconfigured.

Notes for reviewers / before prod

  • Sandbox returns realistic BRL/USD FX and exposes BlindPay's spread (0.1%) + flat fee ($0.10 on the test instance). Re-confirm fees on the production instance.
  • For production, set `BLINDPAY_TOKEN=USDC` or `USDT` — `USDB` is sandbox-only.

ebma added 2 commits July 8, 2026 10:33
…ute comparison

Adds an observational BlindPay payin FX quote (BRL -> USDT/USDB) alongside the
existing SquidRouter/Avenia/Nabla route quotes in compareRoutesUpfront, to
evaluate whether BlindPay is a cheaper source of stablecoin over time.

- New apps/rebalancer/src/services/blindpay: FX-rate client + types
- fetchBlindpayShadowQuoteUsdc returns a USDC-equivalent (6dp) quote, or null
  when unconfigured or below BlindPay's 5 BRL minimum
- Shadow only: logged in the route comparison but never added to candidates,
  so it is never actually routed through
- Optional BLINDPAY_* config; documented in .env.example
…otification

Threads the observational BlindPay shadow quote from compareRoutesUpfront through
the preflight quotes and rebalance state into the Base completion Slack message,
rendered as a 'BlindPay shadow (not routed)' line with the delta vs the executed
route. Absent when BlindPay is unconfigured.
@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for vortex-sandbox ready!

Name Link
🔨 Latest commit 6b2968d
🔍 Latest deploy log https://app.netlify.com/projects/vortex-sandbox/deploys/6a4e0c3346a85b00087a69d6
😎 Deploy Preview https://deploy-preview-1258--vortex-sandbox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for vortexfi ready!

Name Link
🔨 Latest commit 6b2968d
🔍 Latest deploy log https://app.netlify.com/projects/vortexfi/deploys/6a4e0c3393cc2c0008f896ab
😎 Deploy Preview https://deploy-preview-1258--vortexfi.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ebma ebma changed the title feat(rebalancer): BlindPay shadow quote for USDC↔BRLA rebalances Add BlindPay shadow quote for USDC↔BRLA rebalances Jul 8, 2026
@ebma

ebma commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Superseded by #1257, which already merged this feature (plus unit tests + a request timeout) into staging. Nothing left to merge here.

@ebma ebma closed this Jul 8, 2026
@ebma ebma deleted the feat/rebalancer-blindpay-comparison branch July 8, 2026 09:17
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.

1 participant