Skip to main content
Coming Soon: The Developers section is under active development. Documentation will be available soon.

Overview

This guide gets you from zero to your first Centuari integration in minutes.

Installation

npm install @centuari/sdk

Initialize Client

import { Centuari } from '@centuari/sdk';

const client = new Centuari({
  chainId: 42161, // Arbitrum
  rpcUrl: process.env.RPC_URL, // Optional: use default if not specified
});

Read Market Data

// Get current rates
const rates = await client.getRates();
console.log(rates);
// [
//   { asset: 'USDC', maturity: '30d', lendRate: 0.072, borrowRate: 0.085 },
//   { asset: 'USDC', maturity: '90d', lendRate: 0.078, borrowRate: 0.092 },
//   ...
// ]

// Get order book
const orderBook = await client.getOrderBook({
  asset: 'USDC',
  maturity: '90d'
});
console.log(orderBook);
// {
//   lends: [{ rate: 0.085, amount: '50000', ... }],
//   borrows: [{ rate: 0.078, amount: '30000', ... }]
// }

Create a Lend Position

import { Centuari } from '@centuari/sdk';
import { ethers } from 'ethers';

// Connect wallet
const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const client = new Centuari({
  chainId: 42161,
  signer
});

// Approve USDC spending (first time only)
await client.approve('USDC', ethers.MaxUint256);

// Place lend order
const position = await client.lend({
  asset: 'USDC',
  amount: '10000', // 10,000 USDC
  rate: 0.08,      // 8% APY
  maturity: '90d'  // 90 days
});

console.log(`Position ID: ${position.positionId}`);
console.log(`CBT received: ${position.cbtAmount}`);

Create a Borrow Position

// Deposit collateral first
await client.depositCollateral({
  asset: 'ETH',
  amount: '5' // 5 ETH
});

// Check borrowing power
const power = await client.getBorrowingPower({
  borrowAsset: 'USDC'
});
console.log(`Max borrow: ${power.maxBorrow} USDC`);

// Place borrow order
const loan = await client.borrow({
  borrowAsset: 'USDC',
  borrowAmount: '8000', // 8,000 USDC
  maxRate: 0.09,        // Max 9% APY
  maturity: '90d'
});

console.log(`Loan ID: ${loan.positionId}`);
console.log(`Rate: ${loan.rate * 100}% APY`);

Listen to Events

// Subscribe to position updates
client.on('positionMatched', (event) => {
  console.log(`Position ${event.positionId} matched at ${event.rate}`);
});

client.on('positionMatured', (event) => {
  console.log(`Position ${event.positionId} matured`);
});

// Start listening
await client.startListening();

Smart Contract Interaction

For direct contract interaction:
import { ethers } from 'ethers';

const ORDER_BOOK_ADDRESS = '0x...'; // See addresses page
const ORDER_BOOK_ABI = [...]; // See contract docs

const orderBook = new ethers.Contract(
  ORDER_BOOK_ADDRESS,
  ORDER_BOOK_ABI,
  signer
);

// Place lend order directly
const tx = await orderBook.placeLendOrder(
  USDC_ADDRESS,
  ethers.parseUnits('10000', 6), // amount
  800, // rate in basis points (8%)
  maturityTimestamp
);

await tx.wait();

Environment Setup

Testnet

const client = new Centuari({
  chainId: 421614, // Arbitrum Sepolia
  rpcUrl: 'https://sepolia-rollup.arbitrum.io/rpc'
});

Mainnet

const client = new Centuari({
  chainId: 42161, // Arbitrum One
  rpcUrl: process.env.ARBITRUM_RPC_URL
});

Next Steps

Example Repository

Full examples available:
git clone https://github.com/centuari-labs/examples
cd examples
npm install
npm run example:lend

View Examples

Browse complete code examples