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

Adjust aave-like caps validation #673

Merged
merged 1 commit into from
Apr 15, 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.51",
"version": "0.6.52",
"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 @@ -4,7 +4,6 @@ import {
AaveLikePaybackWithdrawDependenciesOmni,
} from '@dma-library/strategies/aave-like/borrow/payback-withdraw'
import {
validateAmountExceedsCap,
validateYieldLoopCloseToLiquidation,
validateYieldLoopSafeFromLiquidation,
} from '@dma-library/strategies/aave-like/omni/validation'
Expand All @@ -25,7 +24,7 @@ export const paybackWithdrawOmni = async (
return {
simulation: {
swaps: [],
errors: [...validateAmountExceedsCap(args.position, targetPosition)],
errors: [],
warnings: [...validateYieldLoopCloseToLiquidation(args.position, targetPosition)],
notices: [],
successes: [...validateYieldLoopSafeFromLiquidation(args.position, targetPosition)],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function validateAmountExceedsCap(
const maxSupply = position.reserveData.collateral.availableToSupply
const maxBorrow = position.reserveData.debt.availableToBorrow

if (targetPosition.collateralAmount.gt(maxSupply)) {
if (targetPosition.collateralAmount.minus(position.collateralAmount).gt(maxSupply)) {
return [
{
name: 'deposit-amount-exceeds-supply-cap',
Expand All @@ -19,7 +19,7 @@ export function validateAmountExceedsCap(
]
}

if (targetPosition.debtAmount.gt(maxBorrow)) {
if (targetPosition.debtAmount.minus(position.debtAmount).gt(maxBorrow)) {
return [
{
name: 'debt-amount-exceeds-borrow-cap',
Expand Down
Loading