Pool API
Pool API description
MarginlyPool
factory
address factoryReturns address of Marginly factory
quoteToken
address quoteTokenReturns the address of quote token from pool
baseToken
address baseTokenReturns the address of base token from pool
uniswapPool
address uniswapPoolReturns the address of associated uniswap pool
mode
enum Mode modeparams
struct MarginlyParams paramsdiscountedQuoteCollateral
uint256 discountedQuoteCollateralSum of all quote token in collateral
discountedQuoteDebt
uint256 discountedQuoteDebtSum of all quote token in debt
discountedBaseCollateral
uint256 discountedBaseCollateralSum of all base token collateral
discountedBaseDebt
uint256 discountedBaseDebtSum of all base token in debt
lastReinitTimestampSeconds
uint256 lastReinitTimestampSecondsTimestamp of last reinit execution
baseCollateralCoeff
struct FP96.FixedPoint baseCollateralCoeffAggregate for base collateral time change calculations
baseDelevCoeff
struct FP96.FixedPoint baseDelevCoeffAggregate for deleveraged base collateral
baseDebtCoeff
struct FP96.FixedPoint baseDebtCoeffAggregate for base debt time change calculations
quoteCollateralCoeff
struct FP96.FixedPoint quoteCollateralCoeffAggregate for quote collateral time change calculations
quoteDelevCoeff
struct FP96.FixedPoint quoteDelevCoeffAggregate for deleveraged quote collateral
quoteDebtCoeff
struct FP96.FixedPoint quoteDebtCoeffAccrued interest rate and fee for quote debt
initialPrice
struct FP96.FixedPoint initialPriceInitial price. Used to sort key and shutdown calculations. Value gets reset for the latter one
emergencyWithdrawCoeff
struct FP96.FixedPoint emergencyWithdrawCoeffRatio of best side collaterals before and after margin call of opposite side in shutdown mode
Leverage
struct Leverage {
uint128 shortX96;
uint128 longX96;
}systemLeverage
struct MarginlyPool.Leverage systemLeveragepositions
mapping(address => struct Position) positionsusers positions
constructor
constructor() publicinitializeMarginlyPool
function _initializeMarginlyPool(address _quoteToken, address _baseToken, bool _quoteTokenIsToken0, address _uniswapPool, struct MarginlyParams _params) internalInitializes Marginly pool
initialize
function initialize(address _quoteToken, address _baseToken, bool _quoteTokenIsToken0, address _uniswapPool, struct MarginlyParams _params) external virtualInitializes the pool
receive
receive() external payablelock
modifier lock()Protects against reentrancy
onlyFactoryOwner
modifier onlyFactoryOwner()setParameters
function setParameters(struct MarginlyParams _params) externalSets the pool parameters. May only be called by the pool owner
getBasePrice
function getBasePrice() public view returns (struct FP96.FixedPoint)Get oracle price baseToken / quoteToken
getLiquidationPrice
function getLiquidationPrice() public view returns (struct FP96.FixedPoint)Get TWAP price used in mc slippage calculations
shutDown
function shutDown(uint256 swapCalldata) externalSwitch to emergency mode when collateral of any side not enough to cover debt
Parameters
swapCalldata
uint256
router calldata for splitting swap to reduce potential sandwich attacks impact
sweepETH
function sweepETH() externalSweep ETH balance of contract
getHeapPosition
function getHeapPosition(uint32 index, bool _short) external view returns (bool success, struct MaxBinaryHeapLib.Node)Used by keeper service
execute
function execute(enum CallType call, uint256 amount1, uint256 amount2, uint256 limitPriceX96, bool flag, address receivePositionAddress, uint256 swapCalldata) external payableParameters
call
enum CallType
amount1
uint256
amount2
uint256
limitPriceX96
uint256
flag
bool
unwrapETH in case of withdraw calls or syncBalance in case of reinit call
receivePositionAddress
address
swapCalldata
uint256
getTimestamp
function getTimestamp() internal view virtual returns (uint256)Last updated
