You are on Devnet — This is a test environment. Tokens have no real value.

Smart Contracts

Devnet

Complete reference for the rFlow Anchor program on Solana. 13 instructions across core yield deals and Meteora LP fee deals.

Overview#

The rFlow program supports two types of yield deals:

  • Yield Deals - Lock receipt tokens (kUSDC, mSOL, jitoSOL) and sell future appreciation
  • Meteora LP Deals - Lock Position NFT and sell future LP fees

Program Information#

Program ID2yUwGR18L5a8UqfkX49M4SenYCrS4B48chioKWCnMG3y
Version0.1.0
FrameworkAnchor 0.32.1
LanguageRust 2021
Instructions13 total (8 core + 5 Meteora LP)
NetworkDevnet
Audit Status
The rFlow smart contracts are pending security audit. Do not use in production until the audit is complete.

Core Instructions#

8 instructions for managing yield deals with receipt tokens (lending, liquid staking):

initialize

Initialize the protocol configuration. Can only be called once by the deployer.

Accounts
authority (signer)config (PDA)treasurysystem_program
create_deal

Create a new yield deal by locking receipt tokens in a vault PDA.

Accounts
seller (signer)configdeal (PDA)seller_token_accountvault (PDA)receipt_token_mintpayment_minttoken_programsystem_program
Parameters
receipt_tokens_amount:u64
principal_value_at_lock:u64
expected_yield:u64
selling_price:u64
duration_days:u16
source_protocol:SourceProtocol
buy_deal

Purchase a deal. Transfers payment to seller (minus protocol fee) and activates the deal.

Accounts
buyer (signer)configdealbuyer_payment_accountseller_payment_accounttreasury_accounttoken_program
cancel_deal

Cancel a deal before it's purchased. Returns locked tokens to seller.

Accounts
seller (signer)dealvaultseller_token_accounttoken_program
settle_deal

Settle a deal after expiry. Distributes yield to buyer and principal to seller based on token appreciation.

Accounts
payer (signer)dealvaultbuyer_token_accountseller_token_accounttoken_program
Parameters
current_token_value:u64
buyback_deal

Seller exits deal early by paying back buyer with a penalty (15% base, decreasing to 5% near expiry).

Accounts
seller (signer)configdealvaultseller_payment_accountseller_receipt_accountbuyer_payment_accounttoken_program
Parameters
yield_accumulated:u64
crank_settle

Permissionless settlement for expired deals. Caller receives vault rent as incentive.

Accounts
payer (signer)dealvaultbuyer_token_accountseller_token_accounttoken_program
Parameters
current_token_value:u64

Meteora LP Instructions#

5 instructions for Meteora DLMM LP fee deals. Locks Position NFT and sells future fee rights:

create_meteora_lp_deal

Create a Meteora LP deal by locking a Position NFT in PayFlow vault.

Accounts
seller (signer)configdeal (PDA)position_nft_mintposition_accountpoolseller_nft_accountvault (PDA)token_programsystem_program
Parameters
expected_fee_a:u64
expected_fee_b:u64
expected_fee_value_usdc:u64
selling_price:u64
duration_days:u16
buy_meteora_lp_deal

Purchase a Meteora LP deal. Buyer gains rights to claim fees during the deal period.

Accounts
buyer (signer)configdealbuyer_payment_accountseller_payment_accounttreasury_accounttoken_program
claim_meteora_fees

Claim accumulated LP fees. Buyer can call anytime during the deal to collect fees.

Accounts
buyer (signer)dealposition_accountpooltoken_a_vaulttoken_b_vaultbuyer_token_a_accountbuyer_token_b_accountmeteora_program
settle_meteora_lp_deal

Settle after expiry. Returns Position NFT to seller. Permissionless.

Accounts
payer (signer)dealvaultseller_nft_accounttoken_program
cancel_meteora_lp_deal

Cancel before purchase. Seller retrieves their Position NFT.

Accounts
seller (signer)dealvaultseller_nft_accounttoken_program

Admin Instructions#

update_config

Update protocol configuration. Authority only.

Accounts
configauthority (signer)
Parameters
fee_bps:Option<u16>
base_penalty_bps:Option<u16>
min_penalty_bps:Option<u16>
is_paused:Option<bool>
new_treasury:Option<Pubkey>
new_authority:Option<Pubkey>
add_mint:Option<Pubkey>
remove_mint:Option<Pubkey>

State Accounts#

ProtocolConfig

Global protocol configuration. Seeds: [b"protocol_config"]

