The RebelFi SDK enables applications to offer yield on stablecoin balances. Users keep custody of their funds while earning competitive returns from DeFi protocols.
Copy
import { RebelfiClient } from '@rebelfi/sdk';import { Connection, VersionedTransaction } from '@solana/web3.js';const client = new RebelfiClient({ apiKey: process.env.REBELFI_API_KEY });// Discover yield opportunitiesconst { venues } = await client.venues.list({ blockchain: 'solana', token: 'USDC' });const strategy = venues[0].strategies[0];// Plan a supply operationconst operation = await client.operations.supply({ walletAddress: userWallet, strategyId: strategy.strategyId, amount: '1000000', // 1 USDC (6 decimals) tokenAddress: strategy.tokenAddress});// Sign the transaction (Solana example)const unsignedTxBase64 = operation.transactions[0].unsignedTransaction;const unsignedTxBuffer = Buffer.from(unsignedTxBase64, 'base64');const transaction = VersionedTransaction.deserialize(unsignedTxBuffer);transaction.sign([userKeypair]);// Broadcast and confirmconst connection = new Connection('https://api.mainnet-beta.solana.com');const txHash = await connection.sendTransaction(transaction);await connection.confirmTransaction(txHash, 'confirmed');// Submit the hash to RebelFiawait client.transactions.submitHash({ operationId: operation.operationId, txHash});