Smart Contract Architecture
Overview of on-chain contracts and integrations powering Metalos.
Overview of on-chain contracts and integrations powering Metalos.
Metalos keeps on-chain complexity low by integrating with proven Solidity vault contracts and layering orchestration on top. The vaults handle custody, strategy execution, and share accounting, while Metalos automation batches transactions, monitors safety thresholds, and coordinates session-key permissions.
deposit
, withdraw
, balance
, and getPricePerFullShare
for accounting.Each vault follows a predictable flow:
deposit
. The contract calculates shares based on the current pricePerShare
and mints them to the depositor.earn()
or automatic hooks. Strategies interact with external protocols, manage liquidity positions, and track pending rewards.pricePerShare
, so all share holders benefit proportionally.withdraw
or withdrawAll
. The vault requests liquidity from the strategy if needed, then transfers underlying assets back to the user.Metalos layers operational controls on top of these audited contracts:
pricePerShare
).pricePerShare
, share supply, liquidity metrics, and strategy balances against expected ranges. Deviations trigger alerts or automatic safeties.Operational dashboards surface live metrics such as vault balances, borrow utilization, LP depth, and slippage data. This telemetry feeds into incident response playbooks and governance reporting.
External developers can treat Metalos vaults like standard ERC-4626 tokens:
deposit(amount, recipient)
using ethers.js or another client library. The vault emits Deposit
events with share amounts and new balances.withdraw(shares, recipient)
to redeem underlying assets. For full exits, withdrawAll()
simplifies the flow. Contracts emit Withdraw
events for off-chain accounting.balanceOf(address)
to read share balances and getPricePerFullShare()
(or convertToAssets()
in strict ERC-4626 implementations) to calculate current value. Combining both yields the user’s portfolio worth.Always validate contract addresses against the official configuration (lib/web3-config.ts
) and re-check them after any governance-approved upgrade. Never interact with unverified contracts that claim to mimic Metalos vaults.
ABI files (lib/abis/vault-abi.ts
) and hook implementations (lib/hooks/use-deposit.ts
, use-withdraw.ts
) in the Metalos app repository provide concrete reference code for integrating with the vaults using ethers.js.