Skip to content

Commit

Permalink
chore: use maker for dai flashloans
Browse files Browse the repository at this point in the history
  • Loading branch information
halaprix committed Aug 13, 2024
1 parent 8467f7f commit 3c8a995
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/dma-library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oasisdex/dma-library",
"version": "0.6.62",
"version": "0.6.63",
"typings": "lib/index.d.ts",
"types": "lib/index.d.ts",
"main": "lib/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ async function buildOperation(
})

const network = await getNetwork(dependencies.provider)
const isDai =
args.position.marketParams.loanToken.toLowerCase() === dependencies.addresses.DAI.toLowerCase()

const morphoBlueMarket = {
loanToken: args.position.marketParams.loanToken,
Expand Down Expand Up @@ -302,7 +304,7 @@ async function buildOperation(
address: args.position.marketParams.loanToken,
},
amount: Domain.debtToCollateralSwapFlashloan(swapAmountBeforeFees),
provider: FlashloanProvider.Balancer,
provider: isDai ? FlashloanProvider.DssFlash : FlashloanProvider.Balancer,
},
}

Expand All @@ -327,7 +329,7 @@ async function buildOperation(
address: args.position.marketParams.loanToken,
},
amount: Domain.collateralToDebtSwapFlashloan(swapData.minToTokenAmount),
provider: FlashloanProvider.Balancer,
provider: isDai ? FlashloanProvider.DssFlash : FlashloanProvider.Balancer,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ async function buildOperation(
? swapData.fromTokenAmount.plus(preSwapFee)
: lockedCollateralAmount

const isDai =
args.position.marketParams.loanToken.toLowerCase() === dependencies.addresses.DAI.toLowerCase()

const closeArgs = {
collateral: {
address: collateralToken.address,
Expand All @@ -245,7 +248,7 @@ async function buildOperation(
amount: Domain.debtToCollateralSwapFlashloan(amountToFlashloan),
address: position.marketParams.loanToken,
},
provider: FlashloanProvider.Balancer,
provider: isDai ? FlashloanProvider.DssFlash : FlashloanProvider.Balancer,
amount: Domain.debtToCollateralSwapFlashloan(amountToFlashloan),
},
position: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ async function buildOperation(
})

const network = await getNetwork(dependencies.provider)
const isDai =
position.marketParams.loanToken.toLowerCase() === dependencies.addresses.DAI.toLowerCase()

const openMultiplyArgs: MorphoBlueOpenOperationArgs = {
morphoBlueMarket: {
Expand Down Expand Up @@ -385,7 +387,7 @@ async function buildOperation(
address: position.marketParams.loanToken,
},
amount: Domain.debtToCollateralSwapFlashloan(swapAmountBeforeFees),
provider: FlashloanProvider.Balancer,
provider: isDai ? FlashloanProvider.DssFlash : FlashloanProvider.Balancer,
},
position: {
type: positionType,
Expand Down
4 changes: 3 additions & 1 deletion packages/dma-library/src/utils/flashloan/resolve-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export function resolveFlashloanProvider({
if (lendingProtocol === 'Spark' && debtToken !== 'DAI') {
return FlashloanProvider.Balancer
}

if (lendingProtocol === 'MorphoBlue' && debtToken !== 'DAI') {
return FlashloanProvider.Balancer
}
if (
lendingProtocol === 'AAVE_V3' &&
aaveIsolatedCollateralTokens.includes(collateralToken.toUpperCase())
Expand Down

0 comments on commit 3c8a995

Please sign in to comment.