Robinhood Chain Testnet

RobinFi Documentation

Complete technical documentation for building with and integrating RobinFi vaults on Robinhood Chain.

RobinFi is an ERC-4626 compliant vault system that enables instant diversification across tokenized stocks on Robinhood Chain. Built on Arbitrum technology, it provides a gas-efficient way to manage diversified stock portfolios on-chain.

📘 What You'll Learn
  • How to interact with RobinFi vaults using web3
  • Smart contract architecture and design patterns
  • Integration examples for your DeFi application
  • Best practices for vault management

Quick Start

1. Connect to Robinhood Chain Testnet

Add Robinhood Chain testnet to your wallet with the following configuration:

{
  "chainId": "0x...",
  "chainName": "Robinhood Chain Testnet",
  "rpcUrls": ["https://testnet.rpc.chain.robinhood.com"],
  "nativeCurrency": {
    "name": "Ethereum",
    "symbol": "ETH",
    "decimals": 18
  },
  "blockExplorerUrls": ["https://testnet.explorer.chain.robinhood.com"]
}

2. Get Testnet Tokens

Visit the Robinhood Chain Faucet to receive:

  • Testnet ETH for gas fees
  • Stock tokens (TSLA, AMZN, NFLX, PLTR, AMD)

3. Install Dependencies

npm install ethers wagmi viem

4. Interact with the Vault

import { ethers } from 'ethers';

// Contract ABI and address
const VAULT_ADDRESS = '0x...';
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const vault = new ethers.Contract(VAULT_ADDRESS, VAULT_ABI, signer);

// Deposit 1 ETH
const tx = await vault.deposit(
  ethers.utils.parseEther("1"),
  { value: ethers.utils.parseEther("1") }
);
await tx.wait();

Architecture

RobinFi follows the ERC-4626 tokenized vault standard, enabling seamless composability with other DeFi protocols.

Core Components

Component Description
RobinFiVault Main vault contract that manages deposits, withdrawals, and rebalancing
VaultFactory Deploys new vault instances with custom basket configurations
PriceOracle Fetches stock token prices via Chainlink oracles
RebalanceStrategy Defines allocation rules and rebalancing logic

Token Flow

  1. User deposits ETH into the vault
  2. Vault swaps ETH for stock tokens via DEX (equal weight distribution)
  3. User receives vault shares (ERC-20 tokens)
  4. Shares appreciate as stock basket value increases
  5. User can redeem shares for pro-rata ETH and stock tokens
⚠️ Testnet Limitations

Current testnet deployment uses mock price feeds and limited liquidity. Production mainnet will integrate Chainlink price oracles and professional market makers.

Vault Contract

The RobinFiVault contract is the core of the system. It's ERC-4626 compliant and manages all user interactions.

Inheritance

contract RobinFiVault is ERC4626, Ownable, ReentrancyGuard {
    // Implementation
}

State Variables

address[] public stockTokens;      // [TSLA, AMZN, NFLX, PLTR, AMD]
uint256[] public targetWeights;     // [20, 20, 20, 20, 20] (equal weight)
address public dexRouter;           // Uniswap V2 compatible router
uint256 public managementFee;       // 0.5% annual (50 basis points)
uint256 public lastRebalance;       // Timestamp of last rebalancing

Core Functions

deposit(uint256 assets)

Deposits ETH and mints vault shares to the caller.

function deposit(uint256 assets) 
    external 
    payable 
    nonReentrant 
    returns (uint256 shares) 
{
    require(msg.value == assets, "ETH amount mismatch");
    
    shares = previewDeposit(assets);
    _buyBasket(assets);
    _mint(msg.sender, shares);
    
    emit Deposit(msg.sender, assets, shares);
}

Parameters:

  • assets - Amount of ETH to deposit (in wei)

Returns:

  • shares - Amount of vault shares minted

withdraw(uint256 shares)

Burns vault shares and returns pro-rata basket tokens to the caller.

function withdraw(uint256 shares) 
    external 
    nonReentrant 
    returns (uint256 assets) 
{
    require(balanceOf(msg.sender) >= shares, "Insufficient shares");
    
    assets = previewWithdraw(shares);
    _burn(msg.sender, shares);
    _sellBasket(shares, msg.sender);
    
    emit Withdraw(msg.sender, assets, shares);
}

rebalance()

Adjusts basket allocations to match target weights. Can be called by vault owner.

