diff --git a/package.json b/package.json index 15b3ce95..230de24e 100644 --- a/package.json +++ b/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", diff --git a/src/pools/index.ts b/src/pools/index.ts index 55e500dd..4b93d6b1 100644 --- a/src/pools/index.ts +++ b/src/pools/index.ts @@ -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}` diff --git a/test/gyro2Pool.spec.ts b/test/gyro2Pool.spec.ts index 104f51a8..8373c8ad 100644 --- a/test/gyro2Pool.spec.ts +++ b/test/gyro2Pool.spec.ts @@ -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); + }); + }); }); });