fix(asset-swapper): Check MAX_IN_RATIO in sampleBuysFromBalancer (#338)

* fix: for swapExactAmountIn

* chore: update change log

* Update packages/asset-swapper/CHANGELOG.json

Co-authored-by: Lawrence Forman <lawrence@0xproject.com>
This commit is contained in:
Phạm Minh Đức 2021-10-06 03:25:02 +07:00 committed by GitHub
parent d9a16ed1f9
commit d46756ae2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -1,4 +1,13 @@
[
{
"version": "16.29.2",
"changes": [
{
"note": "Check MAX_IN_RATIO in sampleBuysFromBalancer",
"pr": 338
}
]
},
{
"version": "16.29.1",
"changes": [

View File

@ -154,6 +154,12 @@ contract BalancerSampler {
)
returns (uint256 amount)
{
// Handles this revert scenario:
// https://github.com/balancer-labs/balancer-core/blob/master/contracts/BPool.sol#L443
if (amount > _bmul(poolState.takerTokenBalance, MAX_IN_RATIO)) {
break;
}
takerTokenAmounts[i] = amount;
// Break early if there are 0 amounts
if (takerTokenAmounts[i] == 0) {