Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .agents/skills/epoch-widget/reference/props.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Required: `isOpen`, `onClose`, `api`. Everything else optional.
| `lockDestinationToken` | `boolean` | `true` | Pay-only; `false` lets user re-pick destination. Forced off in swap. |
| `usdPriceFor` | `(t:{chainId,address,symbol}) => number\|null\|Promise<number\|null>` | — | Resolver for "≈ $…" line. |
| `ctaLabels` | `Partial<{submit, switchNetwork, quoting, preparing, signing, submitting, polling, complete, insufficientBalance, configureRequired}>` | — | Per-state CTA copy. |
| `routingAndLiquidityOptions` | `RoutingAndLiquidityOptions` | `{ preset: "any" }` | Restrict solver routing for quote + submit. Presets: `any`, `filler-single-transaction`, `external-multi-transactions`, `custom`. |
| `earnDefaultTab` | `'deposit' \| 'withdraw'` | `'deposit'` | Earn starting tab. |
| `earnHideTabs` | `boolean` | `false` | Hide deposit/withdraw tabs. |
| `earnMarketsSource` | `OneDeltaConfig[]` | — | Static market configs (e.g. `HARDCODED_ONEDELTA_CONFIGS`). |
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
},
"dependencies": {
"@epoch-protocol/epoch-commons-sdk": "^0.1.14",
"@epoch-protocol/epoch-flows-sdk": "^0.1.1",
"@epoch-protocol/epoch-intents-sdk": "^1.0.26",
"@epoch-protocol/epoch-flows-sdk": "^0.1.2",
"@epoch-protocol/epoch-intents-sdk": "^1.0.27",
"clsx": "^2.1.1",
"tailwind-merge": "^2.6.1"
},
Expand Down
3 changes: 3 additions & 0 deletions src/EpochIntentWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function EpochIntentWidget(props: EpochIntentWidgetProps) {
usdPriceFor,
onSourceTokenChange,
onQuote,
routingAndLiquidityOptions,
} = props;

const rawMode = modeProp ?? flowProp ?? 'pay';
Expand Down Expand Up @@ -111,6 +112,7 @@ export function EpochIntentWidget(props: EpochIntentWidgetProps) {
usdPriceFor,
onSourceTokenChange,
onQuote,
routingAndLiquidityOptions,
};

