Back to Contract Explorer
ParaSwapFacet
dexExecutes token swaps through the ParaSwap aggregator within the Smart Loan. Allows leveraged positions to be rebalanced or assets to be swapped without leaving the loan.
Functions (2)
Usage Example
typescript
// 1. Get swap quote from ParaSwap API
const quote = await fetch(
"https://apiv5.paraswap.io/prices?" +
new URLSearchParams({
srcToken: wethAddress,
destToken: usdcAddress,
amount: parseEther("1").toString(),
network: "8453",
})
).then(r => r.json());
// 2. Build transaction data from ParaSwap
const txData = await fetch(
"https://apiv5.paraswap.io/transactions/8453",
{ method: "POST", body: JSON.stringify({...quote, userAddress: loanAddress}) }
).then(r => r.json());
// 3. Execute swap within the loan
await wrappedContract.paraSwap(txData.data, minOutputAmount);