Skip to main content

create

Description:

Create a vault. When the transaction is executed, one gwei of the deposit token must be stored in the vault to avoid inflation attack. Pay attention to chains where the deposit token is not a native token (such as Gnosis or Chiado). On these chains before creating the vault, ensure that you call the approve function on the deposit token contract, allowing the vault factory address to spend one gwei. You can retrieve the vault factory contract using the helper function: sdk.getVaultFactory({ vaultType: params.type, isErc20: params.isErc20 }).

Arguments:

NameTypeRequiredDescription
userAddressstringYesThe address of the user initiating the action. This address will become the vault admin
typeVaultTypeNoAllowed vault types: Default, Private and Blocklist. Available vault types can be found in the enum VaultType which you can be imported from the library
vaultToken{ name: string, symbol: string }NoIf provided, the vault will be created with its own ERC20 token
capacitybigintNoIf provided, should be defined in gwei. By default, capacity is MaxUint256; the minimum allowed capacity is parseEther('32')
keysManagerFeenumberNoIf provided, should be between 0 and 100, inclusive with a maximum of two decimal digits allowed (e.g., 15.35). By default, the fee is 0
isOwnMevEscrowbooleanNoDefines whether to send block rewards to the Smoothing Pool (false) or keep them only to your Vault (true). By default, this value is false
imagestringNoThe vault image in base64 string format (will be uploaded to IPFS; maximum size is 1 MB)
displayNamestringNoThe vault display name (will be uploaded to IPFS; maximum size is 30 characters)
descriptionstringNoThe vault description (will be uploaded to IPFS; maximum size is 1000 characters)

Example:

const params = {
userAddress: '0x...',
type: VaultType.Default,
vaultToken: {
name: 'Vault Token',
symbol: 'vlt',
},
capacity: MaxUint256,
keysManagerFee: 0,
isOwnMevEscrow: false,
image: 'data:image/png;base64,...',
displayName: 'Example vault',
description: 'Example description',
}

// Transaction example
// Send transaction to create a vault
const hash = await sdk.vault.create(params)
// When you sign transactions on the backend (for custodians)
const { data, to, value } = await sdk.vault.deposit.encode(params)
// Get an approximate gas per transaction
const gas = await sdk.vault.deposit.estimateGas(params)