Integration Guide

Example Integration for Symmetry Funds
Start by installing funds-sdk packages
yarn
npm
yarn add @symmetry-hq/funds-sdk
npm install @symmetry-hq/funds-sdk
Example shows how to create/buy/sell/rebalance/refilter/reweight a fund
Creating fund with following settings:
  • Manager fee : 0.1% - Users pay 0.1% to fund manager on fund buy
  • Is actively managed - Manager can edit fund settings and rules
  • Asset Pool consists of 4 tokens - [USDC, SOL, BTC, ETH]
  • Fund refilters underlying assets every week
  • Fund reweights underlying assets every day
  • Fund rebalances every 2 hours
  • Fund rebalances when target and current weights differ by at least 5%
  • Fund provides swap liquidity for a token if current weight is within
    5% (rebalance) 50%(lpOffset) = 2.5% of target weight
  • Maximum allowed slippage on rebalance is 3% (compared to pyth price)
  • Fund has 1 rule:
  • Select TOP 3 assets by 1 week average MarketCap,
  • Weight chosen assets by square root of 1 day performace
import {
FundsSDK,
Fund,
BuyState,
FilterType,
FilterTime,
SortBy,
WeightType,
WeightTime
} from "@symmetry-hq/funds-sdk";
/* init funds sdk */
let fundsSDK: FundsSDK = await FundsSDK.init(
connection,
wallet
);
/* Create a fund (CreateFund + SetRules + Refilter&Reweight) */
let fund: Fund = await fundsSdk.createFund({
hostPlatform: wallet.publicKey,
hostPlatformFee: 0,
manager: wallet.publicKey,
managerFee: 10, // fee in bps: 10 = 0.1%
activelyManaged: true, // actively managed
assetPool: [0, 1, 2, 26], // USDC, SOL, BTC, ETH
refilterInterval: 7 * 24 * 3600, // 1 week
reweightInterval: 24 * 3600, // 1 day
rebalanceInterval: 2 * 3600, // 2 hours
rebalanceThreshold: 500, // 5%
rebalanceSlippage: 300, // 3%
lpOffsetThreshold: 5000, // 50% of rebalance threshold
rules: {
filterBy: FilterType.MarketCap, // filter assets by marketcap
filterDays: FilterTime.Week, // 1 week average of marketcap
sortBy: SortBy.DescendingOrder, // select top coins by marketcap
totalWeight: 100,
fixedAsset: 0,
numAssets: 3, // select 3 assets
weightBy: WeightType.Performace, // weight by performace
weightDays: WeightTime.Day, // 1 day performace
weightExpo: 0.5, // square root of performace
excludeAssets: [0]. // Exclude USDC
}[],
});
// 1. buy a fund with 50 USDC
// 2. rebalance buyState (buy underlying assets)
// 3. mint fund tokens
let buyState1: BuyState = await funds.buyFund(fund, 50);
let txsRebalanceBuyState1 = await funds.rebalanceBuyState(buyState1);
let txMintFund1 = await funds.mintFund(buyState1);
// 1. buy a fund with 50 USDC without rebalancing
// unspent amount will have *penalty* and counted as if rebalance
// happend with maximum slippage (rebalanceSlippage = 3%)
// 2. mint fund tokens
let buyState2: BuyState = await funds.buyFund(fund, 50);
let txMintFund2 = await funds.mintFund(buyState2);
// 1. sell a fund
// 2. rebalance fund (to USDC)
// 3. claim tokens (USDC + tokens for which rebalance failed)
let sellState1: Fund = await funds.sellFund(fund, 0.4, true);
let txsRebalanceSellState = await funds.rebalanceFund(sellState1);
let txsClaimTokens1 = await funds.claimTokens(sellState);
// 1. sell a fund without rebalancing
// 2. claim tokens (all tokens in a fund)
let sellState2: Fund = await funds.sellFund(fund, 0.4, false);
let txsClaimTokens2 = await funds.claimTokens(sellState2);
// 1. Refilter Fund (RefilterInterval seconds since last refilter)
// 2. Reweight Fund (ReweightInterval seconds since last reweight)
// 3. Rebalance Fund (RebalanceInterval seconds since last rebalanace)
let txRefilter: TransactionSignature = await funds.refilterFund(fund);
let txReweight: TransactionSignature = await funds.reweightFund(fund);
let txsRebalance = await funds.rebalanceFund(fund);