Kujira.Bow (kujira v0.1.32)

Kujira's on-chain Market Maker for FIN.

Summary

Functions

Fetches the Leverage contract and its current config from the chain

Fetches the Pool contract and its current config from the chain

Fetches all Leverage markets

Loads the current pool status onto the pool

Functions

Link to this function

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

Link to this function

get_pool(channel, address)

@spec get_pool(Channel.t(), String.t()) ::
  {:ok, Kujira.Bow.Pool.t()} | {:error, :not_found}

Fetches the Pool contract and its current config from the chain

Link to this function

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

Link to this function

list_pools(channel, code_ids \\ [54, 126, 294, 158, 167, 161, 166])

@spec list_pools(GRPC.Channel.t(), [integer()]) ::
  {:ok, [Kujira.Bow.Pool.t()]} | {:error, GRPC.RPCError.t()}

Fetches all Pools

Link to this function

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

Link to this function

load_pool(channel, pool)

@spec load_pool(Channel.t(), Kujira.Bow.Pool.Xyk.t()) ::
  {:ok, Kujira.Bow.Pool.Xyk.t()} | {:error, :not_found}
@spec load_pool(Channel.t(), Kujira.Bow.Pool.Stable.t()) ::
  {:ok, Kujira.Bow.Pool.Stable.t()} | {:error, :not_found}
@spec load_pool(Channel.t(), Kujira.Bow.Pool.Lsd.t()) ::
  {:ok, Kujira.Bow.Pool.Lsd.t()} | {:error, :not_found}

Loads the current pool status onto the pool