For the complete documentation index, see llms.txt. This page is also available as Markdown.

Code examples

Look up, predict, and deploy KPK funds through the KpkOivFactory and the CCIP orchestrator, with viem, ethers.js, and Python.

Practical examples for looking up a fund's contract addresses, predicting them ahead of a deployment, and deploying a fund across chains through the KpkOivFactory and the CcipOivDeployer orchestrator.

The factory and orchestrator share the same address on every chain; take them from Deployment addresses. The examples use the salt v4 addresses; owner, admin, and fee-receiver addresses are placeholders.

In the returned OivInstance, the field named avatarSafe is the fund's Portfolio Safe (the Zodiac module's avatar, the Safe that holds the fund's assets); kpkSharesProxy is the ERC-20 shares token investors hold. kpkSharesImpl is the chain's shared kpkShares mastercopy. The two timelock fields are address(0) when the fund has no timelock.

1. Look up a registered fund

Funds in the factory's curated registry are returned by getFund(registeredFundId) as an OivInstance. Funds the factory deployed itself are logged in instances(id) with the same shape, for ids 0 to instanceCount() - 1. Stack-only chains log the fund in stacks(id) instead (StackInstance, ids 0 to stackCount() - 1).

The salt v4 registry is empty until the factory owner (the Security Council Safe) registers funds. getFund reverts FundNotRegistered for any id that was never used or has since been unregistered, so iterate 0 to registeredFundCount() - 1 and skip the ids that revert. Registry entries are owner-asserted and not verified onchain; for funds this factory deployed, read instances(id) instead.

struct OivInstance {
    address avatarSafe;           // the fund's Portfolio Safe (holds assets)
    address managerSafe;
    address execRolesModifier;
    address subRolesModifier;
    address managerRolesModifier;
    address kpkSharesImpl;        // the chain's shared kpkShares mastercopy
    address kpkSharesProxy;       // the ERC-20 shares token
    address execTimelock;         // owns the exec Roles Modifier, or address(0)
    address sharesTimelock;       // holds DEFAULT_ADMIN_ROLE on the shares, or address(0)
}

function getFund(uint256 registeredFundId) external view returns (OivInstance memory);

predictOivAddresses(config, caller) on the factory returns the same OivInstance for a set of inputs without sending a transaction, which is useful to look up a fund's Portfolio Safe before it is deployed. For CCIP-deployed funds, predict through the orchestrator instead (next section), which applies the config-and-topology-bound salt.

2. Deploy a fund across chains

A single call to CcipOivDeployer.deployEverywhere on any wired chain deploys the fund there and fans the operational stack out to every other reachable chain that is not a shares chain (see Cross-chain deployment). Build an OivConfig and the fund's sharesChains topology, predict the resulting addresses, quote the native CCIP fee, then deploy with that fee, plus a buffer, as msg.value.

The example deploys a fund whose shares live on Ethereum only, with both admin powers behind 2-day timelocks from birth.

Deploy to a subset of chains with the deployEverywhere(config, sharesChains, destChainIds[], gasLimit) overload, and add a stack chain to an existing fund later, or retry a permanently-failed CCIP delivery, with dispatchTo(config, sharesChains, destChainIds[], gasLimit) using the same config and sharesChains. Fill a second declared shares chain with deployLocal(config, sharesChains) on that chain. See Cross-chain deployment.

Last updated