Skip to content

2.0.1

Compare
Choose a tag to compare
@mike-diamond mike-diamond released this 01 Aug 13:39
· 22 commits to main since this release
ba0e064
  • Add the sdk.vault.create method
  • Add a getVaultFactory helper to retrieve the vault factory contract based on the provided vault type and ERC20 token availability
  • Update the sdk.vault.operate method to accept image, displayName, and description instead of metadataIpfsHash

Updates

sdk.vault.operate

Removed arguments:

Name Type Required Access Description
metadataIpfsHash string No Admin The vault metadata IPFS hash

New arguments:

Name Type Required Access Description
image string No Admin The vault image in base64 string format (will be uploaded to IPFS; maximum size is 1 MB)
displayName string No Admin The vault display name (will be uploaded to IPFS; maximum size is 30 characters)
description string No Admin The vault description (will be uploaded to IPFS; maximum size is 1000 characters)

New

sdk.vault.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:

Name Type Required Description
userAddress string Yes The address of the user initiating the action. This address will become the vault admin
type VaultType No Allowed 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 } No If provided, the vault will be created with its own ERC20 token
capacity bigint No If provided, should be defined in gwei. By default, capacity is MaxUint256; the minimum allowed capacity is parseEther('32')
keysManagerFee number No If 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
isOwnMevEscrow boolean No Defines whether to send block rewards to the Smoothing Pool (false) or keep them only to your Vault (true). By default, this value is false
image string No The vault image in base64 string format (will be uploaded to IPFS; maximum size is 1 MB)
displayName string No The vault display name (will be uploaded to IPFS; maximum size is 30 characters)
description string No The 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)

What's Changed

Full Changelog: 2.0.0...2.0.1