MarketPool
arketPool.sol
arketPool.sol
The MarketPool
contract is a core component of Scall.io, responsible for managing perpetual options, liquidity deposits, and strike price pools for a specific market (e.g., BTC/USDC or ETH/USDC).
Each deployed MarketPool
instance handles one market and uses a Chainlink price feed to determine valid strike prices and market conditions.
🧩 What It Does
Accepts deposits from Liquidity Providers (LPs) who want to earn yield at specific strike prices.
Allows traders to open and close Call or Put perpetual options.
Tracks individual LP positions and open option contracts through NFTs.
📤 Public Functions
Here are the key functions users and external contracts can call:
deposit(bool isCall, uint256 amount)
deposit(bool isCall, uint256 amount)
Called by LPs to provide liquidity at a specific strike price.
Mints an LP NFT representing their position.
Emits:
Deposit
event
withdraw(uint256 lpId)
withdraw(uint256 lpId)
Allows LPs to withdraw their deposited liquidity (if not in use).
Burns the associated LP NFT.
Emits:
Withdraw
event
openContract(bool isCall, uint256 strikeIndex, uint256 amount)
openContract(bool isCall, uint256 strikeIndex, uint256 amount)
Called by traders to open a new perpetual option.
Requires sufficient collateral in the CollateralPool.
Mints a contract NFT.
Emits:
ContractOpened
event
closeContract(uint256 contractId)
closeContract(uint256 contractId)
Allows traders to manually close their perpetual options at any time.
Burns the contract NFT.
Emits:
ContractClosed
event
👀 View Functions
Here are helpful read-only functions to query data:
getMain()
Returns the address of the Main
contract.
getERC721_Contract()
Returns the address of the ERC721 contract representing trader positions.
getERC721_LP()
Returns the address of the ERC721 contract representing LP positions.
getTokenA()
Returns the address of the asset token (e.g., BTC).
getTokenB()
Returns the address of the collateral token (e.g., USDC).
getPriceFeed()
Returns the address of the Chainlink price feed used for indexing.
getIntervalLength()
Returns the strike price interval setting.
getRange()
Returns the range of strike prices around the market price.
getYield()
Returns the current yield (APR) configured for the market.
getContractInfos(uint256 _id)
Returns all stored data for a given trader contract ID.
getLpInfos(uint256 _id)
Returns all stored data for a given LP position ID.
getStrikeInfos(uint256 _strike)
Returns aggregated info about liquidity at a specific strike.
getStrikeHistory(uint256 _strike, uint256 _index)
Returns historical data for a strike (useful for rewards calculations or snapshots).
getPrice()
Fetches the current price from the Chainlink oracle.
getIntervals()
Returns the list of active strike price intervals.
getRewards(uint256 _id)
Returns the claimable rewards for a given LP NFT ID.
🔐 Roles & Interactions
This contract interacts with:
CollateralPool.sol
for rent collection and liquidation triggersMain.sol
to access governance parametersChainlink price feeds for accurate strike pricing
Custom ERC721 contracts for on-chain position tracking
Last updated