if (!isConnected) {
Expand Down Expand Up @@ -162,6 +164,7 @@ export function EpochIntentWidget(props: EpochIntentWidgetProps) {
onSign={onSign}
onSuccess={onSuccess}
onStatus={onStatus}
routingAndLiquidityOptions={routingAndLiquidityOptions}
/>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/EarnIntentWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
OnStartCtx,
OnStatusCtx,
OnSuccessCtx,
RoutingAndLiquidityOptions,
} from '../types';
import { buildEarnDepositIntent } from '../earn/build-deposit-intent';
import { buildEarnWithdrawIntent } from '../earn/build-withdraw-intent';
Expand Down Expand Up @@ -124,6 +125,7 @@ interface EarnIntentWidgetProps {
onSign?: (ctx: OnSignCtx) => void;
onSuccess?: (ctx: OnSuccessCtx) => void;
onStatus?: (ctx: OnStatusCtx) => void;
routingAndLiquidityOptions?: RoutingAndLiquidityOptions;
}

export function EarnIntentWidget({
Expand Down Expand Up @@ -158,6 +160,7 @@ export function EarnIntentWidget({
onSign,
onSuccess,
onStatus,
routingAndLiquidityOptions,
}: EarnIntentWidgetProps) {
const sessionId = useSessionId(isOpen);
const { address, isConnected, connector } = useAccount();
Expand Down Expand Up @@ -603,6 +606,7 @@ export function EarnIntentWidget({
walletClient,
address,
sessionId,
routingAndLiquidityOptions,
onIntentSent,
onIntentComplete,
onError,
Expand Down
3 changes: 3 additions & 0 deletions src/components/PaySwapIntentWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export type PaySwapIntentWidgetProps = Pick<
| "usdPriceFor"
| "onSourceTokenChange"
| "onQuote"
| "routingAndLiquidityOptions"
> & {
/** `pay` vs `swap` — same SDK path; affects copy and `onStart` / internal `mode`. */
variant: "pay" | "swap";
Expand Down Expand Up @@ -115,6 +116,7 @@ export function PaySwapIntentWidget({
usdPriceFor,
onSourceTokenChange,
onQuote,
routingAndLiquidityOptions,
}: PaySwapIntentWidgetProps) {
// `lockDestinationToken` is a Pay-only concept — Swap UX always lets the
// user pick what they receive. Force-disable for Swap regardless of the
Expand Down Expand Up @@ -379,6 +381,7 @@ export function PaySwapIntentWidget({
sessionId,
mode: variant,
receiver,
routingAndLiquidityOptions,
onIntentSent,
onIntentComplete,
onRequestClose: onClose,
Expand Down
14 changes: 13 additions & 1 deletion src/earn/use-earn-intent-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { keccak256, parseUnits, toBytes } from 'viem';
import type { WalletClient } from 'viem';
import { TaskType } from '@epoch-protocol/epoch-commons-sdk';
import { CollateralType, EpochIntentSDK } from '@epoch-protocol/epoch-intents-sdk';
import type { RoutingAndLiquidityOptions } from '../types';
import type {
EarnMidenCreateP2IDNote,
EpochEarnMarket,
Expand Down Expand Up @@ -84,6 +85,7 @@ interface UseEarnIntentFlowParams {
sessionId: string;
/** @deprecated SIO now selects the solver via smallocator; this prop is ignored. */
earnSolverUrl?: string;
routingAndLiquidityOptions?: RoutingAndLiquidityOptions;
onIntentSent?: (data: IntentSentPayload) => void;
onIntentComplete?: (data: IntentCompletePayload) => void;
onError?: (ctx: OnErrorCtx) => void;
Expand Down Expand Up @@ -137,6 +139,7 @@ export function useEarnIntentFlow({
address,
walletClient,
sessionId,
routingAndLiquidityOptions,
onIntentSent,
onIntentComplete,
onError,
Expand Down Expand Up @@ -385,6 +388,9 @@ export function useEarnIntentFlow({
taskTypeString,
intentData,
isNative: false,
...(routingAndLiquidityOptions
? { routingAndLiquidityOptions }
: {}),
});

if (callId !== quoteCallIdRef.current || !mountedRef.current) return;
Expand Down Expand Up @@ -419,7 +425,7 @@ export function useEarnIntentFlow({
setStatus('idle');
}
},
[address, walletClient, apiBaseUrl, buildParams],
[address, walletClient, apiBaseUrl, buildParams, routingAndLiquidityOptions],
);

// ---- Poll intent status ---------------------------------------------------
Expand Down Expand Up @@ -515,6 +521,9 @@ export function useEarnIntentFlow({
taskTypeString,
intentData,
isNative: false,
...(routingAndLiquidityOptions
? { routingAndLiquidityOptions }
: {}),
});
if (!qr?.success) {
throw new Error((qr as { error?: string } | undefined)?.error ?? 'Quote failed');
Expand All @@ -532,6 +541,9 @@ export function useEarnIntentFlow({
taskTypeString,
intentData,
quoteResult,
...(routingAndLiquidityOptions
? { routingAndLiquidityOptions }
: {}),
};

if (submitParams.isMidenDeposit && input.midenSource) {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type {
OnErrorCtx,
OnStatusCtx,
WidgetLifecycleStatus,
RoutingAndLiquidityOptions,
} from './types';
export { DEFAULT_THEME, LIGHT_THEME, DARK_THEME, resolveTheme, themeToCssVars } from './theme';
export { cn } from './lib/cn';
Expand Down
11 changes: 9 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type {
OneDeltaMarketRow,
OneDeltaTokenRisk,
OneDeltaUnderlyingAsset,
RoutingAndLiquidityOptions,
SessionCtx,
WidgetFlow,
WidgetMode,
Expand All @@ -49,6 +50,7 @@ import type {
OneDeltaConfig,
WidgetFlow,
WidgetMode,
RoutingAndLiquidityOptions,
} from '@epoch-protocol/epoch-flows-sdk';

/** SDK config plus widget-only testnet endpoint overrides. */
Expand Down Expand Up @@ -295,12 +297,17 @@ export interface EpochIntentWidgetProps {
earnPoolsSortDir?: 'ASC' | 'DESC';
/** @deprecated retained for backwards compatibility. */
earnUseMockData?: boolean;
/**
* Optional Miden wallet adapter for funding earn deposits from Miden (testnet).
/** Optional Miden wallet adapter for funding earn deposits from Miden (testnet).
* Requires a connected EVM wallet as intent sponsor; Miden supplies collateral via P2IDE note.
*/
earnMiden?: EarnMidenAdapter;

/**
* Restrict which solver liquidity paths SIO may quote for pay, swap, and earn flows.
* Use the same value for quote and submit. Defaults to `{ preset: "any" }` when omitted.
*/
routingAndLiquidityOptions?: RoutingAndLiquidityOptions;

// ---- API ------------------------------------------------------------------

api: ApiConfig;
Expand Down
5 changes: 5 additions & 0 deletions src/use-intent-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
OnSignCtx,
OnSuccessCtx,
OnErrorCtx,
RoutingAndLiquidityOptions,
WidgetFlow,
} from './types';

Expand All @@ -29,6 +30,7 @@ interface UseIntentFlowParams {
sessionId: string;
mode: WidgetFlow;
receiver?: `0x${string}`;
routingAndLiquidityOptions?: RoutingAndLiquidityOptions;
onIntentSent?: (data: IntentSentPayload) => void;
onIntentComplete?: (data: IntentCompletePayload) => void;
onError?: (error: Error) => void;
Expand Down Expand Up @@ -71,6 +73,7 @@ export function useIntentFlow(params: UseIntentFlowParams): UseIntentFlowReturn
sessionId,
mode,
receiver,
routingAndLiquidityOptions,
onIntentSent,
onIntentComplete,
onError,
Expand Down Expand Up @@ -136,6 +139,7 @@ export function useIntentFlow(params: UseIntentFlowParams): UseIntentFlowReturn
intentConfig,
isTestnet,
receiver,
routingAndLiquidityOptions,
});
sessionRef.current = session;

Expand Down Expand Up @@ -183,6 +187,7 @@ export function useIntentFlow(params: UseIntentFlowParams): UseIntentFlowReturn
mode,
isTestnet,
receiver,
routingAndLiquidityOptions,
// Hot deps for the session config — recreating on intent shape changes is
// fine because typed-data signing is per-submit anyway.
requiredToken,
Expand Down