Flash Loans
Dualis Finance offers flash loans that allow users to borrow any amount of available liquidity from a pool without collateral, provided the loan is repaid within the same transaction. Flash loans enable advanced DeFi strategies such as arbitrage, collateral swaps, and self-liquidation at a fee of 0.09% of the borrowed amount.
How Flash Loans Work
A flash loan is an atomic, single-transaction operation. The protocol lends the requested amount to the borrower, the borrower executes arbitrary logic, and the full principal plus fee must be returned before the transaction completes. If the repayment condition is not met, the entire transaction reverts as if it never happened.
On Canton, this atomicity is guaranteed by DAML's transaction model. A flash loan is expressed as a single DAML exercise that checks the repayment invariant as a postcondition. The Canton runtime ensures that all sub-transactions within the exercise either succeed together or fail together.
- The borrower initiates a flash loan request specifying the asset and amount.
- The protocol transfers the requested amount to the borrower within the transaction.
- The borrower executes their strategy (e.g., arbitrage trade, collateral swap).
- The borrower returns the principal plus the 0.09% fee to the pool.
- The DAML postcondition verifies that the pool balance is whole. If not, the entire transaction is rolled back.
Use Cases
Arbitrage
Flash loans enable risk-free arbitrage between Dualis pools and external markets. A trader can borrow an asset, sell it on a market where it is overpriced, buy it back on a market where it is underpriced, repay the loan, and pocket the difference — all in a single transaction with no capital at risk.
Collateral Swap
A borrower who wants to switch their collateral from wETH to wBTC can use a flash loan to repay their existing debt, withdraw their wETH collateral, swap it for wBTC, deposit the wBTC as new collateral, and re-borrow — without ever having the position uncollateralized.
Self-Liquidation
If a borrower's health factor is approaching the liquidation zone, they can use a flash loan to repay their debt, withdraw their collateral, sell enough collateral to cover the flash loan, and keep the remainder. This avoids the liquidation penalty entirely, which can be significantly more expensive than the 0.09% flash loan fee.
Debt Refinancing
Borrowers can use flash loans to migrate debt between pools or restructure their positions. For example, a borrower can flash-borrow USDC to repay a wETH-denominated debt, swap the freed collateral, and re-establish the position in a different pool with more favorable rates.
API Integration
Flash loans are initiated through the Dualis API. The following example demonstrates a basic flash loan request:
const response = await fetch('https://api.dualis.finance/v1/flash-loan', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer <your-api-key>',
},
body: JSON.stringify({
asset: 'USDC',
amount: '1000000.00', // $1M USDC
// Callback contains the operations to execute
// during the flash loan window
callback: {
type: 'collateral-swap',
params: {
fromCollateral: 'wETH',
toCollateral: 'wBTC',
poolId: 'pool_usdc_main',
},
},
}),
});
// Response includes transaction hash and fee paid
const result = await response.json();
// {
// txHash: "canton:tx:abc123...",
// borrowed: "1000000.00",
// feePaid: "900.00", // 0.09% of $1M
// status: "completed"
// }Fee Governance
The flash loan fee rate is a governance-controlled parameter. The current rate of 0.09% was set at protocol launch to balance accessibility with revenue generation.
Risk Considerations
Flash loans are inherently low-risk for the protocol because the atomicity guarantee ensures that funds are never at risk. However, there are considerations for both the protocol and users:
- Pool liquidity impact: During a flash loan, the borrowed liquidity is temporarily unavailable. For extremely large flash loans (approaching total pool liquidity), this could theoretically affect other operations attempting to execute concurrently. Canton's transaction ordering mitigates this risk.
- Gas costs: Flash loan transactions are inherently more complex than standard operations. Users should account for higher transaction fees when calculating profitability.
- Oracle dependency: Strategies that depend on specific price conditions (e.g., arbitrage) should account for potential price movement between the time of estimation and the time of execution.