directShield
Shield wallet funds directly into the active (or selected) Curvy account. ERC-20 allowance is checked and, when necessary, an exact approval is sent for the vault before calling the aggregator. A non-zero insufficient allowance is reset first for USDT-style tokens. The vault pulls directly from the wallet; native deposits attach amount as msg.value.
Import
import { directShield } from "@0xcurvy/curvy-sdk/actions";Usage
const result = await directShield({ networkSlug, amount, token, walletClient, config });Signature
function directShield(parameters: DirectShieldParameters): Promise<DirectShieldResult>Returns
Promise<DirectShieldResult>
The action resolves or returns the value shown in the signature.
Parameters
networkSlug
- Type:
string - Required: yes
Network whose aggregator receives the deposit.
const result = await directShield({
networkSlug,
amount,
token,
walletClient,
});amount
- Type:
bigint - Required: yes
Gross amount deposited, in token base units (fees are deducted on-chain).
const result = await directShield({
networkSlug,
amount,
token,
walletClient,
});token
- Type:
bigint - Required: yes
Vault token id on the selected network.
const result = await directShield({
networkSlug,
amount,
token,
walletClient,
});walletClient
- Type:
WalletClient - Required: yes
Viem wallet that owns the funds and pays gas.
const result = await directShield({
networkSlug,
amount,
token,
walletClient,
});accountId
- Type:
string - Required: no
Curvy account that receives the shielded note; defaults to the active account.
const result = await directShield({
networkSlug,
amount,
token,
walletClient,
accountId,
});contractAddress
- Type:
HexString - Required: no
Override the target aggregator; defaults to the network metadata.
const result = await directShield({
networkSlug,
amount,
token,
walletClient,
contractAddress,
});vaultContractAddress
- Type:
HexString - Required: no
Override the vault approved to pull ERC-20s; defaults to the network metadata.
const result = await directShield({
networkSlug,
amount,
token,
walletClient,
vaultContractAddress,
});config
- Type:
CurvyConfig - Required: no
Curvy config to use. Defaults to the ambient config.
const result = await directShield({
networkSlug,
amount,
token,
walletClient,
config,
});Errors
Errors from config resolution and the underlying SDK operation are propagated to the caller.
Related
Source
packages/@0xcurvy/sdk/src/actions/aggregator/directShield.ts