Contracts
Last updated
Last updated
Below you’ll find an index of every contract exposed to builders, followed by contract‑scoped subsections that list each public or external function, a short intent sentence, and a usage snippet you can paste into tests or scripts.
Click a name to jump straight to that contract’s functions.
(Interface)
(Interface)
grantRole(bytes32 role, address account)
Assign Owner, Manager, or Guardian to a new signer.
solidity\naccess.grantRole(access.MANAGER_ROLE(), msg.sender);
revokeRole(bytes32 role, address account)
Remove a signer from a role.
solidity\naccess.revokeRole(access.GUARDIAN_ROLE(), oldGuardian);
setFee(uint96 fee)
Set vault‑level performance fee (bps).
solidity\nconfig.setFee(300); // 3 %
setDepositCapacity(uint256 cap)
Cap totalAssets to protect slippage.
solidity\nconfig.setDepositCapacity(1_000_000 ether);
enableAssetToDeposit(address token)
Whitelist a new ERC‑20 for deposits.
solidity\nconfig.enableAssetToDeposit(USDC);
All setters are timelocked; reads like isAssetDepositable()
are free‑view.
submitActions(bytes[] calldata data)
Publish a batch and start the timelock.
solidity\nuint id = multicall.submitActions(payloads);
executeActions(uint256 id)
Run the batch after executeAfter
.
solidity\nmulticall.executeActions(id);
vetoActions(uint256 id)
Guardian‑only cancel.
solidity\nguardian.vetoActions(id);
Failed steps bubble MulticallFailed(index, reason)
and revert the whole batch.
supply(address pool, address asset, uint256 amt, uint16 ref)
Lend collateral into a pool.
solidity\nmarkets.supply(AAVE_POOL, USDC, 10_000e6, 0);
borrow(address pool, address asset, uint256 amt, uint256 rate, uint16 ref, address onBehalf)
Open an over‑collateralised loan.
solidity\nmarkets.borrow(AAVE_POOL, DAI, 5_000e18, 2, 0, address(this));
repay(address pool, address asset, uint256 amt, uint256 rate)
Close or shrink debt.
solidity\nmarkets.repay(AAVE_POOL, DAI, type(uint256).max, 2);
Balances roll into share price via accountingMoreMarketsFacet()
.
investWithToken(address lov, InvestQuoteData q)
Enter a leveraged position using ERC‑20.
solidity\norigami.investWithToken(LOV, quote);
exitToToken(address lov, ExitQuoteData q)
Redeem LOV token back to underlying.
solidity\norigami.exitToToken(LOV, quote);
rebalanceUp(params…)
Reduce leverage (safer) via flash‑loan.
solidity\norigami.rebalanceUp(owner, 1e6, 5e5, swap, 1e4, 1.2e18, 1.3e18);
Uses flash‑loan manager interface under the hood.
swapExactTokensForTokens(router, amtIn, amtOutMin, path, deadline)
ERC‑20 → ERC‑20 swap.
solidity\nuni.swapExactTokensForTokens(ROUTER, 1e18, 0.99e18, path, block.timestamp+20);
addLiquidity(router, tokenA, tokenB, …)
Provide 50 / 50 LP.
See function list in API docs
removeLiquidity(router, …)
Burn LP back to tokens.
See API docs
All swap helpers have ETH variants and fee‑on‑transfer support.
exchange(curveRouter, route, params, amt, minDy, pools, recv)
Up to 5 hops across Curve meta‑pools.
solidity\ncurve.exchange(ROUTER, route, params, 1000e18, 999e18, pools, address(this));
Handles stable‑to‑stable routes with minimal slippage.
findBestPath(amtIn, tokenIn, tokenOut, maxSteps)
Off‑chain quote for best path.
solidity\noffer = aggrokitty.findBestPath(1e18, USDC, WETH, 4);
swapNoSplit(trade, to)
Execute a routed swap.
solidity\naggrokitty.swapNoSplit(offer.trade, address(this));
Vault facets wrap these calls; interface shown for indexers.
getFacetSelectors(address facet)
List selectors a registry knows for a facet.
solidity\nbytes4[] memory sel = registry.getFacetSelectors(FACET);
protocolFeeInfo(address vault)
Return fee destination and rate.
solidity\n(address recv, uint96 bps) = registry.protocolFeeInfo(vault);
Acts as the governance layer for allowed facets and oracle pointer.
latestRoundData()
Fetch price and timestamp in one call.
solidity\n(,int256 px,,uint256 upd,) = agg.latestRoundData();
Feeds are referenced via the registry; interface included for completeness.
deposit(uint256 assets, address receiver)
Convert assets into vault shares.
solidity\nvaultFacet.deposit(1_000e6, msg.sender);
withdraw(uint256 assets, address receiver, address owner)
Burn shares and return assets.
solidity\nvaultFacet.withdraw(500e6, msg.sender, msg.sender);
totalAssets()
Return NAV in underlying units.
solidity\nuint256 nav = vaultFacet.totalAssets();
previewDeposit(uint256 assets)
Quote shares for a given asset amount.
helper for front‑ends
Implements ERC‑4626 accounting plus vault‑level deposit caps and asset whitelist checks.
diamondCut(FacetCut[] memory cuts, address init, bytes calldata data)
Add / replace / remove selectors atomically.
solidity\ndiamondCutFacet.diamondCut(cuts, address(0), "");
Only callable via Multicall after timelock; emits DiamondCut
.
facets()
Full selector → facet map.
solidity\n(IDiamondLoupe loupe).facets();
facetFunctionSelectors(address facet)
Selectors owned by one facet.
solidity\nloupe.facetFunctionSelectors(FACET_ADDR);
Read‑only; used by indexers to show live capabilities.
swapAmount(address router, bytes path, uint256 amtIn, uint256 minOut, address recv)
Exact‑in swap across iZUMi path.
solidity\nizumi.swapAmount(ROUTER, path, 1e18, 0.99e18, address(this));
swapDesire(address router, bytes path, uint256 amtOut, uint256 maxIn, address recv)
Exact‑out swap; cap input.
solidity\nizumi.swapDesire(ROUTER, path, 1e18, 1.01e18, address(this));
Path bytes encode token hops + fee tiers; slippage and whitelist enforced pre‑call.
swapNoSplit(address router, Trade calldata trade, address receiver)
Execute best‑path trade proposed by AggroKitty router.
solidity\nkitty.swapNoSplit(AG_ROUTER, trade, address(this));
swapNoSplitFromNative(...)
Wrap native coin → token swap.
see API docs
swapNoSplitToNative(...)
Token → native coin swap + unwrap.
see API docs
Facet is router‑agnostic; trade struct pre‑validated off‑chain.
deployVault(address registry, address wrappedNative, FacetCut[] calldata initCuts)
Mint a new Diamond vault and register it.
solidity\naddress vault = factory.deployVault(REGISTRY, WETH, genesisCuts);
isFactoryVault(address vault)
Verify provenance of an address.
solidity\nbool legit = factory.isFactoryVault(vault);
getVaultsCount()
Total deployed vaults (uint256).
solidity\nuint n = factory.getVaultsCount();
Interface IVaultsFactory
mirrors these calls for SDKs.
setFacetAllowed(address facet, bool allowed)
(Permissioned) Toggle facet allow‑list.
solidity\nregistry.setFacetAllowed(NEW_FACET, true);
updateOracle(address asset, address newFeed)
Rotate Chainlink / Pyth feed.
solidity\nregistry.updateOracle(USDC, NEW_AGG);
protocolFeeInfo(address vault)
Return fee receiver + bps.
solidity\n(address recv, uint96 fee) = registry.protocolFeeInfo(vault);
PermissionlessVaultsRegistry
overrides allow‑list logic to default‑allow every facet and sets protocol fee to zero.
owner()
Return the Diamond admin set at deployment.
solidity\naddress admin = diamond.owner();
supportsInterface(bytes4 id)
ERC‑165 lookup for facet or ERC‑173 compliance.
solidity\nbool ok = diamond.supportsInterface(type(IERC165).interfaceId);
(fallback)
Delegates any other selector to its facet map.
No direct call; used implicitly.
The contract adds no strategy or governance methods; all functional calls route to installed facets via delegatecall
.
(Role constants and modifiers live in AccessControlLib; see .)