Skip to content

Commit

Permalink
fix max amountPoolshares balancer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcos20 committed Oct 28, 2020
1 parent 2d31bd9 commit 4a077a9
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/balancer/OceanPool.ts
Expand Up @@ -691,13 +691,15 @@ export class OceanPool extends Pool {
this.logger.error('ERROR: Not enough poolShares')
return null
}
if (
parseFloat(maximumPoolShares) <
parseFloat(await this.getPoolSharesRequiredToRemoveDT(poolAddress, amount))
) {
const sharesRequired = await this.getPoolSharesRequiredToRemoveDT(poolAddress, amount)
if (parseFloat(maximumPoolShares) < parseFloat(sharesRequired)) {
this.logger.error('ERROR: Not enough poolShares')
return null
}
// Balancer bug fix
if (parseFloat(maximumPoolShares) < parseFloat(sharesRequired))
maximumPoolShares = String(parseFloat(maximumPoolShares) * 0.9999)
// Balance bug fix
return this.exitswapExternAmountOut(
account,
poolAddress,
Expand Down Expand Up @@ -775,13 +777,18 @@ export class OceanPool extends Pool {
this.logger.error('ERROR: Not enough poolShares')
return null
}
if (
parseFloat(maximumPoolShares) <
parseFloat(await this.getPoolSharesRequiredToRemoveOcean(poolAddress, amount))
) {
const sharesRequired = await this.getPoolSharesRequiredToRemoveOcean(
poolAddress,
amount
)
if (parseFloat(maximumPoolShares) < parseFloat(sharesRequired)) {
this.logger.error('ERROR: Not enough poolShares')
return null
}
// Balancer bug fix
if (parseFloat(maximumPoolShares) < parseFloat(sharesRequired))
maximumPoolShares = String(parseFloat(maximumPoolShares) * 0.9999)
// Balance bug fix
return super.exitswapExternAmountOut(
account,
poolAddress,
Expand Down Expand Up @@ -812,7 +819,10 @@ export class OceanPool extends Pool {
this.logger.error('ERROR: Not enough poolShares')
return null
}

// Balancer bug fix
if (parseFloat(usershares) === parseFloat(poolShares))
poolShares = String(parseFloat(poolShares) * 0.9999)
// Balance bug fix
return this.exitPool(account, poolAddress, poolShares, [minDT, minOcean])
}

Expand Down

0 comments on commit 4a077a9

Please sign in to comment.