Skip to main content

CollateralTracker

Git Source

Inherits: Clone, ERC20Minimal, Multicall, TransientReentrancyGuard

Title: Collateral Tracking System / Margin Accounting used in conjunction with a Panoptic Pool.

Author: Axicon Labs Limited

Tracks collateral of users which is key to ensure the correct level of collateralization is achieved. This is represented as an ERC20 share token. A Panoptic pool has 2 tokens, each issued by its own instance of a CollateralTracker. All math within this contract pertains to a single token.

This contract uses the ERC4626 standard allowing the minting and burning of "shares" (represented using ERC20 inheritance) in exchange for underlying "assets". Panoptic uses a collateral tracking system that is similar to TradFi margin accounts. While users can borrow and effectively control funds several times larger than the collateral they deposited, they cannot withdraw those funds from the Panoptic-Uniswap ecosystem. All funds are always owned by the Panoptic protocol, but users will:

1) collect any fees generated by selling an option.

2) get any gain in capital that results from buying an option that becomes in-the-money.

State Variables
​

TICKER_PREFIX
​

Prefix for the token symbol (i.e. poUSDC).

string internal constant TICKER_PREFIX = "po"

NAME_PREFIX
​

Prefix for the token name (i.e POPT-V1 USDC LP on ETH/USDC 30bps).

string internal constant NAME_PREFIX = "POPT-V1"

DECIMALS
​

Decimals for computation (1 bps (1 basis point) precision: 0.01%).

uint type for composability with unsigned integer based mathematical operations.

uint256 internal constant DECIMALS = 10_000

WAD
​

Decimals for WAD calculations.

uint256 internal constant WAD = 1e18

TARGET_RATE_MASK
​

Mask zero the value between bits 112 and 150);

uint256 internal constant TARGET_RATE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFF

DONOT_SKIP_INTEREST
​

bool internal constant DONOT_SKIP_INTEREST = false

SKIP_INTEREST
​

bool internal constant SKIP_INTEREST = true

UTILIZATION_TRANSIENT_SLOT
​

Transient storage slot for the utilization

bytes32 internal constant UTILIZATION_TRANSIENT_SLOT = keccak256("panoptic.utilization.snapshot")

s_depositedAssets
​

Cached amount of assets accounted to be held by the Panoptic Pool β€” ignores donations, pending fee payouts, and other untracked balance changes.

uint128 internal s_depositedAssets

s_assetsInAMM
​

Amount of assets moved from the Panoptic Pool to the AMM.

uint128 internal s_assetsInAMM

s_creditedShares
​

Amount of shares credited to the protocol, includes credits and purchased option liquidity above the rehypothecation threshold.

uint256 internal s_creditedShares

s_initialized
​

Boolean which tracks whether this CollateralTracker has been initialized.

bool internal s_initialized

s_marketState
​

How the Borrow Index Works The borrow index is a global accumulator that tracks how much $1 of debt grows over time with compound interest. It starts at 1e18 (representing 1.0) and increases continuously. Example:

  • User borrows 100 tokens when globalIndex = 1.0e18
  • Time passes, globalIndex grows to 1.2e18 (20% growth)
  • User now owes: 100 * (1.2e18 / 1.0e18) = 120 tokens Each user stores their "checkpoint" index from their last interaction, allowing efficient compound interest calculation without iteration.

Global interest rate accumulator packed into a single 256-bit value

Layout:

  • Left slot (106 bits): Accumulated unrealized interest that hasn't been distributed (max deposit is 2**104)
  • Next 38 bits: the rateAtTarget value in WAD (2**38 = 800% interest rate)
  • Next lowest 32 bits: Last interaction epoch (1 epoch = block.timestamp/4)
  • Lowest 80 bits: Global borrow index in WAD (starts at 1e18). 2*80 = 1.75 years at 800% interest The borrow index tracks the compound growth factor since protocol inception. A user's current debt = originalDebt (currentBorrowIndex / userBorrowIndexSnapshot)
MarketState internal s_marketState

s_interestState
​

Tracks each user's borrowing state and last interaction checkpoint

Packed layout:

  • Left slot (128 bits): Net borrows = netShorts - netLongs Represents the user's net borrowed amount in tokens Can be negative, in which case they purchased more options than they sold
  • Right slot (128 bits): User's borrow index snapshot The global borrow index value when this user last accrued interest

