1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-30 22:01:44 +02:00

prepare to use getAmountInExactOut

This commit is contained in:
Matthias Kretschmann 2022-01-24 15:35:34 +00:00
parent eaf29003c3
commit bfdf7e1b24
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 12 additions and 5 deletions

View File

@ -14,7 +14,6 @@ import { useWeb3 } from '@context/Web3'
import { useAsset } from '@context/Asset' import { useAsset } from '@context/Asset'
import content from '../../../../../../content/price.json' import content from '../../../../../../content/price.json'
import { LoggerInstance, Pool } from '@oceanprotocol/lib' import { LoggerInstance, Pool } from '@oceanprotocol/lib'
import { getOceanConfig } from '@utils/ocean'
export interface FormAddLiquidity { export interface FormAddLiquidity {
amount: number amount: number

View File

@ -53,12 +53,12 @@ export default function Remove({
const [minOceanAmount, setMinOceanAmount] = useState<string>('0') const [minOceanAmount, setMinOceanAmount] = useState<string>('0')
Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 }) Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 })
const poolInstance = new Pool(web3, LoggerInstance)
async function handleRemoveLiquidity() { async function handleRemoveLiquidity() {
setIsLoading(true) setIsLoading(true)
try { try {
const poolInstance = new Pool(web3, LoggerInstance)
const result = await poolInstance.exitswapPoolAmountIn( const result = await poolInstance.exitswapPoolAmountIn(
accountId, accountId,
poolAddress, poolAddress,
@ -89,11 +89,19 @@ export default function Remove({
const getValues = useRef( const getValues = useRef(
debounce(async (newAmountPoolShares) => { debounce(async (newAmountPoolShares) => {
// const amountOcean = await ocean.pool.getOceanRemovedforPoolShares( // TODO: check based on pool tokens sent in, what I get out in baseToken.
// Seems to be not possible with getAmountInExactOut().
// const tokenIn = newAmountPoolShares // TODO: this needs to pool shares?
// const swapMarketFee = '' // TODO: which is it? Swap fee or market fee?
// const baseTokenAmount = '' // TODO: this is what I want to know, why do I need to pass as param then?
// const newAmountOcean = await poolInstance.getAmountInExactOut(
// poolAddress, // poolAddress,
// newAmountPoolShares // tokenIn,
// baseTokenAddress,
// baseTokenAmount,
// swapMarketFee
// ) // )
// setAmountOcean(amountOcean) // setAmountOcean(newAmountOcean)
}, 150) }, 150)
) )
// Check and set outputs when amountPoolShares changes // Check and set outputs when amountPoolShares changes