Created
August 1, 2021 16:42
-
-
Save Ro5s/71addd79f7d74f0b72ec0a35d846994e to your computer and use it in GitHub Desktop.
stake cToken xsushi into bento xsushi shares
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { t } from '@lingui/macro' | |
import { CRXSUSHI, XSUSHI } from '../../../constants' | |
import { ChainId, SUSHI_ADDRESS } from '@sushiswap/sdk' | |
import { tryParseAmount } from '../../../functions' | |
import { useBentoBalance } from '../../bentobox/hooks' | |
import { useActiveWeb3React } from '../../../hooks' | |
import { useTokenBalances } from '../../wallet/hooks' | |
import { StrategyGeneralInfo, StrategyHook, StrategyTokenDefinitions } from '../types' | |
import useBaseInariStrategy from './useBaseInariStrategy' | |
import { useEffect, useMemo } from 'react' | |
export const general: StrategyGeneralInfo = { | |
name: 'Cream → Bento', | |
steps: ['CRXSUSHI', 'xSUSHI', 'BentoBox'], | |
zapMethod: 'compoundToBento', | |
unzapMethod: 'bentoToCompound', | |
description: t`Migrate xSUSHI from Cream into BentoBox in one click. xSUSHI in BentoBox is automatically | |
invested into a passive yield strategy, and can be lent or used as collateral for borrowing in Kashi.`, | |
inputSymbol: 'xSUSHI in Cream', | |
outputSymbol: 'xSUSHI in BentoBox', | |
} | |
export const tokenDefinitions: StrategyTokenDefinitions = { | |
inputToken: { | |
chainId: ChainId.MAINNET, | |
address: '0x228619cca194fbe3ebeb2f835ec1ea5080dafbb2', | |
decimals: 18, | |
symbol: 'crXSUSHI', | |
}, | |
outputToken: { | |
chainId: ChainId.MAINNET, | |
address: '0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272', | |
decimals: 18, | |
symbol: 'XSUSHI', | |
}, | |
} | |
const useCreamToBentoStrategy = (): StrategyHook => { | |
const { account } = useActiveWeb3React() | |
const balances = useTokenBalances(account, [CRXSUSHI, XSUSHI]) | |
const xSushiBentoBalance = useBentoBalance(XSUSHI.address) | |
const { setBalances, ...baseStrategy } = useBaseInariStrategy({ | |
id: 'creamToBentoStrategy', | |
general, | |
tokenDefinitions, | |
usesBentoBox: true, | |
}) | |
useEffect(() => { | |
if (!balances) return | |
setBalances({ | |
inputTokenBalance: balances[CRXSUSHI[ChainId.MAINNET].address], | |
outputTokenBalance: tryParseAmount(xSushiBentoBalance?.value?.toFixed(18) || '0', XSUSHI), | |
}) | |
}, [balances, setBalances, xSushiBentoBalance?.value]) | |
return useMemo( | |
() => ({ | |
setBalances, | |
...baseStrategy, | |
}), | |
[baseStrategy, setBalances] | |
) | |
} | |
export default useCreamToBentoStrategy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment