Skip to main content

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

sources
object[]
required
Selected source chains and amounts (funds that will be pulled)
allSources
object[]
required
All available source options before user selection. Same structure as sources
destination
object
required
Destination chain and amount details
fees
object
required
Comprehensive fee breakdown
token
object
required
Token being bridged
sourcesTotal
string
required
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.
sources
object[]
required
Source tokens and amounts to swap
destination
object
required
Destination token and amount details

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.
intent
ReadableIntent
required
The intent awaiting user approval. See ReadableIntent
allow
() => void
required
Function to approve the intent and proceed with the operation
deny
() => void
required
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.
intent
SwapIntent
required
The swap intent awaiting user approval. See SwapIntent
allow
() => void
required
Function to approve the swap and proceed
deny
() => void
required
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
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
deny
() => void
required
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();
  }
});