mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
refactor
This commit is contained in:
parent
452b0b6b78
commit
8ee1172d21
@ -390,28 +390,31 @@ export class OceanPool extends Pool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns datatoken & Ocean amounts received after spending poolShares
|
* Returns Datatoken & Ocean amounts received after spending poolShares
|
||||||
* @param poolAddress
|
* @param {String} poolAddress
|
||||||
* @param poolShares
|
* @param {String} poolShares
|
||||||
* @return {TokensReceived}
|
* @return {TokensReceived}
|
||||||
*/
|
*/
|
||||||
public async getTokensRemovedforPoolShares(
|
public async getTokensRemovedforPoolShares(
|
||||||
poolAddress: string,
|
poolAddress: string,
|
||||||
poolShares: string
|
poolShares: string
|
||||||
): Promise<TokensReceived> {
|
): Promise<TokensReceived> {
|
||||||
const amounts = { dtAmount: '0', oceanAmount: '0' }
|
|
||||||
try {
|
try {
|
||||||
const totalPoolTokens = await this.getPoolSharesTotalSupply(poolAddress)
|
const totalPoolTokens = await this.getPoolSharesTotalSupply(poolAddress)
|
||||||
amounts.dtAmount = String(
|
const dtReserve = await this.getDTReserve(poolAddress)
|
||||||
(Number(poolShares) / Number(totalPoolTokens)) *
|
const oceanReserve = await this.getOceanReserve(poolAddress)
|
||||||
Number(await this.getDTReserve(poolAddress))
|
|
||||||
)
|
const dtAmount = `${
|
||||||
amounts.oceanAmount = String(
|
(Number(poolShares) / Number(totalPoolTokens)) * Number(dtReserve)
|
||||||
(Number(poolShares) / Number(totalPoolTokens)) *
|
}`
|
||||||
Number(await this.getOceanReserve(poolAddress))
|
const oceanAmount = `${
|
||||||
)
|
(Number(poolShares) / Number(totalPoolTokens)) * Number(oceanReserve)
|
||||||
} catch (e) {}
|
}`
|
||||||
return amounts
|
|
||||||
|
return { dtAmount, oceanAmount }
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`ERROR: Unable to get token info. ${e.message}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user