Creating a DeFindex Vault
Webapp: https://app.defindex.io/
Prerequisites: Vault Roles
Before creating a vault, you'll need to establish the following key roles with their respective addresses:
Core Roles
Vault Manager
Primary owner of the vault
Controls vault settings and role assignments
Manages contract upgrades (if enabled)
Recommended: Use a multisig wallet for enhanced security
Rebalance Manager
Responsible for fund allocation between strategies
Optimizes strategy distribution
Recommended: Implement as an automated bot
Fee Receiver
Designated address for collecting strategy performance fees
Should be a secure, dedicated wallet
Emergency Manager
Handles emergency fund recovery from strategies
Critical for risk management
Recommended: Implement as an automated bot
Deployment Process
Initial Setup
Any address with XLM can deploy the vault
No multisig required for deployment
Recommended: Use a fresh address for deployment
Strategy Selection
Choose from our curated and audited strategies:
Blend Fixed Pool Strategies (with Autocompound)
USDC
EURC
XLM
Blend Yieldblox Pool Strategies (with Autocompound)
USDC
EURC
XLM
Best Practices
Recommended configuration: One asset with two strategies
This provides optimal balance between yield and risk management
Security Initialization
Required: Initial deposit of 1001 stroops of the chosen underlying asset
Purpose: Security verification
Timing: Complete before user implementation
This ensures the vault is properly initialized and secure
Implementation Timeline
Set up all role addresses
Deploy vault
Select strategies
Make initial security deposit
Do first rebalance
Begin user implementation
This structured approach ensures a secure and efficient vault creation process while maintaining best practices for DeFi operations.
First rebalance
You can do the first rebalance using the script vault_usage_example.ts
(discussed on next section) or by using the stellar-cli.
First, you need to setup your keys, make sure the rebalancer manager role defined previously is the one you are going to setup. For example, you can set it up using secret key by:
stellar keys add --secret-key rebalancer
then, you will be prompted to write your secret key.
Next, let's make the rebalance using testnet as example. You can do that by:
stellar contract invoke \
--rpc-url https://soroban-testnet.stellar.org/ \
--network-passphrase 'Test SDF Network ; September 2015' \
--id <CONTRACT_ID> \
--source-account rebalancer \
-- \
rebalance \
--caller <REBALANCER_ADDRESS> \
--instructions '[{"Invest":["<STRATEGY_ADDRESS>", "<AMOUNT_IN_STROOPS>"]}]'
you can find the strategy addresses on ~/public/<network>.contracts.json
.
And that's all!
Interacting with the Vault
Using the Example Script (vault_usage_example.ts
)
vault_usage_example.ts
)You can interact with your DeFindex Vault directly from the command line using the provided example script: Contracts/src/vault_usage_example.ts
. This script demonstrates how to perform key vault operations such as deposit, withdraw, invest, unwind, and harvest.
Prerequisites
Node.js and yarn installed
All dependencies installed (
yarn install
in the project root)Properly configured environment (setup a
.env
file, seeContracts/src/utils/env_config.js
for user/secret setup)The vault and strategy contracts deployed and addresses set in your address book
How to Use
Navigate to the Contracts directory:
cd Contracts
Edit the script if needed: Uncomment the function call(s) you want to run at the bottom of
src/vault_usage_example.ts
(e.g.,await deposit();
).Run the script:
yarn vault-example <network>
Replace <network>
with your target network (e.g., testnet
, mainnet
, or your custom config).
Available Operations
Deposit:
Deposits assets into the vault for the configured user.
await deposit();
Withdraw: Withdraws assets from the vault for the configured user.
await withdraw();
Invest:
Allocates vault funds into a strategy (admin only).
await invest();
Unwind:
Withdraws funds from a strategy back to the vault (admin only).
await unwind();
Harvest: Triggers a strategy harvest (keeper only).
await harvest();
Note: Only uncomment and run one operation at a time to avoid transaction conflicts. Make sure your environment variables and address book are set up for the network you are targeting.
For more details, review the comments and code in vault_usage_example.ts
.
Last updated