Skip to content

Commit

Permalink
Aavelike yield loops only as earn (#3988)
Browse files Browse the repository at this point in the history
  • Loading branch information
piekczyk committed Jul 12, 2024
1 parent 4c48552 commit 9a9d188
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ import type {
OmniFormState,
OmniSupportedNetworkIds,
} from 'features/omni-kit/types'
import { OmniBorrowFormAction, OmniMultiplyFormAction } from 'features/omni-kit/types'
import {
OmniBorrowFormAction,
OmniMultiplyFormAction,
OmniProductType,
} from 'features/omni-kit/types'
import { zero } from 'helpers/zero'
import type { AaveLikeLendingProtocol } from 'lendingProtocols'
import { LendingProtocol } from 'lendingProtocols'
Expand Down Expand Up @@ -132,11 +136,20 @@ export const getAaveLikeParameters = async ({
positionType: 'Borrow' as PositionType,
}

// entry token different from collateral token applies only for multiply (if defined)
const resolvedEntryToken =
state.productType === OmniProductType.Multiply
? {
symbol: entryToken.symbol as AaveLikeTokens,
precision: entryToken.precision,
}
: {
symbol: collateralToken as AaveLikeTokens,
precision: collateralPrecision,
}

const adjustMultiplyPayload = {
entryToken: {
symbol: entryToken.symbol as AaveLikeTokens,
precision: entryToken.precision,
},
entryToken: resolvedEntryToken,
position,
slippage,
debtToken: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AaveLiquidatedNotice } from 'features/notices/VaultsNoticesView'
import { getAutomationMetadataValues } from 'features/omni-kit/automation/helpers'
import { useOmniGeneralContext } from 'features/omni-kit/contexts'
import {
getOmniBorrowDebtMax,
getOmniBorrowishChangeVariant,
getOmniBorrowPaybackMax,
getOmniIsFormEmpty,
Expand Down Expand Up @@ -48,6 +49,7 @@ export const useAaveLikeMetadata: GetOmniMetadata = (productContext) => {
quoteAddress,
quoteBalance,
quoteToken,
quotePrecision,
},
steps: { currentStep },
tx: { txDetails },
Expand Down Expand Up @@ -123,7 +125,11 @@ export const useAaveLikeMetadata: GetOmniMetadata = (productContext) => {
afterBuyingPower: simulation?.buyingPower,
shouldShowDynamicLtv: () => false,
debtMin: zero,
debtMax: position.debtAvailable(),
debtMax: getOmniBorrowDebtMax({
digits: quotePrecision,
position,
simulation,
}),
changeVariant: getOmniBorrowishChangeVariant({ simulation, isOracless }),
afterAvailableToBorrow: simulation && simulation.debtAvailable(),
afterPositionDebt: resolvedSimulation?.debtAmount,
Expand Down
1 change: 1 addition & 0 deletions features/omni-kit/protocols/aave/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const settingsV3: OmniProtocolSettings = {
},
},
entryTokens: {
// entry token different from collateral token applies only for multiply (if defined)
[NetworkIds.MAINNET]: { 'WSTETH-ETH': 'ETH' },
},
availableAutomations: {
Expand Down
8 changes: 6 additions & 2 deletions features/omni-kit/views/OmniFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from 'features/omni-kit/helpers'
import { getOmniSidebarRaysBanner } from 'features/omni-kit/helpers/getOmniSidebarRaysBanner'
import { useOmniProductTypeTransition, useOmniSidebarTitle } from 'features/omni-kit/hooks'
import { OmniSidebarStep } from 'features/omni-kit/types'
import { OmniProductType, OmniSidebarStep } from 'features/omni-kit/types'
import { useConnection } from 'features/web3OnBoard/useConnection'
import { getLocalAppConfig } from 'helpers/config'
import { useModalContext } from 'helpers/modalHook'
Expand Down Expand Up @@ -126,6 +126,10 @@ export function OmniFormView({

const genericSidebarTitle = useOmniSidebarTitle()

// entry token different from collateral token applies only for multiply (if defined)
const resolvedEntryToken =
state.productType === OmniProductType.Multiply ? entryToken.symbol : collateralToken

const flowState = useFlowState({
pairId,
protocol,
Expand All @@ -134,7 +138,7 @@ export function OmniFormView({
...getOmniFlowStateConfig({
protocol,
collateralToken,
entryToken: entryToken.symbol,
entryToken: resolvedEntryToken,
fee: interestRate,
isOpening,
quoteToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ const aaveSeed: AaveProductHubItemSeed[] = [
collateral: 'wstETH',
debt: 'ETH',
strategyType: 'long',
types: ['borrow', 'earn'],
types: ['earn'],
},
{
collateral: 'rETH',
debt: 'ETH',
strategyType: 'long',
types: ['borrow', 'earn'],
types: ['earn'],
},
{
collateral: 'DAI',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ export const aaveV3EthereumMainnetProductHubProducts: ProductHubItemWithoutAddre
earnStrategyDescription: 'WSTETH/ETH Yield Loop',
managementType: 'active',
},
{
product: [OmniProductType.Borrow],
primaryToken: 'WSTETH',
primaryTokenGroup: 'ETH',
secondaryToken: 'ETH',
depositToken: 'WSTETH',
label: 'WSTETH/ETH',
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},
{
product: [OmniProductType.Earn],
primaryToken: 'RETH',
Expand All @@ -44,16 +34,6 @@ export const aaveV3EthereumMainnetProductHubProducts: ProductHubItemWithoutAddre
earnStrategyDescription: 'RETH/ETH Yield Loop',
managementType: 'active',
},
{
product: [OmniProductType.Borrow],
primaryToken: 'RETH',
primaryTokenGroup: 'ETH',
secondaryToken: 'ETH',
depositToken: 'RETH',
label: 'RETH/ETH',
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},
{
product: [OmniProductType.Earn],
primaryToken: 'CBETH',
Expand Down Expand Up @@ -83,16 +63,6 @@ export const aaveV3EthereumMainnetProductHubProducts: ProductHubItemWithoutAddre
liquidity: { ...productHubWeETHRewardsTooltip },
},
},
{
product: [OmniProductType.Borrow],
primaryToken: 'CBETH',
primaryTokenGroup: 'ETH',
secondaryToken: 'ETH',
depositToken: 'CBETH',
label: 'CBETH/ETH',
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},
{
product: [OmniProductType.Multiply],
primaryToken: 'ETH',
Expand Down Expand Up @@ -386,16 +356,6 @@ export const aaveV3EthereumMainnetProductHubProducts: ProductHubItemWithoutAddre
earnStrategyDescription: 'SDAI/USDC Yield Loop',
managementType: 'active',
},
{
product: [OmniProductType.Borrow],
primaryToken: 'SDAI',
primaryTokenGroup: 'DAI',
secondaryToken: 'USDC',
depositToken: 'SDAI',
label: 'SDAI/USDC',
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},
{
product: [OmniProductType.Earn],
primaryToken: 'SDAI',
Expand All @@ -409,17 +369,6 @@ export const aaveV3EthereumMainnetProductHubProducts: ProductHubItemWithoutAddre
earnStrategyDescription: 'SDAI/LUSD Yield Loop',
managementType: 'active',
},
{
product: [OmniProductType.Borrow],
primaryToken: 'SDAI',
primaryTokenGroup: 'DAI',
secondaryToken: 'LUSD',
depositToken: 'SDAI',
label: 'SDAI/LUSD',
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},

{
product: [OmniProductType.Earn],
primaryToken: 'SDAI',
Expand All @@ -433,16 +382,6 @@ export const aaveV3EthereumMainnetProductHubProducts: ProductHubItemWithoutAddre
earnStrategyDescription: 'SDAI/FRAX Yield Loop',
managementType: 'active',
},
{
product: [OmniProductType.Borrow],
primaryToken: 'SDAI',
primaryTokenGroup: 'DAI',
secondaryToken: 'FRAX',
depositToken: 'SDAI',
label: 'SDAI/FRAX',
network: NetworkNames.ethereumMainnet,
protocol: LendingProtocol.AaveV3,
},
{
product: [OmniProductType.Earn],
primaryToken: 'SDAI',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const aaveSeed: AaveProductHubItemSeed[] = [
collateral: 'wstETH',
debt: 'ETH',
strategyType: 'long',
types: ['borrow', 'earn'],
types: ['earn'],
},
{
collateral: 'DAI',
Expand Down Expand Up @@ -107,13 +107,13 @@ const aaveSeed: AaveProductHubItemSeed[] = [
collateral: 'USDC',
debt: 'SUSD',
strategyType: 'long',
types: ['borrow', 'multiply', 'earn'],
types: ['earn'],
},
{
collateral: 'USDC.E',
debt: 'SUSD',
strategyType: 'long',
types: ['borrow', 'multiply', 'earn'],
types: ['earn'],
},
]

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@metamask/eth-sig-util": "^5.0.2",
"@oasisdex/addresses": "0.1.75",
"@oasisdex/automation": "1.6.5-morpho.6",
"@oasisdex/dma-library": "0.6.60",
"@oasisdex/dma-library": "0.6.61",
"@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 @@ -2514,10 +2514,10 @@
dependencies:
ethers "^5.6.2"

"@oasisdex/dma-library@0.6.60":
version "0.6.60"
resolved "https://registry.yarnpkg.com/@oasisdex/dma-library/-/dma-library-0.6.60.tgz#db4ab89d2e695eabda30bf8865b5e94af95c44ee"
integrity sha512-xmlBXvV4v3gCGvPzoCHzjDkszkuEWvDrCUZCYiKbDFeJeYNrdAk2v6qlqL33MpQTwbqej2Y3lYUQrCy5Wc1D3A==
"@oasisdex/dma-library@0.6.61":
version "0.6.61"
resolved "https://registry.yarnpkg.com/@oasisdex/dma-library/-/dma-library-0.6.61.tgz#0a38413c253166c66735129934e7db576aec183c"
integrity sha512-k8ewPCNf2QG0u2zUs2GfQ4a/IAJkLQX3XvbGTrabKruvK4cjo2zPZYHZVDagT1FAdp6gqZwd3URiX4SCSu9r3w==
dependencies:
bignumber.js "9.0.1"
ethers "^5.7.2"
Expand Down

0 comments on commit 9a9d188

Please sign in to comment.