A TypeScript SDK for interacting with DeFindex Vaults on the Stellar Soroban network. DeFindex is a protocol for creating and managing multi-asset investment vaults with customizable strategies.
DeFindex Vaults serve as the core of the DeFindex platform, responsible for:
- Managing multiple assets
- Executing investment strategies
- Ensuring proper asset rebalancing
- Minting/burning dfTokens (vault shares)
npm install defindex-sdk
# or
yarn add defindex-sdk
import { Vault, SorobanNetwork } from 'defindex-sdk';
// Initialize a vault instance
const vault = new Vault({
network: SorobanNetwork.TESTNET,
contractId: 'YOUR_VAULT_CONTRACT_ID'
});
// Deposit assets
const txHash = await vault.deposit(
accountAddress,
100, // amount
true, // signAndSend
sorobanContext,
secretKey
);
- Asset Management: Deposit and withdraw multiple assets
- Balance Tracking: Monitor your vault share balance
- Transaction Handling: Built-in support for Soroban transactions
- Type Safety: Full TypeScript support
The main class for interacting with DeFindex vaults.
new Vault({
network: SorobanNetwork,
contractId: string
})
deposit(account: string, amount: number, signAndSend: boolean, sorobanContext: SorobanContextType, secretKey?: string): Promise<string>
Deposits assets into the vault and receives dfTokens in return.
-
Parameters:
account
: The depositor's addressamount
: Amount to depositsignAndSend
: Whether to sign and submit the transactionsorobanContext
: Soroban context objectsecretKey
: Optional secret key for signing
-
Returns: Transaction hash
withdraw(account: string, amount: number, signAndSend: boolean, sorobanContext: SorobanContextType, secretKey?: string): Promise<string>
Withdraws assets from the vault by burning dfTokens.
-
Parameters:
account
: The withdrawer's addressamount
: Amount of dfTokens to burnsignAndSend
: Whether to sign and submit the transactionsorobanContext
: Soroban context objectsecretKey
: Optional secret key for signing
-
Returns: Transaction hash
Checks the dfToken balance of an account.
-
Parameters:
account
: The account addresssorobanContext
: Soroban context object
-
Returns: Balance amount
import { Vault, SorobanNetwork } from 'defindex-sdk';
async function main() {
// Initialize vault
const vault = new Vault({
network: SorobanNetwork.TESTNET,
contractId: 'YOUR_CONTRACT_ID'
});
// Create Soroban context
const sorobanContext = await createSorobanContext();
// Check initial balance
const balance = await vault.balance(accountAddress, sorobanContext);
console.log('Balance:', balance);
// Deposit assets
const txHash = await vault.deposit(
accountAddress,
100,
true,
sorobanContext,
secretKey
);
console.log('Deposit TX:', txHash);
}
For a complete example, see vault-example.ts.
- Discord: Join our community