state/protocol_config.rs
1pub struct ProtocolConfig {
2 pub authority: Pubkey, // Admin
3 pub treasury: Pubkey, // Fee recipient
4 pub fee_bps: u16, // Protocol fee (default: 200 = 2%)
5 pub min_duration_days: u16, // Min duration (30)
6 pub max_duration_days: u16, // Max duration (365)
7 pub base_penalty_bps: u16, // Buyback penalty (1500 = 15%)
8 pub min_penalty_bps: u16, // Min penalty (500 = 5%)
9 pub is_paused: bool, // Emergency pause
10 pub deal_counter: u64, // Auto-increment ID
11 pub allowed_mints: Vec<Pubkey>, // Whitelist (max 10)
12 pub bump: u8,
13}

YieldDeal

Receipt token deal. Seeds: [b"yield_deal", deal_id.to_le_bytes()]

state/deal.rs
1pub struct YieldDeal {
2 pub deal_id: u64,
3 pub bump: u8,
4 pub seller: Pubkey,
5 pub buyer: Pubkey,
6 pub receipt_token_mint: Pubkey,
7 pub receipt_token_vault: Pubkey,
8 pub receipt_tokens_amount: u64,
9 pub principal_value_at_lock: u64,
10 pub expected_yield: u64,
11 pub selling_price: u64,
12 pub payment_mint: Pubkey,
13 pub duration_days: u16,
14 pub created_at: i64,
15 pub purchased_at: i64,
16 pub ends_at: i64,
17 pub status: DealStatus,
18 pub source_protocol: SourceProtocol,
19}

MeteoraLpDeal

Meteora LP fee deal. Seeds: [b"meteora_lp_deal", deal_id.to_le_bytes()]

state/meteora_lp_deal.rs
1pub struct MeteoraLpDeal {
2 pub deal_id: u64,
3 pub bump: u8,
4 pub seller: Pubkey,
5 pub buyer: Pubkey,
6 // Position info
7 pub position_nft_mint: Pubkey,
8 pub position_account: Pubkey,
9 pub position_nft_vault: Pubkey,
10 pub pool: Pubkey,
11 pub token_a_mint: Pubkey,
12 pub token_b_mint: Pubkey,
13 // Fee snapshots at lock
14 pub fee_a_at_lock: u64,
15 pub fee_b_at_lock: u64,
16 // Expected fees
17 pub expected_fee_a: u64,
18 pub expected_fee_b: u64,
19 pub expected_fee_value_usdc: u64,
20 // Payment
21 pub selling_price: u64,
22 pub payment_mint: Pubkey,
23 // Timing
24 pub duration_days: u16,
25 pub created_at: i64,
26 pub purchased_at: i64,
27 pub ends_at: i64,
28 pub status: DealStatus,
29}

Enums#

DealStatus

rust
1pub enum DealStatus {
2 Created, // Waiting for buyer
3 Active, // Purchased, in progress
4 Settled, // Ended, distributions complete
5 Cancelled, // Cancelled before purchase
6 BoughtBack, // Seller did early buyback
7}

SourceProtocol

Supported yield sources organized by phase:

rust
1pub enum SourceProtocol {
2 // Phase 1 - Lending (receipt tokens appreciate)
3 Kamino, // kUSDC, kSOL
4 MarginFi, // mTokens
5 Solend, // cTokens
6 Save, // saveTokens
7
8 // Phase 1 - Liquid Staking
9 Marinade, // mSOL
10 Jito, // jitoSOL (includes MEV)
11 Blaze, // bSOL
12 Sanctum, // INF, various LSTs
13 Lido, // wstSOL
14
15 // Phase 2 - LP Positions (fee claiming)
16 RaydiumLp,
17 MeteoraLp,
18 OrcaLp,
19
20 // Phase 3 - Fee Streams
21 FeeStream,
22}

Error Codes#

CodeNameDescription
6000ProtocolPausedProtocol is paused
6001InvalidDurationDuration must be 30, 60, or 90 days
6002InvalidPricePrice must be > 0
6003InvalidAmountAmount must be > 0
6004DealNotAvailableDeal not in Created state
6005DealNotActiveDeal not in Active state
6006DealNotEndedDeal hasn't expired yet
6007DealEndedDeal has already ended
6008DealAlreadyActiveDeal already purchased
6009NotSellerCaller is not the seller
6010NotBuyerCaller is not the buyer
6011InsufficientFundsNot enough tokens for buyback
6012UnauthorizedNot authority
6013MathOverflowArithmetic overflow
6014InvalidMintMint not in whitelist
6015WhitelistFullCannot add more than 10 mints
6016MintAlreadyWhitelistedMint already in whitelist
6017MintNotInWhitelistMint not found in whitelist
6018InvalidMeteoraPositionInvalid Meteora position
6019PositionPoolMismatchPosition doesn't belong to expected pool
6020InvalidPositionNftPosition NFT must be amount 1
6021NotDealBuyerCaller is not the deal buyer