getRequirements
Read what the wallet must do before executePrepared — never a hidden approve.
Returns the list of steps required to send a PreparedAction: nothing, an EIP-2612 permit signature, or an ERC-20 approve. This is a pure read. It never sends approve and never signs.
The pattern matches Morpho's getRequirements: the app shows the next step, the user confirms it, then you call executePrepared.
Import
import { createSv3Client } from "@repo/contract-client";
Usage
const prepared = await sv3.trade.prepareBuyForReserveBudget({
market,
amount: parseUsdc("10"),
slippageBps: 100n,
});
const requirements = sv3.authorization.getRequirements(prepared, {
token: context.snapshot.tokens.reserve,
spender: market,
amount: prepared.constraints.maxIn ?? parseUsdc("10"),
allowance: context.reserveAllowance,
nonce: context.reservePermitNonce,
isContractWallet: context.codeSize > 0n,
tokenName: "USD Coin",
mode: "auto",
});
for (const step of requirements) {
if (step.type === "none") continue;
if (step.type === "permit-signature") {
const signature = await walletClient.signTypedData(step.typedData);
await sv3.transactions.executePrepared(prepared, { permit: signature });
}
if (step.type === "approval") {
// send approve yourself, then executePrepared
}
}
mode: 'auto' picks permit for EOAs and allowance for contract wallets unless you constructed the client with permitCapability: 'eip2612'.
Return Value
readonly Requirement[]
type | Meaning |
|---|---|
none | Allowance already covers amount |
permit-signature | Collect EIP-2612 signTypedData using typedData |
approval | Send approve(spender, amount) yourself (unlimited is always false) |
wallet-client | Bind a wallet before sending |
account-match | Prepared account ≠ client account |
chain-switch | Wallet is on the wrong chain |
Parameters
prepared
- Type:
PreparedAction
From sv3.trade.prepare*.
sv3.authorization.getRequirements(prepared, extra);
extra.token
- Type:
Address
Token to spend (USDC on a buy, AVM on a sell).
extra.spender
- Type:
Address
Almost always the FloorMarket.
extra.amount
- Type:
bigint
Amount the market will pull.
extra.allowance
- Type:
bigint
Current allowance, from getTradeContext.
extra.nonce
- Type:
bigint
EIP-2612 nonce for the owner.
extra.isContractWallet
- Type:
boolean
context.codeSize > 0n.
extra.tokenName
- Type:
string
EIP-712 domain name ('USD Coin', or the AVM name).
extra.mode
- Type:
'auto' | 'permit' | 'allowance'
sv3.authorization.getRequirements(prepared, {
token,
spender: market,
amount,
allowance,
nonce,
isContractWallet: false,
tokenName: "USD Coin",
mode: "auto",
});
Tips
- Never set
unlimited: true. The SDK refuses infinite approvals. - Pass a collected permit into
executePrepared(prepared, { permit }). Allowance-route approvals are ordinary ERC-20 writes you send yourself.