Interest calculation: interestOwed = netBorrows * (currentIndex - userIndex) / userIndex

mapping(address account => LeftRightSigned interestState) internal s_interestState

COMMISSION_FEE
​

The commission fee, in basis points, collected from PLPs at option mint.

In Panoptic, options never expire, commissions are only paid when a new position is minted.

We believe that this will eliminate the impact of the commission fee on the user's decision-making process when closing a position.

uint256 immutable COMMISSION_FEE

Functions
​

panopticPool
​

Retrieve the Panoptic Pool that this collateral token belongs to.

function panopticPool() public pure returns (PanopticPool);

Returns

NameTypeDescription
<none>PanopticPoolThe Panoptic Pool associated with this collateral token

underlyingIsToken0
​

Retrieve a boolean indicating whether the underlying token is token0 or token1 in the Uniswap V3 pool.

function underlyingIsToken0() public pure returns (bool _underlyingIsToken0);

Returns

NameTypeDescription
_underlyingIsToken0boolTrue if the underlying token is token0, false if it is token1

underlyingToken
​

Retrieve the address of the underlying token.

function underlyingToken() public pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of the underlying token

token0
​

Retrieve the address of token0 in the Uniswap V3 pool.

function token0() public pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of token0 in the Uniswap V3 pool

token1
​

Retrieve the address of token1 in the Uniswap V3 pool.

function token1() public pure returns (address);

Returns

NameTypeDescription
<none>addressThe address of token1 in the Uniswap V3 pool

riskEngine
​

Retrieve the RiskEngine associated with that CollateralTracker.

function riskEngine() public pure returns (IRiskEngine);

Returns

NameTypeDescription
<none>IRiskEngineThe RiskEngine instance associated with that CollateralTracker's uniswap pool

poolManager
​

Retrieve the PoolManager associated with that CollateralTracker.

stored as zero if not a Uniswap v4 pool

function poolManager() public pure returns (IPoolManager);

Returns

NameTypeDescription
<none>IPoolManagerThe PoolManager instance associated with that CollateralTracker's uniswap V4 pool

poolFee
​

Retrieve the fee of the Uniswap V3 pool.

function poolFee() public pure returns (uint24 _poolFee);

Returns

NameTypeDescription
_poolFeeuint24The fee of the Uniswap V3 pool

onlyPanopticPool
​

Reverts if the associated Panoptic Pool is not the caller.

modifier onlyPanopticPool() ;

_onlyPanopticPool
​

function _onlyPanopticPool() internal view;

constructor
​

Set immutable parameters for the Collateral Tracker.

constructor(uint256 _commissionFee) ;

Parameters

NameTypeDescription
_commissionFeeuint256The commission fee, in basis points, collected from PLPs at option mint

initialize
​

Initializes a new CollateralTracker instance with 1 virtual asset and 10^6 virtual shares. Can only be called once; reverts if already initialized.

function initialize() external;

getPoolData
​

Get information about the utilization of this collateral vault.

function getPoolData()
external
view
returns (uint256 depositedAssets, uint256 insideAMM, uint256 creditedShares, uint256 currentPoolUtilization);

Returns

NameTypeDescription
depositedAssetsuint256Cached amount of assets accounted to be held by the Panoptic Pool β€” ignores donations, pending fee payouts, and other untracked balance changes
insideAMMuint256The underlying token amount held in the AMM
creditedSharesuint256The amount of shares currently held as credit
currentPoolUtilizationuint256The pool utilization defined ass_assetsInAMM * 10_000 / totalAssets(), where totalAssets is the total tracked assets in the AMM and PanopticPool minus fees and donations to the Panoptic pool

borrowIndex
​

Returns the global borrow index that tracks compound interest growth

The index starts at 1e18 and compounds continuously. Represents how much 1 unit of debt has grown since inception

function borrowIndex() external view returns (uint80);

Returns

NameTypeDescription
<none>uint80The current global borrow index in WAD (18 decimals)

lastInteractionTimestamp
​

Returns the last time at which interest rates were compounded.

function lastInteractionTimestamp() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The last time at which the interest rates were compounded

unrealizedGlobalInterest
​

Returns the accumulated unrealized global interest

