From ae13740be37942ac382ded4a642de988ff2d97bc Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 19 Feb 2024 15:16:06 +0000 Subject: [PATCH 01/10] feat: Update version to 0.6.0-dma-v2-workers --- packages/dma-library/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dma-library/package.json b/packages/dma-library/package.json index 6451697f..97532368 100644 --- a/packages/dma-library/package.json +++ b/packages/dma-library/package.json @@ -1,6 +1,6 @@ { "name": "@oasisdex/dma-library", - "version": "0.5.21-dma-v2-workers.19-test.0", + "version": "0.6.0-dma-v2-workers", "typings": "lib/index.d.ts", "types": "lib/index.d.ts", "main": "lib/index.js", From c012247bbcdbcbb6f19b0367f313d772ce366d5e Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 4 Mar 2024 14:12:42 +0000 Subject: [PATCH 02/10] feat: Update package version to 0.6.1-auto --- packages/dma-library/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dma-library/package.json b/packages/dma-library/package.json index c30e8494..5020c281 100644 --- a/packages/dma-library/package.json +++ b/packages/dma-library/package.json @@ -1,6 +1,6 @@ { "name": "@oasisdex/dma-library", - "version": "0.5.21-dma-v2-workers.19-test.17", + "version": "0.6.1-auto", "typings": "lib/index.d.ts", "types": "lib/index.d.ts", "main": "lib/index.js", From c801041fd3ec1b723d432a2ef9f06305a0f11fc1 Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 4 Mar 2024 21:16:04 +0000 Subject: [PATCH 03/10] refactor: Update Aave close strategy types --- .../src/strategies/aave-like/multiply/close/close.ts | 2 ++ .../src/strategies/aave-like/multiply/close/types.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/dma-library/src/strategies/aave-like/multiply/close/close.ts b/packages/dma-library/src/strategies/aave-like/multiply/close/close.ts index 35a8af41..1b6ec69a 100644 --- a/packages/dma-library/src/strategies/aave-like/multiply/close/close.ts +++ b/packages/dma-library/src/strategies/aave-like/multiply/close/close.ts @@ -16,6 +16,8 @@ export const close: AaveLikeClose = async (args, dependencies) => { ? getAaveSwapDataToCloseToCollateral : getAaveSwapDataToCloseToDebt + dependencies.currentPosition.collateral.amount + const collateralTokenAddress = getAaveTokenAddress(args.collateralToken, dependencies.addresses) const debtTokenAddress = getAaveTokenAddress(args.debtToken, dependencies.addresses) const flashloanArgs = diff --git a/packages/dma-library/src/strategies/aave-like/multiply/close/types.ts b/packages/dma-library/src/strategies/aave-like/multiply/close/types.ts index 146ae629..720b1284 100644 --- a/packages/dma-library/src/strategies/aave-like/multiply/close/types.ts +++ b/packages/dma-library/src/strategies/aave-like/multiply/close/types.ts @@ -5,6 +5,7 @@ import { WithFlashLoanArgs } from '@dma-library/types/strategy-params' import { BigNumber } from 'bignumber.js' export type AaveLikeCloseArgs = StrategyParams.WithAaveLikeMultiplyStrategyArgs & + StrategyParams.WithDebtCoverage & StrategyParams.WithCloseToCollateralFlag & Partial From 328665a7f73853aef0c4e85f6fc35e3625ccd23f Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 4 Mar 2024 21:33:15 +0000 Subject: [PATCH 04/10] refactor: Improve handling of debt coverage addition --- .../src/strategies/aave-like/multiply/close/close.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/dma-library/src/strategies/aave-like/multiply/close/close.ts b/packages/dma-library/src/strategies/aave-like/multiply/close/close.ts index 1b6ec69a..32941734 100644 --- a/packages/dma-library/src/strategies/aave-like/multiply/close/close.ts +++ b/packages/dma-library/src/strategies/aave-like/multiply/close/close.ts @@ -16,7 +16,11 @@ export const close: AaveLikeClose = async (args, dependencies) => { ? getAaveSwapDataToCloseToCollateral : getAaveSwapDataToCloseToDebt - dependencies.currentPosition.collateral.amount + if (!args.debtCoverage.isZero()) { + dependencies.currentPosition.debt.amount = dependencies.currentPosition.debt.amount.plus( + args.debtCoverage, + ) + } const collateralTokenAddress = getAaveTokenAddress(args.collateralToken, dependencies.addresses) const debtTokenAddress = getAaveTokenAddress(args.debtToken, dependencies.addresses) From 056f27b37de85771e2b0c3dce86322e595236905 Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 4 Mar 2024 21:34:12 +0000 Subject: [PATCH 05/10] v0.6.2-auto --- packages/dma-library/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dma-library/package.json b/packages/dma-library/package.json index 5020c281..40236ea1 100644 --- a/packages/dma-library/package.json +++ b/packages/dma-library/package.json @@ -1,6 +1,6 @@ { "name": "@oasisdex/dma-library", - "version": "0.6.1-auto", + "version": "0.6.2-auto", "typings": "lib/index.d.ts", "types": "lib/index.d.ts", "main": "lib/index.js", From 3862f0ea36768ac87432716bc04a3a5e8a161cc2 Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Fri, 14 Jun 2024 15:26:19 +0100 Subject: [PATCH 06/10] v0.6.6-auto-rc1 --- packages/dma-library/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dma-library/package.json b/packages/dma-library/package.json index 3fb09e5b..6219d308 100644 --- a/packages/dma-library/package.json +++ b/packages/dma-library/package.json @@ -1,6 +1,6 @@ { "name": "@oasisdex/dma-library", - "version": "0.6.6-automation", + "version": "0.6.6-auto-rc1", "typings": "lib/index.d.ts", "types": "lib/index.d.ts", "main": "lib/index.js", From c4629ca3860c04b77f0db724db31da9081569dfa Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Fri, 14 Jun 2024 15:27:36 +0100 Subject: [PATCH 07/10] v0.6.7-auto-rc1 --- packages/dma-library/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dma-library/package.json b/packages/dma-library/package.json index 6219d308..d851b632 100644 --- a/packages/dma-library/package.json +++ b/packages/dma-library/package.json @@ -1,6 +1,6 @@ { "name": "@oasisdex/dma-library", - "version": "0.6.6-auto-rc1", + "version": "0.6.7-auto-rc1", "typings": "lib/index.d.ts", "types": "lib/index.d.ts", "main": "lib/index.js", From e64a1876eca512f771678c7c95f55fb78e04040a Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 17 Jun 2024 14:44:15 +0100 Subject: [PATCH 08/10] feat: add debtCoverage to adjust args --- .../src/strategies/morphoblue/multiply/adjust.ts | 5 +++-- .../src/strategies/morphoblue/multiply/close.ts | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/dma-library/src/strategies/morphoblue/multiply/adjust.ts b/packages/dma-library/src/strategies/morphoblue/multiply/adjust.ts index c93b4803..afdce0de 100644 --- a/packages/dma-library/src/strategies/morphoblue/multiply/adjust.ts +++ b/packages/dma-library/src/strategies/morphoblue/multiply/adjust.ts @@ -12,6 +12,7 @@ import { SwapData, } from '@dma-library/types' import { SummerStrategy } from '@dma-library/types/ajna/ajna-strategy' +import * as StrategyParams from '@dma-library/types/strategy-params' import * as SwapUtils from '@dma-library/utils/swap' import * as Domain from '@domain' import { isRiskIncreasing } from '@domain/utils' @@ -38,14 +39,14 @@ export interface MorphoAdjustMultiplyPayload { } export type MorphoAdjustRiskStrategy = ( - args: MorphoAdjustMultiplyPayload, + args: MorphoAdjustMultiplyPayload & StrategyParams.WithDebtCoverage, dependencies: MorphoMultiplyDependencies, ) => Promise> const positionType: PositionType = 'Multiply' export const adjustMultiply: MorphoAdjustRiskStrategy = ( - args: MorphoAdjustMultiplyPayload, + args: MorphoAdjustMultiplyPayload & StrategyParams.WithDebtCoverage, dependencies: MorphoMultiplyDependencies, ) => { if (isRiskIncreasing(args.riskRatio.loanToValue, args.position.riskRatio.loanToValue)) { diff --git a/packages/dma-library/src/strategies/morphoblue/multiply/close.ts b/packages/dma-library/src/strategies/morphoblue/multiply/close.ts index a053dc5d..dffda811 100644 --- a/packages/dma-library/src/strategies/morphoblue/multiply/close.ts +++ b/packages/dma-library/src/strategies/morphoblue/multiply/close.ts @@ -15,6 +15,7 @@ import { SwapData, } from '@dma-library/types' import { StrategyError, StrategyWarning } from '@dma-library/types/ajna/ajna-validations' +import * as StrategyParams from "@dma-library/types/strategy-params"; import { encodeOperation } from '@dma-library/utils/operation' import * as SwapUtils from '@dma-library/utils/swap' import * as Domain from '@domain' @@ -33,7 +34,7 @@ export interface MorphoCloseMultiplyPayload { } export type MorphoCloseStrategy = ( - args: MorphoCloseMultiplyPayload, + args: MorphoCloseMultiplyPayload & StrategyParams.WithDebtCoverage, dependencies: MorphoMultiplyDependencies, ) => Promise> @@ -41,8 +42,7 @@ const positionType: PositionType = 'Multiply' export const closeMultiply: MorphoCloseStrategy = async (args, dependencies) => { const position = args.position - console.log("MB Close Multiply") - console.log("shouldCloseToCollateral", args.shouldCloseToCollateral) + const getSwapData = args.shouldCloseToCollateral ? getMorphoSwapDataToCloseToCollateral : getMorphoSwapDataToCloseToDebt @@ -50,12 +50,10 @@ export const closeMultiply: MorphoCloseStrategy = async (args, dependencies) => args.position.marketParams.collateralToken, dependencies.provider, ) - console.log("collateralTokenSymbol", collateralTokenSymbol) const debtTokenSymbol = await getTokenSymbol( args.position.marketParams.loanToken, dependencies.provider, ) - console.log("debtTokenSymbol", debtTokenSymbol) const { swapData, collectFeeFrom, preSwapFee } = await getSwapData( args, From 5a49dbf452a3283ff253b469b4b02e4a02b32eea Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 17 Jun 2024 14:49:39 +0100 Subject: [PATCH 09/10] feat: add debtCoverage to MorphoBlue args --- .../dma-library/src/strategies/morphoblue/multiply/adjust.ts | 4 ++++ .../dma-library/src/strategies/morphoblue/multiply/close.ts | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/dma-library/src/strategies/morphoblue/multiply/adjust.ts b/packages/dma-library/src/strategies/morphoblue/multiply/adjust.ts index afdce0de..76bcb709 100644 --- a/packages/dma-library/src/strategies/morphoblue/multiply/adjust.ts +++ b/packages/dma-library/src/strategies/morphoblue/multiply/adjust.ts @@ -84,6 +84,10 @@ const adjustRiskUp: MorphoAdjustRiskStrategy = async (args, dependencies) => { }, } + if (!args.debtCoverage.isZero()) { + mappedPosition.debtAmount = mappedPosition.debtAmount.plus(args.debtCoverage) + } + // Simulate adjust const riskIsIncreasing = true const simulatedAdjustment = await simulateAdjustment( diff --git a/packages/dma-library/src/strategies/morphoblue/multiply/close.ts b/packages/dma-library/src/strategies/morphoblue/multiply/close.ts index dffda811..573b2775 100644 --- a/packages/dma-library/src/strategies/morphoblue/multiply/close.ts +++ b/packages/dma-library/src/strategies/morphoblue/multiply/close.ts @@ -43,6 +43,10 @@ const positionType: PositionType = 'Multiply' export const closeMultiply: MorphoCloseStrategy = async (args, dependencies) => { const position = args.position + if (!args.debtCoverage.isZero()) { + position.debtAmount = position.debtAmount.plus(args.debtCoverage) + } + const getSwapData = args.shouldCloseToCollateral ? getMorphoSwapDataToCloseToCollateral : getMorphoSwapDataToCloseToDebt @@ -155,7 +159,6 @@ async function getMorphoSwapDataToCloseToCollateral( collateralTokenSymbol: string, debtTokenSymbol: string, ) { - console.log("Morpho Clsoing to Coll...") const outstandingDebt = amountToWei(position.debtAmount, args.quoteTokenPrecision).integerValue( BigNumber.ROUND_DOWN, ) From f1f20e8ce68cb5e833e8457fb2eb590f1fde5654 Mon Sep 17 00:00:00 2001 From: James Tuckett Date: Mon, 17 Jun 2024 14:51:46 +0100 Subject: [PATCH 10/10] v0.6.7-auto-rc2 --- packages/dma-library/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dma-library/package.json b/packages/dma-library/package.json index d851b632..59e6d865 100644 --- a/packages/dma-library/package.json +++ b/packages/dma-library/package.json @@ -1,6 +1,6 @@ { "name": "@oasisdex/dma-library", - "version": "0.6.7-auto-rc1", + "version": "0.6.7-auto-rc2", "typings": "lib/index.d.ts", "types": "lib/index.d.ts", "main": "lib/index.js",