Liquidity Distribution Overview
This is a work-in-progress document that contains a technical explanation of how credit and debt is propagated through the Synthetix protocol.
Chain Nodes
- Market
poolsDebtDistribution
(dynamic, connects to distribution chain)- shares (usd denominated) = distribution[poolId]
- valuePerShare = debt / liquidity
- Pool
vaultsDebtDistribution
(dynamic, connects to debt distribution chain)- shares (usd liquidity) = distribution[vaultId]
- valuePerShare = debt / liquidity
- Vault
accountsIncomingDebtDistribution
(dynamic, connects to debt distribution chain)- shares (usd liquidity) = distribution[accountId]
- valuePerShare = debt / liquidity
accountsConsolidatedDebtDistribution
(static)- t.c.
accountsCollateralDistribution
(static)- t.c.
Example Liquidity Flows
This outlines how debt is propagated from a market, through pools, to accounts' positions in vaults.
- For each of its configured markets…
- Get
acumMarketDebt
from the market (external to distribution chain) - Market to Pool
- Pass the debt to all associated pools with
market.poolsDebtDistribution.distributeValue(acumMarketDebt)
- Update the pool’s shares on
market.poolsDebtDistribution
byacumPoolDebt
=market.poolsDebtDistribution.setActorShares(poolId, newLiquidity)
- Pass the debt to all associated pools with
- Pool to Vault
- Pass the debt to all associated vaults
pool.vaultsDebtDistribtion.distributeValue(acumPoolDebt)
- Update the vault’s shares on
pool.vaultsDebtDistribution
byacumVaultDebt
=pool.vaultsDebtDistribution.setActorShares(vaultId, newLiquidity)
- Pass the debt to all associated vaults
- Vault to Account
- Pass the debt to all associated accounts
vault.accountsDebtDistribtion.distributeValue(acumVaultDebt)
- Update the account’s shares on
vault.accountsDebtDistribution
byacumAccountDebt
=vault.accountsDebtDistribution.setActorShares(accountId, newLiquidity)
- Pass the debt to all associated accounts
- Account to Consolidated debt of the account
vault.consolidatedDebtDistribution.setActorValue(acumAccountDebt + prevAccountDebt)
- Get
Objects
- Pool
distributeDebtToVaults()
- calls
Market.rebalance()
, which returns a change in value - Accumulates each market’s change in value in
cumulativeDebtChange
- Bakes
cumulativeDebtChange
intopool.vaultsDebtDistribution.distributeValue(cumulativeDebtChange)
- calls
- Market
rebalancePools()
- calls
distributeDebtToPools()
- i.e. inflates the debt for all pools - calls
adjustPoolShares()
, which returns a change in value - returns the change in value
- calls
adjustPoolShares()
- Updates the shares of each pool by calling
poolsDebtDistribution.setActorShares(poolId, newLiquidity)
- Returns the change in value
- Updates the shares of each pool by calling
distributeDebtToPools()
- Rolls external market debt to
poolsDebtDistribution
by inflating all of them withpoolsDebtDistribution.distributeValue(acumMarketDebt)
- Rolls external market debt to