Nexus Elements - Deposit
Overview
Install the NexusDeposit widget for a full swap-and-execute deposit flow with unified balances, fee preview, and progress UI.
Prerequisites
- NexusProvider installed and initialized on wallet connect.
- Wallet connection configured.
- You can build an execute call (contract address + encoded data) for the target protocol.
Install (shadcn registry)
- Ensure shadcn/ui is initialized (
components.json exists).
- Ensure registry mapping exists:
"registries": {
"@nexus-elements/": "https://elements.nexus.availproject.org/r/{name}.json"
}
- Install:
npx shadcn@latest add @nexus-elements/deposit
Alternative:
npx shadcn@latest add https://elements.nexus.availproject.org/r/deposit.json
Manual install (no shadcn)
- Download
https://elements.nexus.availproject.org/r/deposit.json.
- Create each file in
files[].target with files[].content.
- Install dependencies listed in
dependencies and each registryDependencies item.
Usage
import NexusDeposit from "@/components/deposit/nexus-deposit";
import {
SUPPORTED_CHAINS,
TOKEN_CONTRACT_ADDRESSES,
TOKEN_METADATA,
CHAIN_METADATA,
} from "@avail-project/nexus-core";
import { encodeFunctionData, type Abi } from "viem";
<NexusDeposit
destination={{
chainId: SUPPORTED_CHAINS.BASE,
tokenAddress: TOKEN_CONTRACT_ADDRESSES["USDC"][SUPPORTED_CHAINS.BASE],
tokenSymbol: "USDC",
tokenDecimals: TOKEN_METADATA["USDC"].decimals,
tokenLogo: TOKEN_METADATA["USDC"].icon,
label: "Deposit USDC on Aave Base",
gasTokenSymbol: CHAIN_METADATA[SUPPORTED_CHAINS.BASE].nativeCurrency.symbol,
explorerUrl: CHAIN_METADATA[SUPPORTED_CHAINS.BASE].blockExplorerUrls[0],
estimatedTime: "~= 30s",
}}
executeDeposit={(tokenSymbol, tokenAddress, amount, _chainId, user) => {
const contractAddress = "0x..." as const;
const abi: Abi = [
{
inputs: [
{ internalType: "address", name: "asset", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "address", name: "onBehalfOf", type: "address" },
{ internalType: "uint16", name: "referralCode", type: "uint16" },
],
name: "supply",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
];
const data = encodeFunctionData({
abi,
functionName: "supply",
args: [tokenAddress, amount, user, 0],
});
return {
to: contractAddress,
data,
tokenApproval: {
token: tokenSymbol,
amount,
spender: contractAddress,
},
};
}}
/>
SDK flow mapping
- Uses
sdk.swapAndExecute(...) under the hood.
- Relies on the swap intent hook (
swapIntent) for confirmation UI.
- Progress updates come from
NEXUS_EVENTS.SWAP_STEP_COMPLETE.
Props (DepositWidgetProps)
destination (required): chainId, tokenAddress, tokenSymbol, tokenDecimals, tokenLogo?, label?, estimatedTime?, gasTokenSymbol?, explorerUrl?, depositTargetLogo?
executeDeposit (required): returns { to, data, value?, tokenApproval? }
embed, heading, className for layout
open, onOpenChange, defaultOpen for modal control
onSuccess, onError, onClose
Notes
- Use
embed={true} for inline rendering; default renders a modal.
executeDeposit receives amount in smallest units (bigint); return calldata + optional tokenApproval.
1---2name: nexus-elements-deposit3description: Install and use the Nexus Deposit widget (swap + execute via swapAndExecute). Use when integrating the full deposit flow with destination config and custom execute builder.4---5
6# Nexus Elements - Deposit
7
8## Overview
9Install the NexusDeposit widget for a full swap-and-execute deposit flow with unified balances, fee preview, and progress UI.
10
11## Prerequisites
12- NexusProvider installed and initialized on wallet connect.
13- Wallet connection configured.
14- You can build an execute call (contract address + encoded data) for the target protocol.
15
16## Install (shadcn registry)
171) Ensure shadcn/ui is initialized (`components.json` exists).
182) Ensure registry mapping exists:
19```json
20"registries": {
21 "@nexus-elements/": "https://elements.nexus.availproject.org/r/{name}.json"
22}
23```
243) Install:
25```bash
26npx shadcn@latest add @nexus-elements/deposit
27```
28Alternative:
29```bash
30npx shadcn@latest add https://elements.nexus.availproject.org/r/deposit.json
31```
32
33## Manual install (no shadcn)
341) Download `https://elements.nexus.availproject.org/r/deposit.json`.
352) Create each file in `files[].target` with `files[].content`.
363) Install dependencies listed in `dependencies` and each `registryDependencies` item.
37
38## Usage
39```tsx
40import NexusDeposit from "@/components/deposit/nexus-deposit";
41import {
42 SUPPORTED_CHAINS,
43 TOKEN_CONTRACT_ADDRESSES,
44 TOKEN_METADATA,
45 CHAIN_METADATA,
46} from "@avail-project/nexus-core";
47import { encodeFunctionData, type Abi } from "viem";
48
49<NexusDeposit
50 destination={{
51 chainId: SUPPORTED_CHAINS.BASE,
52 tokenAddress: TOKEN_CONTRACT_ADDRESSES["USDC"][SUPPORTED_CHAINS.BASE],
53 tokenSymbol: "USDC",
54 tokenDecimals: TOKEN_METADATA["USDC"].decimals,
55 tokenLogo: TOKEN_METADATA["USDC"].icon,
56 label: "Deposit USDC on Aave Base",
57 gasTokenSymbol: CHAIN_METADATA[SUPPORTED_CHAINS.BASE].nativeCurrency.symbol,
58 explorerUrl: CHAIN_METADATA[SUPPORTED_CHAINS.BASE].blockExplorerUrls[0],
59 estimatedTime: "~= 30s",
60 }}
61 executeDeposit={(tokenSymbol, tokenAddress, amount, _chainId, user) => {
62 const contractAddress = "0x..." as const;
63 const abi: Abi = [
64 {
65 inputs: [
66 { internalType: "address", name: "asset", type: "address" },
67 { internalType: "uint256", name: "amount", type: "uint256" },
68 { internalType: "address", name: "onBehalfOf", type: "address" },
69 { internalType: "uint16", name: "referralCode", type: "uint16" },
70 ],
71 name: "supply",
72 outputs: [],
73 stateMutability: "nonpayable",
74 type: "function",
75 },
76 ];
77
78 const data = encodeFunctionData({
79 abi,
80 functionName: "supply",
81 args: [tokenAddress, amount, user, 0],
82 });
83
84 return {
85 to: contractAddress,
86 data,
87 tokenApproval: {
88 token: tokenSymbol,
89 amount,
90 spender: contractAddress,
91 },
92 };
93 }}
94/>
95```
96
97## SDK flow mapping
98- Uses `sdk.swapAndExecute(...)` under the hood.
99- Relies on the swap intent hook (`swapIntent`) for confirmation UI.
100- Progress updates come from `NEXUS_EVENTS.SWAP_STEP_COMPLETE`.
101
102## Props (DepositWidgetProps)
103- `destination` (required): chainId, tokenAddress, tokenSymbol, tokenDecimals, tokenLogo?, label?, estimatedTime?, gasTokenSymbol?, explorerUrl?, depositTargetLogo?
104- `executeDeposit` (required): returns `{ to, data, value?, tokenApproval? }`
105- `embed`, `heading`, `className` for layout
106- `open`, `onOpenChange`, `defaultOpen` for modal control
107- `onSuccess`, `onError`, `onClose`
108
109## Notes
110- Use `embed={true}` for inline rendering; default renders a modal.
111- `executeDeposit` receives `amount` in smallest units (`bigint`); return calldata + optional `tokenApproval`.