POST /migration/defindex-to-defindex
Moves a user’s entire position from one DeFindex vault into another. There is no partial migration: the user’s full share balance in the source vault is withdrawn. The target vault must hold the same assets, in the same order, as the source vault; the endpoint verifies this before building anything, because the deposit matches amounts to assets by position.
Works on both networks. The network query parameter accepts mainnet or testnet and defaults to mainnet. It works between single-asset vaults that hold the same asset. Between vaults with more than one asset, the target vault takes a deposit only in the proportion it already holds its assets, so unless the withdrawn amounts match that proportion exactly, the API can’t build the transaction and answers 503: there is nothing to sign and no funds move. The API also won’t build a migration out of a vault whose withdrawals are temporarily disabled.
Response:
Steps
- Pick the target vault. It must hold the same assets, in the same order, as the source vault: compare
assetsinGET /vault/{address}for both. The endpoint checks this too and answers400on a mismatch. - Build the transaction: call
POST /migration/defindex-to-defindexwith the user’s address and the two vaults. - Have the user sign
xdrwith the key offrom. It is the only signature: the user’s account is the transaction’s source, and the API has already simulated the transaction and set its fee and resources. - Submit the signed XDR with
POST /sendor your own RPC. If the outcome is unknown, send the same signed XDR again:POST /sendreturns the original result when it already landed. - Check the result with
GET /vault/{address}/balanceandfromset to the user:dfTokensis0in the source vault, and the user holds shares in the target vault.
About slippageBps
The transaction deposits a floor, not the exact amount withdrawn.
The deposit needs a fixed amount decided when the transaction is built, but the value of a vault share can move slightly between the moment the transaction is simulated and the moment the user submits it. If the deposit demanded the exact simulated amount and the value dipped in between, the whole transaction would revert. So the amount is shrunk by slippageBps and that lower number is used for both legs. The trade-off:
- The migration is resilient: small share-price movements no longer revert it.
- A sliver stays behind in the user’s wallet, roughly
slippageBpsof the position. At the default 10 bps that is 0.1%.
0, if you want zero dust and are willing to retry on failure.
Errors: 400 when an address is invalid, from is a contract address, fromVault equals toVault, the two vaults hold different assets, or the position is so small it rounds to zero once the buffer is applied; 403 when withdrawals from fromVault are temporarily disabled; 404 when the user holds no shares in fromVault; 503 when the API can’t build the transaction, for example a multi-asset target vault whose proportions don’t match.