function unrealizedGlobalInterest() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total interest that has accumulated but not yet been distributed to lenders

rateAtTarget
​

Returns rateAtTarget of the market

function rateAtTarget() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The rateAtTarget

interestState
​

Returns the borrowing state for a specific user

Returns both the user's borrow index snapshot and their net borrowed amount

function interestState(address user) external view returns (int128 userBorrowIndex, int128 netBorrows);

Returns

NameTypeDescription
userBorrowIndexint128The borrow index when the user last accrued interest (used as the basis for interest calculation)
netBorrowsint128The net borrowed amount for the user (positive = borrower, zero/negative = no interest owed)

name
​

Returns name of token composed of underlying token symbol and pool data.

function name() external view returns (string memory);

Returns

NameTypeDescription
<none>stringThe name of the token

symbol
​

Returns symbol as prefixed symbol of underlying token.

function symbol() external view returns (string memory);

Returns

NameTypeDescription
<none>stringThe symbol of the token

decimals
​

Returns decimals of underlying token (0 if not present).

function decimals() external view returns (uint8);

Returns

NameTypeDescription
<none>uint8The decimals of the token

transfer
​

See IERC20-transfer.

Requirements:

  • the caller must have a balance of at least amount.
  • the caller must not have any open positions on the Panoptic Pool.
function transfer(address recipient, uint256 amount) public override(ERC20Minimal) nonReentrant returns (bool);

transferFrom
​

See IERC20-transferFrom.

Requirements:

  • the from must have a balance of at least amount.
  • the caller must have allowance for from of at least amount tokens.
  • from must not have any open positions on the Panoptic Pool.
function transferFrom(address from, address to, uint256 amount)
public
override(ERC20Minimal)
nonReentrant
returns (bool);

_settleCurrencyDelta
​

Initiates the unlock callback to wrap/unwrap delta amount of the underlying asset and transfer to/from the Panoptic Pool.

function _settleCurrencyDelta(address account, int256 delta) internal;

Parameters

NameTypeDescription
accountaddressThe address of the account to transfer the underlying asset to/from
deltaint256The amount of the underlying asset to wrap/unwrap and transfer

unlockCallback
​

Uniswap V4 unlock callback implementation.

Parameters are (address account, int256 delta, uint256 valueOrigin).

Wraps/unwraps delta amount of the underlying asset and transfers to/from the Panoptic Pool.

function unlockCallback(bytes calldata data) external returns (bytes memory);

Parameters

NameTypeDescription
databytesThe encoded data containing the account, delta, and valueOrigin

Returns

NameTypeDescription
<none>bytesThis function returns no data

asset
​

Get the token contract address of the underlying asset being managed.

function asset() external pure returns (address assetTokenAddress);

Returns

NameTypeDescription
assetTokenAddressaddressThe address of the underlying asset

totalAssets
​

Get the total amount of assets managed by the CollateralTracker vault.

This returns the total tracked assets in the AMM and PanopticPool,

  • EXCLUDING the amount of collected fees (because they are reserved for short options)

  • EXCLUDING any donations that have been made to the pool

function totalAssets() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total amount of assets managed by the CollateralTracker vault

totalSupply
​

Returns the total supply of shares including credited shares

function totalSupply() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256The total supply of shares (internal supply + credited shares)

convertToShares
​

Returns the amount of shares that can be minted for the given amount of assets.

function convertToShares(uint256 assets) public view returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256The amount of assets to be deposited

Returns

NameTypeDescription
sharesuint256The amount of shares that can be minted

convertToAssets
​

Returns the amount of assets that can be redeemed for the given amount of shares.

function convertToAssets(uint256 shares) public view returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256The amount of shares to be redeemed

Returns

NameTypeDescription
assetsuint256The amount of assets that can be redeemed

assetsOf
​

Returns the amount of assets that can be redeem by the user.

function assetsOf(address owner) external view returns (uint256 assets);

Parameters

NameTypeDescription
owneraddressThe redeeming address

Returns

NameTypeDescription
assetsuint256The amount of assets that can be redeemed

maxDeposit
​

Returns the maximum deposit amount.

function maxDeposit(address) external pure returns (uint256 maxAssets);

Returns

NameTypeDescription
maxAssetsuint256The maximum amount of assets that can be deposited

