Lendgine

Inherits pair, jump rate, and immutable state.

Code

Pair.sol

Events

Mint

event Mint(address indexed sender, uint256 collateral, uint256 shares, uint256 liquidity, address indexed to);

Emitted when a power perpetual token (PPT) is minted.

Burn

event Burn(address indexed sender, uint256 collateral, uint256 shares, uint256 liquidity, address indexed to);

Emitted when a PPT is burned.

Deposit

event Deposit(address indexed sender, uint256 size, uint256 liquidity, address indexed to);

Emitted when liquidity is deposited.

Withdraw

event Withdraw(address indexed sender, uint256 size, uint256 liquidity, address indexed to);

Emitted when liquidity is withdrawn.

AccrueInterest

event AccrueInterest(uint256 timeElapsed, uint256 collateral, uint256 liquidity);

Emitted when interest is accrued.

AccruePositionInterest

event AccruePositionInterest(address indexed owner, uint256 rewardPerPosition);

Emitted when interested is accrued from a position.

Collect

event Collect(address indexed owner, address indexed to, uint256 amount);

Emitted when interest is collected from a liquidity position.

Errors

InputError

error InputError();

Occurs when invalid inputs are passed to any function.

CompleteUtilizationError

error CompleteUtilizationError();

Occurs when liquidity is being withdraw either by a position being withdrawn or liquidity being borrowed but the liquidity is fully being borrowed.

InsufficientInputError

error InsufficientInputError();

Occurs when not enough input is sent for how much output was specified.

InsufficientPositionError

error InsufficientPositionError();

Occurs when an accounts attempts to withdraw a larger position than they have.

Read-only functions

positions

function positions(address) external view returns (uint256, uint256, uint256);

Returns the makeup of a position.

totalPositionSize

function totalPositionSize() external view returns (uint256);

Returns the total amount of liquidity positions minted multiplied by 1 ether.

totalLiquidityBorrowed

function totalLiquidityBorrowed() external view returns (uint256);

Returns the total amount of liquidity that is currently borrowed by PPT holders multiplied by 1 ether.

rewardPerPositionStored

function rewardPerPositionStored() external view returns (uint256);

Returns the current amount of interest that each liquidity position has earned since inception multiplied by 1 ether.

lastUpdate

function lastUpdate() external view returns (uint256);

Returns the last unix timestamp that the interest was accrued at.

convertLiquidityToShare

function convertLiquidityToShare(uint256 liquidity) external view returns (uint256);

Converts amount of liquidity borrowed to shares of power perpetual tokens (PPT).

convertShareToLiquidity

function convertShareToLiquidity(uint256 shares) external view returns (uint256);

Converts shares of PPTs to amount of liquidity borrowed.

convertCollateralToLiquidity

function convertCollateralToLiquidity(uint256 collateral) external view returns (uint256);

Converts collateral to liquidity.

convertLiquidityToCollateral

function convertLiquidityToCollateral(uint256 liquidity) external view returns (uint256);

Converts liquidity to collateral.

State-changing functions

mint

function mint(address to, uint256 collateral, bytes calldata data) external returns (uint256 shares);

Mints a PPT by providing token1 as collateral and borrowing a proportional amount of liquidity.

burn

function burn(address to, bytes calldata data) external returns (uint256 collateral);

Burns a power perpetual token (PPT) by minting the required liquidity and unlocking the collateral. The amount of PPT shares to be burned is specified by transferring that amount to this contract before calling it.

deposit

function deposit(address to, uint256 liquidity, bytes calldata data) external returns (uint256 size);

Provide liquidity to the underlying automated market maker.

withdraw

function withdraw(address to, uint256 size) external returns (uint256 amount0, uint256 amount1, uint256 liquidity);

Withdraw liquidity from the underlying automated market maker.

accrueInterest

function accrueInterest() external;

Accrues global interest by decreasing the total amount of liquidity owed by borrowers and rewarding lenders with the borrowers collateral.

accruePositionInterest

function accruePositionInterest() external;

Accrues interest for the callers liquidity position.

collect

function collect(address to, uint256 collateralRequested) external returns (uint256 collateral);

Collects the interest that has been gathered to the callers liquidity position.

Last updated