Prerequisites
Before starting, make sure you have:- A wallet with a Sepolia address (MetaMask, Rabby, or any EVM wallet)
- Node.js 18+ and a package manager (pnpm, npm, or yarn)
- A Sepolia RPC URL (from Alchemy, Infura, or any public Sepolia endpoint)
Steps
Get Sepolia ETH
You need Sepolia ETH to pay gas fees for transactions. Use any Sepolia faucet to get testnet ETH:Verify your balance:
Get Test USDC
The protocol uses MockUSDC on Sepolia, which has a public Verify your MockUSDC balance:
mint function anyone can call. Mint
1,000 USDC (1,000,000,000 raw units with 6 decimals) to your address:- Using cast (Foundry)
- Using viem (TypeScript)
Install the SDK
The
@nile-markets/sdk package provides type-safe ABIs, enum constants, and pair IDs for all
protocol contracts.- pnpm
- npm
- yarn
The SDK has zero runtime dependencies.
viem is listed as a peer dependency for type
compatibility but is not imported by the SDK itself. You need viem (or ethers) separately
to interact with the chain.Read Pool State
Query the PoolVault to see total assets (USDC deposited by LPs) and total share supply:
totalAssets() returns the pool’s USDC balance in raw 6-decimal units. totalSupply() returns
the total share tokens outstanding (also 6 decimals). Share price is the ratio of the two.Query Positions via Subgraph
The protocol’s subgraph indexes all onchain events into a queryable GraphQL API. Use it to
fetch historical positions, account data, and pool statistics.
- Using fetch
- Using graphql-request
Next Steps
You now have the tools to read protocol state on Sepolia. Here are some paths to explore next:
Open a Position
Walk through opening your first LONG or SHORT position with the SDK.
LP Deposit Tutorial
Deposit USDC into the vault and earn fees as a liquidity provider.
Monitor Positions
Build a real-time position monitor using the subgraph and RPC reads.
Core Concepts
Understand synthetic forwards, margin, and the protocol’s risk framework.
Contract Addresses Reference
For quick reference, here are the key contract addresses on Sepolia. See the full list on the Contract Addresses page.| Contract | Address |
|---|---|
| PositionManager | 0x8d81E9f1D0F0d1BdAAc0a91AFc2976522429A0cd |
| PoolVault | 0x61208f0337eE40278b0cbc55daEE7A37Fa180618 |
| MarginAccounts | 0x12c310A5A5B5771459ff96979931CddE75A6D935 |
| OracleModule | 0x1f78995b606CCF768E0a532Be8A1AB6eDf3Cd4D5 |
| MockUSDC | 0x319FeC6Cc374922A183A354a41E89b7A313EE547 |
Troubleshooting
Transaction reverts with 'InsufficientBalance'
Transaction reverts with 'InsufficientBalance'
You need MockUSDC in your wallet. Go back to Step 2 and mint test USDC. Make sure you also have
Sepolia ETH for gas fees.
Oracle returns isValid: false
Oracle returns isValid: false
The oracle may be stale if the publisher has not submitted a recent price update. On testnet,
the publisher runs periodically and there may be gaps. Wait a few minutes and try again.
Subgraph returns empty results
Subgraph returns empty results
Verify you are using the correct subgraph URL. The subgraph may also take a few minutes to index
new blocks after events are emitted. If the deployment is fresh, there may be no positions yet.
RPC rate limiting
RPC rate limiting
Public Sepolia RPC endpoints have rate limits. If you are hitting limits, switch to a dedicated
provider like Alchemy or Infura (both have free tiers that support Sepolia).