|
| 1 | +--- |
| 2 | +title: "Fxdao CDP Integration" |
| 3 | +description: "Borrow and forget: Mint USDx against XLM/BLND collateral and route to a stealth address." |
| 4 | +--- |
| 5 | + |
| 6 | +# Fxdao CDP Integration |
| 7 | + |
| 8 | +Fxdao is Stellar's leading collateralized-debt platform (CDP), allowing you to mint USDx against XLM or BLND collateral. While [Blend](./blend.mdx) covers general lending, Fxdao enables the missing DeFi flow: borrowing-against-collateral directly to a stealth address. This guide details how to build "borrow-and-forget" recipes on Stellar. |
| 9 | + |
| 10 | +## Concept: One-Step Borrow and Route |
| 11 | + |
| 12 | +The core integration flow is as follows: |
| 13 | +1. **Open Vault**: Create a CDP vault with your specified collateral. |
| 14 | +2. **Mint USDx**: Generate USDx against the collateral. |
| 15 | +3. **Send to Stealth**: Route the minted USDx directly to a stealth address in a single atomic flow. |
| 16 | + |
| 17 | +This allows users to collateralize their assets and receive a stablecoin (USDx) privately, without the destination address being linkable to the CDP vault. |
| 18 | + |
| 19 | +## Collateral Management from a Stealth Address |
| 20 | + |
| 21 | +Managing collateral (adding more or withdrawing) from a stealth address requires careful handling of transaction submissions. |
| 22 | +Since the stealth address is the ultimate owner of the assets, any interactions to manage the vault must originate from or be authorized by the stealth keys. |
| 23 | +When building your integration, ensure that collateral management transactions use the proper signatures derived from the user's stealth meta-address. |
| 24 | + |
| 25 | +## Liquidation Risk and Health-Factor |
| 26 | + |
| 27 | +<Warning> |
| 28 | +**Liquidation Risk** |
| 29 | +When minting USDx against volatile collateral like XLM or BLND, your vault is subject to liquidation if the collateral value drops below the required threshold. |
| 30 | +</Warning> |
| 31 | + |
| 32 | +<Info> |
| 33 | +**Health-Factor Monitoring** |
| 34 | +Always implement robust health-factor monitoring for your vaults. Since the minted USDx is routed to a stealth address, users might "borrow-and-forget." Your application should notify users or automatically manage collateral if the health factor approaches liquidation levels. |
| 35 | +</Info> |
| 36 | + |
| 37 | +## End-to-End Futurenet Example |
| 38 | + |
| 39 | +Here is a complete example of the integration running on Stellar Futurenet: |
| 40 | + |
| 41 | +```typescript |
| 42 | +import { FxdaoClient } from '@fxdao/sdk'; |
| 43 | +import { StealthClient } from '@wraith-protocol/sdk'; |
| 44 | + |
| 45 | +async function borrowAndRoute( |
| 46 | + collateralAmount: string, |
| 47 | + mintAmount: string, |
| 48 | + stealthMetaAddress: string |
| 49 | +) { |
| 50 | + // Initialize clients for Futurenet |
| 51 | + const fxdao = new FxdaoClient({ network: 'futurenet' }); |
| 52 | + const stealth = new StealthClient({ network: 'futurenet' }); |
| 53 | + |
| 54 | + // 1. Generate stealth address for the destination |
| 55 | + const { stealthAddress } = await stealth.generateAddress(stealthMetaAddress); |
| 56 | + |
| 57 | + // 2. Open vault and mint USDx |
| 58 | + // Note: In a real-world scenario, this should be an atomic transaction |
| 59 | + const vault = await fxdao.openVault({ |
| 60 | + collateralAsset: 'XLM', |
| 61 | + collateralAmount, |
| 62 | + }); |
| 63 | + |
| 64 | + const mintTx = await fxdao.mintUSDx({ |
| 65 | + vaultId: vault.id, |
| 66 | + amount: mintAmount, |
| 67 | + destination: stealthAddress, // Route directly to stealth address |
| 68 | + }); |
| 69 | + |
| 70 | + console.log(`Successfully minted ${mintAmount} USDx to stealth address ${stealthAddress}`); |
| 71 | + console.log(`Vault ID: ${vault.id} | Health Factor: ${vault.healthFactor}`); |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +For more lending integrations, check out the [Blend Lending Guide](./blend.mdx). |
0 commit comments