WildcatMarketBase.sol

The WildcatMarketBase is the base contract containing core state mutation and computation logic as well as storage variables and immutable values.

sentinel

address public immutable sentinel;

Address with blacklist control, used for blocking sanctioned addresses.

borrower

address public immutable borrower;

Address with authority to borrow assets from the market.

feeRecipient

address public immutable feeRecipient;

Address that receives protocol fees.

protocolFeeBips

uint256 public immutable protocolFeeBips;

Protocol fee added to interest paid by borrower.

One protocol fee bip is 0.01% of an APR bip.

delinquencyFeeBips

uint256 public immutable delinquencyFeeBips;

Penalty fee added to interest earned by lenders, does not affect protocol fee.

delinquencyGracePeriod

uint256 public immutable delinquencyGracePeriod;

Time after which delinquency incurs penalty fee.

controller

address public immutable controller;

Address of the market controller.

asset

address public immutable asset;

Address of the underlying asset.

withdrawalBatchDuration

uint256 public immutable withdrawalBatchDuration;

Time before withdrawal batches are processed.

decimals

uint8 public immutable decimals;

Token decimals, derived from underlying asset.

name

string public name;

Token name, derived from underlying asset.

symbol

string public symbol;

Token symbol, derived from underlying asset.

coverageLiquidity

function coverageLiquidity() external view nonReentrantView returns (uint256);

Liquidity required based on the current market state.

Reverts if:

  • the reentrancy lock is engaged.

scaleFactor

function scaleFactor() external view nonReentrantView returns (uint256);

Scale factor based on the current market state.

Reverts if:

  • the reentrancy lock is engaged.

totalAssets

function totalAssets() public view returns (uint256);

Total market balance of the underlying asset.

borrowableAssets

function borrowableAssets() external view nonReentrantView returns (uint256);

Amount of the underlying asset that may be borrowed based on the current market state.

Reverts if:

  • the reentrancy lock is engaged.

accruedProtocolFees

function accruedProtocolFees() external view nonReentrantView returns (uint256);

Amount of accrued protocol fees based on the current market state.

Reverts if:

  • the reentrancy lock is engaged.

previousState

function previousState() external view returns (MarketState memory);

Returns the state of the market from the last state update, performing no computation or mutations.

currentState

function currentState() external view nonReentrantView returns (MarketState memory state);

Calculates the current market state by applying fees and accrued interest from the last update.

This function does not update the global state, all mutations and computations are performed on a cached version of the market and withdrawal state in memory.

Procedures:

  • If the timestamp matches that of the most recent state update:

    • Return the market state as is, performing no additional computations

  • Otherwise:

    • If a withdrawal batch has expired:

      • Update the market state with the expiry timestamp for:

        • fees

        • delinquency when applicable

        • scale factor

        • withdrawal batch state

    • Otherwise, continue

    • Update the market state with the current timestamp for the following:

      • fees

      • delinquency when applicable

      • scale factor

Reverts if:

  • the reentrancy lock is engaged.

scaledTotalSupply

function scaledTotalSupply() external view nonReentrantView returns (uint256);

Returns the total supply of the current market state scaled by the scale factor.

Reverts if:

  • the reentrancy lock is engaged.

scaledBalanceOf

function scaledBalanceOf(address account) external view nonReentrantView returns (uint256);

Returns the balance of an account scaled by the scale factor.

Reverts if:

  • the reentrancy lock is engaged.

  • the account is blacklisted.

effectiveBorrowerAPR

function effectiveBorrowerAPR() external view returns (uint256);

Effective interest rate paid by the borrower, based on the current market state.

The borrower is responsible for base APR, protocol fee, and penalty APR in place.

effectiveLenderAPR

function effectiveLenderAPR() external view returns (uint256);

Effective interest rate earned by the lenders, based on the current market state.

The lender earns the base APR and any penalty APR in place.

Last updated