Skip to content

Smart Contract

The Rhadow vault is an ERC-4626 tokenized vault implemented in Cairo.

Contract Address

0x05693c7efe1a28d808f388907467cc3edcaeb01749a718d72e0da7c21a4070c3

View on Starkscan →

Key Functions

User Functions (ERC-4626)

FunctionDescription
deposit(assets, receiver)Deposit USDC, receive rUSDC shares
withdraw(assets, receiver, owner)Withdraw USDC by burning shares
redeem(shares, receiver, owner)Redeem shares for USDC

View Functions

FunctionDescription
total_assets()Total vault value in USDC
convert_to_shares(assets)Preview shares for deposit
convert_to_assets(shares)Preview USDC for redemption
get_available_liquidity()Liquid USDC in vault

Keeper Functions

FunctionDescription
allocate_margin(amount)Move USDC to trading account
deallocate_margin(amount)Return USDC from trading
swap_usdc_to_wbtc(amount, min_out, routes)Buy wBTC via AVNU
swap_wbtc_to_usdc(amount, min_out, routes)Sell wBTC via AVNU
report(profit, loss)Report PnL, update share price
set_btc_price(price)Update BTC price oracle

Admin Functions

FunctionDescription
set_trading_account(address)Set keeper account
set_risk_parameters(params)Update risk limits
pause() / unpause()Emergency controls
upgrade(new_class_hash)Upgrade implementation

Total Assets Calculation

cairo
fn total_assets() -> u256 {
    vault_usdc_balance
    + allocated_margin
    + (wbtc_balance * btc_price / 10^8)
}

Events

EventDescription
DepositUser deposited USDC
WithdrawUser withdrew USDC
ReportKeeper reported profit/loss
MarginAllocatedUSDC sent to Extended
MarginDeallocatedUSDC returned from Extended

Dependencies

Built with OpenZeppelin Cairo Contracts:

  • ERC20Component
  • AccessControlComponent
  • PausableComponent
  • ReentrancyGuardComponent
  • UpgradeableComponent