The RebelFi SDK enables platforms to generate yield on stablecoin balances. You keep full custody of funds while earning competitive returns from DeFi protocols.
Ethereum / EVM
Solana
Copy
import { RebelfiClient } from '@rebelfi/sdk';import { ethers } from 'ethers';const client = new RebelfiClient({ apiKey: process.env.REBELFI_API_KEY });// Discover yield opportunitiesconst { venues } = await client.venues.list({ blockchain: 'ethereum', 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 and submit each transaction (EVM may have approve + supply steps)for (const tx of operation.transactions) { const unsignedTx = JSON.parse(Buffer.from(tx.unsignedTransaction, 'hex').toString()); const signedTx = await wallet.signTransaction(unsignedTx); const txResponse = await wallet.sendTransaction(signedTx); const receipt = await txResponse.wait(); await client.transactions.submitHash({ operationId: operation.operationId, txHash: receipt.hash });}
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 transactionconst 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});