Page cover

Typescript SDK

Welcome to the DeFindex TypeScript SDK documentation! This SDK provides server-side access to DeFindex's vault management system through a comprehensive TypeScript interface. With this SDK, you can:

  1. Create and manage decentralized vaults

  2. Perform vault operations (deposit, withdraw, balance queries)

  3. Access real-time APY data

  4. Execute administrative operations

  5. Integrate secure API key authentication

Prerequisites

Before integrating the SDK, ensure you have:

  • Node.js environment (version 16 or higher)

  • TypeScript knowledge for optimal development experience

  • API key from DeFindex

  • Understanding of Stellar/Soroban blockchain concepts

Integration Guide

1. Install the SDK

Add the SDK to your project using your preferred package manager:

2. Import and Initialize

Import the SDK and configure it with your API key:

Quick Start

Here's a minimal example to get you started with vault operations:

Implementation Example

Complete Vault Operations Flow

Here's a comprehensive example demonstrating vault creation, deposits, and withdrawals:


Core Functions

System Operations

Health Check

Monitor API availability and system status:

Factory Operations

Get Factory Address

Retrieve the factory contract address for vault creation:

Create Vault

Deploy a new vault with custom configuration:

Vault Operations

Get Vault Information

Query comprehensive vault details:

Get User Balance

Check user's vault position:

Deposit to Vault

Add funds to a vault:

Withdraw from Vault

Remove funds by specifying amounts:

Withdraw by Shares

Remove funds by burning vault shares:

Get Vault APY

Query current Annual Percentage Yield:

Administrative Operations

Emergency Rescue

Execute emergency asset recovery and pauses strategy (requires Emergency Manager role):

Pause/Unpause Strategy

Control strategy operations (requires appropriate role):

Transaction Management

Submit Signed Transactions

Send signed XDR to the Stellar network:


Error Handling

The SDK provides comprehensive error handling with specific error types:

Security Best Practices

  1. Environment Variables: Always store API keys in environment variables

  1. Error Handling: Always wrap API calls in try-catch blocks

  1. Server-Side Only: This SDK is designed for server-side use only

  2. Role Management: Understand vault roles and permissions before administrative operations


Running Examples

The SDK includes a comprehensive functional example demonstrating all features:

The example demonstrates:

  • SDK initialization and authentication

  • API health checking

  • Factory operations and vault creation

  • Vault deposits and withdrawals

  • Administrative vault management

  • Error handling patterns

TypeScript Support

The SDK provides full TypeScript support with comprehensive type definitions:

Support and Resources

For additional questions or integration support, please reach out to our developer support team.

Last updated