Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use maker for dai flashloans #697

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading