Skip to main content
This tutorial walks through a complete integration: supplying funds, tracking yield, and unwinding positions. We’ll build a simple yield service that your application can use.

Setup

Step 0: Register the Wallet

Register the user’s wallet before any operations:
You can now use walletAddress, walletId, or userId in all subsequent calls. All examples below use walletAddress.

Step 1: Discover Venues and Strategies

First, find available yield opportunities for the user:

Step 2: Check Existing Allocations

Before supplying, check what the user already has:

Step 3: Plan a Supply Operation

Create an operation and get the unsigned transaction:
Sign and submit before expiresAt (five minutes). After it, the operation is EXPIRED and submitSigned() fails with OPERATION_EXPIRED; plan again. Planning again with the same API key replaces your own earlier plan on the wallet, unless a transaction was submitted or reported for it: then wait until operations.get() shows it has left AWAITING_SIGNATURE. A plan by another API key or a dashboard user on the same wallet makes supply() fail with OPERATION_IN_PROGRESS until that plan is submitted, expires, or is cancelled.

Step 4: User Signs the Transaction

Present the transaction to the user for signing. This example uses @solana/web3.js:

Step 5: Submit Transaction Hash

After broadcasting, notify RebelFi:
RebelFi records the hash only if it is the transaction it planned (TRANSACTION_MISMATCH otherwise). Report the hash even if the deadline has passed: submit hash is never refused for it.
Alternatively, use submitSigned to let RebelFi broadcast the transaction for you. If that call fails, you can always resubmit the same signed transaction; see Retrying safely before signing again.

Step 6: Poll for Confirmation

Wait for on-chain confirmation:

Step 7: View Updated Allocation

After confirmation, the allocation is updated:

Step 8: Track Earnings Over Time

Get historical earnings data:

Step 9: Unwind Position

When the user wants to withdraw:

Complete Service Example

Here’s a complete yield service wrapping all operations:

Next Steps

Full Walkthrough

Complete integration walkthrough

TypeScript Reference

Complete type definitions