Kujira.Usk (kujira v0.1.27)

Kujira's decentralized stablecoin

Users deposit collateral and mint USK up to the maximum LTV permitted by the individual market

Summary

Functions

Fetches the Controller contract and its current config from the chain.

Fetches the Margin contract and its current config from the chain.

Fetches the Market contract and its current config from the chain.

Fetches all Margins. This will only change when config changes or new Margins are added. It's Memoized, clearing every 24h.

Fetches all Markets. This will only change when config changes or new Markets are added. It's Memoized, clearing every 24h.

Loads the current Status into the Margin.market. Default Memoization to ~ block time / 2 = 2s

Loads the current Status into the Market. efault Memoization to ~ block time / 2 = 2s

Loads the Market into a format that Orca can consume for health reporting. Default Memoization to 10 mins

Loads a Position by borrower address. Default Memoization to ~ block time / 2 = 2s

Creates a lazy stream for fetching all positions for a Market

Functions

Link to this function

get_controller(channel)

@spec get_controller(GRPC.Channel.t()) ::
  {:ok, Kujira.Usk.Controller.t()} | {:error, :not_found}

Fetches the Controller 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.Usk.invalidate(:get_controller)

Link to this function

get_margin(channel, address)

@spec get_margin(GRPC.Channel.t(), String.t()) ::
  {:ok, Kujira.Usk.Margin.t()} | {:error, :not_found}

Fetches the Margin 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.Usk.invalidate(:get_margin, address)

Link to this function

get_market(channel, address)

@spec get_market(GRPC.Channel.t(), String.t()) ::
  {:ok, Kujira.Usk.Market.t()} | {:error, :not_found}

Fetches the Market 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 Memoize.invalidate(Kujira.Contract, :get, [{Market, address}])

Link to this function

invalidate(atom)

Link to this function

invalidate(atom, address)

Link to this function

invalidate(atom, margin, limit)

Link to this function

list_margins(channel, code_ids \\ 'W')

@spec list_margins(GRPC.Channel.t(), [integer()]) ::
  {:ok, [Kujira.Usk.Margin.t()]} | {:error, GRPC.RPCError.t()}

Fetches all Margins. This will only change when config changes or new Margins are added. It's Memoized, clearing every 24h.

Manually clear with Kujira.Usk.invalidate(:list_margins)

Link to this function

list_markets(channel, code_ids \\ 'I')

@spec list_markets(GRPC.Channel.t(), [integer()]) ::
  {:ok, [Kujira.Usk.Market.t()]} | {:error, GRPC.RPCError.t()}

Fetches all Markets. This will only change when config changes or new Markets are added. It's Memoized, clearing every 24h.

Manually clear with Memoize.invalidate(Kujira.Contract, :list, [Market, code_ids])

Link to this function

load_margin(channel, margin)

@spec load_margin(GRPC.Channel.t(), Kujira.Usk.Margin.t()) ::
  {:ok, Kujira.Usk.Margin.t()} | {:error, GRPC.RPCError.t()}

Loads the current Status into the Margin.market. Default Memoization to ~ block time / 2 = 2s

Manually clear with Kujira.Usk.invalidate(:load_margin, margin)

Link to this function

load_market(channel, market)

@spec load_market(GRPC.Channel.t(), Kujira.Usk.Market.t()) ::
  {:ok, Kujira.Usk.Market.t()} | {:error, GRPC.RPCError.t()}

Loads the current Status into the Market. efault Memoization to ~ block time / 2 = 2s

Manually clear with Kujira.Usk.invalidate(:load_market, address)

Link to this function

load_orca_market(channel, market, precision \\ 3)

@spec load_orca_market(GRPC.Channel.t(), Kujira.Usk.Market.t(), integer() | nil) ::
  {:ok, Kujira.Orca.Market.t()} | {:error, GRPC.RPCError.t()}

Loads the Market into a format that Orca can consume for health reporting. Default Memoization to 10 mins

Can be used for both a Ghost.Market and Ghost.Margin.market, as they both use the same underlying state schema

Manually clear with Kujira.Usk.invalidate(:load_orca_market, market)

Link to this function

load_position(channel, market, borrower)

@spec load_position(GRPC.Channel.t(), Kujira.Usk.Market.t(), String.t()) ::
  {:ok, Kujira.Usk.Position.t()} | {:error, GRPC.RPCError.t()}

Loads a Position by borrower address. Default Memoization to ~ block time / 2 = 2s

Manually clear with Kujira.Usk.invalidate(:load_position, market, borrower)

Link to this function

stream_positions(channel, market)

@spec stream_positions(GRPC.Channel.t(), Kujira.Usk.Market.t()) :: %Stream{
  accs: term(),
  done: term(),
  enum: term(),
  funs: term()
}

Creates a lazy stream for fetching all positions for a Market