previewDeposit
​

Returns shares received for depositing given amount of assets.

function previewDeposit(uint256 assets) public view returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256The amount of assets to be deposited

Returns

NameTypeDescription
sharesuint256The amount of shares that can be minted

deposit
​

Deposit underlying tokens (assets) to the Panoptic pool from the LP and mint corresponding amount of shares.

There is a maximum asset deposit limit of 2^104 - 1.

Shares are minted and sent to the LP (receiver).

function deposit(uint256 assets, address receiver) external payable nonReentrant returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Amount of assets deposited
receiveraddressUser to receive the shares

Returns

NameTypeDescription
sharesuint256The amount of Panoptic pool shares that were minted to the recipient

maxMint
​

Returns the maximum shares received for a deposit.

function maxMint(address) external view returns (uint256 maxShares);

Returns

NameTypeDescription
maxSharesuint256The maximum amount of shares that can be minted

previewMint
​

Returns the amount of assets that would be deposited to mint a given amount of shares.

function previewMint(uint256 shares) public view returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256The amount of shares to be minted

Returns

NameTypeDescription
assetsuint256The amount of assets required to mint shares

mint
​

Deposit required amount of assets to receive specified amount of shares.

There is a maximum asset deposit limit of 2^104 - 1.

Shares are minted and sent to the LP (receiver).

function mint(uint256 shares, address receiver) external payable nonReentrant returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Amount of shares to be minted
receiveraddressUser to receive the shares

Returns

NameTypeDescription
assetsuint256The amount of assets deposited to mint the desired amount of shares

maxWithdraw
​

Returns The maximum amount of assets that can be withdrawn for a given user. If the user has any open positions, the max withdrawable balance is zero.

Calculated from the balance of the user; limited by the assets the pool has available.

function maxWithdraw(address owner) public view returns (uint256 maxAssets);

Parameters

NameTypeDescription
owneraddressThe address being withdrawn for

Returns

NameTypeDescription
maxAssetsuint256The maximum amount of assets that can be withdrawn

_maxWithdrawWithPositions
​

Returns The maximum amount of assets that can be withdrawn for a given user with open positions. If the user has any open positions, the max withdrawable balance is zero.

Calculated from the balance of the user; limited by the assets the pool has available.

function _maxWithdrawWithPositions(address owner) internal view returns (uint256 maxAssets);

Parameters

NameTypeDescription
owneraddressThe address being withdrawn for

Returns

NameTypeDescription
maxAssetsuint256The maximum amount of assets that can be withdrawn

previewWithdraw
​

Returns the amount of shares that would be burned to withdraw a given amount of assets.

function previewWithdraw(uint256 assets) public view returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256The amount of assets to be withdrawn

Returns

NameTypeDescription
sharesuint256The amount of shares that would be burned

withdraw
​

Redeem the amount of shares required to withdraw the specified amount of assets.

We can only use this standard 4626 function if the user has no open positions.

Shares are burned and assets are sent to the LP (receiver).

function withdraw(uint256 assets, address receiver, address owner) external nonReentrant returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Amount of assets to be withdrawn
receiveraddressUser to receive the assets
owneraddressUser to burn the shares from

Returns

NameTypeDescription
sharesuint256The amount of shares burned to withdraw the desired amount of assets

withdraw
​

Redeem the amount of shares required to withdraw the specified amount of assets.

Reverts if the account is not solvent with the given positionIdList.

Shares are burned and assets are sent to the LP (receiver).

function withdraw(
uint256 assets,
address receiver,
address owner,
TokenId[] calldata positionIdList,
bool usePremiaAsCollateral
) external nonReentrant returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Amount of assets to be withdrawn
receiveraddressUser to receive the assets
owneraddressUser to burn the shares from
positionIdListTokenId[]The list of all option positions held by owner
usePremiaAsCollateralboolWhether to compute accumulated premia for all legs held by the user for collateral (true), or just owed premia for long legs (false)

Returns

NameTypeDescription
sharesuint256The amount of shares burned to withdraw the desired amount of assets

maxRedeem
​

Returns the maximum amount of shares that can be redeemed for a given user.

If the user has any open positions, the max redeemable balance is zero.

function maxRedeem(address owner) public view returns (uint256 maxShares);

