Skip to content

API ReferenceTransactions, wallets, and signaturesFunction

buildVaultDepositAuthorization()

function buildVaultDepositAuthorization(ctx, params): Promise<VaultDepositAuthorizationDefinition>;

Builds an inspectable vault CollateralizableDepositApproval without signing it.

The account holder signs the result with signAuthorization. The collateralizable contract named in collateralizableAddress submits the signature to the vault’s depositFromAccount; the vault binds that caller into the digest, verifies the signer as an EOA or through ERC-1271, and consumes the signer’s next deposit-approval nonce. The signature has no deadline: it stays usable until that nonce is consumed or invalidated.

Parameters

ParameterTypeDescription
ctxSDKContextSDK context supplying the public client, profile, and signer.
paramsBuildVaultDepositAuthorizationParamsThe collateralizable, token, and exact amount to bind.

Returns

Promise<VaultDepositAuthorizationDefinition>

The definition whose typedData is what the wallet signs.

Example

// The account holder signs. The collateralizable contract submits the
// bytes to `depositFromAccount`, and the vault verifies them there.
const workflow = await sdk.vault.buildDepositAuthorizationWorkflow({
collateralizableAddress: collateralizable,
tokenAddress: USDC,
depositAmount: 5_000_000_000n, // exact: the vault rejects any other
});
// Chain, vault, signer, nonce, and typed data, before the wallet prompt.
console.log(workflow.operations[0]?.authorization);
const execution = await workflow.execute();
if (execution.status !== 'executed') {
throw new Error(`deposit preflight ended as ${execution.status}`);
}
const [op] = execution.operations;
if (
op?.status !== WalletOperationStatus.Signed ||
op.signature === undefined
) {
throw new Error('signature not obtained');
}
return op.signature; // -> the collateralizable's deposit entry point

Throws

InvalidArgumentError when an address is zero or malformed, or an amount or nonce does not fit its EIP-712 integer width.