Kujira.Usk (kujira v0.1.25)
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
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)
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)
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}])
invalidate(atom)
invalidate(atom, address)
invalidate(atom, margin, limit)
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)
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])
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)
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)
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)
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)
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