Parameters

NameTypeDescription
owneraddressThe redeeming address

Returns

NameTypeDescription
maxSharesuint256The maximum amount of shares that can be redeemed by owner

previewRedeem
​

Returns the amount of assets resulting from a given amount of shares being redeemed.

function previewRedeem(uint256 shares) public view returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256The amount of shares to be redeemed

Returns

NameTypeDescription
assetsuint256The amount of assets resulting from the redemption

redeem
​

Redeem exact shares for underlying assets.

We can only use this standard 4626 function if the user has no open positions.

function redeem(uint256 shares, address receiver, address owner) external nonReentrant returns (uint256 assets);

Parameters

NameTypeDescription
sharesuint256Amount of shares to be redeemed
receiveraddressUser to receive the assets
owneraddressUser to burn the shares from

Returns

NameTypeDescription
assetsuint256The amount of assets resulting from the redemption

Donate exact shares to all shareholders.

Can only be used when the user has no open positions

function donate(uint256 shares) external nonReentrant;

Parameters

NameTypeDescription
sharesuint256Amount of shares to be donated

accrueInterest
​

Accrues protocol-wide interest for the calling user

Updates global interest state and settles any outstanding interest for msg.sender

function accrueInterest() external nonReentrant;

_accrueInterest
​

Accrues protocol-wide interest and settles a specific user's interest.

This function should be called before any user action that affects their borrow balance.

function _accrueInterest(address owner, bool skipInterest) internal;

Parameters

NameTypeDescription
owneraddressthe account which calls accrue interest
skipInterestbool

_calculateCurrentInterestState
​

Calculates the current interest state without modifying storage

Simulates interest accrual from last interaction to current epoch

function _calculateCurrentInterestState(uint128 _assetsInAMM, uint128 interestRateSnapshot)
internal
view
returns (uint128 currentBorrowIndex, uint128 _unrealizedGlobalInterest, uint256 currentEpoch);

Parameters

NameTypeDescription
_assetsInAMMuint128Amount of assets currently deployed in AMM positions
interestRateSnapshotuint128The current interest rate to evaluate at

Returns

NameTypeDescription
currentBorrowIndexuint128Updated global borrow index after simulated accrual
_unrealizedGlobalInterestuint128Total unrealized interest including new accrual
currentEpochuint256Current epoch = block timestamp / 4

_interestRateView
​

function _interestRateView(uint256 utilization) internal view returns (uint128);

interestRate
​

Returns the current interest rate per second based on pool utilization

function interestRate() public view returns (uint128);

Returns

NameTypeDescription
<none>uint128The current interest rate per second in WAD (18 decimal precision)

_updateInterestRate
​

Returns the interest rate per second based on pool utilization

uses the maximum utilization during this transaction, users to prevent flash deposits from lowering the interest rate

function _updateInterestRate() internal returns (uint128);

Returns

NameTypeDescription
<none>uint128The interest rate per second in 18 decimal precision

_getUserInterest
​

Calculates interest owed by a user based on their borrow state

Uses the difference between current and user's last borrow index to compute compound interest

function _getUserInterest(LeftRightSigned userState, uint256 currentBorrowIndex)
internal
pure
returns (uint128 interestOwed);

Parameters

NameTypeDescription
userStateLeftRightSignedPacked state containing user's net borrows (left slot) and last borrow index (right slot)
currentBorrowIndexuint256The current global borrow index

Returns

NameTypeDescription
interestOweduint128Amount of interest the user owes, returns 0 if user is a lender or indices match

owedInterest
​

Returns the current interest owed by a specific user in assets

function owedInterest(address owner) external view returns (uint128);

Parameters

NameTypeDescription
owneraddressAddress of the user to check

Returns

NameTypeDescription
<none>uint128The amount of interest currently owed by the user in assets

assetsAndInterest
​

Returns the assets and interest owed for a specific user

function assetsAndInterest(address owner) external view returns (uint256, uint256);

Parameters

NameTypeDescription
owneraddressAddress of the user to check

Returns

NameTypeDescription
<none>uint256The amount of assets owned by the user (in token units)
<none>uint256The amount of interest currently owed by the user (in token units)

_owedInterest
​

Internal function to calculate interest owed by a user

