JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 47
  • Score
    100M100P100Q66488F
  • License MIT

Concrete SDK for interacting with vault contracts

Package Exports

  • @concrete-xyz/sdk

Readme

@concrete-xyz/sdk

SDK for interacting with vault contracts on multiple EVM networks.

⚠️ Beta Warning: This package is currently in closed beta. If you encounter any issues, please contact us for support.

Installation

npm install @concrete-xyz/sdk

Quick Start

Basic Usage

import { getVault } from '@concrete-xyz/sdk';
import { ethers } from 'ethers';

// Create provider
const provider = new ethers.JsonRpcProvider('YOUR_RPC_URL');

// Create vault instance
const vault = getVault(
  '0x15cE9bE6609db102b70D68ca75a39c555bEa5Fac', // vault address
  'Ethereum', // network name
  provider // ContractRunner instance
);

// Get vault details
const vaultDetails = await vault.getVaultDetails();
console.log('Vault Symbol:', vaultDetails.symbolDetails);

React + Wagmi Integration

For React applications using Wagmi, you can adapt the provider following the Wagmi documentation.

Note: Check the official Wagmi documentation for proper integration patterns and examples.

Examples

1. Get Vault Data

import { getVault } from '@concrete-xyz/sdk';
import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('YOUR_RPC_URL');
const vault = getVault('0x15cE9bE6609db102b70D68ca75a39c555bEa5Fac', 'Ethereum', provider);

// Get complete vault information
const vaultDetails = await vault.getVaultDetails();
console.log('Vault Symbol:', vaultDetails.vaultAsset.symbol);
console.log('Underlying Asset:', vaultDetails.underlaying.symbol);

2. Preview Deposit

// Preview conversion before depositing
const depositAmount = BigInt(1 * 10 ** 18); // 1 token with 18 decimals
const preview = await vault.previewConversion(depositAmount);

console.log(`Input: ${depositAmount} ${vaultDetails.underlaying.symbol}`);
console.log(`Output: ${preview.vaultTokensReciving} ${vaultDetails.vaultAsset.symbol}`);

3. Execute Deposit

// You need a signer for write operations
const signer = new ethers.Wallet('YOUR_PRIVATE_KEY', provider);
const vaultWithSigner = getVault('0x15cE9bE6609db102b70D68ca75a39c555bEa5Fac', 'Ethereum', provider, signer);

// Approve tokens first
const approveTx = await vaultWithSigner.approve(vaultWithSigner.getAddress(), depositAmount);
await approveTx.wait();

// Execute deposit
const depositTx = await vaultWithSigner.deposit(depositAmount);
const receipt = await depositTx.wait();
console.log('Deposit successful:', receipt);

4. Execute Withdrawal

// Preview withdrawal
const withdrawAmount = BigInt(1 * 10 ** (18 + 9)); // 1 vault token
const withdrawalPreview = await vault.previewConversion(withdrawAmount);

console.log(`Input: ${withdrawAmount} ${vaultDetails.vaultAsset.symbol}`);
console.log(`Output: ${withdrawalPreview.underlyingReciving} ${vaultDetails.underlaying.symbol}`);

// Execute withdrawal (using the same signer from previous example)
const withdrawTx = await vaultWithSigner.redeem(withdrawAmount);
const receipt = await withdrawTx.wait();
console.log('Withdrawal successful:', receipt);

Supported Networks

The SDK supports multiple EVM networks including: Ethereum, Corn, Morph, Berachain, and Katana.

Note: Network support may vary based on your specific deployment.

API Reference

getVault(address, network, clientProvider, signerProvider?)

Creates a new Vault instance for interacting with vault contracts.

Parameters:

  • address (string): The vault contract address
  • network (EnabledNetwork): The blockchain network name
  • clientProvider (ContractRunner): Provider for read operations
  • signerProvider (JsonRpcSigner, optional): Signer for write operations

Returns: Vault instance

Vault Methods

The vault is an abstraction of a ERC-4626 Tokenized Vault, which in turn is an ERC-20 token that represents shares of underlying assets.

Technically, all ERC-4626 vault methods are available, but the SDK provides a simplified interface focusing on the most commonly used operations. Some less frequently used methods may not be directly exposed through the SDK wrapper.

Commonly used methods (examples):

  • getVaultDetails(): Get complete vault information
  • previewConversion(amount): Preview deposit/withdrawal conversion
  • deposit(amount): Deposit underlying tokens for vault tokens
  • redeem(amount): Redeem vault tokens for underlying tokens
  • approve(spender, amount): Approve token spending
  • totalAssets(): Get total assets in vault
  • symbol(): Get vault symbol