Rebalancing Set Issuance Details - SetProtocol/set-protocol-contracts GitHub Wiki

A Rebalancing SetToken is composed of a single base SetToken, and the base SetToken is composed of its components.

Formula for calculating base SetToken components required given a Rebalancing SetToken quantity

baseSetRequired = rebalancingSetQuantity * unitShares / rebalancingSetNaturalUnit

componentRequired = baseSetRequired * unit / baseSetNaturalUnit

Formula for calculating rebalancing Set quantity required

baseSetIssuable = componentQuantity * baseSetNaturalUnit / unit

rebalancingSetIssuable = baseSetIssuable * rebalancingSetNaturalUnit / unitShares

Example: Issue a ETH 20 MACO Set

Let's say you wanted to issue the 1 full unit of the 20 Day MACO Set. To calculate the underlying components required, you do the following:

// MACO Set is the instance of the rebalancing Set
const macoSetQuantity = new BigNumber(10 ** 18);
const macoSetUnitShares = await macoSet.unitShares.callAsync();
const macoSetNaturalUnit = await macoSet.naturalUnit.callAsync();

const requiredBaseSetQuantity = macoSetQuantity.mul(macoSetUnitShares).div(macoSetNaturalUnit);

const baseSet = await macoSet.currentSet.callAsync();
const baseSetNaturalUnit = await baseSet.naturalUnit.callAsync();
const baseSetUnits = await baseSet.units.callAsync();

// Calculate required amount of the component
const requiredComponent = requiredBaseSetQuantity.mul(baseSetUnits[0]).div(baseSetNaturalUnit);