Documentation Index
Fetch the complete documentation index at: https://mintlify.com/availproject/nexus-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Intent types represent operations that require user approval, including bridge intents, swap intents, and token allowances.
ReadableIntent
Human-readable representation of a bridge intent, including source routing, destination details, and fee breakdown.
Top-level fields
Selected source chains and amounts (funds that will be pulled)
Amount from this source (human-readable)
Source chain information
Chain name (e.g., “Ethereum”, “Polygon”)
Token information
Token symbol (e.g., “USDC”, “ETH”)
chainLogo
string | undefined
deprecated
Use chain.logo instead
Use token.contractAddress instead
All available source options before user selection. Same structure as sources
Destination chain and amount details
Destination amount (human-readable)
Destination chain logo URL
Comprehensive fee breakdown
Chain abstraction gas fee
Gas supplied to destination chain
Total fees (sum of all fee components)
Token being bridged
Token name (e.g., “USD Coin”)
Token symbol (e.g., “USDC”)
Total amount from all sources combined (human-readable)
Example usage
sdk.setOnIntentHook(({ intent, allow, deny }) => {
console.log('Bridge Intent:');
console.log(`Token: ${intent.token.symbol}`);
console.log(`To: ${intent.destination.chainName}`);
console.log(`Amount: ${intent.destination.amount}`);
console.log('\nSources:');
intent.sources.forEach((source) => {
console.log(` ${source.chain.name}: ${source.amount} ${source.token.symbol}`);
});
console.log('\nFees:');
console.log(` Protocol: ${intent.fees.protocol}`);
console.log(` Solver: ${intent.fees.solver}`);
console.log(` CA Gas: ${intent.fees.caGas}`);
console.log(` Total: ${intent.fees.total}`);
if (userApproves) {
allow();
} else {
deny();
}
});
SwapIntent
Human-readable representation of a swap operation.
Source tokens and amounts to swap
Source amount (human-readable)
Destination token and amount details
Output amount (human-readable)
Destination chain information (same structure as source chain)
Output token information (same structure as source token)
Gas supplied for destination
Gas amount (human-readable)
Gas token information (same structure as source token)
Example usage
sdk.setOnSwapIntentHook(async ({ intent, allow, deny, refresh }) => {
console.log('Swap Intent:');
console.log('\nFrom:');
intent.sources.forEach((source) => {
console.log(` ${source.chain.name}: ${source.amount} ${source.token.symbol}`);
});
console.log('\nTo:');
const dest = intent.destination;
console.log(` ${dest.chain.name}: ${dest.amount} ${dest.token.symbol}`);
console.log(` Gas: ${dest.gas.amount} ${dest.gas.token.symbol}`);
if (userApproves) {
allow();
} else {
deny();
}
});
Hook data structures
OnIntentHookData
Data passed to the intent hook for bridge operations.
Function to approve the intent and proceed with the operation
Function to reject the intent. Throws USER_DENIED_INTENT error
refresh
(selectedSources?: number[]) => Promise<ReadableIntent>
required
Function to refresh the intent, optionally with different source chainsParameters:
selectedSources - Optional array of chain IDs to use as sources
Returns: Updated ReadableIntent with new routing and fees
type OnIntentHook = (data: OnIntentHookData) => void;
sdk.setOnIntentHook(({ intent, allow, deny, refresh }) => {
// Your approval UI logic
});
OnSwapIntentHookData
Data passed to the swap intent hook.
The swap intent awaiting user approval. See SwapIntent
Function to approve the swap and proceed
Function to reject the swap. Throws USER_DENIED_INTENT error
refresh
() => Promise<SwapIntent>
required
Function to refresh the swap quote with updated market rates
type OnSwapIntentHook = (data: OnSwapIntentHookData) => void;
sdk.setOnSwapIntentHook(({ intent, allow, deny, refresh }) => {
// Your swap approval UI logic
});
OnAllowanceHookData
Data passed to the allowance hook for token approvals.
sources
AllowanceHookSources
required
Array of tokens requiring approval
Current and required allowance amounts
Current allowance (human-readable)
Current allowance (atomic units)
Minimum required allowance (human-readable)
Minimum required allowance (atomic units)
allow
(amounts: Array<'max' | 'min' | bigint | string>) => void
required
Function to approve allowances. Pass an array with one value per source:
'max' - Approve unlimited (type(uint256).max)
'min' - Approve exact minimum required
bigint or string - Approve specific amount
Function to reject the allowance request. Throws USER_DENIED_ALLOWANCE error
Allowance examples
sdk.setOnAllowanceHook(({ sources, allow, deny }) => {
console.log('Allowance Required:');
sources.forEach((source) => {
console.log(`\n${source.chain.name}:`);
console.log(` Token: ${source.token.symbol}`);
console.log(` Current: ${source.allowance.current}`);
console.log(` Required: ${source.allowance.minimum}`);
});
if (userApproves) {
allow(['min']); // Approve minimum for all sources
} else {
deny();
}
});