Retrieves user state and current borrow index from storage

function _owedInterest(address owner) internal view returns (uint128);

Parameters

NameTypeDescription
owneraddressAddress of the user to check

Returns

NameTypeDescription
<none>uint128Amount of interest owed based on last compounded index

_calculateCurrentBorrowIndex
​

Calculates the current borrow index including uncompounded time

Simulates interest accrual up to the current block epoch

function _calculateCurrentBorrowIndex() internal view returns (uint256);

Returns

NameTypeDescription
<none>uint256The borrow index as if interest was compounded at current epoch

previewOwedInterest
​

Previews the interest that would be owed if compounded now

Simulates interest accrual without modifying state

function previewOwedInterest(address owner) external view returns (uint128);

Parameters

NameTypeDescription
owneraddressAddress of the user to preview interest for

Returns

NameTypeDescription
<none>uint128The amount of interest that would be owed if accrued at current epoch

_poolUtilization
​

Get the pool utilization defined by the ratio of assets in the AMM to total assets.

calling this function will also store the utilization in the UTILIZATION_TRANSIENT_SLOT as DECIMALS if the current one is higher than the one already stored. This ensures that flash deposits can't lower the utilization for a single tx

function _poolUtilization() internal returns (uint256 poolUtilization);

Returns

NameTypeDescription
poolUtilizationuint256The pool utilization in basis points

_poolUtilizationView
​

Get the pool utilization defined by the ratio of assets in the AMM to total assets.

function _poolUtilizationView() internal view returns (uint256 poolUtilization);

Returns

NameTypeDescription
poolUtilizationuint256The pool utilization in basis points

_poolUtilizationWad
​

Get the pool utilization defined by the ratio of assets in the AMM to total assets.

calling this function will also store the utilization in the UTILIZATION_TRANSIENT_SLOT as DECIMALS if the current one is higher than the one already stored. This ensures that flash deposits can't lower the utilization for a single tx

function _poolUtilizationWad() internal returns (uint256);

Returns

NameTypeDescription
<none>uint256poolUtilization The pool utilization in basis points

_poolUtilizationWadView
​

Get the pool utilization defined by the ratio of assets in the AMM to total assets.

function _poolUtilizationWadView() internal view returns (uint256 poolUtilization);

Returns

NameTypeDescription
poolUtilizationuint256The pool utilization in WAD

delegate
​

Increase the share balance of a user by 2^248 - 1 without updating the total supply.

This is controlled by the Panoptic Pool - not individual users.

function delegate(address delegatee) external onlyPanopticPool nonReentrant;

Parameters

NameTypeDescription
delegateeaddressThe account to increase the balance of

revoke
​

Decrease the share balance of a user by 2^248 - 1 without updating the total supply.

Assumes that delegatee has >=(2^248 - 1) tokens, will revert otherwise.

This is controlled by the Panoptic Pool - not individual users.

function revoke(address delegatee) external onlyPanopticPool nonReentrant;

Parameters

NameTypeDescription
delegateeaddressThe account to decrease the balance of

settleLiquidation
​

Settles liquidation bonus and returns remaining virtual shares to the protocol.

This function is where protocol loss is realized, if it exists.

function settleLiquidation(address liquidator, address liquidatee, int256 bonus)
external
payable
onlyPanopticPool
nonReentrant;

Parameters

NameTypeDescription
liquidatoraddressThe account performing the liquidation of liquidatee
liquidateeaddressThe liquidated account to settle
bonusint256The liquidation bonus, in assets, to be paid to liquidator. May be negative

refund
​

Refunds tokens to refunder from refundee.

Assumes that the refunder has enough money to pay for the refund.

function refund(address refunder, address refundee, int256 assets) external onlyPanopticPool nonReentrant;

Parameters

NameTypeDescription
refunderaddressThe account refunding tokens to refundee
refundeeaddressThe account being refunded to
assetsint256The amount of assets to refund. Positive means a transfer from refunder to refundee, vice versa for negative

_updateBalancesAndSettle
​

Internal function to handle all balance and state updates for position creation and closing.

function _updateBalancesAndSettle(
address optionOwner,
bool isCreation,
int128 longAmount,
int128 shortAmount,
int128 ammDeltaAmount,
int128 realizedPremium
) internal returns (uint32, int128, uint256, uint256);

