Kujira.Ghost (kujira v0.1.24)
Kujira's lending platform.
It has a vault-market architecture, where multiple Market can draw down from a single Vault. A Market must be whitelisted, as the repayment is guaranteed by its own execution logic, e.g. being over-collateralised and having a connection to Orca to liquidate collateral when needed
Summary
Functions
Gets the total deposit value of an address in a Vault. Under the hood, this queries the addresses balance of the receipt token, and adjusts it by the deposit_ratio
Fetches the Market contract and its current config from the chain.
Fetches the Vault contract and its current config from the chain.
Fetches all Markets. This will only change when config changes or new Markets are added. It's Memoized, clearing every 24h.
Fetches all Vaults. This will only change when config changes or new Vaults are added. It's Memoized, clearing every 24h.
Loads the current Status into the Market. Default 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
Loads the current Status into the Vault. Default Memoization to ~ block time / 2 = 2s
Creates a lazy stream for fetching all positions for a Market
Functions
get_deposit(channel, vault, borrower)
@spec get_deposit(GRPC.Channel.t(), Kujira.Ghost.Vault.t(), String.t()) :: {:ok, integer()} | {:error, GRPC.RPCError.t()}
Gets the total deposit value of an address in a Vault. Under the hood, this queries the addresses balance of the receipt token, and adjusts it by the deposit_ratio
Manually clear with Kujira.Ghost.invalidate(:get_deposit, vault, depositor)
get_market(channel, address)
@spec get_market(GRPC.Channel.t(), String.t()) :: {:ok, Kujira.Ghost.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 Kujira.Ghost.invalidate(:get_market, address)
get_vault(channel, address)
@spec get_vault(GRPC.Channel.t(), String.t()) :: {:ok, Kujira.Ghost.Vault.t()} | {:error, :not_found}
Fetches the Vault 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.Ghost.invalidate(:get_vault, address)
invalidate(atom)
invalidate(atom, address)
invalidate(atom, vault, limit)
list_markets(channel, code_ids \\ [291])
@spec list_markets(GRPC.Channel.t(), [integer()]) :: {:ok, [Kujira.Ghost.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 Kujira.Ghost.invalidate(:list_markets)
list_vaults(channel, code_ids \\ [140])
@spec list_vaults(GRPC.Channel.t(), [integer()]) :: {:ok, [Kujira.Ghost.Vault.t()]} | {:error, GRPC.RPCError.t()}
Fetches all Vaults. This will only change when config changes or new Vaults are added. It's Memoized, clearing every 24h.
Manually clear with Kujira.Ghost.invalidate(:list_vaults)
load_market(channel, market)
@spec load_market(GRPC.Channel.t(), Kujira.Ghost.Market.t()) :: {:ok, Kujira.Ghost.Market.t()} | {:error, GRPC.RPCError.t()}
Loads the current Status into the Market. Default Memoization to ~ block time / 2 = 2s
Manually clear with Kujira.Ghost.invalidate(:load_market, market)
load_orca_market(channel, market, precision \\ 3)
@spec load_orca_market(GRPC.Channel.t(), Kujira.Ghost.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
Manually clear with Kujira.Ghost.invalidate(:load_orca_market, market)
load_position(channel, market, borrower)
@spec load_position(GRPC.Channel.t(), Kujira.Ghost.Market.t(), String.t()) :: {:ok, Kujira.Ghost.Position.t()} | {:error, GRPC.RPCError.t()}
Loads a Position by borrower address. Default Memoization to ~ block time / 2 = 2s
Manually clear with Kujira.Ghost.invalidate(:load_position, market, borrower)
load_vault(channel, vault)
@spec load_vault(GRPC.Channel.t(), Kujira.Ghost.Vault.t()) :: {:ok, Kujira.Ghost.Vault.t()} | {:error, GRPC.RPCError.t()}
Loads the current Status into the Vault. Default Memoization to ~ block time / 2 = 2s
Manually clear with Kujira.Ghost.invalidate(:load_vault, vault)
load_vault_oracle_price(channel, vault)
stream_positions(channel, market, vault)
@spec stream_positions( GRPC.Channel.t(), Kujira.Ghost.Market.t(), Kujira.Ghost.Vault.t() ) :: %Stream{ accs: term(), done: term(), enum: term(), funs: term() }
Creates a lazy stream for fetching all positions for a Market