Smart Contract Reference
This page provides a comprehensive technical reference for developers who want to interact with PredMart's smart contracts programmatically. It covers contract addresses, the complete ABI reference, all public functions, events, and integration patterns.
Contract Addresses
| Contract | Network | Chain ID | Address |
|---|---|---|---|
| PredMart Lending Pool (Proxy) | Polygon Mainnet | 137 | 0xD90D012990F0245cAD29823bdf0B4C9AF207d9ee |
| USDC.e | Polygon Mainnet | 137 | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 |
| CTF (ERC-1155) | Polygon Mainnet | 137 | 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045 |
The lending pool is deployed behind a UUPS proxy — always interact with the proxy address, not the implementation address. The proxy delegates all calls to the current implementation.
Core Functions
ERC-4626 Vault (Lending)
These functions follow the ERC-4626 standard and are used by lenders to supply and withdraw USDC.
deposit(uint256 assets, address receiver) → uint256 shares
Deposits USDC into the lending pool and mints pUSDC vault shares to the receiver.
| Parameter | Type | Description |
|---|---|---|
assets | uint256 | Amount of USDC to deposit (6 decimals) |
receiver | address | Address to receive the minted pUSDC shares |
| Returns | uint256 | Number of pUSDC shares minted |
Requirements:
- Caller must have approved the pool to spend at least
assetsUSDC - Protocol must not be paused
mint(uint256 shares, address receiver) → uint256 assets
Mints a specific number of pUSDC shares by depositing the required USDC.
| Parameter | Type | Description |
|---|---|---|
shares | uint256 | Number of pUSDC shares to mint |
receiver | address | Address to receive the minted shares |
| Returns | uint256 | Amount of USDC deposited |
withdraw(uint256 assets, address receiver, address owner) → uint256 shares
Withdraws a specific amount of USDC by burning the required pUSDC shares.
| Parameter | Type | Description |
|---|---|---|
assets | uint256 | Amount of USDC to withdraw |
receiver | address | Address to receive the USDC |
owner | address | Address whose pUSDC shares will be burned |
| Returns | uint256 | Number of pUSDC shares burned |
Requirements:
- Sufficient available liquidity in the pool
- If
owner!= caller, caller must have sufficient allowance
redeem(uint256 shares, address receiver, address owner) → uint256 assets
Burns a specific number of pUSDC shares and sends the corresponding USDC.
| Parameter | Type | Description |
|---|---|---|
shares | uint256 | Number of pUSDC shares to burn |
receiver | address | Address to receive the USDC |
owner | address | Address whose shares will be burned |
| Returns | uint256 | Amount of USDC withdrawn |
View Functions
| Function | Returns | Description |
|---|---|---|
totalAssets() | uint256 | Total USDC in the pool (available + borrowed) |
convertToShares(uint256 assets) | uint256 | How many pUSDC shares for a given USDC amount |
convertToAssets(uint256 shares) | uint256 | How much USDC for a given number of pUSDC shares |
maxDeposit(address) | uint256 | Maximum depositable amount |
maxWithdraw(address owner) | uint256 | Maximum withdrawable amount |
maxRedeem(address owner) | uint256 | Maximum redeemable shares |
previewDeposit(uint256 assets) | uint256 | Preview shares from deposit |
previewMint(uint256 shares) | uint256 | Preview assets needed for mint |
previewWithdraw(uint256 assets) | uint256 | Preview shares burned for withdrawal |
previewRedeem(uint256 shares) | uint256 | Preview assets from redemption |
Collateral Management
depositCollateral(uint256 tokenId, uint256 amount)
Deposits Polymarket CTF shares as collateral. The caller must have approved the pool via CTF.setApprovalForAll().
| Parameter | Type | Description |
|---|---|---|
tokenId | uint256 | Polymarket outcome token ID |
amount | uint256 | Number of shares to deposit |
depositCollateralFrom(address from, uint256 tokenId, uint256 amount)
Deposits collateral from another address (requires that address to have approved the pool). Only callable by the relayer.
Borrowing (Meta-Transaction Relay)
borrowViaRelay(BorrowIntent intent, bytes signature, PriceData priceData)
Executes a borrow on behalf of a user using their signed intent and oracle-signed price data. Only callable by the relayer.
BorrowIntent struct:
struct BorrowIntent {
address borrower;
uint256 tokenId;
uint256 amount;
uint256 nonce;
uint256 deadline;
}
PriceData struct:
struct PriceData {
uint256 chainId;
address pool;
uint256 tokenId;
uint256 price; // WAD scale (0 to 1e18)
uint256 timestamp;
uint256 maxBorrow; // USDC units
bytes signature;
}
withdrawViaRelay(WithdrawIntent intent, bytes signature, PriceData priceData)
Withdraws collateral on behalf of a user. Verifies health factor remains >= 1.0 if debt exists.
WithdrawIntent struct:
struct WithdrawIntent {
address borrower;
address to; // Destination address for the withdrawn collateral
uint256 tokenId;
uint256 amount;
uint256 nonce;
uint256 deadline;
}
Repayment
repay(uint256 tokenId, uint256 amount)
Repays outstanding debt for a position. The caller transfers USDC to the pool and borrow shares are burned.
| Parameter | Type | Description |
|---|---|---|
tokenId | uint256 | Token ID of the position to repay |
amount | uint256 | Amount of USDC to repay (use type(uint256).max for full repayment) |
Requirements:
- Caller must have approved the pool to spend USDC
- The position must have outstanding debt
Liquidation
liquidate(address borrower, uint256 tokenId, uint256 repayAmount, PriceData priceData)
Liquidates an unhealthy position. Only callable by the relayer.
| Parameter | Type | Description |
|---|---|---|
borrower | address | Address of the borrower being liquidated |
tokenId | uint256 | Token ID of the position |
repayAmount | uint256 | Amount of debt to repay |
priceData | PriceData | Oracle-signed price data |
Behavior:
- If above water (collateral value >= debt): Uses close factor (50% or 100%) and liquidation bonus (5%)
- If underwater (collateral value < debt): Seizes all collateral at 10% discount, absorbs bad debt
Market Resolution
resolveMarket(uint256 tokenId, ResolutionData resolutionData)
Registers that a market has resolved. Callable by anyone.
ResolutionData struct:
struct ResolutionData {
uint256 chainId;
address pool;
uint256 tokenId;
bool won;
uint256 timestamp;
bytes signature;
}
redeemWonCollateral(uint256 tokenId, bytes32 conditionId, uint256 indexSet)
Redeems winning CTF shares for USDC through the CTF contract. Callable by anyone.
settleRedemption(address borrower, uint256 tokenId)
Settles a borrower's position after winning collateral has been redeemed. Repays debt from proceeds and sends surplus to borrower. Callable by anyone.
closeResolvedPosition(address borrower, uint256 tokenId)
Closes a position backed by a losing token. Writes off debt as bad debt. Callable by anyone.
View Functions (Position Data)
| Function | Returns | Description |
|---|---|---|
getPosition(address, uint256) | Position | Collateral amount, borrow shares, timestamp |
getDebt(address, uint256) | uint256 | Current debt including accrued interest |
getHealthFactor(address, uint256, uint256 price) | uint256 | Health factor at given price (WAD) |
getLTV(uint256 price) | uint256 | LTV ratio at given price (WAD) |
getLiquidationThreshold(uint256 price) | uint256 | Liquidation threshold at price (WAD) |
totalBorrowAssets() | uint256 | Total outstanding borrows including interest |
totalBorrowShares() | uint256 | Total borrow share tokens |
totalBorrowedPerToken(uint256) | uint256 | Total borrowed against a specific token |
borrowNonce(address) | uint256 | Current borrow nonce for an address |
withdrawNonce(address) | uint256 | Current withdraw nonce for an address |
tokenFrozen(uint256) | bool | Whether a token is frozen |
marketResolved(uint256) | bool | Whether a market has been resolved |
marketWon(uint256) | bool | Whether a resolved market was won |
paused() | bool | Whether the protocol is paused |
admin() | address | Current admin address |
relayer() | address | Current relayer address |
oracle() | address | Current oracle address |
poolCapBps() | uint256 | Current pool cap in basis points |
reserves() | uint256 | Accumulated protocol reserves |
unsettledRedemptions(uint256) | Redemption | Redemption tracking for won markets |
Redemption Struct
When winning collateral is redeemed via redeemWonCollateral(), the protocol tracks the redemption proceeds for subsequent per-borrower settlement:
struct Redemption {
bool redeemed; // Whether CTF shares have been redeemed for USDC
uint256 totalShares; // Total CTF shares that were redeemed
uint256 usdcReceived; // Actual USDC received from the CTF contract
}
This struct is stored in unsettledRedemptions[tokenId] and is consumed by settleRedemption() to proportionally distribute USDC to each borrower based on their share of the total collateral.
Events
Collateral & Borrowing Events
event CollateralDeposited(address indexed borrower, uint256 indexed tokenId, uint256 amount);
event CollateralWithdrawn(address indexed borrower, uint256 indexed tokenId, uint256 amount);
event Borrowed(address indexed borrower, uint256 indexed tokenId, uint256 amount);
event Repaid(address indexed borrower, uint256 indexed tokenId, uint256 amount);
Liquidation Events
event Liquidated(
address indexed liquidator,
address indexed borrower,
uint256 indexed tokenId,
uint256 collateralSeized,
uint256 debtRepaid
);
event BadDebtAbsorbed(address indexed borrower, uint256 indexed tokenId, uint256 amount);
Market Resolution Events
event MarketResolvedEvent(uint256 indexed tokenId, bool won);
event PositionClosed(address indexed borrower, uint256 indexed tokenId, uint256 badDebt);
event CollateralRedeemed(uint256 indexed tokenId, uint256 sharesRedeemed, uint256 usdcReceived);
event RedemptionSettled(
address indexed borrower,
uint256 indexed tokenId,
uint256 debtRepaid,
uint256 surplusToUser
);
Interest & Reserves Events
event InterestAccrued(uint256 interest, uint256 reserve);
event ReservesWithdrawn(address indexed to, uint256 amount);
Admin Events
event OracleUpdated(address indexed oldOracle, address indexed newOracle);
event AnchorsUpdated();
event PausedStateChanged(bool paused);
event TokenFrozenEvent(uint256 indexed tokenId, bool frozen);
event TimelockActivated(uint256 delay);
event PoolCapUpdated(uint256 newCapBps);
event RelayerUpdated(address indexed oldRelayer, address indexed newRelayer);
Governance (Timelock) Events
event OracleChangeProposed(address indexed newOracle, uint256 executeAfter);
event OracleChangeCancelled();
event AnchorsChangeProposed(uint256 executeAfter);
event AnchorsChangeCancelled();
event UpgradeProposed(address indexed newImplementation, uint256 executeAfter);
event UpgradeCancelled();
ERC-4626 Vault Events
// Inherited from ERC-4626/ERC-20 standards
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
EIP-712 Domain
PredMart uses EIP-712 typed structured data for signing borrow and withdraw intents:
EIP712Domain({
name: "Predmart Lending Pool",
version: "0.8.0",
chainId: 137, // Polygon Mainnet
verifyingContract: 0xD90D012990F0245cAD29823bdf0B4C9AF207d9ee
})
BorrowIntent Type Hash
BorrowIntent(address borrower,uint256 tokenId,uint256 amount,uint256 nonce,uint256 deadline)
WithdrawIntent Type Hash
WithdrawIntent(address borrower,address to,uint256 tokenId,uint256 amount,uint256 nonce,uint256 deadline)
REST API Endpoints for Developers
PredMart provides a comprehensive REST API at https://api.predmart.com. Full interactive documentation is available at api.predmart.com/docs (Swagger UI).
Key Endpoints
| Endpoint | Method | Description |
|---|---|---|
/lending/pool-stats | GET | Pool TVL, utilization, rates |
/lending/position/{address}/{token_id} | GET | Single position with risk metrics |
/lending/positions/{address} | GET | All positions for a wallet |
/lending/events/{address} | GET | Lending event history |
/lending/liquidations/{address} | GET | Liquidation history |
/lending/rate-history | GET | Historical rate data |
/lending/depth-status | GET | Depth gate status per token |
/lending/constants | GET | Contract addresses and protocol params |
/oracle/borrow-intent/{borrower}/{token_id}/{amount} | GET | EIP-712 data for borrow signing |
/oracle/borrow-relay | POST | Submit signed borrow intent |
/oracle/withdraw-intent/{borrower}/{to}/{token_id}/{amount} | GET | EIP-712 data for withdraw signing |
/oracle/withdraw-relay | POST | Submit signed withdraw intent |
/health | GET | Simple health check |
/health/detailed | GET | Detailed system health status |
Integration Example: Reading a Position
// Using ethers.js v6
import { Contract, JsonRpcProvider } from 'ethers';
const POOL_ADDRESS = '0xD90D012990F0245cAD29823bdf0B4C9AF207d9ee';
const provider = new JsonRpcProvider('https://polygon-rpc.com');
const pool = new Contract(POOL_ADDRESS, [
'function getPosition(address, uint256) view returns (uint256 collateralAmount, uint256 borrowShares, uint256 lastDepositTimestamp)',
'function getDebt(address, uint256) view returns (uint256)',
'function getHealthFactor(address, uint256, uint256) view returns (uint256)',
'function totalAssets() view returns (uint256)',
'function totalBorrowAssets() view returns (uint256)',
], provider);
// Read a position
const [collateral, shares, _] = await pool.getPosition(borrowerAddress, tokenId);
const debt = await pool.getDebt(borrowerAddress, tokenId);
// Get health factor at a specific price (WAD scale)
const price = ethers.parseUnits('0.65', 18); // $0.65
const healthFactor = await pool.getHealthFactor(borrowerAddress, tokenId, price);
console.log(`Collateral: ${collateral} shares`);
console.log(`Debt: ${ethers.formatUnits(debt, 6)} USDC`);
console.log(`Health Factor: ${ethers.formatUnits(healthFactor, 18)}`);
Deployment Details
| Property | Value |
|---|---|
| Solidity Pragma | ^0.8.24 |
| Compiler Version | 0.8.27 |
| Protocol Version | 0.8.0 |
| Optimizer | Enabled, 1 run |
| via_ir | Enabled |
| Proxy Pattern | UUPS (ERC-1967) |
| Framework | Foundry |
| Network | Polygon (EVM-compatible) |
Next Steps
- Protocol Constants — All parameter values in one place
- Security — Trust assumptions and security model
- FAQ — Common developer questions