Reference
Contracts and addresses
Testnet addresses, units, contract methods and the public API.
Addresses (NEAR testnet)
| What | Value |
|---|---|
| Neap contract | neap-perps.testnet |
| Collateral (test USDC) | usdc.fakes.testnet |
| API | https://neap-backend.onrender.com |
| WebSocket | wss://neap-backend.onrender.com/ws |
Market 0 | NEAR-PERP · major |
Market 1 | TIDE-PERP · long-tail · Ref pool 2962 on ref-finance-101.testnet |
The live list of markets is at GET /markets. Mainnet addresses will be published here at launch.
Units
| Quantity | Encoding |
|---|---|
| USDC amounts | Integer atoms, 6 decimals. 1 USDC = 1000000. |
| Prices | price_e6: USD times 10^6. $5.10 = 5100000. |
| Position size | size_q: units times 10^6. One token is 1000000. |
| Large integers | Sent and returned as strings in JSON. |
User methods
Calls that move value require 1 yoctoNEAR attached, which forces a full-access key signature.
| Method | Purpose |
|---|---|
register() | Create your Neap balance. Pays storage. |
ft_transfer_call on USDC | Deposit USDC. With a CreateMarket message, create a market. |
open_account(market) | Create your margin account in a market. Pays storage. |
deposit(market, amount) | Neap balance to margin. |
withdraw_margin(market, amount) | Margin to Neap balance. |
withdraw(amount) | Neap balance to your NEAR wallet. |
request_order(market, side, size_q, limit_price, expiry_blocks, reduce_only) | Place a two-step order. |
cancel_order(order_id) | Cancel a pending order. |
place_conditional(...) · cancel_conditional(id) | Take-profit, stop-loss and limit orders. |
convert_pnl(market) | Turn matured profit into withdrawable USDC. |
lp_deposit(market, amount) · lp_redeem(market, shares) | Add or remove pool liquidity. |
claim_fees(market, payee) | Lister or protocol claims accrued fees. |
Permissionless keeper methods
| Method | Purpose |
|---|---|
refresh_price(market) | Read the NEAR pool price. |
activate_market(market) | Move a Proposed market to Active once checks pass. |
crank(market) | Advance the price staircase and funding. |
execute_order(order_id) | Fill a pending order. |
execute_conditional(id) | Trigger a TP, SL or limit order. |
liquidate(market, account) | Liquidate an account below maintenance margin. Pays the caller. |
Views
| Method | Returns |
|---|---|
get_market(market) | Mode, price, open interest, pool value, insurance, funding rate. |
get_account(market, account) | Margin, profit and loss, position size. |
get_wallet(account) | Idle Neap balance. |
quote(market, side, size_q) | Execution price, spread in bps and fee for a hypothetical order. |
get_order(id) · get_conditional(id) | One order. |
get_lp_shares(market, account) | Pool shares held. |
get_fee_ledger(market, payee) | Accrued, unclaimed fees. |
get_custody() | Total user balances and total vault balances held by the contract. |
near contract call-function as-read-only neap-perps.testnet get_market \
json-args '{"market": 0}' network-config testnet nowAPI
The API is read-only market data, served from the indexer. Pagination is ?limit=50&offset=0, maximum 500.
| Endpoint | Returns |
|---|---|
GET /health · /config | Service status, network and contract. |
GET /markets · /markets/:id | Live market state with 24 hour stats. |
GET /markets/:id/candles?interval=60 | Price candles, oldest first. |
GET /markets/:id/fills · /orders · /conditionals · /liquidations | Market history. |
GET /markets/:id/quote?side=Long&size_q=… | The contract's quote. |
GET /account/:owner | Balances and positions for one account. |
GET /account/:owner/fills · /orders · /conditionals · /liquidations | Account history. |
WS /ws | A snapshot on connect, then market state every few seconds and every contract event. |
Events follow NEP-297 with standard: "neap": order_requested, fill, liquidation, price_observed, market_created, market_activated, market_mode_changed and others.
