Perpetual
Handle all the logic involving the pool. Interact with the CryptoSwap pool
function DEFAULT_ADMIN_ROLE() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function EMERGENCY_ADMIN() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function GOVERNANCE() external view returns (bytes32)
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function changePosition(address account, uint256 amount, uint256 minAmount, enum LibPerpetual.Side direction, bool isLiquidation) external nonpayable returns (int256 quoteProceeds, int256 baseProceeds, int256 profit, int256 tradingFeesPayed, bool isPositionIncreased, bool isPositionClosed)
Open or increase or reduce a position, either LONG or SHORT
Function can be used to extend or reduce a position. Reversing a position is prohibited.
Name | Type | Description |
---|---|---|
account | address | Trader |
amount | uint256 | Amount in vQuote (if LONG) or vBase (if SHORT) to sell. 18 decimals |
minAmount | uint256 | Minimum amount that the user is willing to accept. 18 decimals |
direction | enum LibPerpetual.Side | Whether the trader wants to go in the LONG or SHORT direction overall |
isLiquidation | bool | Transaction is a liquidation (true) or a regular transaction (false) |
Name | Type | Description |
---|---|---|
quoteProceeds | int256 | undefined |
baseProceeds | int256 | undefined |
profit | int256 | undefined |
tradingFeesPayed | int256 | undefined |
isPositionIncreased | bool | undefined |
isPositionClosed | bool | undefined |
function clearingHouse() external view returns (contract IClearingHouse)
Clearing House contract
Name | Type | Description |
---|---|---|
_0 | contract IClearingHouse | undefined |
function curveCryptoViews() external view returns (contract ICurveCryptoViews)
Curve Crypto Views
Name | Type | Description |
---|---|---|
_0 | contract ICurveCryptoViews | undefined |
function getGlobalPosition() external view returns (struct LibPerpetual.GlobalPosition)
Get global market position
Name | Type | Description |
---|---|---|
_0 | LibPerpetual.GlobalPosition | undefined |
function getLpLiquidity(address account) external view returns (uint256)
Get the lp tokens owned by a Liquidity Provider
Name | Type | Description |
---|---|---|
account | address | Liquidity Provider |
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function getLpOpenNotional(address account) external view returns (int256)
Get the dollar value of the liquidity provided by a liquidity Provider
Name | Type | Description |
---|---|---|
account | address | Address of the LP |
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function getLpPosition(address account) external view returns (struct LibPerpetual.LiquidityProviderPosition)
Get the position of a liquidity provider
Name | Type | Description |
---|---|---|
account | address | Address to get the LP position from |
Name | Type | Description |
---|---|---|
_0 | LibPerpetual.LiquidityProviderPosition | undefined |
function getLpPositionAfterWithdrawal(address account) external view returns (struct LibPerpetual.TraderPosition)
Get the (active) position of a liquidity provider after withdrawing liquidity
Name | Type | Description |
---|---|---|
account | address | Address to get the LP position from |
Name | Type | Description |
---|---|---|
_0 | LibPerpetual.TraderPosition | undefined |
function getLpTradingFees(address account) external view returns (uint256 tradingFeesEarned)
Get the trading fees earned by a LP
Name | Type | Description |
---|---|---|
account | address | Address of the liquidity provider |
Name | Type | Description |
---|---|---|
tradingFeesEarned | uint256 | undefined |
function getLpUnrealizedPnL(address account) external view returns (int256 pnl)
Get the unrealized profit and loss of a LP
Name | Type | Description |
---|---|---|
account | address | Address of the liquidity provider |
Name | Type | Description |
---|---|---|
pnl | int256 | undefined |
function getPendingPnL(address account) external view returns (int256 pnL)
Get the Profit and Loss of a user
Name | Type | Description |
---|---|---|
account | address | Address to get the pnL from |
Name | Type | Description |
---|---|---|
pnL | int256 | undefined |
function getRoleAdmin(bytes32 role) external view returns (bytes32)
Returns the admin role that controls
role
. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
Name | Type | Description |
---|---|---|
_0 | bytes32 | undefined |
function getTotalLiquidityProvided() external view returns (uint256)
Get the market total liquidity provided to the Crypto Swap pool
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function getTraderPosition(address account) external view returns (struct LibPerpetual.TraderPosition)
Get the position of a trader
Name | Type | Description |
---|---|---|
account | address | Address to get the trading position from |
Name | Type | Description |
---|---|---|
_0 | LibPerpetual.TraderPosition | undefined |
function getTraderUnrealizedPnL(address account) external view returns (int256 pnl)
Get the unrealized profit and loss of a trader
Name | Type | Description |
---|---|---|
account | address | Trader |
Name | Type | Description |
---|---|---|
pnl | int256 | undefined |
function getUserDebt(address account) external view returns (int256 debt)
Get the user debt of an user
Name | Type | Description |
---|---|---|
account | address | Address to get the pnL from |
Name | Type | Description |
---|---|---|
debt | int256 | undefined |
function grantRole(bytes32 role, address account) external nonpayable
Grants
role
to account
. If account
had not been already granted role
, emits a {RoleGranted} event. Requirements: - the caller must have role
's admin role. May emit a {RoleGranted} event.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
function hasRole(bytes32 role, address account) external view returns (bool)
Returns
true
if account
has been granted role
.Name | Type | Description |
---|---|---|
role | bytes32 | undefined |
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function indexPrice() external view returns (int256)
Return the current off-chain exchange rate for vBase/vQuote
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function insuranceFee() external view returns (int256)
paid on dollar value of an opened position (used in ClearingHouse)
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function isEmergencyAdmin(address account) external view returns (bool)
Name | Type | Description |
---|---|---|
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function isGovernor(address account) external view returns (bool)
Name | Type | Description |
---|---|---|
account | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function isLpPositionOpen(address account) external view returns (bool)
Whether or not a LP position is opened
Name | Type | Description |
---|---|---|
account | address | Address of the LP |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function isTraderPositionOpen(address account) external view returns (bool)
Whether a trader position is opened or not
Name | Type | Description |
---|---|---|
account | address | Address of the trader |
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function isTradingExpansionAllowed() external view returns (bool)
wether opening and extending trading positions is allowed
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function lockPeriod() external view returns (uint256)
time when the liquidity provision has to be locked
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function lpDebtCoef() external view returns (int256)
lp debt coefficient
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function market() external view returns (contract ICryptoSwap)
Curve CryptoSwap pool
Name | Type | Description |
---|---|---|
_0 | contract ICryptoSwap | undefined |
function marketCumulativeAmount() external view returns (int256)
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function marketCumulativeAmountAtBeginningOfPeriod() external view returns (int256)
Name | Type | Description |
---|---|---|
_0 | int256 | undefined |
function marketPrice() external view returns (uint256)
Return the last traded price (used for TWAP)
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function marketTwap() external view returns (int128)
Market Time-weighted average price of base
Name | Type | Description |
---|---|---|
_0 | int128 | undefined |
function maxBlockTradeAmount() external view returns (uint256)
max trade amount in one block
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function maxLiquidityProvided() external view returns (uint256)
maximum liquidity which can be provided to the pool