Skip to content

Commit

Permalink
fix: balancer: integration-test virutal boosted
Browse files Browse the repository at this point in the history
Resolves BACK-845.
  • Loading branch information
Louis-Amas committed Dec 19, 2022
1 parent 81ad689 commit e404965
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 45 deletions.
80 changes: 36 additions & 44 deletions src/dex/balancer-v2/balancer-v2-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,57 +131,49 @@ describe('BalancerV2', function () {
});
});

describe.only('PhantomStable', () => {
describe('PhantomStable', () => {
/*
As advised by @shresth this test has been commented out.
checkPoolPrices expects price to decrease as higher amounts are used. Linear/PhantomStable can sometimes return same or better.
Example (confirmed on EVM):
PhantomStable Pool: DAI>BBADAI
prices: [ 0n, 1002063220340675582n, 2004126440858960874n ] (1002063220340675582, 1002063220518285292)
*/
it('getPoolIdentifiers and getPricesVolume', async function () {
const dexHelper = new DummyDexHelper(Network.MAINNET);
const blocknumber = await dexHelper.provider.getBlockNumber();
const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);

await balancerV2.initializePricing(blocknumber);

const pools = await balancerV2.getPoolIdentifiers(
BBAUSD,
BBADAI,
SwapSide.SELL,
blocknumber,
);
console.log('BBAUSD <> BBADAI Pool Identifiers: ', pools);

expect(pools.length).toBeGreaterThan(0);

const poolPrices = await balancerV2.getPricesVolume(
BBAUSD,
BBADAI,
amounts,
SwapSide.SELL,
blocknumber,
pools,
);
console.log('BBAUSD <> BBADAI Pool Prices: ', poolPrices);

expect(poolPrices).not.toBeNull();
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
});

it('getTopPoolsForToken', async function () {
const dexHelper = new DummyDexHelper(Network.MAINNET);
const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);

const poolLiquidity = await balancerV2.getTopPoolsForToken(
BBAUSD.address,
10,
);
console.log('BBAUSD Top Pools:', poolLiquidity);

checkPoolsLiquidity(poolLiquidity, BBAUSD.address, dexKey);
});
// it('getPoolIdentifiers and getPricesVolume', async function () {
// const dexHelper = new DummyDexHelper(Network.MAINNET);
// const blocknumber = await dexHelper.provider.getBlockNumber();
// const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
// await balancerV2.initializePricing(blocknumber);
// const pools = await balancerV2.getPoolIdentifiers(
// BBAUSD,
// BBADAI,
// SwapSide.SELL,
// blocknumber,
// );
// console.log('BBAUSD <> BBADAI Pool Identifiers: ', pools);
// expect(pools.length).toBeGreaterThan(0);
// const poolPrices = await balancerV2.getPricesVolume(
// BBAUSD,
// BBADAI,
// amounts,
// SwapSide.SELL,
// blocknumber,
// pools,
// );
// console.log('BBAUSD <> BBADAI Pool Prices: ', poolPrices);
// expect(poolPrices).not.toBeNull();
// checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
// });
// it('getTopPoolsForToken', async function () {
// const dexHelper = new DummyDexHelper(Network.MAINNET);
// const balancerV2 = new BalancerV2(Network.MAINNET, dexKey, dexHelper);
// const poolLiquidity = await balancerV2.getTopPoolsForToken(
// BBAUSD.address,
// 10,
// );
// console.log('BBAUSD Top Pools:', poolLiquidity);
// checkPoolsLiquidity(poolLiquidity, BBAUSD.address, dexKey);
// });
});

describe('VirtualBoosted Pools', () => {
Expand Down
7 changes: 6 additions & 1 deletion src/dex/balancer-v2/balancer-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,12 @@ export class BalancerV2
})
: poolsWithTokens;

console.log(allowedPools);
console.log(
allowedPools,
limitPools,
poolsWithTokens,
this.eventPools.virtualBoostedPools,
);
if (!allowedPools.length) return null;

const unitVolume = getBigIntPow(
Expand Down

0 comments on commit e404965

Please sign in to comment.