function rebalance() external onlyOwner {
    uint256[] memory currentWeights = _getCurrentWeights();
    
    for (uint256 i = 0; i < stockTokens.length; i++) {
        if (currentWeights[i] != targetWeights[i]) {
            _adjustPosition(stockTokens[i], targetWeights[i]);
        }
    }
    
    lastRebalance = block.timestamp;
    emit Rebalanced(block.timestamp);
}

totalAssets()

Returns the total value of all assets held by the vault in ETH terms.

function totalAssets() public view returns (uint256) {
    uint256 totalValue = 0;
    
    for (uint256 i = 0; i < stockTokens.length; i++) {
        uint256 balance = IERC20(stockTokens[i]).balanceOf(address(this));
        uint256 price = _getTokenPrice(stockTokens[i]);
        totalValue += balance * price / 1e18;
    }
    
    return totalValue;
}

Events

Event Description
Deposit(address indexed user, uint256 assets, uint256 shares) Emitted when a user deposits ETH
Withdraw(address indexed user, uint256 assets, uint256 shares) Emitted when a user withdraws
Rebalanced(uint256 timestamp) Emitted when vault is rebalanced
ManagementFeeCharged(uint256 amount) Emitted when management fee is collected

Web3 Setup

Using Wagmi (React)

import { useContractWrite, useContractRead } from 'wagmi';
import { parseEther } from 'viem';

function DepositForm() {
  const { write } = useContractWrite({
    address: VAULT_ADDRESS,
    abi: VAULT_ABI,
    functionName: 'deposit',
  });

  const handleDeposit = (amount) => {
    write({
      args: [parseEther(amount)],
      value: parseEther(amount),
    });
  };

  return (
    
  );
}

Using Ethers.js

async function depositToVault(amount) {
  const provider = new ethers.providers.Web3Provider(window.ethereum);
  await provider.send("eth_requestAccounts", []);
  
  const signer = provider.getSigner();
  const vault = new ethers.Contract(VAULT_ADDRESS, VAULT_ABI, signer);
  
  const tx = await vault.deposit(
    ethers.utils.parseEther(amount),
    { value: ethers.utils.parseEther(amount) }
  );
  
  const receipt = await tx.wait();
  console.log('Deposit successful:', receipt);
}

Depositing

When you deposit into a RobinFi vault, the following happens:

  1. Your ETH is transferred to the vault contract
  2. The vault calculates how many shares you should receive based on current share price
  3. ETH is split equally among the basket tokens (20% each for 5 tokens)
  4. Vault swaps ETH for each stock token via DEX
  5. Vault shares (ERC-20 tokens) are minted to your address

Calculate Expected Shares

const shares = await vault.previewDeposit(ethers.utils.parseEther("1"));
console.log('You will receive:', ethers.utils.formatEther(shares), 'shares');
💡 Pro Tip

Always call previewDeposit() before depositing to see how many shares you'll receive. Share price increases as the basket appreciates.

Withdrawing

Withdrawals are permissionless and can happen anytime. You'll receive your pro-rata share of the basket.

Full Withdrawal

// Withdraw all your shares
const balance = await vault.balanceOf(userAddress);
const tx = await vault.withdraw(balance);
await tx.wait();

Partial Withdrawal

// Withdraw 50% of your shares
const balance = await vault.balanceOf(userAddress);
const halfShares = balance.div(2);
const tx = await vault.withdraw(halfShares);
await tx.wait();

Preview Withdrawal

const assets = await vault.previewWithdraw(sharesToBurn);
console.log('You will receive:', ethers.utils.formatEther(assets), 'worth of assets');

Network Details

Parameter Value
Network Name Robinhood Chain Testnet
Chain ID TBD
RPC URL https://testnet.rpc.chain.robinhood.com
Explorer testnet.explorer.chain.robinhood.com
Faucet faucet.testnet.chain.robinhood.com

Contract Addresses

⚠️ Testnet Only

These contracts are deployed on testnet. Do not use real funds.

Contract Address
RobinFiVault (Tech Giants) 0x...
VaultFactory 0x...
PriceOracle 0x...

Supported Stock Tokens

Current testnet supports 5 tokenized stocks in equal-weight allocation:

Token Symbol Weight Contract Address
Tesla TSLA 20% 0x...
Amazon AMZN 20% 0x...
Netflix NFLX 20% 0x...
Palantir PLTR 20% 0x...
AMD AMD 20% 0x...
📈 Future Expansion

Mainnet launch will support custom basket creation via VaultFactory, allowing users to deploy vaults with their own token selections and allocation strategies.

Need Help?

Join our community for support, updates, and to connect with other builders: