Make AlfredPay sell discounts executable - #1327
Open
ebma wants to merge 10 commits into
Open
Conversation
✅ Deploy Preview for vortexfi ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ Deploy Preview for vortex-sandbox failed. Why did it fail? →
|
❌ Deploy Preview for vrtx-dashboard failed. Why did it fail? →
|
ebma
force-pushed
the
codex/alfredpay-effective-target-discount
branch
from
August 11, 2026 18:14
e1ba562 to
d5dcf5f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Makes AlfredPay SELL discounts executable while enforcing provider, partner, bridge, and settlement limits.
Changes:
- Reconciles quotes against AlfredPay and Squid guaranteed terms.
- Hardens settlement, recovery, and residual cleanup.
- Expands contract, corridor, recovery, and security documentation coverage.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/shared/src/services/squidrouter/schemas.ts |
Validates guaranteed route output. |
packages/shared/src/services/squidrouter/schemas.test.ts |
Tests minimum-output validation. |
packages/shared/src/services/squidrouter/offramp.ts |
Returns the selected Squid route. |
packages/shared/src/services/alfredpay/schemas.ts |
Expands quote and order schemas. |
packages/shared/src/services/alfredpay/schemas.test.ts |
Tests expanded AlfredPay contracts. |
docs/security-spec/06-cross-chain/fund-routing.md |
Documents settlement guarantees and caps. |
docs/security-spec/05-integrations/alfredpay.md |
Documents SELL pricing and recovery. |
docs/security-spec/03-ramp-engine/ramp-phase-flows.md |
Documents flow v4 behavior. |
docs/security-spec/03-ramp-engine/quote-lifecycle.md |
Documents quote selection and replacement. |
docs/security-spec/03-ramp-engine/fee-integrity.md |
Documents reserve and subsidy accounting. |
docs/security-spec/03-ramp-engine/ephemeral-accounts.md |
Documents user-directed cleanup. |
docs/security-spec/03-ramp-engine/discount-mechanism.md |
Documents executable discount reconciliation. |
apps/api/src/tests/sdk-contract.alfredpay-offramp.test.ts |
Updates provider lifecycle simulation. |
apps/api/src/tests/corridors/mxn-offramp.scenario.test.ts |
Adds pricing and recovery scenarios. |
apps/api/src/tests/corridors/alfredpay-currencies.scenario.test.ts |
Updates multi-currency lifecycle behavior. |
apps/api/src/tests/contracts/alfredpay.contract.test.ts |
Expands provider contract coverage. |
apps/api/src/test-utils/fake-world/fake-squidrouter.ts |
Models guaranteed route output. |
apps/api/src/test-utils/fake-world/fake-evm.ts |
Models ERC-20 cleanup transfers. |
apps/api/src/test-utils/fake-world/fake-anchors.ts |
Models AlfredPay limits and orders. |
apps/api/src/api/services/phases/post-process/polygon-post-process-handler.ts |
Returns SELL residuals to users. |
apps/api/src/api/services/phases/blocks/README.md |
Documents block ownership. |
apps/api/src/api/services/phases/blocks/phases/final-settlement-subsidy/execution.ts |
Hardens capped settlement acquisition. |
apps/api/src/api/services/phases/blocks/phases/alfredpay-offramp/transactions.ts |
Binds preparation to guaranteed output. |
apps/api/src/api/services/phases/blocks/phases/alfredpay-offramp/simulation.ts |
Implements executable SELL pricing. |
apps/api/src/api/services/phases/blocks/phases/alfredpay-offramp/registration.ts |
Validates refreshed provider orders. |
apps/api/src/api/services/phases/blocks/phases/alfredpay-offramp/lifecycle.ts |
Preserves generic metadata typing. |
apps/api/src/api/services/phases/blocks/phases/alfredpay-offramp/execution.ts |
Hardens transfer and order recovery. |
apps/api/src/api/services/phases/blocks/flows/catalog.ts |
Simplifies persisted-flow resolution. |
apps/api/src/api/services/phases/blocks/flows/alfredpay-offramp.ts |
Advances AlfredPay SELL to flow v4. |
apps/api/src/api/services/phases/blocks/core/squidrouter.ts |
Exposes guaranteed route amounts. |
apps/api/src/api/services/phases/blocks/core/financial-operation.ts |
Adds request-shape recovery support. |
apps/api/src/api/services/phases/blocks/core/financial-operation.test.ts |
Tests durable-operation compatibility. |
apps/api/src/api/services/phases/blocks/__tests__/evm-executor-regressions.test.ts |
Tests acquisition and subsidy safeguards. |
apps/api/src/api/services/phases/blocks/__tests__/alfredpay-offramp.registration.test.ts |
Tests strict registration binding. |
apps/api/src/api/services/phases/blocks/__tests__/alfredpay-offramp.flow.test.ts |
Pins flow v4/schema 3. |
Suppressed comments (1)
packages/shared/src/services/alfredpay/schemas.ts:155
- The production
createOfframpandgetOfframpTransactionmethods still raw-cast JSON and never invoke this expanded schema. As a result, the recovery executor binds transfers and lifecycle decisions to unvalidated order identity, amounts, status, address, and expiry despite these fields now being security-critical. Apply this schema in both service methods before returning provider transactions.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+28
to
+32
| const squidrouterRouteEstimateSchema = z | ||
| .looseObject({ | ||
| aggregateSlippage: z.number().optional(), | ||
| toAmount: z.string().regex(RAW_UNITS), | ||
| toAmountMin: z.string().regex(RAW_UNITS), |
Comment on lines
106
to
+107
| export const alfredpayQuoteResponseSchema = z.looseObject({ | ||
| chain: z.enum(AlfredpayChain).optional(), |
Comment on lines
+123
to
+127
| if (operation.status === "not_started") { | ||
| // No financial side effect has been claimed yet. Refreshing a preflight's | ||
| // request is safe and lets legacy/live observations converge on the stable | ||
| // authorization used by the current executor. | ||
| await operation.update({ requestHash }); |
…fective-target-discount # Conflicts: # docs/security-spec/03-ramp-engine/quote-lifecycle.md # docs/security-spec/05-integrations/alfredpay.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Simplification
Commit structure
Validation
Notes