Skip to main content

Introduction

Omnipair provides a comprehensive developer toolkit for building DeFi applications on Solana. Whether you’re integrating swaps, building lending interfaces, or creating automated strategies, our stack gives you everything you need.

Architecture

Program ID

The Omnipair program is deployed on Solana mainnet and devnet:
NetworkProgram ID
MainnetomnixgS8fnqHfCcTGKWj6JtKjzpJZ1Y5y9pyFkQDkYE
DevnetomnixgS8fnqHfCcTGKWj6JtKjzpJZ1Y5y9pyFkQDkYE

Quick Start

1. Install the SDK

npm install @omnipair/program-interface @coral-xyz/anchor @solana/web3.js

2. Initialize the Program

import { Program, AnchorProvider } from "@coral-xyz/anchor";
import { Connection, PublicKey } from "@solana/web3.js";
import { IDL, Omnipair, PROGRAM_ID } from "@omnipair/program-interface";

// Create connection and provider
const connection = new Connection("https://api.mainnet-beta.solana.com");
const provider = new AnchorProvider(connection, wallet, {});

// Initialize typed program instance
const program = new Program<Omnipair>(IDL, PROGRAM_ID, provider);

3. Fetch Pool Data

import { derivePairAddress } from "@omnipair/program-interface";

// Derive pair PDA
const token0 = new PublicKey("So11111111111111111111111111111111111111112"); // SOL
const token1 = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // USDC
const [pairAddress] = derivePairAddress(token0, token1);

// Fetch pair account
const pair = await program.account.pair.fetch(pairAddress);

console.log("Reserve0:", pair.reserve0.toString());
console.log("Reserve1:", pair.reserve1.toString());
console.log("Total Debt0:", pair.totalDebt0.toString());

4. Execute a Swap

// Build swap instruction
const swapIx = await program.methods
  .swap({
    amountIn: new BN(1_000_000), // 1 USDC
    minAmountOut: new BN(0),     // Set appropriate slippage
    isToken0In: false,           // Swapping token1 (USDC) for token0 (SOL)
  })
  .accounts({
    pair: pairAddress,
    // ... other accounts
  })
  .instruction();

// Sign and send transaction
const tx = new Transaction().add(swapIx);
const signature = await sendAndConfirmTransaction(connection, tx, [wallet]);

Protocol Constants

Key protocol parameters that are useful for calculations:
ConstantValueDescription
MAX_COLLATERAL_FACTOR_BPS8,500Maximum 85% LTV for dynamic CF
LTV_BUFFER_BPS5005% buffer between borrow and liquidation
LIQUIDATION_PENALTY_BPS3003% total penalty on liquidation
LIQUIDATION_INCENTIVE_BPS500.5% reward for liquidators
FLASHLOAN_FEE_BPS50.05% flash loan fee
LIQUIDITY_WITHDRAWAL_FEE_BPS1001% LP withdrawal fee
NAD1,000,000,00010^9 precision for fixed-point math
BPS_DENOMINATOR10,000Basis points denominator

Resources

Support