Skip to main content

ERC-4626 Tokenized Vaults

Deploy yield vaults where users deposit ERC-20 tokens and receive proportional shares.

When to Use

  • Yield strategies — pool tokens into a shared vault, distribute returns proportionally
  • Staking pools — users stake tokens and receive transferable share tokens
  • Fee collection — aggregate protocol fees into a vault for stakeholders
  • DAO treasuries — ERC-4626 compatible treasury with transparent accounting
How Shares Work

When you deposit 1000 tokens and the vault has a 1:1 exchange rate, you receive 1000 share tokens. As the vault earns yield, each share becomes worth more underlying tokens. Redeeming 1000 shares later might return 1050 tokens if the vault earned 5%.

Deploy a Vault

const vault = await urblock.vaults.create({
name: "Yield Vault",
symbol: "yMTK",
asset_token_id: "tok_abc123", // underlying ERC-20 token
network: "polygon_amoy",
idempotency_key: "vault-001",
});

Deposit Assets

Deposit ERC-20 tokens into the vault, receiving vault shares:

const tx = await urblock.vaults.deposit("vlt_abc123", {
depositor: "0xDepositor...",
assets: "1000000000000000000000", // 1000 tokens
receiver: "0xDepositor...",
idempotency_key: "deposit-001",
});

Withdraw Assets

Withdraw a specific amount of assets:

const tx = await urblock.vaults.withdraw("vlt_abc123", {
assets: "500000000000000000000",
receiver: "0xReceiver...",
owner: "0xShareHolder...",
idempotency_key: "withdraw-001",
});

Redeem Shares

Redeem vault shares for the underlying assets:

const tx = await urblock.vaults.redeem("vlt_abc123", {
shares: "1000000000000000000000",
receiver: "0xReceiver...",
owner: "0xShareHolder...",
idempotency_key: "redeem-001",
});

Preview Operations

Check how many shares or assets an operation would yield:

const preview = await urblock.vaults.preview("vlt_abc123", {
action: "deposit",
amount: "1000000000000000000000",
});
console.log(preview.output_amount); // expected shares

Convert Between Assets and Shares

const result = await urblock.vaults.convert("vlt_abc123", {
direction: "to_shares",
amount: "1000000000000000000000",
});
console.log(result.output_amount); // equivalent shares

Check Limits

const limits = await urblock.vaults.getLimits("vlt_abc123", {
address: "0xUser...",
});
console.log(limits.max_deposit);
console.log(limits.max_withdraw);

curl Example

# Deploy a vault
curl -X POST https://api.urblock.io/v1/vaults \
-H "Authorization: Bearer sk_test_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Yield Vault",
"symbol": "yMTK",
"asset_token_id": "tok_abc123",
"network": "polygon_amoy",
"idempotency_key": "vault-001"
}'

# Deposit assets
curl -X POST https://api.urblock.io/v1/vaults/vlt_abc123/deposit \
-H "Authorization: Bearer sk_test_..." \
-H "Content-Type: application/json" \
-d '{
"depositor": "0xDepositor...",
"assets": "1000000000000000000000",
"receiver": "0xDepositor...",
"idempotency_key": "deposit-001"
}'

Next Steps