OnRe Smart Contract Integration

Quick Start

Property
Value

Program ID

onreuGhHHgVzMWSkj2oQDLDtvvGvoepBPkqyaubFcwe

Network

Solana Mainnet

Anchor Version

0.31.1

Overview

The OnRe program enables token exchanges through offers. Each offer represents a trading pair (e.g., USDC → ONyc) with dynamic pricing based on time-based APR growth.

Key Concepts:

  • Offer: A PDA account identified by a token pair (token_in_mint, token_out_mint)

  • Token In: The token users pay (e.g., USDC, USDG)

  • Token Out: The token users receive (e.g., ONyc)

  • Pricing Vectors: Time-based price schedules with APR-driven growth

Choosing Your Integration Path

take_offer vs take_offer_permissionless

Feature
take_offer
take_offer_permissionless

Token Routing

Direct user-to-boss transfers

Routes through program-owned intermediary accounts

Smart Contract Integration

Works well

Simpler setup (recommended)

Approval Message

Optional (when offer requires)

Optional (when offer requires)

Pricing

Same

Same

Fees

Same

Same

Account Setup

Fewer accounts needed

More accounts, but program-controlled

Recommendation

Use take_offer_permissionless for most integrations:

  • Simpler integration – no direct user-to-boss token account relationships needed

  • Atomic routing through program-controlled PDAs

  • Better for smart contract CPI calls

PDA Seeds Reference

All PDAs are derived from the program ID: onreuGhHHgVzMWSkj2oQDLDtvvGvoepBPkqyaubFcwe

PDA
Seed
Description

State

"state"

Program state (contains boss, kill switch, approvers)

Offer

"offer" + token_in_mint + token_out_mint

Offer account for a token pair

Vault Authority

"offer_vault_authority"

Authority for vault token accounts

Permissionless Authority

"permissionless-1"

Authority for intermediary token routing

Mint Authority

"mint_authority"

Authority for mint operations

Integration: take_offer_permissionless

This is the recommended integration path for most use cases.

Instruction Discriminator

[37, 190, 224, 77, 197, 39, 203, 230]

Arguments

Name
Type
Description

token_in_amount

u64

Amount of token_in the user is paying (including fees)

approval_message

Option<ApprovalMessage>

Pass null for permissionless offers

Building Transaction Manually (Low-Level)

Use this approach when building transactions without Anchor or for CPI.

Integration: take_offer

The direct flow requires fewer accounts but uses direct user-to-boss transfers.

Instruction Discriminator

[137, 6, 172, 191, 222, 117, 178, 131]

Using Anchor Client

Fetching Market Data

Get Boss Address

Check Offer Configuration

Get Current NAV (Price)

Get Current APY

Calculate Expected Output

Pricing Model

The OnRe program uses a discrete interval pricing model with APR-based growth.

How Price is Calculated

  1. Find Active Vector: The program finds the pricing vector with the latest start_time ≤ current time

  2. Calculate Interval: interval = floor((current_time - base_time) / price_fix_duration)

  3. Calculate Effective Time: effective_time = (interval + 1) * price_fix_duration

  4. Calculate Price: price = base_price * (1 + apr * effective_time / SECONDS_IN_YEAR)

Constants:

  • base_price has 9 decimal precision (1.0 = 1,000,000,000)

  • apr is scaled by 1,000,000 (1% APR = 1,000,000)

  • SECONDS_IN_YEAR = 31,536,000

Example Price Calculation

Error Handling

Common Error Codes

Error
Code
Description

NoActiveVector

6001

No pricing vector is active at current time

KillSwitchActivated

6002

Program operations are halted

PermissionlessNotAllowed

6003

Offer doesn't allow permissionless access

InvalidBoss

6004

Boss account doesn't match state

ApprovalRequired

6005

Offer requires approval message

InvalidTokenInMint

6006

Token in mint doesn't match offer

InvalidTokenOutMint

6007

Token out mint doesn't match offer

OverflowError

6008

Arithmetic overflow in calculations

Error Handling Example

CPI from Rust Programs

For calling take_offer_permissionless from another Solana program via CPI:

Rust PDA Derivation

Support

Last updated