Skip to content

Commit

Permalink
Merge pull request #322 from balancer-labs/develop
Browse files Browse the repository at this point in the history
Reactivate Gyro Pools
  • Loading branch information
gmbronco committed Nov 21, 2022
2 parents 969e411 + 8d23531 commit 9df290b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@balancer-labs/sor",
"version": "4.0.1-beta.12",
"version": "4.0.1-beta.13",
"license": "GPL-3.0-only",
"main": "dist/index.js",
"module": "dist/index.esm.js",
Expand Down
6 changes: 3 additions & 3 deletions src/pools/index.ts
Expand Up @@ -68,9 +68,9 @@ export function parseNewPool(
pool.poolType === 'ComposableStable'
)
newPool = PhantomStablePool.fromPool(pool);
// else if (pool.poolType === 'Gyro2') newPool = Gyro2Pool.fromPool(pool);
// else if (pool.poolType === 'Gyro3') newPool = Gyro3Pool.fromPool(pool);
// else if (pool.poolType === 'GyroE') newPool = GyroEPool.fromPool(pool);
else if (pool.poolType === 'Gyro2') newPool = Gyro2Pool.fromPool(pool);
else if (pool.poolType === 'Gyro3') newPool = Gyro3Pool.fromPool(pool);
else if (pool.poolType === 'GyroE') newPool = GyroEPool.fromPool(pool);
else {
console.error(
`Unknown pool type or type field missing: ${pool.poolType} ${pool.id}`
Expand Down
96 changes: 48 additions & 48 deletions test/gyro2Pool.spec.ts
Expand Up @@ -149,53 +149,53 @@ describe('Gyro2Pool tests USDC > DAI', () => {
});
});

// context('FullSwap', () => {
// it(`Full Swap - swapExactIn, Token>Token`, async () => {
// const pools: any = cloneDeep(testPools.pools);
// const tokenIn = USDC.address;
// const tokenOut = DAI.address;
// const swapType = SwapTypes.SwapExactIn;
// const swapAmt = parseFixed('13.5', 6);

// const gasPrice = parseFixed('30', 9);
// const maxPools = 4;
// const provider = new JsonRpcProvider(
// `https://mainnet.infura.io/v3/${process.env.INFURA}`
// );

// const sor = new SOR(
// provider,
// sorConfigEth,
// new MockPoolDataService(pools),
// mockTokenPriceService
// );
// const fetchSuccess = await sor.fetchPools();
// expect(fetchSuccess).to.be.true;

// const swapInfo: SwapInfo = await sor.getSwaps(
// tokenIn,
// tokenOut,
// swapType,
// swapAmt,
// { gasPrice, maxPools }
// );

// console.log(`Return amt:`);
// console.log(swapInfo.returnAmount.toString());
// // This value is hard coded as sanity check if things unexpectedly change. Taken from V2 test run (with extra fee logic added).
// // TO DO - expect(swapInfo.returnAmount.toString()).eq('999603');
// expect(swapInfo.swaps.length).eq(1);
// expect(swapInfo.swaps[0].amount.toString()).eq(
// swapAmt.toString()
// );
// expect(swapInfo.swaps[0].poolId).eq(testPools.pools[0].id);
// expect(
// swapInfo.tokenAddresses[swapInfo.swaps[0].assetInIndex]
// ).eq(tokenIn);
// expect(
// swapInfo.tokenAddresses[swapInfo.swaps[0].assetOutIndex]
// ).eq(tokenOut);
// });
// });
context('FullSwap', () => {
it(`Full Swap - swapExactIn, Token>Token`, async () => {
const pools: any = cloneDeep(testPools.pools);
const tokenIn = USDC.address;
const tokenOut = DAI.address;
const swapType = SwapTypes.SwapExactIn;
const swapAmt = parseFixed('13.5', 6);

const gasPrice = parseFixed('30', 9);
const maxPools = 4;
const provider = new JsonRpcProvider(
`https://mainnet.infura.io/v3/${process.env.INFURA}`
);

const sor = new SOR(
provider,
sorConfigEth,
new MockPoolDataService(pools),
mockTokenPriceService
);
const fetchSuccess = await sor.fetchPools();
expect(fetchSuccess).to.be.true;

const swapInfo: SwapInfo = await sor.getSwaps(
tokenIn,
tokenOut,
swapType,
swapAmt,
{ gasPrice, maxPools }
);

console.log(`Return amt:`);
console.log(swapInfo.returnAmount.toString());
// This value is hard coded as sanity check if things unexpectedly change. Taken from V2 test run (with extra fee logic added).
// TO DO - expect(swapInfo.returnAmount.toString()).eq('999603');
expect(swapInfo.swaps.length).eq(1);
expect(swapInfo.swaps[0].amount.toString()).eq(
swapAmt.toString()
);
expect(swapInfo.swaps[0].poolId).eq(testPools.pools[0].id);
expect(
swapInfo.tokenAddresses[swapInfo.swaps[0].assetInIndex]
).eq(tokenIn);
expect(
swapInfo.tokenAddresses[swapInfo.swaps[0].assetOutIndex]
).eq(tokenOut);
});
});
});
});

0 comments on commit 9df290b

Please sign in to comment.