Kujira.Bow (kujira v0.1.28)
Kujira's on-chain Market Maker for FIN.
Summary
Functions
Fetches the Leverage contract and its current config from the chain.
Fetches an XYK algorithm pool and its current config from the chain.
Fetches all Leverage markets. This will only change when config changes or new markets are added. It's Memoized, clearing every 24h.
Loads the current pool status onto the pool
Functions
get_leverage(channel, address)
@spec get_leverage(Channel.t(), String.t()) :: {:ok, Kujira.Bow.Leverage.t()} | {:error, :not_found}
Fetches the Leverage contract and its current config from the chain.
Config is very very rarely changed, if ever, and so this function is Memoized by default.
Manually clear with Kujira.Bow.invalidate(:get_leverage, address)
get_pool_xyk(channel, address)
@spec get_pool_xyk(Channel.t(), String.t()) :: {:ok, Kujira.Bow.Leverage.t()} | {:error, :not_found}
Fetches an XYK algorithm pool and its current config from the chain.
Config is very very rarely changed, if ever, and so this function is Memoized by default.
Manually clear with Kujira.Bow.invalidate(:get_pool_xyk, address)
list_leverage(channel, code_ids \\ [188, 290])
@spec list_leverage(GRPC.Channel.t(), [integer()]) :: {:ok, [Kujira.Bow.Leverage.t()]} | {:error, GRPC.RPCError.t()}
Fetches all Leverage markets. This will only change when config changes or new markets are added. It's Memoized, clearing every 24h.
Manually clear with Kujira.Bow.invalidate(:list_leverage)
load_orca_market(channel, market, precision \\ 3)
@spec load_orca_market(Channel.t(), Kujira.Bow.Leverage.t(), integer() | nil) :: {:ok, Kujira.Orca.Market.t()} | {:error, GRPC.RPCError.t()}
WIP
Loads the Leverage Market into a format that Orca can consume for health reporting. Default Memoization to 10 mins
The liquidation price of a position is dependent on the algorithm of the BOW pool.
Eg: KUJI is at 2 USDC when a position is opened. The BOW pool is in a 1:2 ratio, and I deposit 100 KUJI and borrow 200 USDC. My initial LTV is 0.5 - a total of $400 of LP tokens with $200 borrowed. Say the max LTV is 0.8, then liquidation can ocurr when the LP value decreases to 250 USDC. In this instance, as the ratio of the pool should be the current price, there will be 125 USDC and X * 125 = 20000 so 160 KUJI where the price is now 0.78125
The liquidation price if KUJI is the borrowed asset is the same deviation in the opposite direction I deposit 200 USDC and borrow 100 KUJI Max LTV 0.8 liquidation can ocurr when LP value is 125 KUJI So there'll be 62.5 KUJI and 62.5 * Y = 20000 so 320 USDC and the price is 5.12
Blended liquidation price I deposit 100 USDC, 75 KUJI and borrow 100 USDC and 25 KUJI Max LTV 0.8 liquidation can ocurr when LP value is 125 KUJI So there'll be 62.5 KUJI and 62.5 * Y = 20000 so 320 USDC and the price is 5.12
Manually clear with Kujira.Bow.invalidate(:load_orca_market, market)
load_pool(channel, pool)
@spec load_pool(Channel.t(), Kujira.Bow.Xyk.t()) :: {:ok, Kujira.Bow.Xyk.t()} | {:error, :not_found}
@spec load_pool(Channel.t(), Kujira.Bow.Stable.t()) ::
{:ok, Kujira.Bow.Stable.t()} | {:error, :not_found}
@spec load_pool(Channel.t(), Kujira.Bow.Lsd.t()) ::
{:ok, Kujira.Bow.Lsd.t()} | {:error, :not_found}
Loads the current pool status onto the pool
It's Memoized, clearing every 2 seconds.
Manually clear with Kujira.Bow.invalidate(:load_pool, address)