From 4dbdf5c609f6c814a472b8873cdfbba71caf4a95 Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 19 Feb 2024 10:03:40 +0000 Subject: [PATCH] refactor: add debt coverage arg to adjust simulation --- .../src/strategies/aave-like/multiply/adjust/simulate.ts | 3 +++ .../src/strategies/aave-like/multiply/adjust/types.ts | 1 + packages/dma-library/src/types/strategy-params.ts | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/packages/dma-library/src/strategies/aave-like/multiply/adjust/simulate.ts b/packages/dma-library/src/strategies/aave-like/multiply/adjust/simulate.ts index 0a7d8b93..825b1428 100644 --- a/packages/dma-library/src/strategies/aave-like/multiply/adjust/simulate.ts +++ b/packages/dma-library/src/strategies/aave-like/multiply/adjust/simulate.ts @@ -32,6 +32,9 @@ export async function simulate( ) const currentPosition = await resolveCurrentPositionForProtocol(args, dependencies) + if (!args.debtCoverage.isZero()) { + currentPosition.debt.amount = currentPosition.debt.amount.plus(args.debtCoverage) + } const protocolData = await resolveProtocolData( { collateralTokenAddress, diff --git a/packages/dma-library/src/strategies/aave-like/multiply/adjust/types.ts b/packages/dma-library/src/strategies/aave-like/multiply/adjust/types.ts index 1c971ad7..c02a0788 100644 --- a/packages/dma-library/src/strategies/aave-like/multiply/adjust/types.ts +++ b/packages/dma-library/src/strategies/aave-like/multiply/adjust/types.ts @@ -8,6 +8,7 @@ import BigNumber from 'bignumber.js' export type AaveLikeAdjustArgs = StrategyParams.WithAaveLikeMultiplyStrategyArgs & StrategyParams.WithMultiple & StrategyParams.WithDeposit & + StrategyParams.WithDebtCoverage & Partial export type ExtendedAaveLikeAdjustArgs = AaveLikeAdjustArgs & StrategyParams.WithFlashLoanArgs diff --git a/packages/dma-library/src/types/strategy-params.ts b/packages/dma-library/src/types/strategy-params.ts index 49b7b896..6e06e582 100644 --- a/packages/dma-library/src/types/strategy-params.ts +++ b/packages/dma-library/src/types/strategy-params.ts @@ -154,3 +154,7 @@ export type WithCollateralTokenAddress = { export type WithDebtTokenAddress = { debtTokenAddress: string } + +export type WithDebtCoverage = { + debtCoverage: BigNumber +}