Parameters

NameTypeDescription
optionOwneraddressThe user minting the option
isCreationboolA boolean flag to indicate if this is for option creation (true) or closing (false).
longAmountint128The amount of longs
shortAmountint128The amount of shorts
ammDeltaAmountint128The amount of tokens moved during creation of the option position
realizedPremiumint128

settleMint
​

Take commission and settle ITM amounts on option creation.

function settleMint(
address optionOwner,
int128 longAmount,
int128 shortAmount,
int128 ammDeltaAmount,
RiskParameters riskParameters
) external onlyPanopticPool nonReentrant returns (uint32, int128);

Parameters

NameTypeDescription
optionOwneraddressThe user minting the option
longAmountint128The amount of longs
shortAmountint128The amount of shorts
ammDeltaAmountint128The amount of tokens moved during creation of the option position
riskParametersRiskParametersThe RiskEngine's core parameters

Returns

NameTypeDescription
<none>uint32utilization The final utilization of the collateral vault (in basis points)
<none>int128tokenPaid The total amount of tokens paid by the option owner (negative if tokens were received)

settleBurn
​

Exercise an option and pay to the seller what is owed from the buyer.

Called when a position is burnt because it may need to be exercised.

function settleBurn(
address optionOwner,
int128 longAmount,
int128 shortAmount,
int128 ammDeltaAmount,
int128 realizedPremium,
RiskParameters riskParameters
) external onlyPanopticPool nonReentrant returns (int128);

Parameters

NameTypeDescription
optionOwneraddressThe owner of the option being burned
longAmountint128The notional value of the long legs of the position (if any)
shortAmountint128The notional value of the short legs of the position (if any)
ammDeltaAmountint128The amount of tokens moved during the option close
realizedPremiumint128Premium to settle on the current positions
riskParametersRiskParametersThe RiskEngine's core risk parameters

Returns

NameTypeDescription
<none>int128The amount of tokens paid when closing that position

Events
​

Deposit
​

Emitted when assets are deposited into the Collateral Tracker.

event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);

Parameters

NameTypeDescription
senderaddressThe address of the caller
owneraddressThe address of the recipient of the newly minted shares
assetsuint256The amount of assets deposited by sender in exchange for shares
sharesuint256The amount of shares minted to owner

Withdraw
​

Emitted when assets are withdrawn from the Collateral Tracker.

event Withdraw(
address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares
);

Parameters

NameTypeDescription
senderaddressThe address of the caller
receiveraddressThe address of the recipient of the withdrawn assets
owneraddressThe address of the owner of the shares being burned
assetsuint256The amount of assets withdrawn to receiver
sharesuint256The amount of shares burned by owner in exchange for assets

Emitted when shares are donated to the protocol.

event Donate(address indexed sender, uint256 shares);

Parameters

NameTypeDescription
senderaddressThe address of the caller
sharesuint256The amount of shares burned by the sender

CommissionPaid
​

Emitted when a commission is paid.

event CommissionPaid(
address indexed owner, address indexed builder, uint128 commissionPaidProtocol, uint128 commissionPaidBuilder
);

Parameters

NameTypeDescription
owneraddressThe address of the owner of the shares being used to pay for the commission
builderaddressThe address of the account that received the commission if a builderCode is provided
commissionPaidProtocoluint128The amount of assets paid that goes to the PLPs (if builder == address(0)) or to the protocol
commissionPaidBuilderuint128The amount of assets paid that goes to the builder

InsolvencyPenaltyApplied
​

Emitted when a user attempts to settle interest but lacks sufficient shares to pay in full.

The user's borrow index is not updated, meaning they will need to pay this interest again in the future.

event InsolvencyPenaltyApplied(
address indexed owner, uint256 interestOwed, uint256 interestPaid, uint256 sharesBurned
);

Parameters

NameTypeDescription
owneraddressThe address of the insolvent user
interestOweduint256The total amount of interest the user owed
interestPaiduint256The actual amount of interest paid (value of shares burned)
sharesBurneduint256The number of shares burned in the partial payment

ProtocolLossRealized
​

event ProtocolLossRealized(
address indexed liquidatee, address indexed liquidator, uint256 protocolLossAssets, uint256 protocolLossShares
);
Table of Contents