Asset Management
Tutorial - Deploying a Vault
Launching a policy-controlled asset management vault.
Tutorial: Deploying a Vault
In this tutorial, we will deploy a Kernel Smart Account configured as an "Index Fund" managed by a Matador Policy.
Prerequisites
- A Kernel v3 Smart Account.
- Matador CLI.
- A "Manager" address (the human trader).
Mandates are enforceable contracts
The policy is the mandate. The manager's discretion only exists inside the policy's boundaries.
Step 1: Define the Mandate
We want a "Blue Chip" fund that only holds WETH and WBTC.
blue-chip.matador:
import "abis/UniswapRouter.json" as Uniswap;
permission BlueChipVault -> 1.0.0 {
parameters: {
router: address,
tokenA: address,
tokenB: address
}
when: {
// Only allow interaction with the configured router.
context.target == parameters.router,
Uniswap.exactInputSingle(params: tuple),
any {
all {
calldata.params.tokenIn == parameters.tokenA,
calldata.params.tokenOut == parameters.tokenB
},
all {
calldata.params.tokenIn == parameters.tokenB,
calldata.params.tokenOut == parameters.tokenA
}
}
}
}Step 2: Compile & Deploy
matador compile blue-chip.matador --out ./outDeploy the policy bytecode to the blockchain (or upload to IPFS if using off-chain resolution, but on-chain is standard for security).
Step 3: Configure the Kernel
We need to install the Matador Module and set the permissions.
// 1. Enable Matador Module
await kernelClient.enableModule(MATADOR_ADDRESS);
// 2. Install Policy
// We permit the MANAGER address to call the Uniswap Router,
// BUT only if it passes the Policy checks.
await matadorModule.setPolicy(
policyId,
bytecode,
MANAGER_ADDRESS // The human trader
);Step 4: Fund & Trade
- Deposit: Send 10 ETH to the Kernel address.
- Trade (Valid): The Manager submits a tx to swap 5 ETH for WBTC.
- Matador: Checks policy. Tokens are WETH/WBTC. Approved.
- Trade (Invalid): The Manager tries to swap 5 ETH for PEPE.
- Matador: Checks policy. Token PEPE is not in [WETH, WBTC]. Reverted.
Result
You have created a Trustless Fund. Investors can deposit knowing that the manager literally cannot rug pull them into a memecoin, enforced by the EVM.