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

[FIX] Aave Close to Coll Fix #2766

Merged
merged 3 commits into from
Aug 22, 2023
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
12 changes: 1 addition & 11 deletions actions/aave/open/get-open-deposit-borrow-position-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import { IOpenDepositBorrowStrategy, strategies } from '@oasisdex/dma-library'
import { getTokenAddresses } from 'actions/aave/get-token-addresses'
import { networkIdToLibraryNetwork } from 'actions/aave/helpers'
import { OpenAaveDepositBorrowParameters } from 'actions/aave/types'
import { getOnChainPosition } from 'actions/aave/view'
import { getRpcProvider, NetworkIds } from 'blockchain/networks'
import { getToken } from 'blockchain/tokensMetadata'
import { amountToWei } from 'blockchain/utils'
import { LendingProtocol } from 'lendingProtocols'

function assertNetwork(networkId: NetworkIds): asserts networkId is NetworkIds.MAINNET {
if (networkId !== NetworkIds.MAINNET) {
throw new Error('Open simple borrow position works only on Ethereum Mainnet')
}
}

export async function getOpenDepositBorrowPositionParameters(
args: OpenAaveDepositBorrowParameters,
): Promise<IOpenDepositBorrowStrategy> {
Expand Down Expand Up @@ -49,22 +48,13 @@ export async function getOpenDepositBorrowPositionParameters(
},
}

const onChainPosition = await getOnChainPosition({
networkId,
proxyAddress,
collateralToken,
debtToken,
protocol: LendingProtocol.AaveV3,
})

const deps: types[1] = {
addresses: getTokenAddresses(networkId),
provider: getRpcProvider(networkId),
proxy: proxyAddress,
user: userAddress,
network: networkIdToLibraryNetwork(networkId),
positionType: 'Borrow' as const,
currentPosition: onChainPosition,
}

return await strategies.aave.v3.openDepositBorrow(libArgs, deps)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@next/mdx": "12.0.4",
"@oasisdex/addresses": "0.0.42",
"@oasisdex/automation": "^1.5.2",
"@oasisdex/dma-library": "0.4.8",
"@oasisdex/dma-library": "0.4.10",
"@oasisdex/multiply": "^0.2.11",
"@oasisdex/transactions": "0.1.4-alpha.0",
"@oasisdex/utils": "^0.0.8",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3914,10 +3914,10 @@
dependencies:
ethers "^5.6.2"

"@oasisdex/[email protected].8":
version "0.4.8"
resolved "https://registry.yarnpkg.com/@oasisdex/dma-library/-/dma-library-0.4.8.tgz#6f6adab1e87eb4ff51c276fc37517831bbe4c5d7"
integrity sha512-+3olkGx+k8rCldbl95vR1aW5Ag2jOUP+Z3jKQaNhE3Vjp5ffy0XEse0v/lARodwJgLJ4E1ivSV52L0meQSeEUg==
"@oasisdex/[email protected].10":
version "0.4.10"
resolved "https://registry.yarnpkg.com/@oasisdex/dma-library/-/dma-library-0.4.10.tgz#a15f887df59be8c8489bd3175f22265ee765f3b7"
integrity sha512-6iUlMwGtp1WgtlVNHVHLGUsfj0Hr3ZHyC0o1CnFcNuT3elQda+td2ZbWFvOmFfrA7KvXB9zvxgDtYSRmg9Rtig==
dependencies:
bignumber.js "9.0.1"
ethers "5.6.2"
Expand Down
Loading