├── .env.sample ├── .gitignore ├── .husky ├── pre-commit └── pre-push ├── .prettierrc.json ├── .solhint.json ├── LICENSE ├── README.md ├── docs └── adding-new-adapter.md ├── hardhat.config.js ├── package.json ├── src ├── abis │ ├── ArableSFAdapter.json │ ├── BalancerlikeAdapter.json │ ├── BridgeMigrationAdapter.json │ ├── BridgeToken.json │ ├── BytesManipulation.json │ ├── Curve1Adapter.json │ ├── Curve2Adapter.json │ ├── CurveDeUSDCAdapter.json │ ├── CurveLikeAdapter.json │ ├── CurveMimAdapter.json │ ├── CurveMoreAdapter.json │ ├── CurvePlainAdapter.json │ ├── CurvelikeMetaAdapter.json │ ├── ERC20.json │ ├── ERC20Burnable.json │ ├── GeodeWPAdapter.json │ ├── GmxAdapter.json │ ├── IAdapter.json │ ├── IBasePool.json │ ├── ICurve1.json │ ├── ICurve2.json │ ├── ICurveLikePool.json │ ├── ICurveMim.json │ ├── ICurvePlain.json │ ├── ICurvelikeMeta.json │ ├── IERC20.json │ ├── IGeodePortal.json │ ├── IGeodeWP.json │ ├── IGmxVault.json │ ├── IGmxVaultPriceFeed.json │ ├── IGmxVaultUtils.json │ ├── IKyberPool.json │ ├── IKyberRouter.json │ ├── IMinimalSwapInfoPool.json │ ├── IPlatypus.json │ ├── ISAVAX.json │ ├── IStabilityFund.json │ ├── IUnilikeAVAXRouter.json │ ├── IUnilikeETHRouter.json │ ├── IUnilikeFactory.json │ ├── IUnilikePair.json │ ├── IVault.json │ ├── IWETH.json │ ├── IWooPP.json │ ├── IWooRouter.json │ ├── IgAVAX.json │ ├── ImYAK.json │ ├── IwAVAX.json │ ├── IxJOE.json │ ├── KyberAdapter.json │ ├── MiniYakAdapter.json │ ├── NTInjector.json │ ├── Ownable.json │ ├── PlatypusAdapter.json │ ├── SAvaxAdapter.json │ ├── TestToken.json │ ├── UnilikeAdapter.json │ ├── WAvaxAdapter.json │ ├── WoofiAdapter.json │ ├── XJoeAdapter.json │ ├── YakAdapter.json │ └── YakRouter.json ├── contracts │ ├── YakAdapter.sol │ ├── YakRouter.sol │ ├── YakWrapRouter.sol │ ├── YakWrapRouterAlt.sol │ ├── YakWrapper.sol │ ├── adapters │ │ ├── AaveAdapter.sol │ │ ├── AgniAdapter.sol │ │ ├── AlgebraAdapter.sol │ │ ├── ArableSFAdapter.sol │ │ ├── BalancerV2Adapter.sol │ │ ├── BridgeMigrationAdapter.sol │ │ ├── CamelotAdapter.sol │ │ ├── Curve1Adapter.sol │ │ ├── Curve2Adapter.sol │ │ ├── CurveMetaAdapter.sol │ │ ├── CurveMetaV2Adapter.sol │ │ ├── CurveMetaV3Adapter.sol │ │ ├── CurveMetaWithSwapperAdapter.sol │ │ ├── CurvePlain128Adapter.sol │ │ ├── CurvePlain128NativeAdapter.sol │ │ ├── CurvePlain256Adapter.sol │ │ ├── DodoV1Adapter.sol │ │ ├── DodoV2Adapter.sol │ │ ├── DxSwapAdapter.sol │ │ ├── FusionAdapter.sol │ │ ├── GGAvaxAdapter.sol │ │ ├── GeodeWPAdapter.sol │ │ ├── GmxAdapter.sol │ │ ├── KyberAdapter.sol │ │ ├── KyberElasticAdapter.sol │ │ ├── LB2Adapter.sol │ │ ├── LBAdapter.sol │ │ ├── MiniYakAdapter.sol │ │ ├── PancakeV3Adapter.sol │ │ ├── PlatypusAdapter.sol │ │ ├── PoolsideV1Adapter.sol │ │ ├── RamsesV2Adapter.sol │ │ ├── ReservoirAdapter.sol │ │ ├── SaddleAdapter.sol │ │ ├── SaddleMetaAdapter.sol │ │ ├── TokenMillAdapter.sol │ │ ├── UniswapV2Adapter.sol │ │ ├── UniswapV3Adapter.sol │ │ ├── UniswapV3AdapterBase.sol │ │ ├── UniswapV3likeAdapter.sol │ │ ├── VelodromeAdapter.sol │ │ ├── WAvaxAdapter.sol │ │ ├── WNativeAdapter.sol │ │ ├── WombatAdapter.sol │ │ ├── WoofiAdapter.sol │ │ ├── WoofiV2Adapter.sol │ │ ├── XJoeAdapter.sol │ │ ├── YYDerivativeAdapter.sol │ │ └── aAvaxAdapter.sol │ ├── interface │ │ ├── IAaveAToken.sol │ │ ├── IAavePool.sol │ │ ├── IAdapter.sol │ │ ├── IAsset.sol │ │ ├── IBasePool.sol │ │ ├── IButtonTokenFactory.sol │ │ ├── IButtonWrapper.sol │ │ ├── IButtonswapFactory.sol │ │ ├── IButtonswapPair.sol │ │ ├── ICurve1.sol │ │ ├── ICurve2.sol │ │ ├── ICurveMeta.sol │ │ ├── ICurvePlain128.sol │ │ ├── ICurvePlain128Native.sol │ │ ├── ICurvePlain256.sol │ │ ├── IDodoV1.sol │ │ ├── IDodoV2.sol │ │ ├── IERC20.sol │ │ ├── IGGAvax.sol │ │ ├── IGenericFactory.sol │ │ ├── IGeodePortal.sol │ │ ├── IGeodeWP.sol │ │ ├── IGlpManager.sol │ │ ├── IGmxRewardRouter.sol │ │ ├── IGmxVault.sol │ │ ├── IKyberPool.sol │ │ ├── IKyberRouter.sol │ │ ├── ILB2Pair.sol │ │ ├── ILBFactory.sol │ │ ├── ILBPair.sol │ │ ├── ILBRouter.sol │ │ ├── IMinimalSwapInfoPool.sol │ │ ├── IPlatypus.sol │ │ ├── IPoolSwapStructs.sol │ │ ├── IReservoirPair.sol │ │ ├── IReservoirQuoter.sol │ │ ├── ISAVAX.sol │ │ ├── ISaddle.sol │ │ ├── ISaddleMeta.sol │ │ ├── IStabilityFund.sol │ │ ├── ITMFactory.sol │ │ ├── ITMMarket.sol │ │ ├── IUnilikeAVAXRouter.sol │ │ ├── IUnilikeETHRouter.sol │ │ ├── IUniswapFactory.sol │ │ ├── IUniswapPair.sol │ │ ├── IVault.sol │ │ ├── IWETH.sol │ │ ├── IWombat.sol │ │ ├── IWooPP.sol │ │ ├── IWooPPV2.sol │ │ ├── IWooRouter.sol │ │ ├── IWrapper.sol │ │ ├── IYYDerivative.sol │ │ ├── IYakRouter.sol │ │ ├── IgAVAX.sol │ │ ├── ImYAK.sol │ │ └── IxJOE.sol │ ├── lib │ │ ├── Maintainable.sol │ │ ├── Recoverable.sol │ │ ├── SafeERC20.sol │ │ ├── TypeConversion.sol │ │ └── YakViewUtils.sol │ ├── test │ │ ├── BridgeToken.sol │ │ ├── DummyMaintainable.sol │ │ ├── NTInjector.sol │ │ ├── TestToken.sol │ │ └── TestWrapper.sol │ └── wrappers │ │ ├── GlpWrapper.sol │ │ └── GlpWrapperFeeSelection.sol ├── deploy │ ├── arbitrum │ │ ├── adapters │ │ │ ├── aave │ │ │ │ └── aaveUSDC.js │ │ │ ├── balancer │ │ │ │ └── balancerV2.js │ │ │ ├── curve │ │ │ │ ├── 2pool.js │ │ │ │ ├── 3poolV2.js │ │ │ │ ├── crvusd_frax.js │ │ │ │ ├── crvusd_usdc.js │ │ │ │ ├── crvusd_usdce.js │ │ │ │ ├── crvusd_usdt.js │ │ │ │ ├── frax_bp.js │ │ │ │ ├── meta.js │ │ │ │ └── vst_frax.js │ │ │ ├── dodo │ │ │ │ ├── dodoV1.js │ │ │ │ └── dodoV2.js │ │ │ ├── gmx │ │ │ │ └── gmx.js │ │ │ ├── kyber │ │ │ │ ├── kyber.js │ │ │ │ └── kyberElastic.js │ │ │ ├── liquidity-book │ │ │ │ ├── joe-lb-2-2.js │ │ │ │ ├── joe-lb-2.js │ │ │ │ └── joe-lb.js │ │ │ ├── pancake │ │ │ │ └── pancakeV3.js │ │ │ ├── ramses │ │ │ │ └── ramses.js │ │ │ ├── saddle │ │ │ │ ├── arbusd.js │ │ │ │ ├── arbusdV2.js │ │ │ │ └── meta_arbusdV2.js │ │ │ ├── uniswapV2 │ │ │ │ ├── camelot.js │ │ │ │ ├── oreoswap.js │ │ │ │ ├── sushiswap.js │ │ │ │ ├── swapfish.js │ │ │ │ └── swapr.js │ │ │ ├── uniswapV3 │ │ │ │ ├── arbidex.js │ │ │ │ ├── camelot.js │ │ │ │ └── uniV3.js │ │ │ ├── weth.js │ │ │ ├── wombat │ │ │ │ └── wombat.js │ │ │ └── woofi │ │ │ │ └── woofiV2.js │ │ ├── routers │ │ │ ├── yakWrapRouter.js │ │ │ └── yakrouter.js │ │ └── wrappers │ │ │ └── glpWrapper.js │ ├── avalanche │ │ ├── adapters │ │ │ ├── arable │ │ │ │ └── arable.js │ │ │ ├── axial │ │ │ │ ├── AM3D.js │ │ │ │ └── AS4D.js │ │ │ ├── curve │ │ │ │ ├── 3poolV2.js │ │ │ │ ├── 3poolf.js │ │ │ │ ├── aave.js │ │ │ │ ├── atricrypto.js │ │ │ │ ├── deusdc.js │ │ │ │ ├── mim.js │ │ │ │ ├── more.js │ │ │ │ ├── ren.js │ │ │ │ ├── usdc.js │ │ │ │ └── yusd.js │ │ │ ├── geode │ │ │ │ └── WPyyAvax.js │ │ │ ├── glacier │ │ │ │ └── glacier.js │ │ │ ├── gmx │ │ │ │ └── gmx.js │ │ │ ├── kyber │ │ │ │ ├── kyber.js │ │ │ │ └── kyberElastic.js │ │ │ ├── liquidity-book │ │ │ │ ├── joe-lb-2-2.js │ │ │ │ ├── joe-lb-2.js │ │ │ │ └── joe-lb.js │ │ │ ├── other │ │ │ │ ├── ggavax.js │ │ │ │ ├── miniYak.js │ │ │ │ ├── savax.js │ │ │ │ ├── wavax.js │ │ │ │ └── xjoe.js │ │ │ ├── pharaoh │ │ │ │ └── pharaoh.js │ │ │ ├── platypus │ │ │ │ └── router.js │ │ │ ├── poolside │ │ │ │ └── poolside.js │ │ │ ├── reservoir │ │ │ │ └── reservoir.js │ │ │ ├── solisnek │ │ │ │ └── solisnek.js │ │ │ ├── synapse │ │ │ │ └── synapse.js │ │ │ ├── tokenmill │ │ │ │ └── tokenmill.js │ │ │ ├── uniswapV2 │ │ │ │ ├── arena.js │ │ │ │ ├── hakuswap.js │ │ │ │ ├── pangolin.js │ │ │ │ ├── sushiswap.js │ │ │ │ ├── swapsicle.js │ │ │ │ └── traderjoe.js │ │ │ ├── univ3 │ │ │ │ └── uniV3.js │ │ │ ├── wombat │ │ │ │ └── wombat.js │ │ │ └── woofi │ │ │ │ ├── woofiUSDC.js │ │ │ │ └── woofiV2.js │ │ ├── routers │ │ │ ├── yakWrapRouter.js │ │ │ ├── yakrouter.js │ │ │ └── yakrouterMinimal.js │ │ └── wrappers │ │ │ └── glpWrapper.js │ ├── dogechain │ │ ├── adapters │ │ │ ├── uniV2 │ │ │ │ ├── dogeswap.js │ │ │ │ ├── kibbleswap.js │ │ │ │ └── yodeswap.js │ │ │ └── uniV3 │ │ │ │ └── quickswap.js │ │ └── routers │ │ │ └── yakrouter.js │ ├── mantle │ │ ├── adapters │ │ │ ├── agni │ │ │ │ └── agni.js │ │ │ ├── fusion │ │ │ │ └── fusion.js │ │ │ ├── liquidity-book │ │ │ │ └── joe-lb-2.js │ │ │ ├── uniswapV2 │ │ │ │ └── moe.js │ │ │ └── wmnt.js │ │ └── routers │ │ │ └── yakrouter.js │ ├── optimism │ │ ├── adapters │ │ │ ├── balancer │ │ │ │ └── beethoven.js │ │ │ ├── curve │ │ │ │ ├── meta_susd_3crv.js │ │ │ │ ├── seth.js │ │ │ │ ├── tripool.js │ │ │ │ └── wsteth.js │ │ │ ├── kyber │ │ │ │ └── kyberElastic.js │ │ │ ├── saddle │ │ │ │ ├── frax_usdc_bp.js │ │ │ │ ├── meta_frax_optusd.js │ │ │ │ ├── meta_susd_bp.js │ │ │ │ └── optusd.js │ │ │ ├── uniswapV2 │ │ │ │ └── zipswap.js │ │ │ ├── uniswapV3 │ │ │ │ └── uniV3.js │ │ │ ├── velodrome │ │ │ │ └── velodrome.js │ │ │ └── woofi │ │ │ │ └── woofiV2.js │ │ └── routers │ │ │ └── yakrouter.js │ └── utils.js ├── deployments │ ├── arbitrum │ │ ├── .chainId │ │ ├── AaveUSDCAdapter.json │ │ ├── ArbiDexAdapter.json │ │ ├── BalancerV2Adapter.json │ │ ├── BytesManipulation.json │ │ ├── CamelotAdapter.json │ │ ├── CamelotAlgebraAdapter.json │ │ ├── Curve2crvUsdFrax.json │ │ ├── Curve2crvUsdUsdc.json │ │ ├── Curve2crvUsdUsdce.json │ │ ├── Curve2crvUsdUsdt.json │ │ ├── Curve2stableAdapter.json │ │ ├── Curve3cryptoAdapter.json │ │ ├── CurveFraxBpAdapter.json │ │ ├── CurveFraxVstAdapter.json │ │ ├── CurveMetaAdapter.json │ │ ├── DodoV1Adapter.json │ │ ├── DodoV2Adapter.json │ │ ├── GlpWrapper.json │ │ ├── GlpWrapperV0.json │ │ ├── GmxAdapter.json │ │ ├── KyberAdapter.json │ │ ├── KyberElasticAdapter.json │ │ ├── LiquidityBook2.2Adapter.json │ │ ├── LiquidityBook2Adapter.json │ │ ├── LiquidityBookAdapter.json │ │ ├── OreoswapAdapter.json │ │ ├── PancakeV3Adapter.json │ │ ├── RamsesV2Adapter.json │ │ ├── SaddleArbUsdAdapter.json │ │ ├── SaddleArbUsdV2Adapter.json │ │ ├── SaddleMetaArbUsdV2Adapter.json │ │ ├── SushiswapAdapter.json │ │ ├── SwapfishAdapter.json │ │ ├── SwaprAdapter.json │ │ ├── UniswapV3Adapter.json │ │ ├── UniswapV3AdapterV0.json │ │ ├── WETHAdapter.json │ │ ├── WombatAdapter.json │ │ ├── WoofiV2Adapter.json │ │ ├── WoofiV2AdapterV0.json │ │ ├── YakRouter.json │ │ ├── YakWrapRouter.json │ │ ├── YakWrapRouterV0.json │ │ └── solcInputs │ │ │ ├── 179be234bf310622fd3658efc7f3a159.json │ │ │ ├── 18fc46a3cbc1e360808df0b876e7963d.json │ │ │ ├── 19acba8bd2ff6e1270319735883515f7.json │ │ │ ├── 1b8ff83bdb827179aa107dce2f481e62.json │ │ │ ├── 1ee685f013d8a551ae65f6725ac5d6d7.json │ │ │ ├── 20592def1b20e8454b690a7f48e5aad4.json │ │ │ ├── 2f7c552725bac4cbb59f7eeca6343ccc.json │ │ │ ├── 479404d062d4cea09f9c354f78701eb1.json │ │ │ ├── 50979828fa2949427bff7dfcbe4b8236.json │ │ │ ├── 77548a07f9bd409ad57f4fe6eb82b488.json │ │ │ ├── 83cd75ebce60a5db3c9a86b276dac812.json │ │ │ ├── 88a4ef4f7dda73936d2d93e291d25ed5.json │ │ │ ├── 8d057c001a3740562bb605e9433c4073.json │ │ │ ├── 93f7e9415d67256a5fb2f564c125e7b9.json │ │ │ ├── b19bf4bd7fc2018aea4e0bcaaaafabcb.json │ │ │ ├── b69b18266f35a19e29ab258127d21a51.json │ │ │ ├── bfe031e3986ad8467035f544a4e43fc0.json │ │ │ ├── c63216e5dea0ee3451108c607815cc9b.json │ │ │ ├── cd434ce84402276851749722b60b1dfc.json │ │ │ └── ceff6081ab1a62c70e6dbe2d6ebb7019.json │ ├── avalanche │ │ ├── .chainId │ │ ├── ArableAdapter.json │ │ ├── ArenaAdapter.json │ │ ├── AxialAA3DYakAdapterV0.json │ │ ├── AxialAC4DYakAdapterV0.json │ │ ├── AxialAM3DUSDCYakAdapterV0.json │ │ ├── AxialAM3DYakAdapterV0.json │ │ ├── AxialAS4DAdapter.json │ │ ├── BaguetteYakAdapterV0.json │ │ ├── BridgeMigrationAdapterV0.json │ │ ├── ButtonWrappersAdapter.json │ │ ├── BytesManipulationV0.json │ │ ├── CanaryYakAdapterV0.json │ │ ├── ComplusAdapterV0.json │ │ ├── Curve3poolV2Adapter.json │ │ ├── Curve3poolfAdapter.json │ │ ├── CurveAaveAdapter.json │ │ ├── CurveAtricryptoAdapter.json │ │ ├── CurveAtricryptoAdapterV0.json │ │ ├── CurveDeUSDCAdapter.json │ │ ├── CurveMimAdapterV0.json │ │ ├── CurveMoreAdapter.json │ │ ├── CurveRenAdapter.json │ │ ├── CurveUSDCAdapter.json │ │ ├── CurveYUSDAdapter.json │ │ ├── ElkAdapter.json │ │ ├── EmbrAdapterV0.json │ │ ├── GGAvaxAdapter.json │ │ ├── GGAvaxAdapterV0.json │ │ ├── GeodeWPAdapter.json │ │ ├── GlacierAdapter.json │ │ ├── GlacierAdapterV0.json │ │ ├── GlpWrapper.json │ │ ├── GlpWrapperV0.json │ │ ├── GmxAdapter.json │ │ ├── GondolaBTCYakAdapterV0.json │ │ ├── GondolaDAIDAIeYakAdapterV0.json │ │ ├── GondolaDAIYakAdapterV0.json │ │ ├── GondolaETHYakAdapterV0.json │ │ ├── GondolaUSD4AdapterV0.json │ │ ├── GondolaUSDAdapterV0.json │ │ ├── GondolaUSDTUSDTeYakAdapterV0.json │ │ ├── GondolaUSDTYakAdapterV0.json │ │ ├── GondolaUSDTeDAIeYakAdapterV0.json │ │ ├── GondolaUSDTeMIMAdapterV0.json │ │ ├── GondolaUSDTeTSDAdapterV0.json │ │ ├── GondolaUSDTeUSDCeAdapterV0.json │ │ ├── GondolaWBTCWBTCeYakAdapterV0.json │ │ ├── GondolaWBTCrenBTCYakAdapterV0.json │ │ ├── GondolaWETHWETHeYakAdapterV0.json │ │ ├── GondolaYAKmYAKAdapterV0.json │ │ ├── GondolaYAKmYAKv2AdapterV0.json │ │ ├── HakuSwapAdapterV0.json │ │ ├── KyberAdapter.json │ │ ├── KyberElasticAdapter.json │ │ ├── LiquidityBook2.2Adapter.json │ │ ├── LiquidityBook2.2AdapterV0.json │ │ ├── LiquidityBook2Adapter.json │ │ ├── LiquidityBook2AdapterV0.json │ │ ├── LiquidityBookAdapter.json │ │ ├── LydiaYakAdapterV0.json │ │ ├── MiniYakAdapter.json │ │ ├── MinimalYakRouter.json │ │ ├── OliveYakAdapterV0.json │ │ ├── PandaYakAdapterV0.json │ │ ├── PangolinAdapter.json │ │ ├── PartyswapAdapterV0.json │ │ ├── PlatypusAdapter.json │ │ ├── PlatypusV1YakAdapterV0.json │ │ ├── PoolsideV1Adapter.json │ │ ├── PoolsideV1AdapterV0.json │ │ ├── RamsesV2Adapter.json │ │ ├── ReservoirAdapter.json │ │ ├── SAvaxAdapter.json │ │ ├── SnobF3YakAdapterV0.json │ │ ├── SnobS3YakAdapterV0.json │ │ ├── SnobS4YakAdapterV0.json │ │ ├── SolisnekAdapter.json │ │ ├── SushiswapAdapter.json │ │ ├── SwapsicleAdapter.json │ │ ├── SynapseAdapter.json │ │ ├── TokenMillAdapter.json │ │ ├── TokenMillAdapterV0.json │ │ ├── TraderJoeAdapter.json │ │ ├── UniswapV3Adapter.json │ │ ├── WAvaxAdapter.json │ │ ├── WombatAdapter.json │ │ ├── WoofiAdapter.json │ │ ├── WoofiUSDCAdapter.json │ │ ├── WoofiV2Adapter.json │ │ ├── WoofiV2AdapterV0.json │ │ ├── XJoeAdapter.json │ │ ├── YakRouter.json │ │ ├── YakWrapRouter.json │ │ ├── YakWrapRouterV0.json │ │ ├── YetiYakAdapterV0.json │ │ ├── ZeroYakAdapterV0.json │ │ └── solcInputs │ │ │ ├── 00ca45a748242f5ad1058ab1d0ff28f5.json │ │ │ ├── 0b47e405fca1129ed419269a23eb0ffa.json │ │ │ ├── 0b68f4e8285ff65cab2afd3a901f8983.json │ │ │ ├── 0d6534e3241f265a915ddce2bcb5ff63.json │ │ │ ├── 152b103428ef5ce260df82f89dad8e2f.json │ │ │ ├── 17dee0a0bba06b361a93f3292068c80c.json │ │ │ ├── 18fc46a3cbc1e360808df0b876e7963d.json │ │ │ ├── 19acba8bd2ff6e1270319735883515f7.json │ │ │ ├── 1ba0bc61e437703fd2d610521cf05c22.json │ │ │ ├── 27f92b3dec4a725451e5e05078b487d5.json │ │ │ ├── 289b9af284d5a9e1c26720f9696bc0c1.json │ │ │ ├── 28ee8270ec1222a9ff9ac2bd04df5129.json │ │ │ ├── 2a75ec5bdd567c29e1774b0543c80c73.json │ │ │ ├── 2d6fbe667828e32e2b8eebc81573a17d.json │ │ │ ├── 2f7c552725bac4cbb59f7eeca6343ccc.json │ │ │ ├── 30fea43f8b47c0563b28a8124c9d7d35.json │ │ │ ├── 34737a4cc41178acbac03cc354befc80.json │ │ │ ├── 393769a929e817c0cb8fedbf2b9d814d.json │ │ │ ├── 3dc2efddab103bdb85bf419c26927af7.json │ │ │ ├── 4320d71078ad01ad4c61c76d0ef751e0.json │ │ │ ├── 479404d062d4cea09f9c354f78701eb1.json │ │ │ ├── 4810e2d6d632f5481a5015bd2ec44d59.json │ │ │ ├── 4c7c55a5b08d081d77b4006408c4f415.json │ │ │ ├── 50979828fa2949427bff7dfcbe4b8236.json │ │ │ ├── 5593fdd594f884f36a9b1ab0ad7c6cd8.json │ │ │ ├── 5696fdf550e4f05675240a9ad44895ab.json │ │ │ ├── 5f40cbd9dd7a169ca14386ff66d296a1.json │ │ │ ├── 5f5705918c1ff2a96ff3ebbc1267b9c0.json │ │ │ ├── 6037291b53f6dd2e8d3b89f93ec8a64e.json │ │ │ ├── 6644ea8cf03a3dbf35c12288ca07aec1.json │ │ │ ├── 68ff6732b09e918771e28011c69c4646.json │ │ │ ├── 69bd644335bf26a0ab02e013f17e2ed9.json │ │ │ ├── 6b088325b46bd7d8175e56de056bf1d2.json │ │ │ ├── 6cd92a97b65c100635f69fedb56ebe60.json │ │ │ ├── 73fbd5fe5b3d378f092ae833cb94e383.json │ │ │ ├── 7939e2ceedc965deb8cefbb9ec07de6e.json │ │ │ ├── 7d4546ec59777a3e8de25d8efa400313.json │ │ │ ├── 7ddb4a8ff84a0dcc682900238940e5d9.json │ │ │ ├── 7f9a380052ec74a5424d22707537f79b.json │ │ │ ├── 81b0360d1070652a28530b6a003fbb69.json │ │ │ ├── 83cd75ebce60a5db3c9a86b276dac812.json │ │ │ ├── 874d12ece4c919f2c3b425938ea86a63.json │ │ │ ├── 88a4ef4f7dda73936d2d93e291d25ed5.json │ │ │ ├── 890a153173b4ebb67e6d2a462c5b84ba.json │ │ │ ├── 8a2260f81bfe9316b510f45c690edd09.json │ │ │ ├── 8bda1702997d2004f64cb3b02b8bb9e3.json │ │ │ ├── 936bd86ddc8c33cc43b305ce923770eb.json │ │ │ ├── 93f7e9415d67256a5fb2f564c125e7b9.json │ │ │ ├── 964383080f437204e9c99d0a484b361f.json │ │ │ ├── 97b87fefd3587760bc7af142641bdbd2.json │ │ │ ├── 9a0637aa3a3674edda3c40170a1c77b2.json │ │ │ ├── 9c25b4fdca0d40861c37c9df688f2e12.json │ │ │ ├── 9f52d25c82367dd41f449ba601551351.json │ │ │ ├── a40197e5cf865886a10ec8feeaa31282.json │ │ │ ├── ababd0e21084e2caf542b40cdd03662c.json │ │ │ ├── b1ccd4c0434ccddb8299b5ded89d3bc2.json │ │ │ ├── b50260058db9dd0b790ebd064bec4c3e.json │ │ │ ├── b91bf53bcb2a09f248c1e2834b19f008.json │ │ │ ├── b92cd98d5638cc16286ef66ff5cad523.json │ │ │ ├── bdfdf0648699885899f40363d273a34d.json │ │ │ ├── c4ca94036f9d92fa1982e390596fcb82.json │ │ │ ├── c63216e5dea0ee3451108c607815cc9b.json │ │ │ ├── ce85a137a332be87acdbb0a53d27fd99.json │ │ │ ├── ceb61e2973e2701b2ebc64dfae8dc00d.json │ │ │ ├── cf248847d104fb275bb8f3639a58af9c.json │ │ │ ├── cff30f6d6ae2d47f54dad85f10194d49.json │ │ │ ├── d1ce6bd19602bcdb493b1a573714937c.json │ │ │ ├── d9b0559cdc6c4f6c37a22c036da43e60.json │ │ │ ├── dac3c3c09e48de6e8ce772ccee460d6c.json │ │ │ ├── db3373507e0573cc59f02bec16c3365e.json │ │ │ ├── df149fb05e48c7177d3a20b0f9f9aa62.json │ │ │ ├── dff493cabd1c4144dca64c2e89f9efe0.json │ │ │ ├── f038503f457f15fab9860bdb170e5de2.json │ │ │ ├── f41d12f319e58cbfbb9182ea9d302dbe.json │ │ │ ├── f8f4bc36d1b09ec52fe8f52ac635a28a.json │ │ │ ├── f9a6f4032d4e5cd242dec4b79665d7db.json │ │ │ └── ff94ebf0a91a1596d693132be134d989.json │ ├── dogechain │ │ ├── .chainId │ │ ├── BytesManipulation.json │ │ ├── DogeSwapAdapter.json │ │ ├── KibbleSwapAdapter.json │ │ ├── QuickswapAdapter.json │ │ ├── YakRouter.json │ │ ├── YodeSwapAdapter.json │ │ └── solcInputs │ │ │ ├── 6c06f0c07a7cf608ae739729f208d1a9.json │ │ │ ├── 874d12ece4c919f2c3b425938ea86a63.json │ │ │ ├── cd1e82c4a890d6a69c5cfa18b70ef2ac.json │ │ │ └── f3797818a37fb82d775750768bfe50df.json │ ├── hardhat │ │ ├── .chainId │ │ ├── GmxAdapter.json │ │ └── solcInputs │ │ │ └── ebfbe93a5d5618748c23a7bc84a6d737.json │ ├── mantle │ │ ├── .chainId │ │ ├── AgniAdapter.json │ │ ├── FusionAdapter.json │ │ ├── LiquidityBook2Adapter.json │ │ ├── MerchantMoeAdapter.json │ │ ├── WMNTAdapter.json │ │ ├── YakRouter.json │ │ └── solcInputs │ │ │ ├── 181e18ee6b5c9089007809ce1741fb68.json │ │ │ ├── 18fc46a3cbc1e360808df0b876e7963d.json │ │ │ ├── 2b4071fab82733441d75c39014ed58a6.json │ │ │ ├── 7499595553dc363289f52a00301fa953.json │ │ │ ├── b72b6a63dadac4d8e139a52a2375c465.json │ │ │ └── f21dc4d747695093567e46554bf4716f.json │ └── optimism │ │ ├── .chainId │ │ ├── BeethovenxAdapter.json │ │ ├── BytesManipulation.json │ │ ├── Curve3stableAdapter.json │ │ ├── CurveMetaSUSDCRVAdapter.json │ │ ├── CurveSethAdapter.json │ │ ├── CurveWstethAdapter.json │ │ ├── KyberElasticAdapter.json │ │ ├── SaddleFraxBPAdapter.json │ │ ├── SaddleMetaFraxAdapter.json │ │ ├── SaddleMetaSUSDAdapter.json │ │ ├── SaddleOptUsdAdapter.json │ │ ├── UniswapV3Adapter.json │ │ ├── VelodromeAdapter.json │ │ ├── WoofiV2Adapter.json │ │ ├── YakRouter.json │ │ ├── ZipswapAdapter.json │ │ └── solcInputs │ │ ├── 1b8ff83bdb827179aa107dce2f481e62.json │ │ ├── 702685e0c52e0e947ac67b4595682298.json │ │ ├── a6317898440e20256d8d757474b2faa0.json │ │ └── bb2e2939db1cde18a37f845655f44c85.json ├── examples │ └── debridge │ │ └── main.js ├── misc │ ├── addresses.json │ ├── constants.json │ └── deployOptions.js ├── tasks │ ├── find-best-path-wrapped.js │ ├── find-best-path.js │ ├── list-adapters.js │ ├── update-adapters.js │ ├── update-hop-tokens.js │ └── verify-contract.js └── test │ ├── helpers.js │ ├── spec │ ├── arbitrum │ │ └── adapters │ │ │ ├── arbidex.spec.js │ │ │ ├── atoken.spec.js │ │ │ ├── balancerV2.spec.js │ │ │ ├── camelot-algebra.spec.js │ │ │ ├── camelot.spec.js │ │ │ ├── curve.spec.js │ │ │ ├── dodov1.spec.js │ │ │ ├── dodov2.spec.js │ │ │ ├── gmx.spec.js │ │ │ ├── pancakeV3.spec.js │ │ │ ├── ramses.spec.js │ │ │ ├── saddle.spec.js │ │ │ ├── swapr.spec.js │ │ │ ├── uniV3.spec.js │ │ │ ├── wombat.spec.js │ │ │ └── woofiV2.spec.js │ ├── avalanche │ │ ├── adapters │ │ │ ├── arable.spec.js │ │ │ ├── arena.spec.js │ │ │ ├── axial.spec.js │ │ │ ├── curve.spec.js │ │ │ ├── geode.spec.js │ │ │ ├── ggavax.spec.js │ │ │ ├── gmx.spec.js │ │ │ ├── kyber-elastic.spec.js │ │ │ ├── liquidity-book-2.spec.js │ │ │ ├── liquidity-book.spec.js │ │ │ ├── pharaoh.spec.js │ │ │ ├── platypus.spec.js │ │ │ ├── poolside.spec.js │ │ │ ├── reservoir.spec.js │ │ │ ├── savax.spec.js │ │ │ ├── solisnek.spec.js │ │ │ ├── swapsicle.spec.js │ │ │ ├── synapse.spec.js │ │ │ ├── traderjoe.spec.js │ │ │ ├── uniV3.spec.js │ │ │ ├── wombat.spec.js │ │ │ ├── woofi.spec.js │ │ │ ├── woofiV2.spec.js │ │ │ └── yyJoe.spec.js │ │ ├── erc20Utils.spec.js │ │ ├── maintainable.spec.js │ │ └── wrappers │ │ │ ├── glpWrapRouter.spec.js │ │ │ └── glpWrapper.spec.js │ ├── dogechain │ │ └── adapters │ │ │ └── quickswap.spec.js │ ├── mantle │ │ └── adapters │ │ │ ├── agni.spec.js │ │ │ ├── fusion.spec.js │ │ │ ├── liquidity-book-2.spec.js │ │ │ └── moe.spec.js │ └── optimism │ │ └── adapters │ │ ├── curve.spec.js │ │ ├── uniV3.spec.js │ │ └── velodrome.spec.js │ └── utils │ ├── adapter-test-env.js │ └── test-env.js └── yarn.lock /.env.sample: -------------------------------------------------------------------------------- 1 | AVALANCHE_PK_DEPLOYER="1111111111111111111111111111111111111111111111111111111111111111" 2 | AVALANCHE_RPC="https://api.avax.network/ext/bc/C/rpc" 3 | FUJI_RPC="https://api.avax-test.network/ext/bc/C/rpc" 4 | 5 | ARBITRUM_PK_DEPLOYER="1111111111111111111111111111111111111111111111111111111111111111" 6 | ARBITRUM_RPC="https://arb1.arbitrum.io/rpc" 7 | 8 | OPTIMISM_PK_DEPLOYER="1111111111111111111111111111111111111111111111111111111111111111" 9 | OPTIMISM_RPC="https://mainnet.optimism.io" 10 | 11 | AURORA_PK_DEPLOYER="1111111111111111111111111111111111111111111111111111111111111111" 12 | AURORA_RPC="https://mainnet.aurora.dev" 13 | 14 | DOGECHAIN_PK_DEPLOYER="1111111111111111111111111111111111111111111111111111111111111111" 15 | DOGECHAIN_RPC="https://rpc01-sg.dogechain.dog" 16 | 17 | ETHERSCAN_API_KEY="UEPS5EZJFNJM3N8GEMAJKZMTSYAAY8X1FP" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | deployments/localhost 2 | package-lock.json 3 | node_modules 4 | playground 5 | artifacts 6 | .DS_Store 7 | .scripts 8 | .vscode 9 | cache 10 | .env 11 | out 12 | .vscode -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | # yarn prettier:solidity:write 5 | -------------------------------------------------------------------------------- /.husky/pre-push: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx hardhat remove-logs 5 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "overrides": [ 4 | { 5 | "files": "*.sol", 6 | "options": { 7 | "singleQuote": false, 8 | "tabWidth": 4, 9 | "bracketSpacing": true, 10 | "explicitTypes": "always" 11 | } 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /.solhint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "solhint:recommended", 3 | "plugins": ["prettier"], 4 | "rules": { 5 | "func-visibility": ["warn", { "ignoreConstructors": true }], 6 | "reason-string": ["error", { "maxLength": 64 }], 7 | "compiler-version": ["error", "^0.8.0"], 8 | "max-line-length": ["error", 120], 9 | "prettier/prettier": "error", 10 | "no-inline-assembly": "off", 11 | "not-rely-on-time": "off", 12 | "no-empty-blocks": "off" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "avax-aggregator", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test:avalanche": "npx hardhat test ./src/test/spec/avalanche/**/*.spec.js", 8 | "test:arbitrum": "npx hardhat test ./src/test/spec/arbitrum/**/*.spec.js", 9 | "test:optimism": "npx hardhat test ./src/test/spec/optimism/**/*.spec.js", 10 | "test:dogechain": "npx hardhat test ./src/test/spec/dogechain/**/*.spec.js", 11 | "deploy:avalanche": "npx hardhat deploy --network avalanche --tags avalanche", 12 | "deploy:arbitrum": "npx hardhat deploy --network arbitrum --tags arbitrum", 13 | "deploy:optimism": "npx hardhat deploy --network optimism --tags optimism", 14 | "deploy:aurora": "npx hardhat deploy --network aurora --tags aurora", 15 | "deploy:dogechain": "npx hardhat deploy --network dogechain --tags dogechain", 16 | "solhint": "./node_modules/.bin/solhint -f table ./src/contracts/**/*.sol", 17 | "prettier:solidity:write": "./node_modules/.bin/prettier -w ./src/contracts", 18 | "prettier:solidity": "./node_modules/.bin/prettier -c ./src/contracts", 19 | "prepare": "husky install" 20 | }, 21 | "author": "", 22 | "license": "ISC", 23 | "devDependencies": { 24 | "@nomiclabs/hardhat-ethers": "^2.0.2", 25 | "@nomiclabs/hardhat-waffle": "^2.0.1", 26 | "@openzeppelin/contracts": "^4.7.3", 27 | "chai": "^4.3.4", 28 | "ethereum-waffle": "^3.3.0", 29 | "ethereumjs-util": "^7.0.10", 30 | "ethers": "^5.1.3", 31 | "hardhat": "^2.12.7", 32 | "hardhat-abi-exporter": "^2.2.1", 33 | "hardhat-contract-sizer": "^2.0.3", 34 | "hardhat-deploy": "^0.7.10", 35 | "hardhat-deploy-ethers": "0.3.0-beta.13", 36 | "hardhat-gas-reporter": "^1.0.4", 37 | "hardhat-log-remover": "^2.0.2", 38 | "husky": "^8.0.1" 39 | }, 40 | "dependencies": { 41 | "@nomiclabs/hardhat-etherscan": "^2.1.8", 42 | "dotenv": "^8.2.0", 43 | "hardhat-tracer": "^1.0.0-alpha.5", 44 | "minimist": "^1.2.6", 45 | "prettier": "^2.7.1", 46 | "prettier-plugin-solidity": "^1.0.0-beta.24", 47 | "prompt-sync": "^4.2.0", 48 | "solc": "^0.6.12", 49 | "solhint": "^3.3.7", 50 | "solhint-plugin-prettier": "^0.0.5", 51 | "typescript": "^4.2.4" 52 | }, 53 | "mocha": { 54 | "timeout": 100000 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/abis/BytesManipulation.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "bytes", 6 | "name": "a", 7 | "type": "bytes" 8 | }, 9 | { 10 | "internalType": "bytes", 11 | "name": "b", 12 | "type": "bytes" 13 | } 14 | ], 15 | "name": "mergeBytes", 16 | "outputs": [ 17 | { 18 | "internalType": "bytes", 19 | "name": "c", 20 | "type": "bytes" 21 | } 22 | ], 23 | "stateMutability": "pure", 24 | "type": "function" 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /src/abis/IAdapter.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "name", 5 | "outputs": [ 6 | { 7 | "internalType": "string", 8 | "name": "", 9 | "type": "string" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "internalType": "uint256", 19 | "name": "", 20 | "type": "uint256" 21 | }, 22 | { 23 | "internalType": "address", 24 | "name": "", 25 | "type": "address" 26 | }, 27 | { 28 | "internalType": "address", 29 | "name": "", 30 | "type": "address" 31 | } 32 | ], 33 | "name": "query", 34 | "outputs": [ 35 | { 36 | "internalType": "uint256", 37 | "name": "", 38 | "type": "uint256" 39 | } 40 | ], 41 | "stateMutability": "view", 42 | "type": "function" 43 | }, 44 | { 45 | "inputs": [ 46 | { 47 | "internalType": "uint256", 48 | "name": "", 49 | "type": "uint256" 50 | }, 51 | { 52 | "internalType": "uint256", 53 | "name": "", 54 | "type": "uint256" 55 | }, 56 | { 57 | "internalType": "address", 58 | "name": "", 59 | "type": "address" 60 | }, 61 | { 62 | "internalType": "address", 63 | "name": "", 64 | "type": "address" 65 | }, 66 | { 67 | "internalType": "address", 68 | "name": "", 69 | "type": "address" 70 | } 71 | ], 72 | "name": "swap", 73 | "outputs": [], 74 | "stateMutability": "nonpayable", 75 | "type": "function" 76 | }, 77 | { 78 | "inputs": [], 79 | "name": "swapGasEstimate", 80 | "outputs": [ 81 | { 82 | "internalType": "uint256", 83 | "name": "", 84 | "type": "uint256" 85 | } 86 | ], 87 | "stateMutability": "view", 88 | "type": "function" 89 | } 90 | ] 91 | -------------------------------------------------------------------------------- /src/abis/IBasePool.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "getPoolId", 5 | "outputs": [ 6 | { 7 | "internalType": "bytes32", 8 | "name": "", 9 | "type": "bytes32" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /src/abis/ICurve1.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "tokenIndexFrom", 7 | "type": "uint256" 8 | }, 9 | { 10 | "internalType": "uint256", 11 | "name": "tokenIndexTo", 12 | "type": "uint256" 13 | }, 14 | { 15 | "internalType": "uint256", 16 | "name": "dx", 17 | "type": "uint256" 18 | }, 19 | { 20 | "internalType": "uint256", 21 | "name": "minDy", 22 | "type": "uint256" 23 | } 24 | ], 25 | "name": "exchange_underlying", 26 | "outputs": [], 27 | "stateMutability": "nonpayable", 28 | "type": "function" 29 | }, 30 | { 31 | "inputs": [ 32 | { 33 | "internalType": "uint256", 34 | "name": "tokenIndexFrom", 35 | "type": "uint256" 36 | }, 37 | { 38 | "internalType": "uint256", 39 | "name": "tokenIndexTo", 40 | "type": "uint256" 41 | }, 42 | { 43 | "internalType": "uint256", 44 | "name": "dx", 45 | "type": "uint256" 46 | } 47 | ], 48 | "name": "get_dy_underlying", 49 | "outputs": [ 50 | { 51 | "internalType": "uint256", 52 | "name": "", 53 | "type": "uint256" 54 | } 55 | ], 56 | "stateMutability": "view", 57 | "type": "function" 58 | }, 59 | { 60 | "inputs": [ 61 | { 62 | "internalType": "uint256", 63 | "name": "index", 64 | "type": "uint256" 65 | } 66 | ], 67 | "name": "underlying_coins", 68 | "outputs": [ 69 | { 70 | "internalType": "address", 71 | "name": "", 72 | "type": "address" 73 | } 74 | ], 75 | "stateMutability": "view", 76 | "type": "function" 77 | } 78 | ] 79 | -------------------------------------------------------------------------------- /src/abis/ICurve2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "int128", 6 | "name": "tokenIndexFrom", 7 | "type": "int128" 8 | }, 9 | { 10 | "internalType": "int128", 11 | "name": "tokenIndexTo", 12 | "type": "int128" 13 | }, 14 | { 15 | "internalType": "uint256", 16 | "name": "dx", 17 | "type": "uint256" 18 | }, 19 | { 20 | "internalType": "uint256", 21 | "name": "minDy", 22 | "type": "uint256" 23 | } 24 | ], 25 | "name": "exchange_underlying", 26 | "outputs": [], 27 | "stateMutability": "nonpayable", 28 | "type": "function" 29 | }, 30 | { 31 | "inputs": [ 32 | { 33 | "internalType": "int128", 34 | "name": "tokenIndexFrom", 35 | "type": "int128" 36 | }, 37 | { 38 | "internalType": "int128", 39 | "name": "tokenIndexTo", 40 | "type": "int128" 41 | }, 42 | { 43 | "internalType": "uint256", 44 | "name": "dx", 45 | "type": "uint256" 46 | } 47 | ], 48 | "name": "get_dy_underlying", 49 | "outputs": [ 50 | { 51 | "internalType": "uint256", 52 | "name": "", 53 | "type": "uint256" 54 | } 55 | ], 56 | "stateMutability": "view", 57 | "type": "function" 58 | }, 59 | { 60 | "inputs": [ 61 | { 62 | "internalType": "uint256", 63 | "name": "index", 64 | "type": "uint256" 65 | } 66 | ], 67 | "name": "underlying_coins", 68 | "outputs": [ 69 | { 70 | "internalType": "address", 71 | "name": "", 72 | "type": "address" 73 | } 74 | ], 75 | "stateMutability": "view", 76 | "type": "function" 77 | } 78 | ] 79 | -------------------------------------------------------------------------------- /src/abis/ICurveMim.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "index", 7 | "type": "uint256" 8 | } 9 | ], 10 | "name": "coins", 11 | "outputs": [ 12 | { 13 | "internalType": "address", 14 | "name": "", 15 | "type": "address" 16 | } 17 | ], 18 | "stateMutability": "view", 19 | "type": "function" 20 | }, 21 | { 22 | "inputs": [ 23 | { 24 | "internalType": "address", 25 | "name": "pool", 26 | "type": "address" 27 | }, 28 | { 29 | "internalType": "int128", 30 | "name": "tokenIndexFrom", 31 | "type": "int128" 32 | }, 33 | { 34 | "internalType": "int128", 35 | "name": "tokenIndexTo", 36 | "type": "int128" 37 | }, 38 | { 39 | "internalType": "uint256", 40 | "name": "dx", 41 | "type": "uint256" 42 | }, 43 | { 44 | "internalType": "uint256", 45 | "name": "minDy", 46 | "type": "uint256" 47 | } 48 | ], 49 | "name": "exchange_underlying", 50 | "outputs": [], 51 | "stateMutability": "nonpayable", 52 | "type": "function" 53 | }, 54 | { 55 | "inputs": [ 56 | { 57 | "internalType": "int128", 58 | "name": "tokenIndexFrom", 59 | "type": "int128" 60 | }, 61 | { 62 | "internalType": "int128", 63 | "name": "tokenIndexTo", 64 | "type": "int128" 65 | }, 66 | { 67 | "internalType": "uint256", 68 | "name": "dx", 69 | "type": "uint256" 70 | } 71 | ], 72 | "name": "get_dy_underlying", 73 | "outputs": [ 74 | { 75 | "internalType": "uint256", 76 | "name": "", 77 | "type": "uint256" 78 | } 79 | ], 80 | "stateMutability": "view", 81 | "type": "function" 82 | }, 83 | { 84 | "inputs": [ 85 | { 86 | "internalType": "uint256", 87 | "name": "index", 88 | "type": "uint256" 89 | } 90 | ], 91 | "name": "underlying_coins", 92 | "outputs": [ 93 | { 94 | "internalType": "address", 95 | "name": "", 96 | "type": "address" 97 | } 98 | ], 99 | "stateMutability": "view", 100 | "type": "function" 101 | } 102 | ] 103 | -------------------------------------------------------------------------------- /src/abis/ICurvePlain.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "index", 7 | "type": "uint256" 8 | } 9 | ], 10 | "name": "coins", 11 | "outputs": [ 12 | { 13 | "internalType": "address", 14 | "name": "", 15 | "type": "address" 16 | } 17 | ], 18 | "stateMutability": "view", 19 | "type": "function" 20 | }, 21 | { 22 | "inputs": [ 23 | { 24 | "internalType": "int128", 25 | "name": "tokenIndexFrom", 26 | "type": "int128" 27 | }, 28 | { 29 | "internalType": "int128", 30 | "name": "tokenIndexTo", 31 | "type": "int128" 32 | }, 33 | { 34 | "internalType": "uint256", 35 | "name": "dx", 36 | "type": "uint256" 37 | }, 38 | { 39 | "internalType": "uint256", 40 | "name": "minDy", 41 | "type": "uint256" 42 | } 43 | ], 44 | "name": "exchange", 45 | "outputs": [ 46 | { 47 | "internalType": "uint256", 48 | "name": "", 49 | "type": "uint256" 50 | } 51 | ], 52 | "stateMutability": "nonpayable", 53 | "type": "function" 54 | }, 55 | { 56 | "inputs": [ 57 | { 58 | "internalType": "int128", 59 | "name": "tokenIndexFrom", 60 | "type": "int128" 61 | }, 62 | { 63 | "internalType": "int128", 64 | "name": "tokenIndexTo", 65 | "type": "int128" 66 | }, 67 | { 68 | "internalType": "uint256", 69 | "name": "dx", 70 | "type": "uint256" 71 | } 72 | ], 73 | "name": "get_dy", 74 | "outputs": [ 75 | { 76 | "internalType": "uint256", 77 | "name": "", 78 | "type": "uint256" 79 | } 80 | ], 81 | "stateMutability": "view", 82 | "type": "function" 83 | } 84 | ] 85 | -------------------------------------------------------------------------------- /src/abis/IGmxVaultPriceFeed.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "bool", 11 | "name": "", 12 | "type": "bool" 13 | }, 14 | { 15 | "internalType": "bool", 16 | "name": "", 17 | "type": "bool" 18 | }, 19 | { 20 | "internalType": "bool", 21 | "name": "", 22 | "type": "bool" 23 | } 24 | ], 25 | "name": "getPrice", 26 | "outputs": [ 27 | { 28 | "internalType": "uint256", 29 | "name": "", 30 | "type": "uint256" 31 | } 32 | ], 33 | "stateMutability": "view", 34 | "type": "function" 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /src/abis/IGmxVaultUtils.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "address", 11 | "name": "", 12 | "type": "address" 13 | }, 14 | { 15 | "internalType": "uint256", 16 | "name": "", 17 | "type": "uint256" 18 | } 19 | ], 20 | "name": "getSwapFeeBasisPoints", 21 | "outputs": [ 22 | { 23 | "internalType": "uint256", 24 | "name": "", 25 | "type": "uint256" 26 | } 27 | ], 28 | "stateMutability": "view", 29 | "type": "function" 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/abis/IKyberPool.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "getTradeInfo", 5 | "outputs": [ 6 | { 7 | "internalType": "uint112", 8 | "name": "_vReserve0", 9 | "type": "uint112" 10 | }, 11 | { 12 | "internalType": "uint112", 13 | "name": "_vReserve1", 14 | "type": "uint112" 15 | }, 16 | { 17 | "internalType": "uint112", 18 | "name": "reserve0", 19 | "type": "uint112" 20 | }, 21 | { 22 | "internalType": "uint112", 23 | "name": "reserve1", 24 | "type": "uint112" 25 | }, 26 | { 27 | "internalType": "uint256", 28 | "name": "feeInPrecision", 29 | "type": "uint256" 30 | } 31 | ], 32 | "stateMutability": "view", 33 | "type": "function" 34 | }, 35 | { 36 | "inputs": [ 37 | { 38 | "internalType": "uint256", 39 | "name": "amount0Out", 40 | "type": "uint256" 41 | }, 42 | { 43 | "internalType": "uint256", 44 | "name": "amount1Out", 45 | "type": "uint256" 46 | }, 47 | { 48 | "internalType": "address", 49 | "name": "to", 50 | "type": "address" 51 | }, 52 | { 53 | "internalType": "bytes", 54 | "name": "data", 55 | "type": "bytes" 56 | } 57 | ], 58 | "name": "swap", 59 | "outputs": [], 60 | "stateMutability": "nonpayable", 61 | "type": "function" 62 | }, 63 | { 64 | "inputs": [], 65 | "name": "token0", 66 | "outputs": [ 67 | { 68 | "internalType": "address", 69 | "name": "", 70 | "type": "address" 71 | } 72 | ], 73 | "stateMutability": "view", 74 | "type": "function" 75 | }, 76 | { 77 | "inputs": [], 78 | "name": "token1", 79 | "outputs": [ 80 | { 81 | "internalType": "address", 82 | "name": "", 83 | "type": "address" 84 | } 85 | ], 86 | "stateMutability": "view", 87 | "type": "function" 88 | } 89 | ] 90 | -------------------------------------------------------------------------------- /src/abis/IKyberRouter.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "amountIn", 7 | "type": "uint256" 8 | }, 9 | { 10 | "internalType": "address[]", 11 | "name": "poolsPath", 12 | "type": "address[]" 13 | }, 14 | { 15 | "internalType": "contract IERC20[]", 16 | "name": "path", 17 | "type": "address[]" 18 | } 19 | ], 20 | "name": "getAmountsOut", 21 | "outputs": [ 22 | { 23 | "internalType": "uint256[]", 24 | "name": "amounts", 25 | "type": "uint256[]" 26 | } 27 | ], 28 | "stateMutability": "view", 29 | "type": "function" 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/abis/IMinimalSwapInfoPool.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "name": "getPoolId", 5 | "outputs": [ 6 | { 7 | "internalType": "bytes32", 8 | "name": "", 9 | "type": "bytes32" 10 | } 11 | ], 12 | "stateMutability": "view", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "components": [ 19 | { 20 | "internalType": "enum IVault.SwapKind", 21 | "name": "kind", 22 | "type": "uint8" 23 | }, 24 | { 25 | "internalType": "contract IERC20", 26 | "name": "tokenIn", 27 | "type": "address" 28 | }, 29 | { 30 | "internalType": "contract IERC20", 31 | "name": "tokenOut", 32 | "type": "address" 33 | }, 34 | { 35 | "internalType": "uint256", 36 | "name": "amount", 37 | "type": "uint256" 38 | }, 39 | { 40 | "internalType": "bytes32", 41 | "name": "poolId", 42 | "type": "bytes32" 43 | }, 44 | { 45 | "internalType": "uint256", 46 | "name": "lastChangeBlock", 47 | "type": "uint256" 48 | }, 49 | { 50 | "internalType": "address", 51 | "name": "from", 52 | "type": "address" 53 | }, 54 | { 55 | "internalType": "address", 56 | "name": "to", 57 | "type": "address" 58 | }, 59 | { 60 | "internalType": "bytes", 61 | "name": "userData", 62 | "type": "bytes" 63 | } 64 | ], 65 | "internalType": "struct IPoolSwapStructs.SwapRequest", 66 | "name": "swapRequest", 67 | "type": "tuple" 68 | }, 69 | { 70 | "internalType": "uint256", 71 | "name": "currentBalanceTokenIn", 72 | "type": "uint256" 73 | }, 74 | { 75 | "internalType": "uint256", 76 | "name": "currentBalanceTokenOut", 77 | "type": "uint256" 78 | } 79 | ], 80 | "name": "onSwap", 81 | "outputs": [ 82 | { 83 | "internalType": "uint256", 84 | "name": "amount", 85 | "type": "uint256" 86 | } 87 | ], 88 | "stateMutability": "view", 89 | "type": "function" 90 | } 91 | ] 92 | -------------------------------------------------------------------------------- /src/abis/IUnilikeFactory.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "tokenA", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "address", 11 | "name": "tokenB", 12 | "type": "address" 13 | } 14 | ], 15 | "name": "getPair", 16 | "outputs": [ 17 | { 18 | "internalType": "address", 19 | "name": "pair", 20 | "type": "address" 21 | } 22 | ], 23 | "stateMutability": "view", 24 | "type": "function" 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /src/abis/IWooRouter.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "address", 6 | "name": "fromToken", 7 | "type": "address" 8 | }, 9 | { 10 | "internalType": "address", 11 | "name": "toToken", 12 | "type": "address" 13 | }, 14 | { 15 | "internalType": "uint256", 16 | "name": "fromAmount", 17 | "type": "uint256" 18 | } 19 | ], 20 | "name": "querySwap", 21 | "outputs": [ 22 | { 23 | "internalType": "uint256", 24 | "name": "toAmount", 25 | "type": "uint256" 26 | } 27 | ], 28 | "stateMutability": "view", 29 | "type": "function" 30 | }, 31 | { 32 | "inputs": [ 33 | { 34 | "internalType": "address", 35 | "name": "fromToken", 36 | "type": "address" 37 | }, 38 | { 39 | "internalType": "address", 40 | "name": "toToken", 41 | "type": "address" 42 | }, 43 | { 44 | "internalType": "uint256", 45 | "name": "fromAmount", 46 | "type": "uint256" 47 | }, 48 | { 49 | "internalType": "uint256", 50 | "name": "minToAmount", 51 | "type": "uint256" 52 | }, 53 | { 54 | "internalType": "address payable", 55 | "name": "to", 56 | "type": "address" 57 | }, 58 | { 59 | "internalType": "address", 60 | "name": "rebateTo", 61 | "type": "address" 62 | } 63 | ], 64 | "name": "swap", 65 | "outputs": [ 66 | { 67 | "internalType": "uint256", 68 | "name": "realToAmount", 69 | "type": "uint256" 70 | } 71 | ], 72 | "stateMutability": "payable", 73 | "type": "function" 74 | } 75 | ] 76 | -------------------------------------------------------------------------------- /src/abis/IwAVAX.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "", 7 | "type": "uint256" 8 | } 9 | ], 10 | "name": "withdraw", 11 | "outputs": [], 12 | "stateMutability": "nonpayable", 13 | "type": "function" 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /src/abis/IxJOE.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "uint256", 6 | "name": "", 7 | "type": "uint256" 8 | } 9 | ], 10 | "name": "enter", 11 | "outputs": [], 12 | "stateMutability": "nonpayable", 13 | "type": "function" 14 | }, 15 | { 16 | "inputs": [ 17 | { 18 | "internalType": "uint256", 19 | "name": "", 20 | "type": "uint256" 21 | } 22 | ], 23 | "name": "leave", 24 | "outputs": [], 25 | "stateMutability": "nonpayable", 26 | "type": "function" 27 | }, 28 | { 29 | "inputs": [], 30 | "name": "totalSupply", 31 | "outputs": [ 32 | { 33 | "internalType": "uint256", 34 | "name": "", 35 | "type": "uint256" 36 | } 37 | ], 38 | "stateMutability": "view", 39 | "type": "function" 40 | } 41 | ] 42 | -------------------------------------------------------------------------------- /src/abis/NTInjector.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [], 4 | "stateMutability": "payable", 5 | "type": "constructor" 6 | }, 7 | { 8 | "inputs": [ 9 | { 10 | "internalType": "address payable", 11 | "name": "_reciever", 12 | "type": "address" 13 | } 14 | ], 15 | "name": "injectFunds", 16 | "outputs": [], 17 | "stateMutability": "nonpayable", 18 | "type": "function" 19 | } 20 | ] 21 | -------------------------------------------------------------------------------- /src/abis/Ownable.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "anonymous": false, 4 | "inputs": [ 5 | { 6 | "indexed": true, 7 | "internalType": "address", 8 | "name": "previousOwner", 9 | "type": "address" 10 | }, 11 | { 12 | "indexed": true, 13 | "internalType": "address", 14 | "name": "newOwner", 15 | "type": "address" 16 | } 17 | ], 18 | "name": "OwnershipTransferred", 19 | "type": "event" 20 | }, 21 | { 22 | "inputs": [], 23 | "name": "owner", 24 | "outputs": [ 25 | { 26 | "internalType": "address", 27 | "name": "", 28 | "type": "address" 29 | } 30 | ], 31 | "stateMutability": "view", 32 | "type": "function" 33 | }, 34 | { 35 | "inputs": [], 36 | "name": "renounceOwnership", 37 | "outputs": [], 38 | "stateMutability": "nonpayable", 39 | "type": "function" 40 | }, 41 | { 42 | "inputs": [ 43 | { 44 | "internalType": "address", 45 | "name": "newOwner", 46 | "type": "address" 47 | } 48 | ], 49 | "name": "transferOwnership", 50 | "outputs": [], 51 | "stateMutability": "nonpayable", 52 | "type": "function" 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /src/contracts/YakWrapper.sol: -------------------------------------------------------------------------------- 1 | // ╟╗ ╔╬ 2 | // ╞╬╬ ╬╠╬ 3 | // ╔╣╬╬╬ ╠╠╠╠╦ 4 | // ╬╬╬╬╬╩ ╘╠╠╠╠╬ 5 | // ║╬╬╬╬╬ ╘╠╠╠╠╬ 6 | // ╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╬╬╬╬╬╬╬╜ ╠╠╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╠ 7 | // ╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╕ ╬╬╬╬╬╬╬╜ ╣╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╩ 8 | // ╙╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╔╬╬╬╬╬╬╬ ╔╠╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬╬╬╬╬╠╠╠╠╝╙ 9 | // ╘╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╠╠╠╬╠╬╩╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╣╬╬╬╬╬╬╬╙ 10 | // ╣╬╬╬╬╬╬╬╬╬╬╠╣ ╣╬╠╠╠╬╩ ╚╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 11 | // ╣╬╬╬╬╬╬╬╬╬╣ ╣╬╠╠╠╬╬ ╣╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 12 | // ╟╬╬╬╬╬╬╬╩ ╬╬╠╠╠╠╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╠╬╬╬╬╬╬╬ 13 | // ╬╬╬╬╬╬╬ ╒╬╬╠╠╬╠╠╬╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬ 14 | // ╬╬╬╬╬╬╬ ╬╬╬╠╠╠╠╝╝╝╝╝╝╝╠╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╚╬╬╬╬╬╬╬╬ 15 | // ╬╬╬╬╬╬╬ ╣╬╬╬╬╠╠╩ ╘╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╙╬╬╬╬╬╬╬╬ 16 | // 17 | 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | pragma solidity ^0.8.0; 20 | 21 | import "./YakAdapter.sol"; 22 | 23 | abstract contract YakWrapper is YakAdapter { 24 | 25 | constructor(string memory name, uint256 gasEstimate) YakAdapter(name, gasEstimate) {} 26 | 27 | function getTokensIn() external view virtual returns (address[] memory); 28 | function getTokensOut() external view virtual returns (address[] memory); 29 | function getWrappedToken() external view virtual returns (address); 30 | 31 | } -------------------------------------------------------------------------------- /src/contracts/adapters/AgniAdapter.sol: -------------------------------------------------------------------------------- 1 | // ╟╗ ╔╬ 2 | // ╞╬╬ ╬╠╬ 3 | // ╔╣╬╬╬ ╠╠╠╠╦ 4 | // ╬╬╬╬╬╩ ╘╠╠╠╠╬ 5 | // ║╬╬╬╬╬ ╘╠╠╠╠╬ 6 | // ╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╬╬╬╬╬╬╬╜ ╠╠╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╠ 7 | // ╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╕ ╬╬╬╬╬╬╬╜ ╣╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╩ 8 | // ╙╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╔╬╬╬╬╬╬╬ ╔╠╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬╬╬╬╬╠╠╠╠╝╙ 9 | // ╘╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╠╠╠╬╠╬╩╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╣╬╬╬╬╬╬╬╙ 10 | // ╣╬╬╬╬╬╬╬╬╬╬╠╣ ╣╬╠╠╠╬╩ ╚╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 11 | // ╣╬╬╬╬╬╬╬╬╬╣ ╣╬╠╠╠╬╬ ╣╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 12 | // ╟╬╬╬╬╬╬╬╩ ╬╬╠╠╠╠╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╠╬╬╬╬╬╬╬ 13 | // ╬╬╬╬╬╬╬ ╒╬╬╠╠╬╠╠╬╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬ 14 | // ╬╬╬╬╬╬╬ ╬╬╬╠╠╠╠╝╝╝╝╝╝╝╠╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╚╬╬╬╬╬╬╬╬ 15 | // ╬╬╬╬╬╬╬ ╣╬╬╬╬╠╠╩ ╘╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╙╬╬╬╬╬╬╬╬ 16 | // 17 | 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | pragma solidity ^0.8.0; 20 | 21 | import "./UniswapV3AdapterBase.sol"; 22 | 23 | contract AgniAdapter is UniswapV3AdapterBase { 24 | 25 | constructor( 26 | string memory _name, 27 | uint256 _swapGasEstimate, 28 | uint256 _quoterGasLimit, 29 | address _quoter, 30 | address _factory, 31 | uint24[] memory _defaultFees 32 | ) UniswapV3AdapterBase(_name, _swapGasEstimate, _quoterGasLimit, _quoter, _factory, _defaultFees) { 33 | } 34 | 35 | function agniSwapCallback ( 36 | int256 amount0Delta, 37 | int256 amount1Delta, 38 | bytes calldata 39 | ) external { 40 | if (amount0Delta > 0) { 41 | IERC20(IUniV3Pool(msg.sender).token0()).transfer(msg.sender, uint256(amount0Delta)); 42 | } else { 43 | IERC20(IUniV3Pool(msg.sender).token1()).transfer(msg.sender, uint256(amount1Delta)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/contracts/adapters/FusionAdapter.sol: -------------------------------------------------------------------------------- 1 | // ╟╗ ╔╬ 2 | // ╞╬╬ ╬╠╬ 3 | // ╔╣╬╬╬ ╠╠╠╠╦ 4 | // ╬╬╬╬╬╩ ╘╠╠╠╠╬ 5 | // ║╬╬╬╬╬ ╘╠╠╠╠╬ 6 | // ╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╬╬╬╬╬╬╬╜ ╠╠╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╠ 7 | // ╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╕ ╬╬╬╬╬╬╬╜ ╣╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╩ 8 | // ╙╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╔╬╬╬╬╬╬╬ ╔╠╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬╬╬╬╬╠╠╠╠╝╙ 9 | // ╘╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╠╠╠╬╠╬╩╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╣╬╬╬╬╬╬╬╙ 10 | // ╣╬╬╬╬╬╬╬╬╬╬╠╣ ╣╬╠╠╠╬╩ ╚╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 11 | // ╣╬╬╬╬╬╬╬╬╬╣ ╣╬╠╠╠╬╬ ╣╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 12 | // ╟╬╬╬╬╬╬╬╩ ╬╬╠╠╠╠╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╠╬╬╬╬╬╬╬ 13 | // ╬╬╬╬╬╬╬ ╒╬╬╠╠╬╠╠╬╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬ 14 | // ╬╬╬╬╬╬╬ ╬╬╬╠╠╠╠╝╝╝╝╝╝╝╠╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╚╬╬╬╬╬╬╬╬ 15 | // ╬╬╬╬╬╬╬ ╣╬╬╬╬╠╠╩ ╘╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╙╬╬╬╬╬╬╬╬ 16 | // 17 | 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | pragma solidity ^0.8.0; 20 | 21 | import "./UniswapV3AdapterBase.sol"; 22 | 23 | contract FusionAdapter is UniswapV3AdapterBase { 24 | 25 | constructor( 26 | string memory _name, 27 | uint256 _swapGasEstimate, 28 | uint256 _quoterGasLimit, 29 | address _quoter, 30 | address _factory, 31 | uint24[] memory _defaultFees 32 | ) UniswapV3AdapterBase(_name, _swapGasEstimate, _quoterGasLimit, _quoter, _factory, _defaultFees) { 33 | } 34 | 35 | function fusionXV3SwapCallback ( 36 | int256 amount0Delta, 37 | int256 amount1Delta, 38 | bytes calldata 39 | ) external { 40 | if (amount0Delta > 0) { 41 | IERC20(IUniV3Pool(msg.sender).token0()).transfer(msg.sender, uint256(amount0Delta)); 42 | } else { 43 | IERC20(IUniV3Pool(msg.sender).token1()).transfer(msg.sender, uint256(amount1Delta)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/contracts/adapters/PancakeV3Adapter.sol: -------------------------------------------------------------------------------- 1 | // ╟╗ ╔╬ 2 | // ╞╬╬ ╬╠╬ 3 | // ╔╣╬╬╬ ╠╠╠╠╦ 4 | // ╬╬╬╬╬╩ ╘╠╠╠╠╬ 5 | // ║╬╬╬╬╬ ╘╠╠╠╠╬ 6 | // ╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╬╬╬╬╬╬╬╜ ╠╠╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╠ 7 | // ╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╕ ╬╬╬╬╬╬╬╜ ╣╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╩ 8 | // ╙╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╔╬╬╬╬╬╬╬ ╔╠╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬╬╬╬╬╠╠╠╠╝╙ 9 | // ╘╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╠╠╠╬╠╬╩╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╣╬╬╬╬╬╬╬╙ 10 | // ╣╬╬╬╬╬╬╬╬╬╬╠╣ ╣╬╠╠╠╬╩ ╚╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 11 | // ╣╬╬╬╬╬╬╬╬╬╣ ╣╬╠╠╠╬╬ ╣╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 12 | // ╟╬╬╬╬╬╬╬╩ ╬╬╠╠╠╠╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╠╬╬╬╬╬╬╬ 13 | // ╬╬╬╬╬╬╬ ╒╬╬╠╠╬╠╠╬╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬ 14 | // ╬╬╬╬╬╬╬ ╬╬╬╠╠╠╠╝╝╝╝╝╝╝╠╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╚╬╬╬╬╬╬╬╬ 15 | // ╬╬╬╬╬╬╬ ╣╬╬╬╬╠╠╩ ╘╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╙╬╬╬╬╬╬╬╬ 16 | // 17 | 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | pragma solidity ^0.8.0; 20 | 21 | import "./UniswapV3AdapterBase.sol"; 22 | 23 | contract PancakeV3Adapter is UniswapV3AdapterBase { 24 | 25 | constructor( 26 | string memory _name, 27 | uint256 _swapGasEstimate, 28 | uint256 _quoterGasLimit, 29 | address _quoter, 30 | address _factory, 31 | uint24[] memory _defaultFees 32 | ) UniswapV3AdapterBase(_name, _swapGasEstimate, _quoterGasLimit, _quoter, _factory, _defaultFees) { 33 | } 34 | 35 | function pancakeV3SwapCallback ( 36 | int256 amount0Delta, 37 | int256 amount1Delta, 38 | bytes calldata 39 | ) external { 40 | if (amount0Delta > 0) { 41 | IERC20(IUniV3Pool(msg.sender).token0()).transfer(msg.sender, uint256(amount0Delta)); 42 | } else { 43 | IERC20(IUniV3Pool(msg.sender).token1()).transfer(msg.sender, uint256(amount1Delta)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/contracts/adapters/UniswapV3Adapter.sol: -------------------------------------------------------------------------------- 1 | // ╟╗ ╔╬ 2 | // ╞╬╬ ╬╠╬ 3 | // ╔╣╬╬╬ ╠╠╠╠╦ 4 | // ╬╬╬╬╬╩ ╘╠╠╠╠╬ 5 | // ║╬╬╬╬╬ ╘╠╠╠╠╬ 6 | // ╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╬╬╬╬╬╬╬╜ ╠╠╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╠ 7 | // ╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╕ ╬╬╬╬╬╬╬╜ ╣╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╩ 8 | // ╙╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╔╬╬╬╬╬╬╬ ╔╠╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬╬╬╬╬╠╠╠╠╝╙ 9 | // ╘╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╠╠╠╬╠╬╩╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╣╬╬╬╬╬╬╬╙ 10 | // ╣╬╬╬╬╬╬╬╬╬╬╠╣ ╣╬╠╠╠╬╩ ╚╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 11 | // ╣╬╬╬╬╬╬╬╬╬╣ ╣╬╠╠╠╬╬ ╣╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 12 | // ╟╬╬╬╬╬╬╬╩ ╬╬╠╠╠╠╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╠╬╬╬╬╬╬╬ 13 | // ╬╬╬╬╬╬╬ ╒╬╬╠╠╬╠╠╬╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬ 14 | // ╬╬╬╬╬╬╬ ╬╬╬╠╠╠╠╝╝╝╝╝╝╝╠╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╚╬╬╬╬╬╬╬╬ 15 | // ╬╬╬╬╬╬╬ ╣╬╬╬╬╠╠╩ ╘╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╙╬╬╬╬╬╬╬╬ 16 | // 17 | 18 | // SPDX-License-Identifier: GPL-3.0-only 19 | pragma solidity ^0.8.0; 20 | 21 | import "./UniswapV3AdapterBase.sol"; 22 | 23 | contract UniswapV3Adapter is UniswapV3AdapterBase { 24 | 25 | constructor( 26 | string memory _name, 27 | uint256 _swapGasEstimate, 28 | uint256 _quoterGasLimit, 29 | address _quoter, 30 | address _factory, 31 | uint24[] memory _defaultFees 32 | ) UniswapV3AdapterBase(_name, _swapGasEstimate, _quoterGasLimit, _quoter, _factory, _defaultFees) { 33 | } 34 | 35 | function uniswapV3SwapCallback( 36 | int256 amount0Delta, 37 | int256 amount1Delta, 38 | bytes calldata 39 | ) external { 40 | if (amount0Delta > 0) { 41 | IERC20(IUniV3Pool(msg.sender).token0()).transfer(msg.sender, uint256(amount0Delta)); 42 | } else { 43 | IERC20(IUniV3Pool(msg.sender).token1()).transfer(msg.sender, uint256(amount1Delta)); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/contracts/adapters/WAvaxAdapter.sol: -------------------------------------------------------------------------------- 1 | // ╟╗ ╔╬ 2 | // ╞╬╬ ╬╠╬ 3 | // ╔╣╬╬╬ ╠╠╠╠╦ 4 | // ╬╬╬╬╬╩ ╘╠╠╠╠╬ 5 | // ║╬╬╬╬╬ ╘╠╠╠╠╬ 6 | // ╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╬╬╬╬╬╬╬╜ ╠╠╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╠ 7 | // ╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╕ ╬╬╬╬╬╬╬╜ ╣╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╩ 8 | // ╙╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╔╬╬╬╬╬╬╬ ╔╠╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬╬╬╬╬╠╠╠╠╝╙ 9 | // ╘╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╠╠╠╬╠╬╩╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╣╬╬╬╬╬╬╬╙ 10 | // ╣╬╬╬╬╬╬╬╬╬╬╠╣ ╣╬╠╠╠╬╩ ╚╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 11 | // ╣╬╬╬╬╬╬╬╬╬╣ ╣╬╠╠╠╬╬ ╣╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 12 | // ╟╬╬╬╬╬╬╬╩ ╬╬╠╠╠╠╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╠╬╬╬╬╬╬╬ 13 | // ╬╬╬╬╬╬╬ ╒╬╬╠╠╬╠╠╬╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬ 14 | // ╬╬╬╬╬╬╬ ╬╬╬╠╠╠╠╝╝╝╝╝╝╝╠╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╚╬╬╬╬╬╬╬╬ 15 | // ╬╬╬╬╬╬╬ ╣╬╬╬╬╠╠╩ ╘╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╙╬╬╬╬╬╬╬╬ 16 | // 17 | // 18 | 19 | // SPDX-License-Identifier: GPL-3.0-only 20 | pragma solidity ^0.8.0; 21 | 22 | import "../YakAdapter.sol"; 23 | 24 | contract WAvaxAdapter is YakAdapter { 25 | address internal constant WAVAX = 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7; 26 | 27 | constructor(uint256 _swapGasEstimate) YakAdapter("WAvaxAdapter", _swapGasEstimate) { 28 | setSwapGasEstimate(_swapGasEstimate); 29 | } 30 | 31 | function _query( 32 | uint256 _amountIn, 33 | address _tokenIn, 34 | address _tokenOut 35 | ) internal pure override returns (uint256 amountOut) { 36 | if (_tokenIn == WAVAX && _tokenOut == WAVAX) { 37 | amountOut = _amountIn; 38 | } 39 | } 40 | 41 | function _swap( 42 | uint256, 43 | uint256 _amountOut, 44 | address, 45 | address _tokenOut, 46 | address _to 47 | ) internal override { 48 | _returnTo(_tokenOut, _amountOut, _to); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/contracts/adapters/WNativeAdapter.sol: -------------------------------------------------------------------------------- 1 | // ╟╗ ╔╬ 2 | // ╞╬╬ ╬╠╬ 3 | // ╔╣╬╬╬ ╠╠╠╠╦ 4 | // ╬╬╬╬╬╩ ╘╠╠╠╠╬ 5 | // ║╬╬╬╬╬ ╘╠╠╠╠╬ 6 | // ╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╬╬╬╬╬╬╬╜ ╠╠╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╠ 7 | // ╙╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╕ ╬╬╬╬╬╬╬╜ ╣╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╬╬╬╬╬╬╬╬╬╠╠╠╠╠╠╠╩ 8 | // ╙╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╔╬╬╬╬╬╬╬ ╔╠╠╠╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬╬╬╬╬╠╠╠╠╝╙ 9 | // ╘╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬ ╒╠╠╠╬╠╬╩╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╣╬╬╬╬╬╬╬╙ 10 | // ╣╬╬╬╬╬╬╬╬╬╬╠╣ ╣╬╠╠╠╬╩ ╚╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 11 | // ╣╬╬╬╬╬╬╬╬╬╣ ╣╬╠╠╠╬╬ ╣╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╬╬╬╬╬╬╬ 12 | // ╟╬╬╬╬╬╬╬╩ ╬╬╠╠╠╠╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬╠╬╬╬╬╬╬╬ 13 | // ╬╬╬╬╬╬╬ ╒╬╬╠╠╬╠╠╬╬╬╬╬╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╣╬╬╬╬╬╬╬ 14 | // ╬╬╬╬╬╬╬ ╬╬╬╠╠╠╠╝╝╝╝╝╝╝╠╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╚╬╬╬╬╬╬╬╬ 15 | // ╬╬╬╬╬╬╬ ╣╬╬╬╬╠╠╩ ╘╬╬╬╬╬╬╬ ╠╬╬╬╬╬╬╬ ╙╬╬╬╬╬╬╬╬ 16 | // 17 | // 18 | 19 | // SPDX-License-Identifier: GPL-3.0-only 20 | pragma solidity ^0.8.0; 21 | 22 | import "../YakAdapter.sol"; 23 | 24 | contract WNativeAdapter is YakAdapter { 25 | address internal immutable WNATIVE; 26 | 27 | constructor( 28 | address _wNative, 29 | uint256 _swapGasEstimate 30 | ) YakAdapter("WAvaxAdapter", _swapGasEstimate) { 31 | WNATIVE = _wNative; 32 | setSwapGasEstimate(_swapGasEstimate); 33 | } 34 | 35 | function _query( 36 | uint256 _amountIn, 37 | address _tokenIn, 38 | address _tokenOut 39 | ) internal view override returns (uint256 amountOut) { 40 | if (_tokenIn == WNATIVE && _tokenOut == WNATIVE) 41 | amountOut = _amountIn; 42 | } 43 | 44 | function _swap( 45 | uint256 _amountIn, 46 | uint256, 47 | address, 48 | address _tokenOut, 49 | address _to 50 | ) internal override { 51 | _returnTo(_tokenOut, _amountIn, _to); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/contracts/interface/IAaveAToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IAaveAToken { 5 | function POOL() external view returns (address); 6 | function UNDERLYING_ASSET_ADDRESS() external view returns (address); 7 | } 8 | -------------------------------------------------------------------------------- /src/contracts/interface/IAavePool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IAavePool { 5 | function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external; 6 | } 7 | -------------------------------------------------------------------------------- /src/contracts/interface/IAdapter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IAdapter { 5 | function name() external view returns (string memory); 6 | 7 | function swapGasEstimate() external view returns (uint256); 8 | 9 | function swap( 10 | uint256, 11 | uint256, 12 | address, 13 | address, 14 | address 15 | ) external; 16 | 17 | function query( 18 | uint256, 19 | address, 20 | address 21 | ) external view returns (uint256); 22 | } 23 | -------------------------------------------------------------------------------- /src/contracts/interface/IAsset.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IAsset { 5 | // solhint-disable-previous-line no-empty-blocks 6 | } 7 | -------------------------------------------------------------------------------- /src/contracts/interface/IBasePool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IPoolSwapStructs.sol"; 5 | 6 | interface IBasePool is IPoolSwapStructs { 7 | function getPoolId() external view returns (bytes32); 8 | } 9 | -------------------------------------------------------------------------------- /src/contracts/interface/IButtonTokenFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | pragma solidity ^0.8.4; 3 | 4 | interface IButtonTokenFactory { 5 | //@dev https://github.com/buttonwood-protocol/button-wrappers/blob/main/contracts/utilities/InstanceRegistry.sol#L33 6 | function isInstance(address instance) external view returns (bool validity); 7 | 8 | //@dev https://github.com/buttonwood-protocol/button-wrappers/blob/main/contracts/utilities/InstanceRegistry.sol#L37 9 | function instanceCount() external view returns (uint256 count); 10 | 11 | //@dev https://github.com/buttonwood-protocol/button-wrappers/blob/main/contracts/utilities/InstanceRegistry.sol#L41 12 | function instanceAt(uint256 index) external view returns (address instance); 13 | } 14 | -------------------------------------------------------------------------------- /src/contracts/interface/IButtonWrapper.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | pragma solidity ^0.8.4; 3 | 4 | // https://github.com/buttonwood-protocol/button-wrappers/blob/main/contracts/interfaces/IButtonWrapper.sol 5 | interface IButtonWrapper { 6 | /// @return The address of the underlying token. 7 | function underlying() external view returns (address); 8 | 9 | /// @param uAmount The amount of underlying tokens. 10 | /// @return The amount of wrapper tokens exchangeable. 11 | function underlyingToWrapper(uint256 uAmount) external view returns (uint256); 12 | 13 | /// @param amount The amount of wrapper tokens. 14 | /// @return The amount of underlying tokens exchangeable. 15 | function wrapperToUnderlying(uint256 amount) external view returns (uint256); 16 | 17 | /// @notice Burns wrapper tokens from {msg.sender} and transfers 18 | /// the underlying tokens to the specified beneficiary. 19 | /// @param to The beneficiary account. 20 | /// @param amount The amount of wrapper tokens to burn. 21 | /// @return The amount of underlying tokens withdrawn. 22 | function burnTo(address to, uint256 amount) external returns (uint256); 23 | 24 | /// @notice Transfers underlying tokens from {msg.sender} to the contract and 25 | /// mints wrapper tokens to the specified beneficiary. 26 | /// @param to The beneficiary account. 27 | /// @param uAmount The amount of underlying tokens to deposit. 28 | /// @return The amount of wrapper tokens mint. 29 | function depositFor(address to, uint256 uAmount) external returns (uint256); 30 | } 31 | -------------------------------------------------------------------------------- /src/contracts/interface/IButtonswapFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | pragma solidity ^0.8.4; 3 | 4 | // https://github.com/buttonwood-protocol/buttonswap-core/blob/main/src/interfaces/IButtonswapFactory/IButtonswapFactory.sol 5 | interface IButtonswapFactory { 6 | /** 7 | * @notice Get the (unique) Pair address created for the given combination of `tokenA` and `tokenB`. 8 | * If the Pair does not exist then zero address is returned. 9 | * @param tokenA The first unsorted token 10 | * @param tokenB The second unsorted token 11 | * @return pair The address of the Pair instance 12 | */ 13 | function getPair(address tokenA, address tokenB) external view returns (address pair); 14 | } 15 | -------------------------------------------------------------------------------- /src/contracts/interface/IButtonswapPair.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | pragma solidity ^0.8.4; 3 | 4 | // https://github.com/buttonwood-protocol/buttonswap-core/blob/main/src/interfaces/IButtonswapPair/IButtonswapPair.sol 5 | interface IButtonswapPair { 6 | /** 7 | * @notice Get the current liquidity values. 8 | * @return _pool0 The active `token0` liquidity 9 | * @return _pool1 The active `token1` liquidity 10 | * @return _reservoir0 The inactive `token0` liquidity 11 | * @return _reservoir1 The inactive `token1` liquidity 12 | * @return _blockTimestampLast The timestamp of when the price was last updated 13 | */ 14 | function getLiquidityBalances() 15 | external 16 | view 17 | returns ( 18 | uint112 _pool0, 19 | uint112 _pool1, 20 | uint112 _reservoir0, 21 | uint112 _reservoir1, 22 | uint32 _blockTimestampLast 23 | ); 24 | 25 | /** 26 | * @notice Swaps one token for the other, taking `amountIn0` of `token0` and `amountIn1` of `token1` from the sender and sending `amountOut0` of `token0` and `amountOut1` of `token1` to `to`. 27 | * The price of the swap is determined by maintaining the "K Invariant". 28 | * A 0.3% fee is collected to distribute between liquidity providers and the protocol. 29 | * @dev The token deposits are deduced to be the delta between the current Pair contract token balances and the last stored balances. 30 | * Optional calldata can be passed to `data`, which will be used to confirm the output token transfer with `to` if `to` is a contract that implements the {IButtonswapCallee} interface. 31 | * Refer to [swap-math.md](https://github.com/buttonwood-protocol/buttonswap-core/blob/main/notes/swap-math.md) for more detail. 32 | * @param amountIn0 The amount of `token0` that the sender sends 33 | * @param amountIn1 The amount of `token1` that the sender sends 34 | * @param amountOut0 The amount of `token0` that the recipient receives 35 | * @param amountOut1 The amount of `token1` that the recipient receives 36 | * @param to The account that receives the swap output 37 | */ 38 | function swap( 39 | uint256 amountIn0, 40 | uint256 amountIn1, 41 | uint256 amountOut0, 42 | uint256 amountOut1, 43 | address to 44 | ) external; 45 | } 46 | -------------------------------------------------------------------------------- /src/contracts/interface/ICurve1.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface ICurve1 { 5 | function underlying_coins(uint256 index) external view returns (address); 6 | 7 | function exchange_underlying( 8 | uint256 tokenIndexFrom, 9 | uint256 tokenIndexTo, 10 | uint256 dx, 11 | uint256 minDy 12 | ) external; 13 | 14 | function get_dy_underlying( 15 | uint256 tokenIndexFrom, 16 | uint256 tokenIndexTo, 17 | uint256 dx 18 | ) external view returns (uint256); 19 | } 20 | -------------------------------------------------------------------------------- /src/contracts/interface/ICurve2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface ICurve2 { 5 | function underlying_coins(uint256 index) external view returns (address); 6 | 7 | function get_dy_underlying( 8 | int128 tokenIndexFrom, 9 | int128 tokenIndexTo, 10 | uint256 dx 11 | ) external view returns (uint256); 12 | 13 | function exchange_underlying( 14 | int128 tokenIndexFrom, 15 | int128 tokenIndexTo, 16 | uint256 dx, 17 | uint256 minDy 18 | ) external; 19 | } 20 | -------------------------------------------------------------------------------- /src/contracts/interface/ICurveMeta.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface ICurveMeta { 5 | function base_coins(uint256) external view returns (address); 6 | 7 | function coins(uint256 index) external view returns (address); 8 | 9 | function get_dy_underlying( 10 | int128 tokenIndexFrom, 11 | int128 tokenIndexTo, 12 | uint256 dx 13 | ) external view returns (uint256); 14 | 15 | function exchange_underlying( 16 | int128 tokenIndexFrom, 17 | int128 tokenIndexTo, 18 | uint256 dx, 19 | uint256 minDy 20 | ) external; 21 | } 22 | -------------------------------------------------------------------------------- /src/contracts/interface/ICurvePlain128.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface ICurvePlain128 { 5 | function coins(uint256 index) external view returns (address); 6 | 7 | function exchange( 8 | int128 tokenIndexFrom, 9 | int128 tokenIndexTo, 10 | uint256 dx, 11 | uint256 minDy 12 | ) external returns (uint256); 13 | 14 | function get_dy( 15 | int128 tokenIndexFrom, 16 | int128 tokenIndexTo, 17 | uint256 dx 18 | ) external view returns (uint256); 19 | } 20 | -------------------------------------------------------------------------------- /src/contracts/interface/ICurvePlain128Native.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface ICurvePlain128Native { 5 | function coins(uint256 index) external view returns (address); 6 | 7 | function exchange( 8 | int128 tokenIndexFrom, 9 | int128 tokenIndexTo, 10 | uint256 dx, 11 | uint256 minDy 12 | ) external payable returns (uint256); 13 | 14 | function get_dy( 15 | int128 tokenIndexFrom, 16 | int128 tokenIndexTo, 17 | uint256 dx 18 | ) external view returns (uint256); 19 | } 20 | -------------------------------------------------------------------------------- /src/contracts/interface/ICurvePlain256.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface ICurvePlain256 { 5 | function coins(uint256 index) external view returns (address); 6 | 7 | function exchange( 8 | uint256 tokenIndexFrom, 9 | uint256 tokenIndexTo, 10 | uint256 dx, 11 | uint256 minDy 12 | ) external; 13 | 14 | function get_dy( 15 | uint256 tokenIndexFrom, 16 | uint256 tokenIndexTo, 17 | uint256 dx 18 | ) external view returns (uint256); 19 | } 20 | -------------------------------------------------------------------------------- /src/contracts/interface/IDodoV1.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IDodoHelper { 5 | function querySellQuoteToken(address dodo, uint256 amount) external view returns (uint256); 6 | } 7 | 8 | interface IDodoV1 { 9 | function _QUOTE_TOKEN_() external view returns (address); 10 | 11 | function _BASE_TOKEN_() external view returns (address); 12 | 13 | function querySellBaseToken(uint256 amount) external view returns (uint256); 14 | 15 | function queryBuyBaseToken(uint256 amount) external view returns (uint256); 16 | 17 | function sellBaseToken( 18 | uint256 amount, 19 | uint256 minReceiveQuote, 20 | bytes calldata data 21 | ) external returns (uint256); 22 | 23 | function buyBaseToken( 24 | uint256 amount, 25 | uint256 maxPayQuote, 26 | bytes calldata data 27 | ) external returns (uint256); 28 | } 29 | -------------------------------------------------------------------------------- /src/contracts/interface/IDodoV2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IDodoV2 { 5 | function _QUOTE_TOKEN_() external view returns (address); 6 | 7 | function _BASE_TOKEN_() external view returns (address); 8 | 9 | function querySellBase(address trader, uint256 payBaseAmount) external view returns (uint256 receiveQuoteAmount); 10 | 11 | function querySellQuote(address trader, uint256 payQuoteAmount) external view returns (uint256 receiveBaseAmount); 12 | 13 | function sellBase(address to) external returns (uint256 receiveQuoteAmount); 14 | 15 | function sellQuote(address to) external returns (uint256 receiveBaseAmount); 16 | } 17 | -------------------------------------------------------------------------------- /src/contracts/interface/IERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IERC20 { 5 | event Approval(address, address, uint256); 6 | event Transfer(address, address, uint256); 7 | 8 | function name() external view returns (string memory); 9 | 10 | function decimals() external view returns (uint8); 11 | 12 | function transferFrom( 13 | address, 14 | address, 15 | uint256 16 | ) external returns (bool); 17 | 18 | function allowance(address, address) external view returns (uint256); 19 | 20 | function approve(address, uint256) external returns (bool); 21 | 22 | function transfer(address, uint256) external returns (bool); 23 | 24 | function balanceOf(address) external view returns (uint256); 25 | 26 | function nonces(address) external view returns (uint256); // Only tokens that support permit 27 | 28 | function permit( 29 | address, 30 | address, 31 | uint256, 32 | uint256, 33 | uint8, 34 | bytes32, 35 | bytes32 36 | ) external; // Only tokens that support permit 37 | 38 | function swap(address, uint256) external; // Only Avalanche bridge tokens 39 | 40 | function swapSupply(address) external view returns (uint256); // Only Avalanche bridge tokens 41 | 42 | function totalSupply() external view returns (uint256); 43 | } 44 | -------------------------------------------------------------------------------- /src/contracts/interface/IGGAvax.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IERC20.sol"; 5 | 6 | interface IGGAvax is IERC20 { 7 | function maxDeposit(address _owner) external view returns (uint256); 8 | function previewDeposit(uint256 assets) external view returns (uint256); 9 | function previewRedeem(uint256 shares) external view returns (uint256); 10 | function stakingTotalAssets() external view returns (uint256); 11 | function totalAssets() external view returns (uint256); 12 | function deposit(uint256 assets, address receiver) external returns (uint256 shares); 13 | function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets); 14 | } 15 | -------------------------------------------------------------------------------- /src/contracts/interface/IGenericFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | interface IGenericFactory { 5 | function allPairs() external view returns (address[] memory); 6 | function getPair(address tokenA, address tokenB, uint256 curveId) external view returns (address); 7 | } 8 | -------------------------------------------------------------------------------- /src/contracts/interface/IGeodePortal.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IGeodePortal { 5 | function gAVAX() external view returns (address); 6 | 7 | function getNameFromId(uint256 _id) external view returns (bytes memory); 8 | 9 | function planetCurrentInterface(uint256 _id) external view returns (address); 10 | 11 | function planetWithdrawalPool(uint256 _id) external view returns (address); 12 | 13 | function getMaintainerFromId(uint256) external view returns (address); 14 | 15 | function isStakingPausedForPool(uint256) external view returns (bool); 16 | 17 | function unpauseStakingForPool(uint256) external; 18 | 19 | function pauseStakingForPool(uint256) external; 20 | 21 | function stake( 22 | uint256 planetId, 23 | uint256 minGavax, 24 | uint256 deadline 25 | ) external payable returns (uint256 totalgAvax); 26 | } 27 | -------------------------------------------------------------------------------- /src/contracts/interface/IGeodeWP.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IGeodeWP { 5 | function paused() external view returns (bool); 6 | 7 | function getDebt() external view returns (uint256); 8 | 9 | function getToken() external view returns (uint256); 10 | 11 | function getERC1155() external view returns (address); 12 | 13 | function getTokenBalance(uint8) external view returns (uint256); 14 | 15 | function calculateSwap( 16 | uint8 tokenIndexFrom, 17 | uint8 tokenIndexTo, 18 | uint256 dx 19 | ) external view returns (uint256); 20 | 21 | function swap( 22 | uint8 tokenIndexFrom, 23 | uint8 tokenIndexTo, 24 | uint256 dx, 25 | uint256 minDy, 26 | uint256 deadline 27 | ) external payable returns (uint256); 28 | 29 | function addLiquidity( 30 | uint256[] calldata amounts, 31 | uint256 minToMint, 32 | uint256 deadline 33 | ) external payable; 34 | } 35 | -------------------------------------------------------------------------------- /src/contracts/interface/IGlpManager.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IGlpManager { 5 | function getAumInUsdg(bool maximise) external view returns (uint256); 6 | 7 | function vault() external view returns (address); 8 | } 9 | -------------------------------------------------------------------------------- /src/contracts/interface/IGmxRewardRouter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IGmxRewardRouter { 5 | function glpManager() external view returns (address); 6 | 7 | function mintAndStakeGlp( 8 | address _token, 9 | uint256 _amount, 10 | uint256 _minUsdg, 11 | uint256 _minGlp 12 | ) external returns (uint256); 13 | 14 | function unstakeAndRedeemGlp( 15 | address _tokenOut, 16 | uint256 _glpAmount, 17 | uint256 _minOut, 18 | address _receiver 19 | ) external returns (uint256); 20 | } 21 | -------------------------------------------------------------------------------- /src/contracts/interface/IKyberPool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IKyberPool { 5 | function swap( 6 | uint256 amount0Out, 7 | uint256 amount1Out, 8 | address to, 9 | bytes calldata data 10 | ) external; 11 | 12 | function getTradeInfo() 13 | external 14 | view 15 | returns ( 16 | uint112 _vReserve0, 17 | uint112 _vReserve1, 18 | uint112 reserve0, 19 | uint112 reserve1, 20 | uint256 feeInPrecision 21 | ); 22 | 23 | function token0() external view returns (address); 24 | 25 | function token1() external view returns (address); 26 | } 27 | -------------------------------------------------------------------------------- /src/contracts/interface/IKyberRouter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IERC20.sol"; 5 | 6 | interface IKyberRouter { 7 | function getAmountsOut( 8 | uint256 amountIn, 9 | address[] calldata poolsPath, 10 | IERC20[] calldata path 11 | ) external view returns (uint256[] memory amounts); 12 | } 13 | -------------------------------------------------------------------------------- /src/contracts/interface/ILB2Pair.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | interface ILBPair { 6 | function getTokenX() external view returns (address); 7 | 8 | function getTokenY() external view returns (address); 9 | 10 | function swap(bool swapForY, address to) external returns (bytes32 amountsOut); 11 | 12 | function getSwapOut(uint128 amountIn, bool swapForY) 13 | external 14 | view 15 | returns (uint128 amountInLeft, uint128 amountOut, uint128 fee); 16 | } 17 | -------------------------------------------------------------------------------- /src/contracts/interface/ILBFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | interface ILBFactory { 6 | struct LBPairInformation { 7 | uint24 binStep; 8 | address LBPair; 9 | bool createdByOwner; 10 | bool ignoredForRouting; 11 | } 12 | 13 | function getAllLBPairs(address tokenX, address tokenY) 14 | external 15 | view 16 | returns (LBPairInformation[] memory LBPairsBinStep); 17 | } 18 | -------------------------------------------------------------------------------- /src/contracts/interface/ILBPair.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | interface ILBPair { 6 | function tokenX() external view returns (address); 7 | 8 | function tokenY() external view returns (address); 9 | 10 | function swap(bool sentTokenY, address to) external returns (uint256 amountXOut, uint256 amountYOut); 11 | } 12 | -------------------------------------------------------------------------------- /src/contracts/interface/ILBRouter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | interface ILBRouter { 6 | function factory() external view returns (address); 7 | 8 | function getSwapOut( 9 | address pair, 10 | uint256 amountIn, 11 | bool swapForY 12 | ) external view returns (uint256 amountOut, uint256 feesIn); 13 | 14 | function swapExactTokensForTokens( 15 | uint256 amountIn, 16 | uint256 amountOutMin, 17 | uint256[] memory pairBinSteps, 18 | address[] memory tokenPath, 19 | address to, 20 | uint256 deadline 21 | ) external returns (uint256 amountOut); 22 | } 23 | -------------------------------------------------------------------------------- /src/contracts/interface/IMinimalSwapInfoPool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IBasePool.sol"; 5 | 6 | interface IMinimalSwapInfoPool is IBasePool { 7 | function onSwap( 8 | SwapRequest memory swapRequest, 9 | uint256 currentBalanceTokenIn, 10 | uint256 currentBalanceTokenOut 11 | ) external view returns (uint256 amount); 12 | } 13 | -------------------------------------------------------------------------------- /src/contracts/interface/IPlatypus.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IPlatypus { 5 | // Views 6 | function quotePotentialSwap( 7 | address fromToken, 8 | address totoken, 9 | uint256 fromAmount 10 | ) external view returns (uint256 potentialOutcome); // Second arg (haircut) is not used 11 | 12 | function getTokenAddresses() external view returns (address[] memory); 13 | 14 | function paused() external view returns (bool); 15 | 16 | // Modifiers 17 | function swap( 18 | address fromToken, 19 | address toToken, 20 | uint256 fromAmount, 21 | uint256 minAmountOut, 22 | address to, 23 | uint256 deadline 24 | ) external; 25 | 26 | function pause() external; 27 | 28 | function unpause() external; 29 | } 30 | -------------------------------------------------------------------------------- /src/contracts/interface/IPoolSwapStructs.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IVault.sol"; 5 | 6 | interface IPoolSwapStructs { 7 | struct SwapRequest { 8 | IVault.SwapKind kind; 9 | IERC20 tokenIn; 10 | IERC20 tokenOut; 11 | uint256 amount; 12 | bytes32 poolId; 13 | uint256 lastChangeBlock; 14 | address from; 15 | address to; 16 | bytes userData; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/contracts/interface/IReservoirPair.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | interface IReservoirPair { 5 | function token0() external returns (address); 6 | function token1() external returns (address); 7 | function swap(int256 aAmount, bool aExactIn, address aTo, bytes calldata aData) 8 | external 9 | returns (uint256 rAmountOut); 10 | } 11 | -------------------------------------------------------------------------------- /src/contracts/interface/IReservoirQuoter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | interface IQuoter { 5 | /// @dev aPath array of ERC20 tokens to swap into 6 | function getAmountsOut(uint256 aAmountIn, address[] calldata aPath, uint256[] calldata aCurveIds) 7 | external 8 | view 9 | returns (uint256[] memory rAmountsOut); 10 | } 11 | -------------------------------------------------------------------------------- /src/contracts/interface/ISAVAX.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IERC20.sol"; 5 | 6 | interface ISAVAX is IERC20 { 7 | function getSharesByPooledAvax(uint256) external view returns (uint256); 8 | 9 | function submit() external payable returns (uint256); 10 | 11 | function mintingPaused() external view returns (bool); 12 | 13 | function totalPooledAvax() external view returns (uint256); 14 | 15 | function totalPooledAvaxCap() external view returns (uint256); 16 | } 17 | -------------------------------------------------------------------------------- /src/contracts/interface/ISaddle.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IERC20.sol"; 5 | 6 | interface ISaddle { 7 | function getTokenIndex(address tokenAddress) external view returns (uint8); 8 | 9 | function getTokenBalance(uint8 index) external view returns (uint256); 10 | 11 | function getToken(uint8 index) external view returns (address); 12 | 13 | function getVirtualPrice() external view returns (uint256); 14 | 15 | function owner() external view returns (address); 16 | 17 | function paused() external view returns (bool); 18 | 19 | function calculateSwap( 20 | uint8 tokenIndexFrom, 21 | uint8 tokenIndexTo, 22 | uint256 dx 23 | ) external view returns (uint256); 24 | 25 | function unpause() external; 26 | 27 | function pause() external; 28 | 29 | function swap( 30 | uint8 tokenIndexFrom, 31 | uint8 tokenIndexTo, 32 | uint256 dx, 33 | uint256 minDy, 34 | uint256 deadline 35 | ) external returns (uint256); 36 | } 37 | -------------------------------------------------------------------------------- /src/contracts/interface/ISaddleMeta.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IERC20.sol"; 5 | 6 | struct SwapStorage { 7 | uint256 initialA; 8 | uint256 futureA; 9 | uint256 initialATime; 10 | uint256 futureATime; 11 | uint256 swapFee; 12 | uint256 adminFee; 13 | address lpToken; 14 | } 15 | 16 | interface ISaddleMeta { 17 | function getToken(uint8 index) external view returns (address); 18 | 19 | function getVirtualPrice() external view returns (uint256); 20 | 21 | function owner() external view returns (address); 22 | 23 | function paused() external view returns (bool); 24 | 25 | function calculateSwapUnderlying( 26 | uint8 tokenIndexFrom, 27 | uint8 tokenIndexTo, 28 | uint256 dx 29 | ) external view returns (uint256); 30 | 31 | function unpause() external; 32 | 33 | function pause() external; 34 | 35 | function swapUnderlying( 36 | uint8 tokenIndexFrom, 37 | uint8 tokenIndexTo, 38 | uint256 dx, 39 | uint256 minDy, 40 | uint256 deadline 41 | ) external returns (uint256); 42 | 43 | function metaSwapStorage() external returns (address); 44 | 45 | function swapStorage() external returns (SwapStorage memory); 46 | } 47 | -------------------------------------------------------------------------------- /src/contracts/interface/IStabilityFund.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IStabilityFund { 5 | function swap( 6 | address token0, 7 | uint256 amount, 8 | address token1 9 | ) external; 10 | 11 | function swapEnabled() external view returns (bool); 12 | 13 | function isStableToken(address) external view returns (bool); 14 | 15 | function isTokenDisabled(address) external view returns (bool); 16 | 17 | function getStableTokens() external view returns (address[] memory); 18 | 19 | function getStableTokensCount() external view returns (uint256); 20 | 21 | function swapFee() external view returns (uint256); 22 | } 23 | -------------------------------------------------------------------------------- /src/contracts/interface/ITMFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | interface ITMFactory { 5 | function getMarket(address tokenA, address tokenB) external view returns (bool tokenAisBase, address market); 6 | } 7 | -------------------------------------------------------------------------------- /src/contracts/interface/ITMMarket.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0-only 2 | pragma solidity ^0.8.0; 3 | 4 | interface ITMMarket { 5 | function getFactory() external pure returns (address); 6 | 7 | function getBaseToken() external pure returns (address); 8 | 9 | function getQuoteToken() external pure returns (address); 10 | 11 | function getDeltaAmounts(int256 deltaAmount, bool swapB2Q) 12 | external 13 | view 14 | returns (int256 deltaBaseAmount, int256 deltaQuoteAmount, uint256 quoteFees); 15 | 16 | function swap(address recipient, int256 deltaAmount, bool swapB2Q, bytes calldata data, address referrer) 17 | external 18 | returns (int256 deltaBaseAmount, int256 deltaQuoteAmount); 19 | } 20 | -------------------------------------------------------------------------------- /src/contracts/interface/IUniswapFactory.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IUniswapFactory { 5 | function getPair(address tokenA, address tokenB) external view returns (address pair); 6 | } 7 | -------------------------------------------------------------------------------- /src/contracts/interface/IUniswapPair.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IUniswapPair { 5 | event Swap( 6 | address indexed sender, 7 | uint256 amount0In, 8 | uint256 amount1In, 9 | uint256 amount0Out, 10 | uint256 amount1Out, 11 | address indexed to 12 | ); 13 | 14 | function factory() external view returns (address); 15 | 16 | function token0() external view returns (address); 17 | 18 | function token1() external view returns (address); 19 | 20 | function getReserves() 21 | external 22 | view 23 | returns ( 24 | uint112 reserve0, 25 | uint112 reserve1, 26 | uint32 blockTimestampLast 27 | ); 28 | 29 | function swap( 30 | uint256 amount0Out, 31 | uint256 amount1Out, 32 | address to, 33 | bytes calldata data 34 | ) external; 35 | } 36 | -------------------------------------------------------------------------------- /src/contracts/interface/IVault.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IERC20.sol"; 5 | 6 | interface IVault { 7 | enum SwapKind { 8 | GIVEN_IN, 9 | GIVEN_OUT 10 | } 11 | 12 | struct SingleSwap { 13 | bytes32 poolId; 14 | SwapKind kind; 15 | address assetIn; 16 | address assetOut; 17 | uint256 amount; 18 | bytes userData; 19 | } 20 | 21 | struct FundManagement { 22 | address sender; 23 | bool fromInternalBalance; 24 | address payable recipient; 25 | bool toInternalBalance; 26 | } 27 | 28 | function swap( 29 | SingleSwap memory singleSwap, 30 | FundManagement memory funds, 31 | uint256 limit, 32 | uint256 deadline 33 | ) external payable returns (uint256); 34 | 35 | function getPoolTokens(bytes32 poolId) 36 | external 37 | view 38 | returns ( 39 | IERC20[] memory tokens, 40 | uint256[] memory balances, 41 | uint256 lastChangeBlock 42 | ); 43 | 44 | struct BatchSwapStep { 45 | bytes32 poolId; 46 | uint256 assetInIndex; 47 | uint256 assetOutIndex; 48 | uint256 amount; 49 | bytes userData; 50 | } 51 | 52 | function queryBatchSwap( 53 | SwapKind kind, 54 | BatchSwapStep[] memory swaps, 55 | address[] memory assets, 56 | FundManagement memory funds 57 | ) external returns (int256[] memory assetDeltas); 58 | } 59 | -------------------------------------------------------------------------------- /src/contracts/interface/IWETH.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IERC20.sol"; 5 | 6 | interface IWETH is IERC20 { 7 | function withdraw(uint256 amount) external; 8 | 9 | function deposit() external payable; 10 | } 11 | -------------------------------------------------------------------------------- /src/contracts/interface/IWombat.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IWombat { 5 | // Views 6 | function quotePotentialSwap( 7 | address fromToken, 8 | address totoken, 9 | int256 fromAmount 10 | ) external view returns (uint256 potentialOutcome); // Second arg (haircut) is not used 11 | 12 | function getTokens() external view returns (address[] memory); 13 | 14 | function paused() external view returns (bool); 15 | 16 | // Modifiers 17 | function swap( 18 | address fromToken, 19 | address toToken, 20 | uint256 fromAmount, 21 | uint256 minAmountOut, 22 | address to, 23 | uint256 deadline 24 | ) external; 25 | 26 | function pause() external; 27 | 28 | function unpause() external; 29 | } 30 | -------------------------------------------------------------------------------- /src/contracts/interface/IWooPP.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IWooPP { 5 | function quoteToken() external view returns (address); 6 | 7 | function querySellQuote(address, uint256) external view returns (uint256); 8 | 9 | function querySellBase(address, uint256) external view returns (uint256); 10 | 11 | function sellBase( 12 | address baseToken, 13 | uint256 baseAmount, 14 | uint256 minQuoteAmount, 15 | address to, 16 | address rebateTo 17 | ) external returns (uint256 quoteAmount); 18 | 19 | function sellQuote( 20 | address baseToken, 21 | uint256 quoteAmount, 22 | uint256 minBaseAmount, 23 | address to, 24 | address rebateTo 25 | ) external returns (uint256 baseAmount); 26 | } 27 | -------------------------------------------------------------------------------- /src/contracts/interface/IWooPPV2.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IWooPPV2 { 5 | /// @notice The quote token address (immutable). 6 | /// @return address of quote token 7 | function quoteToken() external view returns (address); 8 | 9 | /// @notice Gets the pool size of the specified token (swap liquidity). 10 | /// @param token the token address 11 | /// @return the pool size 12 | function poolSize(address token) external view returns (uint256); 13 | 14 | /// @notice Query the amount to swap `fromToken` to `toToken`, without checking the pool reserve balance. 15 | /// @param fromToken the from token 16 | /// @param toToken the to token 17 | /// @param fromAmount the amount of `fromToken` to swap 18 | /// @return toAmount the swapped amount of `toToken` 19 | function tryQuery( 20 | address fromToken, 21 | address toToken, 22 | uint256 fromAmount 23 | ) external view returns (uint256 toAmount); 24 | 25 | /// @notice Query the amount to swap `fromToken` to `toToken`, with checking the pool reserve balance. 26 | /// @dev tx reverts when 'toToken' balance is insufficient. 27 | /// @param fromToken the from token 28 | /// @param toToken the to token 29 | /// @param fromAmount the amount of `fromToken` to swap 30 | /// @return toAmount the swapped amount of `toToken` 31 | function query( 32 | address fromToken, 33 | address toToken, 34 | uint256 fromAmount 35 | ) external view returns (uint256 toAmount); 36 | 37 | /// @notice Swap `fromToken` to `toToken`. 38 | /// @param fromToken the from token 39 | /// @param toToken the to token 40 | /// @param fromAmount the amount of `fromToken` to swap 41 | /// @param minToAmount the minimum amount of `toToken` to receive 42 | /// @param to the destination address 43 | /// @param rebateTo the rebate address (optional, can be address ZERO) 44 | /// @return realToAmount the amount of toToken to receive 45 | function swap( 46 | address fromToken, 47 | address toToken, 48 | uint256 fromAmount, 49 | uint256 minToAmount, 50 | address to, 51 | address rebateTo 52 | ) external returns (uint256 realToAmount); 53 | 54 | /// @notice Deposit the specified token into the liquidity pool of WooPPV2. 55 | /// @param token the token to deposit 56 | /// @param amount the deposit amount 57 | function deposit(address token, uint256 amount) external; 58 | } 59 | -------------------------------------------------------------------------------- /src/contracts/interface/IWooRouter.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | pragma experimental ABIEncoderV2; 4 | 5 | interface IWooRouter { 6 | function querySwap( 7 | address fromToken, 8 | address toToken, 9 | uint256 fromAmount 10 | ) external view returns (uint256 toAmount); 11 | 12 | function swap( 13 | address fromToken, 14 | address toToken, 15 | uint256 fromAmount, 16 | uint256 minToAmount, 17 | address payable to, 18 | address rebateTo 19 | ) external payable returns (uint256 realToAmount); 20 | } 21 | -------------------------------------------------------------------------------- /src/contracts/interface/IWrapper.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IAdapter.sol"; 5 | 6 | interface IWrapper is IAdapter { 7 | function getTokensIn() external view returns (address[] memory); 8 | function getTokensOut() external view returns (address[] memory); 9 | function getWrappedToken() external view returns (address); 10 | function isWhitelisted(address token) external view returns (bool); 11 | } 12 | -------------------------------------------------------------------------------- /src/contracts/interface/IYYDerivative.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IYYDerivative { 5 | function deposit(uint256 amount) external; 6 | 7 | function depositsEnabled() external view returns (bool); 8 | } 9 | -------------------------------------------------------------------------------- /src/contracts/interface/IgAVAX.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | // @note: operator stands for interface address 5 | interface IgAVAX { 6 | function setApprovalForAll(address operator, bool approved) external; 7 | 8 | function pricePerShare(uint256 _id) external view returns (uint256); 9 | 10 | function balanceOf(address account, uint256 id) external view returns (uint256); 11 | 12 | function isInterface(address operator, uint256 id) external view returns (bool); 13 | 14 | function isApprovedForAll(address account, address operator) external view returns (bool); 15 | } 16 | -------------------------------------------------------------------------------- /src/contracts/interface/ImYAK.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "./IERC20.sol"; 5 | 6 | interface ImYAK is IERC20 { 7 | function unmoon(uint256, address) external; 8 | 9 | function moon(uint256, address) external; 10 | } 11 | -------------------------------------------------------------------------------- /src/contracts/interface/IxJOE.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IxJOE { 5 | function leave(uint256) external; 6 | 7 | function enter(uint256) external; 8 | 9 | function totalSupply() external view returns (uint256); 10 | } 11 | -------------------------------------------------------------------------------- /src/contracts/lib/Maintainable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "@openzeppelin/contracts/access/AccessControl.sol"; 6 | 7 | /** 8 | * @dev Contract module which extends the basic access control mechanism of Ownable 9 | * to include many maintainers, whom only the owner (DEFAULT_ADMIN_ROLE) may add and 10 | * remove. 11 | * 12 | * By default, the owner account will be the one that deploys the contract. This can 13 | * later be changed with {transferOwnership}. 14 | * 15 | * This module is used through inheritance. It will make available this modifier: 16 | * `onlyMaintainer`, which can be applied to your functions to restrict their use to 17 | * the accounts with the role of maintainer. 18 | */ 19 | 20 | abstract contract Maintainable is Context, AccessControl { 21 | bytes32 public constant MAINTAINER_ROLE = keccak256("MAINTAINER_ROLE"); 22 | 23 | constructor() { 24 | address msgSender = _msgSender(); 25 | // members of the DEFAULT_ADMIN_ROLE alone may revoke and grant role membership 26 | _setupRole(DEFAULT_ADMIN_ROLE, msgSender); 27 | _setupRole(MAINTAINER_ROLE, msgSender); 28 | } 29 | 30 | function addMaintainer(address addedMaintainer) public virtual { 31 | grantRole(MAINTAINER_ROLE, addedMaintainer); 32 | } 33 | 34 | function removeMaintainer(address removedMaintainer) public virtual { 35 | revokeRole(MAINTAINER_ROLE, removedMaintainer); 36 | } 37 | 38 | function renounceRole(bytes32 role) public virtual { 39 | address msgSender = _msgSender(); 40 | renounceRole(role, msgSender); 41 | } 42 | 43 | function transferOwnership(address newOwner) public virtual { 44 | address msgSender = _msgSender(); 45 | grantRole(DEFAULT_ADMIN_ROLE, newOwner); 46 | renounceRole(DEFAULT_ADMIN_ROLE, msgSender); 47 | } 48 | 49 | modifier onlyMaintainer() { 50 | address msgSender = _msgSender(); 51 | require(hasRole(MAINTAINER_ROLE, msgSender), "Maintainable: Caller is not a maintainer"); 52 | _; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/contracts/lib/Recoverable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.8.0; 3 | 4 | import "./SafeERC20.sol"; 5 | import "./Maintainable.sol"; 6 | 7 | 8 | abstract contract Recoverable is Maintainable { 9 | using SafeERC20 for IERC20; 10 | 11 | event Recovered( 12 | address indexed _asset, 13 | uint amount 14 | ); 15 | 16 | /** 17 | * @notice Recover ERC20 from contract 18 | * @param _tokenAddress token address 19 | * @param _tokenAmount amount to recover 20 | */ 21 | function recoverERC20(address _tokenAddress, uint _tokenAmount) external onlyMaintainer { 22 | require(_tokenAmount > 0, "Nothing to recover"); 23 | IERC20(_tokenAddress).safeTransfer(msg.sender, _tokenAmount); 24 | emit Recovered(_tokenAddress, _tokenAmount); 25 | } 26 | 27 | /** 28 | * @notice Recover native asset from contract 29 | * @param _amount amount 30 | */ 31 | function recoverNative(uint _amount) external onlyMaintainer { 32 | require(_amount > 0, "Nothing to recover"); 33 | payable(msg.sender).transfer(_amount); 34 | emit Recovered(address(0), _amount); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /src/contracts/test/DummyMaintainable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | import "../lib/Maintainable.sol"; 5 | 6 | contract DummyMaintainable is Maintainable { 7 | function onlyMaintainerFunction() public onlyMaintainer {} 8 | } 9 | -------------------------------------------------------------------------------- /src/contracts/test/NTInjector.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | // Inject native-token into contract without fallback function 5 | contract NTInjector { 6 | constructor(address payable _reciever) payable { 7 | selfdestruct(_reciever); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/contracts/test/TestToken.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 6 | 7 | contract TestToken is ERC20 { 8 | bytes32 public DOMAIN_SEPARATOR; 9 | // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); 10 | bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; 11 | mapping(address => uint256) public nonces; 12 | 13 | constructor(string memory _tokenName, string memory _tokenSymbol) ERC20(_tokenName, _tokenSymbol) { 14 | uint256 chainId; 15 | assembly { 16 | chainId := chainid() 17 | } 18 | DOMAIN_SEPARATOR = keccak256( 19 | abi.encode( 20 | keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), 21 | keccak256(bytes(_tokenName)), 22 | keccak256(bytes("1")), 23 | chainId, 24 | address(this) 25 | ) 26 | ); 27 | } 28 | 29 | function mint(address _to, uint256 _amount) public { 30 | _mint(_to, _amount); 31 | } 32 | 33 | function burnFrom(address _from, uint256 _amount) public {} 34 | 35 | function permit( 36 | address owner, 37 | address spender, 38 | uint256 value, 39 | uint256 deadline, 40 | uint8 v, 41 | bytes32 r, 42 | bytes32 s 43 | ) external { 44 | require(deadline >= block.timestamp, "Pangolin: EXPIRED"); 45 | bytes32 digest = keccak256( 46 | abi.encodePacked( 47 | "\x19\x01", 48 | DOMAIN_SEPARATOR, 49 | keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) 50 | ) 51 | ); 52 | address recoveredAddress = ecrecover(digest, v, r, s); 53 | require(recoveredAddress != address(0) && recoveredAddress == owner, "Pangolin: INVALID_SIGNATURE"); 54 | _approve(owner, spender, value); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/aave/aaveUSDC.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require("../../../utils"); 2 | const { aArbUSDCn } = addresses.arbitrum.assets; 3 | 4 | const networkName = "arbitrum"; 5 | const tags = ["aave_usdc"]; 6 | const name = "AaveUSDCAdapter"; 7 | const contractName = "AaveAdapter"; 8 | 9 | const gasEstimate = 170_000; 10 | const args = [name, aArbUSDCn, gasEstimate]; 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args); 13 | -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/balancer/balancerV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const balancerV2 = addresses.arbitrum.balancerV2 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'balancerV2' ] 6 | const name = 'BalancerV2Adapter' 7 | const contractName = 'BalancerV2Adapter' 8 | 9 | const gasEstimate = 280_000 10 | const args = [ 11 | name, 12 | balancerV2.vault, 13 | Object.values(balancerV2.pools), 14 | gasEstimate 15 | ] 16 | 17 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/2pool.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { twostable } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', '2pool', 'twostable' ] 6 | const name = 'Curve2stableAdapter' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 260_000 10 | const pool = twostable 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/3poolV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { tricrypto } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', '3crypto', 'tricrypto' ] 6 | const name = 'Curve3cryptoAdapter' 7 | const contractName = 'CurvePlain256Adapter' 8 | 9 | const gasEstimate = 660_000 10 | const pool = tricrypto 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/crvusd_frax.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { crvusd_frax } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', 'crvusd_frax'] 6 | const name = 'Curve2crvUsdFrax' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 320_000 10 | const pool = crvusd_frax 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/crvusd_usdc.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { crvusd_usdc } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', 'crvusd_usdc'] 6 | const name = 'Curve2crvUsdUsdc' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 320_000 10 | const pool = crvusd_usdc 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/crvusd_usdce.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { crvusd_usdce } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', 'crvusd_usdce'] 6 | const name = 'Curve2crvUsdUsdce' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 320_000 10 | const pool = crvusd_usdce 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/crvusd_usdt.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { crvusd_usdt } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', 'crvusd_usdt'] 6 | const name = 'Curve2crvUsdUsdt' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 320_000 10 | const pool = crvusd_usdt 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/frax_bp.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { frax_bp } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', 'frax_bp' ] 6 | const name = 'CurveFraxBpAdapter' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 660_000 10 | const pool = frax_bp 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/meta.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { meta_mim } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', 'meta' ] 6 | const name = 'CurveMetaAdapter' 7 | const contractName = 'CurveMetaV3Adapter' 8 | 9 | const gasEstimate = 480_000 10 | const pools = [ meta_mim ] 11 | const args = [ name, pools, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/curve/vst_frax.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { vst_frax } = addresses.arbitrum.curve 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'curve', 'vst_frax' ] 6 | const name = 'CurveFraxVstAdapter' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 660_000 10 | const pool = vst_frax 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/dodo/dodoV1.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { helper, pools } = addresses.arbitrum.dodo.v1 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'dodov1' ] 6 | const name = 'DodoV1Adapter' 7 | const contractName = 'DodoV1Adapter' 8 | 9 | const gasEstimate = 335_000 10 | const args = [ name, Object.values(pools), helper, gasEstimate ] 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/dodo/dodoV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { pools } = addresses.arbitrum.dodo.v2 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'dodov2' ] 6 | const name = 'DodoV2Adapter' 7 | const contractName = 'DodoV2Adapter' 8 | 9 | const gasEstimate = 290_000 10 | const args = [ name, Object.values(pools), gasEstimate ] 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/gmx/gmx.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { vault } = addresses.arbitrum.gmx 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'gmx' ] 6 | const name = 'GmxAdapter' 7 | const contractName = 'GmxAdapter' 8 | 9 | const gasEstimate = 630_000 10 | const args = [ name, vault, gasEstimate ] 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/kyber/kyber.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { kyberPools } = addresses.arbitrum 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'kyber' ] 6 | const name = 'KyberAdapter' 7 | const contractName = 'KyberAdapter' 8 | 9 | const gasEstimate = 182_000 10 | const pools = [ kyberPools.mai_usdc ] 11 | const args = [ name, pools, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/kyber/kyberElastic.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { kyberElastic } = addresses.arbitrum 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'kyberElastic' ] 6 | const name = 'KyberElasticAdapter' 7 | const contractName = 'KyberElasticAdapter' 8 | 9 | const gasEstimate = 210_000 10 | const quoterGasLimit = gasEstimate 11 | const pools = Object.values(kyberElastic.pools) 12 | const args = [ name, gasEstimate, quoterGasLimit, kyberElastic.quoter, pools ] 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/liquidity-book/joe-lb-2-2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require("../../../utils"); 2 | const { liquidityBook } = addresses.arbitrum; 3 | 4 | const networkName = "arbitrum"; 5 | const tags = ["lb22"]; 6 | const name = "LiquidityBook2.2Adapter"; 7 | const contractName = "LB2Adapter"; 8 | 9 | const gasEstimate = 1_000_000; 10 | const quoteGasLimit = 600_000; 11 | const factory = liquidityBook.factoryV22; 12 | const args = [name, gasEstimate, quoteGasLimit, factory]; 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args); 15 | -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/liquidity-book/joe-lb-2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { liquidityBook } = addresses.arbitrum 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'liquidity-book', 'lb2' ] 6 | const name = 'LiquidityBook2Adapter' 7 | const contractName = 'LB2Adapter' 8 | 9 | const gasEstimate = 1_000_000 10 | const quoteGasLimit = 600_000 11 | const factory = liquidityBook.factoryV2 12 | const args = [ name, gasEstimate, quoteGasLimit, factory ] 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/liquidity-book/joe-lb.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { liquidityBook } = addresses.arbitrum 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'liquidity-book', 'joe-lb' ] 6 | const name = 'LiquidityBookAdapter' 7 | const contractName = 'LBAdapter' 8 | 9 | const gasEstimate = 535_345 10 | const args = [ name, gasEstimate, liquidityBook.routerV1 ] 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/pancake/pancakeV3.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factoryV3, quoter } = addresses.arbitrum.pancake 3 | 4 | const networkName = 'arbitrum' 5 | const contractName = 'PancakeV3Adapter' 6 | const tags = [ 'pancakeV3' ] 7 | const name = 'PancakeV3Adapter' 8 | const gasEstimate = 385_000 9 | const quoterGasLimit = gasEstimate - 60_000 10 | const defaultFees = [100, 500, 2500, 10_000] 11 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factoryV3, defaultFees ] 12 | 13 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/ramses/ramses.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory, quoter } = addresses.arbitrum.ramses 3 | 4 | const networkName = 'arbitrum' 5 | const contractName = 'RamsesV2Adapter' 6 | const tags = [ 'ramses' ] 7 | const name = 'RamsesAdapter' 8 | const gasEstimate = 400_000 9 | const quoterGasLimit = gasEstimate - 60_000 10 | const defaultFees = [50, 100, 250, 500, 3_000, 10_000] 11 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory, defaultFees ] 12 | 13 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/saddle/arbusd.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { arbusd } = addresses.arbitrum.saddle 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'saddle', 'arbusd' ] 6 | const name = 'SaddleArbUsdAdapter' 7 | const contractName = 'SaddleAdapter' 8 | 9 | const gasEstimate = 330_000 10 | const pool = arbusd 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/saddle/arbusdV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { arbusdV2 } = addresses.arbitrum.saddle 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'saddle', 'arbusdV2' ] 6 | const name = 'SaddleArbUsdV2Adapter' 7 | const contractName = 'SaddleAdapter' 8 | 9 | const gasEstimate = 310_000 10 | const pool = arbusdV2 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/saddle/meta_arbusdV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { meta_arbusdV2 } = addresses.arbitrum.saddle 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'saddle', 'meta_arbusdV2' ] 6 | const name = 'SaddleMetaArbUsdV2Adapter' 7 | const contractName = 'SaddleMetaAdapter' 8 | 9 | const gasEstimate = 625_000 10 | const pool = meta_arbusdV2 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/uniswapV2/camelot.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory } = addresses.arbitrum.camelot 3 | 4 | const networkName = 'arbitrum' 5 | const contractName = 'CamelotAdapter' 6 | const tags = [ 'camelot' ] 7 | const name = contractName 8 | const gasEstimate = 238_412 9 | const args = [ name, factory, gasEstimate ] 10 | 11 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/uniswapV2/oreoswap.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { factory } = addresses.arbitrum.oreoswap 3 | 4 | const networkName = 'arbitrum' 5 | const name = 'OreoswapAdapter' 6 | const tags = [ 'oreoswap' ] 7 | const fee = 3 8 | 9 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/uniswapV2/sushiswap.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { factory } = addresses.arbitrum.sushiswap 3 | 4 | const networkName = 'arbitrum' 5 | const name = 'SushiswapAdapter' 6 | const tags = [ 'sushiswap' ] 7 | const fee = 3 8 | 9 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/uniswapV2/swapfish.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { factory } = addresses.arbitrum.swapfish 3 | 4 | const networkName = 'arbitrum' 5 | const name = 'SwapfishAdapter' 6 | const tags = [ 'swapfish' ] 7 | const fee = 3 8 | 9 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/uniswapV2/swapr.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory } = addresses.arbitrum.swapr 3 | 4 | const networkName = 'arbitrum' 5 | const name = 'SwaprAdapter' 6 | const contractName = 'DxSwapAdapter' 7 | const tags = [ 'swapr', 'dxswap' ] 8 | const gasEstimate = 180_000 9 | const args = [ name, factory, gasEstimate ] 10 | 11 | module.exports = deployAdapter(networkName, tags, name, contractName, args) 12 | -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/uniswapV3/arbidex.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory, quoter } = addresses.arbitrum.arbidex 3 | 4 | const networkName = 'arbitrum' 5 | const contractName = 'UniswapV3Adapter' 6 | const tags = [ 'arbidex' ] 7 | const name = "ArbiDexAdapter" 8 | const gasEstimate = 300_000 9 | const quoterGasLimit = 300_000 10 | const defaultFees = [80, 450, 2_500, 10_000] 11 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory, defaultFees ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/uniswapV3/camelot.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { camelot, other } = addresses.arbitrum 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'camelot_algebra' ] 6 | const name = 'CamelotAlgebraAdapter' 7 | const contractName = 'AlgebraAdapter' 8 | 9 | const gasEstimate = 250_000 10 | const quoterGasLimit = gasEstimate 11 | const factory = camelot.algebraFactory 12 | const quoter = other.algebraQuoter 13 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory ] 14 | 15 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/uniswapV3/uniV3.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require("../../../utils"); 2 | const { factory, quoter } = addresses.arbitrum.uniV3; 3 | 4 | const networkName = "arbitrum"; 5 | const contractName = "UniswapV3Adapter"; 6 | const tags = ["uniswapV3"]; 7 | const name = contractName; 8 | const gasEstimate = 300_000; 9 | const quoterGasLimit = 300_000; 10 | const defaultFees = [100, 500, 3_000, 10_000]; 11 | const args = [name, gasEstimate, quoterGasLimit, quoter, factory, defaultFees]; 12 | 13 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args); 14 | -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/weth.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../utils') 2 | const { WETH } = addresses.arbitrum.assets 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'weth' ] 6 | const name = 'WETHAdapter' 7 | const contractName = 'WNativeAdapter' 8 | 9 | const gasEstimate = 80_000 10 | const wnative = WETH 11 | const args = [ wnative, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/wombat/wombat.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require("../../../utils"); 2 | const { wombat } = addresses.arbitrum; 3 | 4 | const networkName = "arbitrum"; 5 | const tags = ["wombat"]; 6 | const name = "WombatAdapter"; 7 | const contractName = "WombatAdapter"; 8 | 9 | const gasEstimate = 280_000; 10 | const pools = [wombat.main, wombat.frax_sfrax_usdc, wombat.frax_usdv, wombat.frxETH, wombat.fusdc, wombat.mpendle_pendle]; 11 | const args = [name, gasEstimate, pools]; 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args); 14 | -------------------------------------------------------------------------------- /src/deploy/arbitrum/adapters/woofi/woofiV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { woofiV2Pool } = addresses.arbitrum.other 3 | 4 | const networkName = 'arbitrum' 5 | const tags = [ 'woofiV2' ] 6 | const name = 'WoofiV2Adapter' 7 | const contractName = 'WoofiV2Adapter' 8 | 9 | const gasEstimate = 410_000 10 | const pool = woofiV2Pool 11 | const args = [ name, gasEstimate, pool, ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/arbitrum/routers/yakWrapRouter.js: -------------------------------------------------------------------------------- 1 | const { deployYakWrapRouterAlt } = require("../../utils"); 2 | 3 | const networkName = "arbitrum"; 4 | module.exports = deployYakWrapRouterAlt(networkName, "YakRouter"); 5 | -------------------------------------------------------------------------------- /src/deploy/arbitrum/routers/yakrouter.js: -------------------------------------------------------------------------------- 1 | const { deployRouter } = require('../../utils') 2 | 3 | const networkName = 'arbitrum' 4 | module.exports = deployRouter(networkName) -------------------------------------------------------------------------------- /src/deploy/arbitrum/wrappers/glpWrapper.js: -------------------------------------------------------------------------------- 1 | const { deployWrapper, addresses } = require("../../utils"); 2 | const { rewardRouter } = addresses.arbitrum.gmx; 3 | const { GLP, sGLP } = addresses.arbitrum.assets; 4 | const { WETH, WBTC, LINK, UNI, USDCe, USDC, USDT, DAI, FRAX } = addresses.arbitrum.assets; 5 | 6 | const networkName = "arbitrum"; 7 | const tags = ["gmx"]; 8 | const name = "GlpWrapper"; 9 | const contractName = "GlpWrapperFeeSelection"; 10 | 11 | const whiteListedTokens = [WETH, WBTC, LINK, UNI, USDCe, USDC, USDT, DAI, FRAX]; 12 | 13 | const gasEstimate = 1_600_000; 14 | const args = [name, gasEstimate, rewardRouter, whiteListedTokens, 10_000, 3, GLP, sGLP]; 15 | 16 | module.exports = deployWrapper(networkName, tags, name, contractName, args); 17 | -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/arable/arable.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { ArableSF } = addresses.avalanche.other 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'arable' ] 6 | const name = 'ArableAdapter' 7 | const contractName = 'ArableSFAdapter' 8 | 9 | const gasEstimate = 235_000 10 | const vault = ArableSF 11 | const args = [ name, vault, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/axial/AM3D.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { AxialAM3D } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'axial', 'axialAM3D' ] 6 | const name = 'AxialAM3DAdapter' 7 | const contractName = 'SaddleAdapter' 8 | 9 | const gasEstimate = 320_000 10 | const pool = AxialAM3D 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/axial/AS4D.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { AxialAS4D } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'axial', 'axialAS4D' ] 6 | const name = 'AxialAS4DAdapter' 7 | const contractName = 'SaddleAdapter' 8 | 9 | const gasEstimate = 330_000 10 | const pool = AxialAS4D 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/3poolV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { Curve3poolV2 } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'curve', 'curve3poolV2' ] 6 | const name = 'Curve3poolV2Adapter' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 250_000 10 | const pool = Curve3poolV2 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/3poolf.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { Curve3poolf } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'curve', 'curve3poolf' ] 6 | const name = 'Curve3poolfAdapter' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 250_000 10 | const pool = Curve3poolf 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/aave.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { CurveAave } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'curve', 'curveAave' ] 6 | const name = 'CurveAaveAdapter' 7 | const contractName = 'Curve2Adapter' 8 | 9 | const gasEstimate = 770_000 10 | const pool = CurveAave 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/atricrypto.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require("../../../utils"); 2 | const { CurveAtricrypto } = addresses.avalanche.curvelikePools; 3 | const { WBTCe } = addresses.avalanche.assets; 4 | 5 | const networkName = "avalanche"; 6 | const tags = ["curve", "curveAtricrypto"]; 7 | const name = "CurveAtricryptoAdapter"; 8 | const contractName = "Curve1Adapter"; 9 | 10 | const gasEstimate = 1_500_000; 11 | const pool = CurveAtricrypto; 12 | const blacklist = [WBTCe]; 13 | const args = [name, pool, blacklist, gasEstimate]; 14 | 15 | module.exports = deployAdapter(networkName, tags, name, contractName, args); 16 | -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/deusdc.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { CurveDeUSDC, CurveAave } = addresses.avalanche.curvelikePools 3 | const { curveMetaSwapper } = addresses.avalanche.other 4 | 5 | const networkName = 'avalanche' 6 | const tags = [ 'curve', 'curveDeUSDC' ] 7 | const name = 'CurveDeUSDCAdapter' 8 | const contractName = 'CurveMetaWithSwapperAdapter' 9 | 10 | const metaPool = CurveDeUSDC 11 | const basePool = CurveAave 12 | const swapper = curveMetaSwapper 13 | const gasEstimate = 1_100_000 14 | const args = [ name, gasEstimate, metaPool, basePool, swapper ] 15 | 16 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/mim.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { CurveMim, CurveAave } = addresses.avalanche.curvelikePools 3 | const { curveMetaSwapper } = addresses.avalanche.other 4 | 5 | const networkName = 'avalanche' 6 | const tags = [ 'curve', 'curveMim' ] 7 | const name = 'CurveMimAdapter' 8 | const contractName = 'CurveMetaWithSwapperAdapter' 9 | 10 | const metaPool = CurveMim 11 | const basePool = CurveAave 12 | const swapper = curveMetaSwapper 13 | const gasEstimate = 1_100_000 14 | const args = [ name, gasEstimate, metaPool, basePool, swapper ] 15 | 16 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/more.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { CurveMore, CurveAave } = addresses.avalanche.curvelikePools 3 | const { curveMetaSwapper } = addresses.avalanche.other 4 | 5 | const networkName = 'avalanche' 6 | const tags = [ 'curve', 'curveMore' ] 7 | const name = 'CurveMoreAdapter' 8 | const contractName = 'CurveMetaWithSwapperAdapter' 9 | 10 | const metaPool = CurveMore 11 | const basePool = CurveAave 12 | const swapper = curveMetaSwapper 13 | const gasEstimate = 1_100_000 14 | const args = [ name, gasEstimate, metaPool, basePool, swapper ] 15 | 16 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/ren.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { CurveRen } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'curve', 'curveRen' ] 6 | const name = 'CurveRenAdapter' 7 | const contractName = 'Curve2Adapter' 8 | 9 | const pool = CurveRen 10 | const gasEstimate = 500_000 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/usdc.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { CurveUSDC } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'curve', 'curveUsdc' ] 6 | const name = 'CurveUSDCAdapter' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const pool = CurveUSDC 10 | const gasEstimate = 240_000 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/curve/yusd.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { CurveYUSD } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'curve', 'curveYUSD' ] 6 | const name = 'CurveYUSDAdapter' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const pool = CurveYUSD 10 | const gasEstimate = 280_000 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/geode/WPyyAvax.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses, constants } = require('../../../utils') 2 | const { GeodePortal } = addresses.avalanche.other 3 | const { yyPlanet } = constants.geode 4 | 5 | const networkName = 'avalanche' 6 | const tags = [ 'geode' ] 7 | const name = 'GeodeWPAdapter' 8 | const contractName = 'GeodeWPAdapter' 9 | 10 | const gasEstimate = 340_000 11 | const portal = GeodePortal 12 | const planetId = yyPlanet 13 | const args = [ name, portal, planetId, gasEstimate ] 14 | 15 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/glacier/glacier.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { GlacierFactory: factory } = addresses.avalanche.other 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'glacier' ] 6 | const name = 'GlacierAdapter' 7 | const contractName = 'VelodromeAdapter' 8 | 9 | const gasEstimate = 280_000 10 | const args = [ name, factory, gasEstimate ] 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/gmx/gmx.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { GmxVault } = addresses.avalanche.other 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'gmx' ] 6 | const name = 'GmxAdapter' 7 | const contractName = 'GmxAdapter' 8 | 9 | const gasEstimate = 630_000 10 | const vault = GmxVault 11 | const args = [ name, vault, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/kyber/kyber.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { kyberPools } = addresses.avalanche 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'kyber' ] 6 | const name = 'KyberAdapter' 7 | const contractName = 'KyberAdapter' 8 | 9 | const gasEstimate = 182_000 10 | const pools = [ kyberPools.USDTeUSDCe ] 11 | const args = [ name, pools, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/kyber/kyberElastic.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { kyberElastic } = addresses.avalanche 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'kyberElastic' ] 6 | const name = 'KyberElasticAdapter' 7 | const contractName = 'KyberElasticAdapter' 8 | 9 | const gasEstimate = 210_000 10 | const quoterGasLimit = gasEstimate 11 | const pools = Object.values(kyberElastic.pools) 12 | const args = [ name, gasEstimate, quoterGasLimit, kyberElastic.quoter, pools ] 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/liquidity-book/joe-lb-2-2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require("../../../utils"); 2 | const { liquidityBook } = addresses.avalanche; 3 | 4 | const networkName = "avalanche"; 5 | const tags = ["lb22"]; 6 | const name = "LiquidityBook2.2Adapter"; 7 | const contractName = "LB2Adapter"; 8 | 9 | const gasEstimate = 1_000_000; 10 | const quoteGasLimit = 600_000; 11 | const factory = liquidityBook.factoryV22; 12 | const args = [name, gasEstimate, quoteGasLimit, factory]; 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args); 15 | -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/liquidity-book/joe-lb-2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { liquidityBook } = addresses.avalanche 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'liquidity-book', 'lb2' ] 6 | const name = 'LiquidityBook2Adapter' 7 | const contractName = 'LB2Adapter' 8 | 9 | const gasEstimate = 1_000_000 10 | const quoteGasLimit = 600_000 11 | const factory = liquidityBook.factoryV2 12 | const args = [ name, gasEstimate, quoteGasLimit, factory ] 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/liquidity-book/joe-lb.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { liquidityBook } = addresses.avalanche 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'liquidity-book', 'joe-lb' ] 6 | const name = 'LiquidityBookAdapter' 7 | const contractName = 'LBAdapter' 8 | 9 | const gasEstimate = 535_345 10 | const router = liquidityBook.routerV1 11 | const args = [ name, gasEstimate, router ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/other/ggavax.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter } = require('../../../utils') 2 | 3 | const networkName = 'avalanche' 4 | const tags = [ 'ggavax' ] 5 | const name = 'GGAvaxAdapter' 6 | const contractName = 'GGAvaxAdapter' 7 | 8 | const gasEstimate = 180_000 9 | const args = [ gasEstimate ] 10 | 11 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/other/miniYak.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter } = require('../../../utils') 2 | 3 | const networkName = 'avalanche' 4 | const tags = [ 'miniyak' ] 5 | const name = 'MiniYakAdapter' 6 | const contractName = 'MiniYakAdapter' 7 | 8 | const gasEstimate = 82_000 9 | const args = [ gasEstimate ] 10 | 11 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/other/savax.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter } = require('../../../utils') 2 | 3 | const networkName = 'avalanche' 4 | const tags = [ 'savax' ] 5 | const name = 'SAvaxAdapter' 6 | const contractName = 'SAvaxAdapter' 7 | 8 | const gasEstimate = 170_000 9 | const args = [ gasEstimate ] 10 | 11 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/other/wavax.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter } = require('../../../utils') 2 | 3 | const networkName = 'avalanche' 4 | const tags = [ 'wavax' ] 5 | const name = 'WAvaxAdapter' 6 | const contractName = 'WAvaxAdapter' 7 | 8 | const gasEstimate = 1 9 | const args = [ gasEstimate ] 10 | 11 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/other/xjoe.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter } = require('../../../utils') 2 | 3 | const networkName = 'avalanche' 4 | const tags = [ 'xjoe' ] 5 | const name = 'XJoeAdapter' 6 | const contractName = 'XJoeAdapter' 7 | 8 | const gasEstimate = 150_000 9 | const args = [ gasEstimate ] 10 | 11 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/pharaoh/pharaoh.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory, quoter } = addresses.avalanche.pharaoh 3 | 4 | const networkName = 'avalanche' 5 | const contractName = 'RamsesV2Adapter' 6 | const tags = [ 'pharaoh' ] 7 | const name = 'PharaohAdapter' 8 | const gasEstimate = 300_000 9 | const quoterGasLimit = gasEstimate - 60_000 10 | const defaultFees = [50, 100, 250, 500, 3_000, 10_000] 11 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory, defaultFees ] 12 | 13 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/platypus/router.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { platypus } = addresses.avalanche 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'platypus' ] 6 | const name = 'PlatypusAdapter' 7 | const contractName = 'PlatypusAdapter' 8 | 9 | const gasEstimate = 470_000 10 | const pools = [ 11 | platypus.main, 12 | platypus.frax, 13 | platypus.mim, 14 | platypus.savax, 15 | platypus.btc, 16 | platypus.yusd, 17 | platypus.h20, 18 | platypus.money, 19 | platypus.tsd, 20 | ] 21 | const args = [ name, gasEstimate, pools ] 22 | 23 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/poolside/poolside.js: -------------------------------------------------------------------------------- 1 | const {deployAdapter, addresses} = require('../../../utils') 2 | const {ButtonTokenFactory, PoolsideV1Factory} = addresses.avalanche.other 3 | 4 | const networkName = 'avalanche' 5 | const tags = ['poolside'] 6 | const name = 'PoolsideV1Adapter' 7 | const contractName = 'PoolsideV1Adapter' 8 | 9 | const gasEstimate = 415_000 10 | const _buttonswapFactory = PoolsideV1Factory 11 | const _buttonTokenFactory = ButtonTokenFactory 12 | const args = [name, _buttonswapFactory, _buttonTokenFactory, gasEstimate] 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args) 15 | -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/reservoir/reservoir.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory, quoter } = addresses.avalanche.reservoir 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'reservoir', 'stableswap' ] 6 | const name = 'ReservoirAdapter' 7 | const contractName = 'ReservoirAdapter' 8 | 9 | const gasEstimate = 350_000 10 | const args = [ name, factory, quoter, gasEstimate ] 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args) 13 | -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/solisnek/solisnek.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { SolisnekFactory: factory } = addresses.avalanche.other 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'solisnek' ] 6 | const name = 'SolisnekAdapter' 7 | const contractName = 'VelodromeAdapter' 8 | 9 | const gasEstimate = 400_000 10 | const args = [ name, factory, gasEstimate ] 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/synapse/synapse.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { SynapseDAIeUSDCeUSDTeNUSD } = addresses.avalanche.curvelikePools 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'synapse' ] 6 | const name = 'SynapseAdapter' 7 | const contractName = 'SaddleAdapter' 8 | 9 | const gasEstimate = 320_000 10 | const pool = SynapseDAIeUSDCeUSDTeNUSD 11 | const args = [ name, pool, gasEstimate, ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/tokenmill/tokenmill.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { other } = addresses.avalanche 3 | 4 | const networkName = 'avalanche' 5 | const contractName = 'TokenMillAdapter' 6 | const name = 'TokenMillAdapter' 7 | const referrer = '0xDcEDF06Fd33E1D7b6eb4b309f779a0e9D3172e44' 8 | const tags = [ 'tokenmill' ] 9 | 10 | const gasEstimate = 210_000; 11 | const factory = other.TokenMillFactory 12 | const args = [name,factory, referrer, gasEstimate ]; 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/uniswapV2/arena.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require("../../../utils"); 2 | const { unilikeFactories } = addresses.avalanche; 3 | 4 | const factory = unilikeFactories.arena; 5 | const networkName = "avalanche"; 6 | const name = "ArenaAdapter"; 7 | const tags = ["arena"]; 8 | const fee = 3; 9 | 10 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee); 11 | -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/uniswapV2/hakuswap.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { unilikeFactories } = addresses.avalanche 3 | 4 | const factory = unilikeFactories.hakuswap 5 | const networkName = 'avalanche' 6 | const name = 'HakuswapAdapter' 7 | const tags = [ 'hakuswap' ] 8 | const fee = 2 9 | 10 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/uniswapV2/pangolin.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { unilikeFactories } = addresses.avalanche 3 | 4 | const factory = unilikeFactories.pangolin 5 | const networkName = 'avalanche' 6 | const name = 'PangolinAdapter' 7 | const tags = [ 'pangolin' ] 8 | const fee = 3 9 | 10 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/uniswapV2/sushiswap.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { unilikeFactories } = addresses.avalanche 3 | 4 | const factory = unilikeFactories.sushiswap 5 | const networkName = 'avalanche' 6 | const name = 'SushiswapAdapter' 7 | const tags = [ 'sushiswap' ] 8 | const fee = 3 9 | 10 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/uniswapV2/swapsicle.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { unilikeFactories } = addresses.avalanche 3 | 4 | const factory = unilikeFactories.swapsicle 5 | const networkName = 'avalanche' 6 | const name = 'SwapsicleAdapter' 7 | const tags = [ 'swapsicle' ] 8 | const fee = 3 9 | 10 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/uniswapV2/traderjoe.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { unilikeFactories } = addresses.avalanche 3 | 4 | const factory = unilikeFactories.joe 5 | const networkName = 'avalanche' 6 | const name = 'TraderjoeAdapter' 7 | const tags = [ 'traderjoe' ] 8 | const fee = 3 9 | 10 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/univ3/uniV3.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory, quoter } = addresses.avalanche.uniV3 3 | 4 | const networkName = 'avalanche' 5 | const contractName = 'UniswapV3Adapter' 6 | const tags = [ 'uniswapV3' ] 7 | const name = contractName 8 | const gasEstimate = 300_000 9 | const quoterGasLimit = gasEstimate - 60_000 10 | const defaultFees = [500, 3_000, 10_000] 11 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory, defaultFees ] 12 | 13 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/wombat/wombat.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require("../../../utils"); 2 | const { wombat } = addresses.avalanche; 3 | 4 | const networkName = "avalanche"; 5 | const tags = ["wombat"]; 6 | const name = "WombatAdapter"; 7 | const contractName = "WombatAdapter"; 8 | 9 | const gasEstimate = 290_000; 10 | const pools = [wombat.savax, wombat.main, wombat.usdv]; 11 | const args = [name, gasEstimate, pools]; 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args); 14 | -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/woofi/woofiUSDC.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { WoofiPoolUSDC } = addresses.avalanche.other 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'woofi' ] 6 | const name = 'WoofiUSDCAdapter' 7 | const contractName = 'WoofiAdapter' 8 | 9 | const gasEstimate = 525_000 10 | const pool = WoofiPoolUSDC 11 | const args = [ name, gasEstimate, pool, ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/adapters/woofi/woofiV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { woofiV2Pool } = addresses.avalanche.other 3 | 4 | const networkName = 'avalanche' 5 | const tags = [ 'woofiV2' ] 6 | const name = 'WoofiV2Adapter' 7 | const contractName = 'WoofiV2Adapter' 8 | 9 | const gasEstimate = 410_000 10 | const pool = woofiV2Pool 11 | const args = [ name, gasEstimate, pool, ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/avalanche/routers/yakWrapRouter.js: -------------------------------------------------------------------------------- 1 | const { deployYakWrapRouter } = require('../../utils') 2 | 3 | const networkName = 'avalanche' 4 | module.exports = deployYakWrapRouter(networkName, 'MinimalYakRouter') -------------------------------------------------------------------------------- /src/deploy/avalanche/routers/yakrouter.js: -------------------------------------------------------------------------------- 1 | const { deployRouter } = require('../../utils') 2 | 3 | const networkName = 'avalanche' 4 | module.exports = deployRouter(networkName) -------------------------------------------------------------------------------- /src/deploy/avalanche/routers/yakrouterMinimal.js: -------------------------------------------------------------------------------- 1 | const { deployMinimalRouter } = require('../../utils') 2 | 3 | const networkName = 'avalanche' 4 | module.exports = deployMinimalRouter(networkName) -------------------------------------------------------------------------------- /src/deploy/avalanche/wrappers/glpWrapper.js: -------------------------------------------------------------------------------- 1 | const { deployWrapper, addresses } = require('../../utils') 2 | const { GmxRewardRouter } = addresses.avalanche.other 3 | const { GLP, sGLP } = addresses.avalanche.assets 4 | 5 | const networkName = 'avalanche' 6 | const tags = [ 'gmx' ] 7 | const name = 'GlpWrapper' 8 | const contractName = 'GlpWrapper' 9 | 10 | const gasEstimate = 1_600_000 11 | const rewardRouter = GmxRewardRouter 12 | const args = [ name, gasEstimate, rewardRouter, GLP, sGLP ] 13 | 14 | module.exports = deployWrapper(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/dogechain/adapters/uniV2/dogeswap.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | 3 | const factory = addresses.dogechain.univ2.factories.dogeswap 4 | const networkName = 'dogechain' 5 | const name = 'DogeSwapAdapter' 6 | const tags = [ 'dogeswap' ] 7 | const fee = 2 8 | 9 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/dogechain/adapters/uniV2/kibbleswap.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | 3 | const factory = addresses.dogechain.univ2.factories.kibbleswap 4 | const networkName = 'dogechain' 5 | const name = 'KibbleSwapAdapter' 6 | const tags = [ 'kibbleswap' ] 7 | const fee = 3 8 | 9 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) 10 | -------------------------------------------------------------------------------- /src/deploy/dogechain/adapters/uniV2/yodeswap.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | 3 | const factory = addresses.dogechain.univ2.factories.yodeswap 4 | const networkName = 'dogechain' 5 | const name = 'YodeSwapAdapter' 6 | const tags = [ 'yodeswap' ] 7 | const fee = 5 8 | 9 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/dogechain/adapters/uniV3/quickswap.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { quickswap } = addresses.dogechain 3 | 4 | const networkName = 'dogechain' 5 | const tags = [ 'quickswap', 'algebra' ] 6 | const name = 'QuickswapAdapter' 7 | const contractName = 'AlgebraAdapter' 8 | 9 | const gasEstimate = 250_000 10 | const quoterGasLimit = gasEstimate 11 | const factory = quickswap.quickswapFactory 12 | const quoter = quickswap.algebraQuoter 13 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory ] 14 | 15 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/dogechain/routers/yakrouter.js: -------------------------------------------------------------------------------- 1 | const { deployRouter } = require('../../utils') 2 | 3 | const networkName = 'dogechain' 4 | module.exports = deployRouter(networkName) -------------------------------------------------------------------------------- /src/deploy/mantle/adapters/agni/agni.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory, quoter } = addresses.mantle.agni 3 | 4 | const networkName = 'mantle' 5 | const contractName = 'AgniAdapter' 6 | const tags = [ 'agni' ] 7 | const name = contractName 8 | const gasEstimate = 300_000 9 | const quoterGasLimit = gasEstimate - 60_000 10 | const defaultFees = [100, 500, 2_500, 10_000] 11 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory, defaultFees ] 12 | 13 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args) -------------------------------------------------------------------------------- /src/deploy/mantle/adapters/fusion/fusion.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory, quoter } = addresses.mantle.fusion 3 | 4 | const networkName = 'mantle' 5 | const contractName = 'FusionAdapter' 6 | const tags = [ 'fusion' ] 7 | const name = contractName 8 | const gasEstimate = 420_000 9 | const quoterGasLimit = gasEstimate - 60_000 10 | const defaultFees = [100, 500, 2_500, 10_000] 11 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory, defaultFees ] 12 | 13 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args) -------------------------------------------------------------------------------- /src/deploy/mantle/adapters/liquidity-book/joe-lb-2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require("../../../utils"); 2 | const { liquidityBook } = addresses.mantle; 3 | 4 | const networkName = "mantle"; 5 | const tags = ["lb22"]; 6 | const name = "LiquidityBook2Adapter"; 7 | const contractName = "LB2Adapter"; 8 | 9 | const gasEstimate = 1_000_000; 10 | const quoteGasLimit = 600_000; 11 | const factory = liquidityBook.factoryV2; 12 | const args = [name, gasEstimate, quoteGasLimit, factory]; 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args); 15 | -------------------------------------------------------------------------------- /src/deploy/mantle/adapters/uniswapV2/moe.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { unilikeFactories } = addresses.mantle 3 | 4 | const factory = unilikeFactories.moe 5 | const networkName = 'mantle' 6 | const name = 'MerchantMoeAdapter' 7 | const tags = [ 'moe' ] 8 | const fee = 3 9 | 10 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/mantle/adapters/wmnt.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../utils') 2 | const { WMNT } = addresses.mantle.assets 3 | 4 | const networkName = 'mantle' 5 | const tags = [ 'wmnt' ] 6 | const name = 'WMNTAdapter' 7 | const contractName = 'WNativeAdapter' 8 | 9 | const gasEstimate = 80_000 10 | const wnative = WMNT 11 | const args = [ wnative, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/mantle/routers/yakrouter.js: -------------------------------------------------------------------------------- 1 | const { deployRouter } = require('../../utils') 2 | 3 | const networkName = 'mantle' 4 | module.exports = deployRouter(networkName) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/balancer/beethoven.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const beethovenx = addresses.optimism.beethovenx 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'beethovenx' ] 6 | const name = 'BeethovenxAdapter' 7 | const contractName = 'BalancerV2Adapter' 8 | 9 | const gasEstimate = 280_000 10 | const args = [ 11 | name, 12 | beethovenx.vault, 13 | Object.values(beethovenx.pools), 14 | gasEstimate 15 | ] 16 | 17 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/curve/meta_susd_3crv.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { susd_3crv } = addresses.optimism.curve.metav2 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'curve', 'meta' ] 6 | const name = 'CurveMetaSUSDCRVAdapter' 7 | const contractName = 'CurveMetaV2Adapter' 8 | 9 | const gasEstimate = 480_000 10 | const pool = susd_3crv 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/curve/seth.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { seth_eth } = addresses.optimism.curve.plain128_native 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'curve', 'seth' ] 6 | const name = 'CurveSethAdapter' 7 | const contractName = 'CurvePlain128NativeAdapter' 8 | 9 | const gasEstimate = 260_000 10 | const pool = seth_eth 11 | const args = [ name, gasEstimate, pool, addresses.optimism.assets.WETH ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/curve/tripool.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { tripool } = addresses.optimism.curve.plain128 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'curve', 'tripool' ] 6 | const name = 'Curve3stableAdapter' 7 | const contractName = 'CurvePlain128Adapter' 8 | 9 | const gasEstimate = 260_000 10 | const pool = tripool 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/curve/wsteth.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { wsteth_eth } = addresses.optimism.curve.plain128_native 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'curve', 'wsteth' ] 6 | const name = 'CurveWstethAdapter' 7 | const contractName = 'CurvePlain128NativeAdapter' 8 | 9 | const gasEstimate = 260_000 10 | const pool = wsteth_eth 11 | const args = [ name, gasEstimate, pool, addresses.optimism.assets.WETH ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/kyber/kyberElastic.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { kyberElastic } = addresses.optimism 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'kyberElastic' ] 6 | const name = 'KyberElasticAdapter' 7 | const contractName = 'KyberElasticAdapter' 8 | 9 | const gasEstimate = 210_000 10 | const quoterGasLimit = gasEstimate 11 | const pools = Object.values(kyberElastic.pools) 12 | const args = [ name, gasEstimate, quoterGasLimit, kyberElastic.quoter, pools ] 13 | 14 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/saddle/frax_usdc_bp.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { frax_usdc_bp } = addresses.optimism.saddle 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'saddle', 'frax_usdc_bp' ] 6 | const name = 'SaddleFraxBPAdapter' 7 | const contractName = 'SaddleAdapter' 8 | 9 | const gasEstimate = 310_000 10 | const pool = frax_usdc_bp 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/saddle/meta_frax_optusd.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { frax_meta_optusd } = addresses.optimism.saddle 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'saddle', 'frax_meta_optusd' ] 6 | const name = 'SaddleMetaFraxAdapter' 7 | const contractName = 'SaddleMetaAdapter' 8 | 9 | const gasEstimate = 625_000 10 | const pool = frax_meta_optusd 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/saddle/meta_susd_bp.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { susd_meta_fraxbp } = addresses.optimism.saddle 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'saddle', 'susd_meta_fraxbp' ] 6 | const name = 'SaddleMetaSUSDAdapter' 7 | const contractName = 'SaddleMetaAdapter' 8 | 9 | const gasEstimate = 625_000 10 | const pool = susd_meta_fraxbp 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/saddle/optusd.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { opt_usd } = addresses.optimism.saddle 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'saddle', 'optusd' ] 6 | const name = 'SaddleOptUsdAdapter' 7 | const contractName = 'SaddleAdapter' 8 | 9 | const gasEstimate = 330_000 10 | const pool = opt_usd 11 | const args = [ name, pool, gasEstimate ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/uniswapV2/zipswap.js: -------------------------------------------------------------------------------- 1 | const { deployUniV2Contract, addresses } = require('../../../utils') 2 | const { zipswap: factory } = addresses.optimism.univ2Factories 3 | 4 | const networkName = 'optimism' 5 | const name = 'ZipswapAdapter' 6 | const tags = [ 'zipswap' ] 7 | const fee = 3 8 | 9 | module.exports = deployUniV2Contract(networkName, tags, name, factory, fee) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/uniswapV3/uniV3.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory, quoter } = addresses.optimism.uniV3 3 | 4 | const networkName = 'optimism' 5 | const contractName = 'UniswapV3Adapter' 6 | const tags = [ 'uniswapV3' ] 7 | const name = contractName 8 | const gasEstimate = 300_000 9 | const quoterGasLimit = 300_000 10 | const defaultFees = [500, 3_000, 10_000] 11 | const args = [ name, gasEstimate, quoterGasLimit, quoter, factory, defaultFees ] 12 | 13 | module.exports = deployAdapter(networkName, tags, contractName, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/velodrome/velodrome.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { factory } = addresses.optimism.velodrome 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'velodrome' ] 6 | const name = 'VelodromeAdapter' 7 | const contractName = 'VelodromeAdapter' 8 | 9 | const gasEstimate = 280_000 10 | const args = [ name, factory, gasEstimate ] 11 | 12 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/adapters/woofi/woofiV2.js: -------------------------------------------------------------------------------- 1 | const { deployAdapter, addresses } = require('../../../utils') 2 | const { woofiV2Pool } = addresses.optimism.woofi 3 | 4 | const networkName = 'optimism' 5 | const tags = [ 'woofiV2' ] 6 | const name = 'WoofiV2Adapter' 7 | const contractName = 'WoofiV2Adapter' 8 | 9 | const gasEstimate = 410_000 10 | const pool = woofiV2Pool 11 | const args = [ name, gasEstimate, pool, ] 12 | 13 | module.exports = deployAdapter(networkName, tags, name, contractName, args) -------------------------------------------------------------------------------- /src/deploy/optimism/routers/yakrouter.js: -------------------------------------------------------------------------------- 1 | const { deployRouter } = require('../../utils') 2 | 3 | const networkName = 'optimism' 4 | module.exports = deployRouter(networkName) -------------------------------------------------------------------------------- /src/deployments/arbitrum/.chainId: -------------------------------------------------------------------------------- 1 | 42161 -------------------------------------------------------------------------------- /src/deployments/avalanche/.chainId: -------------------------------------------------------------------------------- 1 | 43114 -------------------------------------------------------------------------------- /src/deployments/dogechain/.chainId: -------------------------------------------------------------------------------- 1 | 2000 -------------------------------------------------------------------------------- /src/deployments/hardhat/.chainId: -------------------------------------------------------------------------------- 1 | 43114 -------------------------------------------------------------------------------- /src/deployments/mantle/.chainId: -------------------------------------------------------------------------------- 1 | 5000 -------------------------------------------------------------------------------- /src/deployments/optimism/.chainId: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /src/examples/debridge/main.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config() 2 | const { ethers, config } = require('hardhat') 3 | 4 | const { assets } = require('../../misc/addresses.json').avalanche 5 | const yakRouterAddressAvax = require('../../deployments/avalanche/YakRouterV0.json').address 6 | const yakRouterAbi = require('../../abis/YakRouter.json') 7 | 8 | const providerAvax = new ethers.providers.JsonRpcProvider(config.networks.avalanche) 9 | const YakRouter = new ethers.Contract( 10 | yakRouterAddressAvax, 11 | yakRouterAbi, 12 | providerAvax 13 | ) 14 | 15 | async function query(tknFrom, tknTo, amountIn) { 16 | const maxHops = 3 17 | const gasPrice = ethers.utils.parseUnits('225', 'gwei') 18 | return YakRouter.findBestPathWithGas( 19 | amountIn, 20 | tknFrom, 21 | tknTo, 22 | maxHops, 23 | gasPrice, 24 | { gasLimit: 1e9 } 25 | ) 26 | } 27 | 28 | async function swap(signer, tknFrom, tknTo, amountIn) { 29 | const queryRes = await query(tknFrom, tknTo, amountIn) 30 | const amountOutMin = queryRes.amounts[queryRes.amounts.length-1] 31 | const fee = 0 32 | await YakRouter.connect(signer).swapNoSplit( 33 | [ 34 | amountIn, 35 | amountOutMin, 36 | queryRes.path, 37 | queryRes.adapters 38 | ], 39 | signer.address, 40 | fee 41 | ).then(r => r.wait()) 42 | .then(console.log) 43 | } 44 | 45 | async function exampleQuery() { 46 | const amountIn = ethers.utils.parseUnits('1000', 6) 47 | const tknFrom = assets.deUSDC 48 | const tknTo = assets.YAK 49 | const r = await query(tknFrom, tknTo, amountIn) 50 | console.log(r) 51 | } 52 | 53 | async function exampleSwap() { 54 | const signer = new ethers.Wallet(process.env.PK_TEST, provider) 55 | const amountIn = ethers.utils.parseUnits('0.5') 56 | const tknFrom = assets.WAVAX 57 | const tknTo = assets.deUSDC 58 | const r = await swap(signer, tknFrom, tknTo, amountIn) 59 | console.log(r) 60 | } 61 | 62 | exampleQuery() 63 | // exampleSwap() 64 | -------------------------------------------------------------------------------- /src/misc/constants.json: -------------------------------------------------------------------------------- 1 | { 2 | "geode": { 3 | "yyPlanet": "0x65293248ac7dc05120c6bee23cd982992894bed99a7f0b75c2c5b011ef1e4f38" 4 | } 5 | } -------------------------------------------------------------------------------- /src/tasks/list-adapters.js: -------------------------------------------------------------------------------- 1 | const { task } = require("hardhat/config"); 2 | 3 | task("list-adapters", "Lists all adapters for the current YakRouter", async (_, hre) => { 4 | const YakRouter = await hre.ethers.getContract("YakRouter") 5 | const adapterLen = await YakRouter.adaptersCount() 6 | const adapterIndices = Array.from(Array(adapterLen.toNumber()).keys()) 7 | const liveAdapters = await Promise.all(adapterIndices.map(async (i) => { 8 | const adapter = await YakRouter.ADAPTERS(i) 9 | const name = await hre.ethers.getContractAt("YakAdapter", adapter) 10 | .then(a => a.name()) 11 | return { adapter, name } 12 | })) 13 | console.table(liveAdapters) 14 | }) -------------------------------------------------------------------------------- /src/tasks/verify-contract.js: -------------------------------------------------------------------------------- 1 | const { task } = require("hardhat/config"); 2 | const path = require("path"); 3 | 4 | // npx hardhat verify-contract --network {network} --deployment-file-path {path} 5 | task("verify-contract", "Verifies the contract in the explorer", async function ({ deploymentFilePath }, hre, _) { 6 | console.log(`Verifying ${deploymentFilePath}`); 7 | const deploymentFile = require(deploymentFilePath); 8 | const args = deploymentFile.args; 9 | const contractAddress = deploymentFile.address; 10 | 11 | await hre.run("verify:verify", { 12 | address: contractAddress, 13 | constructorArguments: args, 14 | }); 15 | }).addParam("deploymentFilePath", "Deployment file path"); 16 | -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/atoken.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv } = require("../../../utils/test-env"); 2 | 3 | describe("YakAdapter - atoken", () => { 4 | let testEnv; 5 | let tkns; 6 | let ate; // adapter-test-env 7 | 8 | before(async () => { 9 | const networkName = "arbitrum"; 10 | const forkBlockNumber = 215498965; 11 | testEnv = await setTestEnv(networkName, forkBlockNumber); 12 | tkns = testEnv.supportedTkns; 13 | 14 | const contractName = "AaveAdapter"; 15 | const adapterArgs = [contractName, tkns.aArbUSDCn, 170_000]; 16 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 17 | }); 18 | 19 | beforeEach(async () => { 20 | testEnv.updateTrader(); 21 | }); 22 | 23 | describe("Swapping matches query", async () => { 24 | it("100 USDC -> aArbUSDCn", async () => { 25 | await ate.checkSwapMatchesQuery("100", tkns.USDC, tkns.aArbUSDCn); 26 | }); 27 | }); 28 | 29 | it("Query returns zero if tokens not found", async () => { 30 | const supportedTkn = tkns.USDC; 31 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn); 32 | }); 33 | 34 | it("Gas-estimate is between max-gas-used and 110% max-gas-used", async () => { 35 | const options = [["1", tkns.USDC, tkns.aArbUSDCn]]; 36 | await ate.checkGasEstimateIsSensible(options); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/balancerV2.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { balancerV2 } = addresses.arbitrum 3 | 4 | 5 | describe('YakAdapter - BalancerV2', function() { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'arbitrum' 13 | const forkBlockNumber = 16152472 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'BalancerV2Adapter' 18 | const adapterArgs = [ 19 | 'BalancerV2', 20 | balancerV2.vault, 21 | Object.values(balancerV2.pools), 22 | 280_000, 23 | ] 24 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 25 | }) 26 | 27 | beforeEach(async () => { 28 | testEnv.updateTrader() 29 | }) 30 | 31 | describe('Swapping matches query', async () => { 32 | 33 | it('100 USDC -> WETH', async () => { 34 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WETH) 35 | }) 36 | it('10 BTC -> WETH', async () => { 37 | await ate.checkSwapMatchesQuery('10', tkns.WBTC, tkns.WETH) 38 | }) 39 | it('100 USDC -> STG', async () => { 40 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.STG) 41 | }) 42 | 43 | }) 44 | 45 | it('Query returns zero if tokens not found', async () => { 46 | const supportedTkn = tkns.USDC 47 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 48 | }) 49 | 50 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 51 | const options = [ 52 | [ '100', tkns.USDC, tkns.STG ], 53 | [ '100', tkns.USDC, tkns.WBTC ], 54 | [ '100', tkns.USDC, tkns.WETH ], 55 | ] 56 | await ate.checkGasEstimateIsSensible(options) 57 | }) 58 | 59 | }) -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/camelot.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { camelot } = addresses.arbitrum 3 | 4 | 5 | describe('YakAdapter - Camelot', () => { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'arbitrum' 13 | const forkBlockNumber = 52762574 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'CamelotAdapter' 18 | const adapterArgs = [ 'CamelotAdapter', camelot.factory, 238_412 ] 19 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 20 | }) 21 | 22 | beforeEach(async () => { 23 | testEnv.updateTrader() 24 | }) 25 | 26 | describe('Swapping matches query', async () => { 27 | 28 | it('100 USDC -> WETH', async () => { 29 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WETH) 30 | }) 31 | it('10 BTC -> WETH', async () => { 32 | await ate.checkSwapMatchesQuery('10', tkns.WBTC, tkns.WETH) 33 | }) 34 | it('100 USDC -> USDT', async () => { 35 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.USDT) 36 | }) 37 | 38 | }) 39 | 40 | it('Query returns zero if tokens not found', async () => { 41 | const supportedTkn = tkns.USDC 42 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 43 | }) 44 | 45 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 46 | const options = [ 47 | [ '1', tkns.USDC, tkns.USDT ], 48 | [ '1', tkns.WETH, tkns.WBTC ], 49 | [ '1', tkns.USDC, tkns.WETH ], 50 | ] 51 | await ate.checkGasEstimateIsSensible(options) 52 | }) 53 | 54 | }) -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/dodov1.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { dodo } = addresses.arbitrum 3 | 4 | 5 | describe('YakAdapter - DodoV1', function() { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'arbitrum' 13 | const forkBlockNumber = 16152472 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'DodoV1Adapter' 18 | const adapterArgs = [ 19 | 'DodoV1Adapter', 20 | Object.values(dodo.v1.pools), 21 | dodo.v1.helper, 22 | 335_000, 23 | ] 24 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 25 | }) 26 | 27 | beforeEach(async () => { 28 | testEnv.updateTrader() 29 | }) 30 | 31 | describe('Swapping matches query', async () => { 32 | 33 | it('100 USDC -> WETH', async () => { 34 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WETH) 35 | }) 36 | it('10 BTC -> USDC', async () => { 37 | await ate.checkSwapMatchesQuery('10', tkns.WBTC, tkns.USDC) 38 | }) 39 | it('100 USDC -> USDT', async () => { 40 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.USDT) 41 | }) 42 | 43 | }) 44 | 45 | it('Query returns zero if tokens not found', async () => { 46 | const supportedTkn = tkns.USDC 47 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 48 | }) 49 | 50 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 51 | const options = [ 52 | [ '100', tkns.USDC, tkns.USDT ], 53 | [ '100', tkns.USDC, tkns.WBTC ], 54 | [ '100', tkns.USDC, tkns.WETH ], 55 | ] 56 | await ate.checkGasEstimateIsSensible(options) 57 | }) 58 | 59 | }) -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/dodov2.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { dodo } = addresses.arbitrum 3 | 4 | 5 | describe('YakAdapter - DodoV2', function() { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'arbitrum' 13 | const forkBlockNumber = 16152472 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'DodoV2Adapter' 18 | const adapterArgs = [ 19 | 'DodoV1Adapter', 20 | Object.values(dodo.v2.pools), 21 | 290_000, 22 | ] 23 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 24 | }) 25 | 26 | beforeEach(async () => { 27 | testEnv.updateTrader() 28 | }) 29 | 30 | describe('Swapping matches query', async () => { 31 | 32 | it('100 USDC -> DODO', async () => { 33 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.DODO) 34 | }) 35 | it('10 DODO -> USDC', async () => { 36 | await ate.checkSwapMatchesQuery('10', tkns.DODO, tkns.USDC) 37 | }) 38 | 39 | }) 40 | 41 | it('Query returns zero if tokens not found', async () => { 42 | const supportedTkn = tkns.USDC 43 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 44 | }) 45 | 46 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 47 | const options = [ 48 | [ '100', tkns.USDC, tkns.DODO ], 49 | [ '100', tkns.DODO, tkns.USDC ], 50 | ] 51 | await ate.checkGasEstimateIsSensible(options) 52 | }) 53 | 54 | }) -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/gmx.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { gmx } = addresses.arbitrum 3 | 4 | 5 | describe('YakAdapter - Gmx', () => { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'arbitrum' 13 | const forkBlockNumber = 16485220 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'GmxAdapter' 18 | const adapterArgs = [ 'GmxAdapter', gmx.vault, 630_000 ] 19 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 20 | }) 21 | 22 | beforeEach(async () => { 23 | testEnv.updateTrader() 24 | }) 25 | 26 | describe('Swapping matches query', async () => { 27 | 28 | it('100 USDC -> WETH', async () => { 29 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WETH) 30 | }) 31 | it('100 FRAX -> UNI', async () => { 32 | await ate.checkSwapMatchesQuery('100', tkns.FRAX, tkns.UNI) 33 | }) 34 | it('100 DAI -> WBTC', async () => { 35 | await ate.checkSwapMatchesQuery('100', tkns.DAI, tkns.WBTC) 36 | }) 37 | 38 | }) 39 | 40 | it('Query returns zero if tokens not found', async () => { 41 | const supportedTkn = tkns.USDC 42 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 43 | }) 44 | 45 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 46 | const options = [ 47 | [ '1', tkns.USDC, tkns.DAI ], 48 | [ '1', tkns.DAI, tkns.WETH ], 49 | [ '1', tkns.FRAX, tkns.UNI ], 50 | ] 51 | await ate.checkGasEstimateIsSensible(options) 52 | }) 53 | 54 | }) -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/pancakeV3.spec.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | const { ethers } = require("hardhat"); 3 | const { setTestEnv, addresses } = require("../../../utils/test-env"); 4 | const { pancake } = addresses.arbitrum; 5 | 6 | describe("YakAdapter - Pancake", function () { 7 | let testEnv; 8 | let tkns; 9 | let ate; // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = "arbitrum"; 13 | const forkBlockNumber = 171689274; 14 | testEnv = await setTestEnv(networkName, forkBlockNumber); 15 | tkns = testEnv.supportedTkns; 16 | 17 | const contractName = "PancakeV3Adapter"; 18 | const gasEstimate = 325_000; 19 | const quoterGasLimit = gasEstimate; 20 | const defaultFees = [100, 500, 2500, 10_000]; 21 | const adapterArgs = ["PancakeV3Adapter", gasEstimate, quoterGasLimit, pancake.quoter, pancake.factoryV3, defaultFees]; 22 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 23 | }); 24 | 25 | beforeEach(async () => { 26 | testEnv.updateTrader(); 27 | }); 28 | 29 | describe("Swapping matches query", async () => { 30 | it("50 ARB -> WETH", async () => { 31 | await ate.checkSwapMatchesQuery("50", tkns.ARB, tkns.WETH); 32 | }); 33 | 34 | it("200 USDC -> USDCe", async () => { 35 | await ate.checkSwapMatchesQuery("200", tkns.USDC, tkns.USDCe); 36 | }); 37 | }); 38 | 39 | it('Query returns zero if tokens not found', async () => { 40 | const supportedTkn = tkns.ARB 41 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 42 | }) 43 | 44 | it('Swapping too much returns zero', async () => { 45 | const dy = await ate.Adapter.query( 46 | ethers.utils.parseUnits('10000', 18), 47 | tkns.USDC.address, 48 | tkns.WETH.address 49 | ) 50 | expect(dy).to.eq(0) 51 | }) 52 | 53 | it('Adapter can only spend max-gas + buffer', async () => { 54 | const gasBuffer = ethers.BigNumber.from('70000') 55 | const quoterGasLimit = await ate.Adapter.quoterGasLimit() 56 | const dy = await ate.Adapter.estimateGas.query( 57 | ethers.utils.parseUnits('2000', 6), 58 | tkns.USDC.address, 59 | tkns.WETH.address 60 | ) 61 | expect(dy).to.lt(quoterGasLimit.add(gasBuffer)) 62 | }) 63 | 64 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 65 | const options = [ 66 | [ '10', tkns.USDC, tkns.WETH ] 67 | ] 68 | await ate.checkGasEstimateIsSensible(options) 69 | }) 70 | }); 71 | -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/ramses.spec.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | const { ethers } = require("hardhat"); 3 | const { setTestEnv, addresses } = require("../../../utils/test-env"); 4 | const { ramses } = addresses.arbitrum; 5 | 6 | describe("YakAdapter - Ramses", function () { 7 | let testEnv; 8 | let tkns; 9 | let ate; // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = "arbitrum"; 13 | const forkBlockNumber = 171350880; 14 | testEnv = await setTestEnv(networkName, forkBlockNumber); 15 | tkns = testEnv.supportedTkns; 16 | 17 | const contractName = "RamsesV2Adapter"; 18 | const gasEstimate = 325_000; 19 | const quoterGasLimit = gasEstimate; 20 | const defaultFees = [50, 100, 250, 500, 3_000, 10_000]; 21 | const adapterArgs = ["RamsesV2Adapter", gasEstimate, quoterGasLimit, ramses.quoter, ramses.factory, defaultFees]; 22 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 23 | }); 24 | 25 | beforeEach(async () => { 26 | testEnv.updateTrader(); 27 | }); 28 | 29 | describe("Swapping matches query", async () => { 30 | it("50 ARB -> WETH", async () => { 31 | await ate.checkSwapMatchesQuery("50", tkns.ARB, tkns.WETH); 32 | }); 33 | 34 | it("200 USDC -> USDCe", async () => { 35 | await ate.checkSwapMatchesQuery("200", tkns.USDC, tkns.USDCe); 36 | }); 37 | }); 38 | 39 | it('Query returns zero if tokens not found', async () => { 40 | const supportedTkn = tkns.ARB 41 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 42 | }) 43 | 44 | it('Swapping too much returns zero', async () => { 45 | const dy = await ate.Adapter.query( 46 | ethers.utils.parseUnits('10000', 18), 47 | tkns.USDC.address, 48 | tkns.WETH.address 49 | ) 50 | expect(dy).to.eq(0) 51 | }) 52 | 53 | it('Adapter can only spend max-gas + buffer', async () => { 54 | const gasBuffer = ethers.BigNumber.from('70000') 55 | const quoterGasLimit = await ate.Adapter.quoterGasLimit() 56 | const dy = await ate.Adapter.estimateGas.query( 57 | ethers.utils.parseUnits('2000', 6), 58 | tkns.USDC.address, 59 | tkns.WETH.address 60 | ) 61 | expect(dy).to.lt(quoterGasLimit.add(gasBuffer)) 62 | }) 63 | 64 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 65 | const options = [ 66 | [ '10', tkns.USDC, tkns.WETH ] 67 | ] 68 | await ate.checkGasEstimateIsSensible(options) 69 | }) 70 | }); 71 | -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/swapr.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { swapr } = addresses.arbitrum 3 | 4 | 5 | describe('YakAdapter - Swapr', () => { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'arbitrum' 13 | const forkBlockNumber = 16152472 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'DxSwapAdapter' 18 | const adapterArgs = [ 'DxSwapAdapter', swapr.factory, 180_000 ] 19 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 20 | }) 21 | 22 | beforeEach(async () => { 23 | testEnv.updateTrader() 24 | }) 25 | 26 | describe('Swapping matches query', async () => { 27 | 28 | it('100 USDC -> WETH', async () => { 29 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WETH) 30 | }) 31 | it('10 BTC -> WETH', async () => { 32 | await ate.checkSwapMatchesQuery('10', tkns.WBTC, tkns.WETH) 33 | }) 34 | it('100 USDC -> USDT', async () => { 35 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.USDT) 36 | }) 37 | 38 | }) 39 | 40 | it('Query returns zero if tokens not found', async () => { 41 | const supportedTkn = tkns.USDC 42 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 43 | }) 44 | 45 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 46 | const options = [ 47 | [ '1', tkns.USDC, tkns.USDT ], 48 | [ '1', tkns.WETH, tkns.WBTC ], 49 | [ '1', tkns.USDC, tkns.WETH ], 50 | ] 51 | await ate.checkGasEstimateIsSensible(options) 52 | }) 53 | 54 | }) -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/wombat.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require("../../../utils/test-env"); 2 | const { wombat } = addresses.arbitrum; 3 | 4 | describe("YakAdapter - Wombat", () => { 5 | let testEnv; 6 | let tkns; 7 | let ate; // adapter-test-env 8 | 9 | before(async () => { 10 | const networkName = "arbitrum"; 11 | const forkBlockNumber = 171366228; 12 | testEnv = await setTestEnv(networkName, forkBlockNumber); 13 | tkns = testEnv.supportedTkns; 14 | 15 | const contractName = "WombatAdapter"; 16 | const adapterArgs = ["WombatAdapter", 280_000, [wombat.main, wombat.frax_sfrax_usdc, wombat.frax_usdv, wombat.frxETH, wombat.fusdc, wombat.mpendle_pendle]]; 17 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 18 | }); 19 | 20 | beforeEach(async () => { 21 | testEnv.updateTrader(); 22 | }); 23 | 24 | describe("Swapping matches query :: main", async () => { 25 | it("100 USDC -> USDT", async () => { 26 | await ate.checkSwapMatchesQuery("100", tkns.USDC, tkns.USDT); 27 | }); 28 | it("100 USDT -> USDC", async () => { 29 | await ate.checkSwapMatchesQuery("100", tkns.USDT, tkns.USDC); 30 | }); 31 | }); 32 | 33 | describe("Swapping matches query :: usdv", async () => { 34 | it("10 USDC -> DAI", async () => { 35 | await ate.checkSwapMatchesQuery("100", tkns.USDC, tkns.DAI); 36 | }); 37 | }); 38 | 39 | it("Query returns zero if tokens not found", async () => { 40 | const supportedTkn = tkns.USDC; 41 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn); 42 | }); 43 | 44 | it("Gas-estimate is between max-gas-used and 110% max-gas-used", async () => { 45 | const options = [["1", tkns.USDC, tkns.USDT]]; 46 | await ate.checkGasEstimateIsSensible(options); 47 | }); 48 | }); 49 | -------------------------------------------------------------------------------- /src/test/spec/arbitrum/adapters/woofiV2.spec.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | const { setTestEnv, addresses } = require("../../../utils/test-env"); 3 | const { woofiV2Pool } = addresses.arbitrum.other; 4 | 5 | describe("YakAdapter - woofiV2", () => { 6 | let testEnv; 7 | let tkns; 8 | let ate; // adapter-test-env 9 | 10 | before(async () => { 11 | const networkName = "arbitrum"; 12 | const forkBlockNumber = 204016043; 13 | testEnv = await setTestEnv(networkName, forkBlockNumber); 14 | tkns = testEnv.supportedTkns; 15 | 16 | const contractName = "WoofiV2Adapter"; 17 | const adapterArgs = ["WoofiV2Adapter", 410_000, woofiV2Pool]; 18 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 19 | }); 20 | 21 | beforeEach(async () => { 22 | testEnv.updateTrader(); 23 | }); 24 | 25 | describe("Swapping matches query :: base->quote", async () => { 26 | it("1 WETH -> USDC", async () => { 27 | await ate.checkSwapMatchesQuery("1", tkns.WETH, tkns.USDC); 28 | }); 29 | it("1 WBTC -> USDC", async () => { 30 | await ate.checkSwapMatchesQuery("1", tkns.WBTC, tkns.USDC); 31 | }); 32 | }); 33 | 34 | describe("Swapping matches query :: base->quote", async () => { 35 | it("1 USDC -> WETH", async () => { 36 | await ate.checkSwapMatchesQuery("1", tkns.USDC, tkns.WETH); 37 | }); 38 | it("1 USDC -> WBTC", async () => { 39 | await ate.checkSwapMatchesQuery("1", tkns.USDC, tkns.WBTC); 40 | }); 41 | }); 42 | 43 | describe("Swapping matches query :: base->base", async () => { 44 | it("1 WETH -> WBTC :: 1 bps err", async () => { 45 | const errBps = 1; 46 | await ate.checkSwapMatchesQueryWithErr("1", tkns.WETH, tkns.WBTC, errBps); 47 | }); 48 | it("0.01 WBTC -> USDC", async () => { 49 | await ate.checkSwapMatchesQuery("0.01", tkns.WBTC, tkns.USDC); 50 | }); 51 | }); 52 | 53 | it("Query returns zero if tokens not found", async () => { 54 | const supportedTkn = tkns.USDC; 55 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn); 56 | }); 57 | 58 | it("Gas-estimate is between max-gas-used and 110% max-gas-used", async () => { 59 | const options = [ 60 | ["1", tkns.USDC, tkns.WBTC], 61 | ["1", tkns.WETH, tkns.USDC], 62 | ]; 63 | await ate.checkGasEstimateIsSensible(options); 64 | }); 65 | }); 66 | -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/arena.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require("../../../utils/test-env"); 2 | const { unilikeFactories } = addresses.avalanche; 3 | 4 | describe("YakAdapter - Arena DEX", () => { 5 | let testEnv; 6 | let tkns; 7 | let ate; // adapter-test-env 8 | 9 | before(async () => { 10 | const networkName = "avalanche"; 11 | const forkBlockNumber = 61603077; 12 | testEnv = await setTestEnv(networkName, forkBlockNumber); 13 | tkns = testEnv.supportedTkns; 14 | 15 | const contractName = "UniswapV2Adapter"; 16 | const adapterArgs = ["UniswapV2Adapter", unilikeFactories.arena, 3, 170_000]; 17 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 18 | }); 19 | 20 | beforeEach(async () => { 21 | testEnv.updateTrader(); 22 | }); 23 | 24 | describe("Swapping matches query", async () => { 25 | it("10 ARENA -> WAVAX", async () => { 26 | await ate.checkSwapMatchesQuery("10", tkns.ARENA, tkns.WAVAX); 27 | }); 28 | }); 29 | 30 | it("Query returns zero if tokens not found", async () => { 31 | const supportedTkn = tkns.WAVAX; 32 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn); 33 | }); 34 | 35 | it("Gas-estimate is between max-gas-used and 110% max-gas-used", async () => { 36 | const options = [["1", tkns.WAVAX, tkns.ARENA]]; 37 | await ate.checkGasEstimateIsSensible(options); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/ggavax.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv } = require("../../../utils/test-env"); 2 | 3 | describe("YakAdapter - savax", () => { 4 | let testEnv; 5 | let tkns; 6 | let ate; // adapter-test-env 7 | 8 | before(async () => { 9 | const networkName = "avalanche"; 10 | const forkBlockNumber = 47577367; 11 | testEnv = await setTestEnv(networkName, forkBlockNumber); 12 | tkns = testEnv.supportedTkns; 13 | 14 | const contractName = "GGAvaxAdapter"; 15 | const adapterArgs = [170_000]; 16 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 17 | }); 18 | 19 | beforeEach(async () => { 20 | testEnv.updateTrader(); 21 | }); 22 | 23 | describe("Swapping matches query", async () => { 24 | it("100 WAVAX -> ggAVAX", async () => { 25 | await ate.checkSwapMatchesQuery("1", tkns.WAVAX, tkns.ggAVAX); 26 | }); 27 | it("100 ggAVAX -> WAVAX", async () => { 28 | await ate.checkSwapMatchesQuery("1", tkns.ggAVAX, tkns.WAVAX); 29 | }); 30 | }); 31 | 32 | it("Query returns zero if tokens not found", async () => { 33 | const supportedTkn = tkns.WAVAX; 34 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn); 35 | }); 36 | 37 | it("Gas-estimate is between max-gas-used and 110% max-gas-used", async () => { 38 | const options = [["1", tkns.WAVAX, tkns.ggAVAX]]; 39 | await ate.checkGasEstimateIsSensible(options); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/gmx.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { GmxVault } = addresses.avalanche.other 3 | 4 | 5 | describe('YakAdapter - Gmx', () => { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'avalanche' 13 | const forkBlockNumber = 19595355 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'GmxAdapter' 18 | const adapterArgs = [ 'GmxAdapter', GmxVault, 630_000 ] 19 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 20 | }) 21 | 22 | beforeEach(async () => { 23 | testEnv.updateTrader() 24 | }) 25 | 26 | describe('Swapping matches query', async () => { 27 | 28 | it('100 USDCe -> WAVAX', async () => { 29 | await ate.checkSwapMatchesQuery('100', tkns.USDCe, tkns.WAVAX) 30 | }) 31 | it('100 WAVAX -> USDC', async () => { 32 | await ate.checkSwapMatchesQuery('100', tkns.WAVAX, tkns.USDC) 33 | }) 34 | it('1 WBTCe -> USDCe', async () => { 35 | await ate.checkSwapMatchesQuery('1', tkns.WBTCe, tkns.USDCe) 36 | }) 37 | it('100 WETHe -> WBTCe', async () => { 38 | await ate.checkSwapMatchesQuery('100', tkns.WETHe, tkns.WBTCe) 39 | }) 40 | it('100 USDC -> WETHe', async () => { 41 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WETHe) 42 | }) 43 | 44 | }) 45 | 46 | it('Query returns zero if tokens not found', async () => { 47 | const supportedTkn = tkns.WAVAX 48 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 49 | }) 50 | 51 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 52 | const options = [ 53 | [ '1', tkns.USDC, tkns.USDCe ], 54 | [ '1', tkns.WBTCe, tkns.USDC ], 55 | [ '1', tkns.WAVAX, tkns.WETHe ], 56 | ] 57 | await ate.checkGasEstimateIsSensible(options) 58 | }) 59 | 60 | }) -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/reservoir.spec.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai") 2 | const { setTestEnv, addresses } = require('../../../utils/test-env') 3 | const { reservoir } = addresses.avalanche 4 | 5 | describe('YakAdapter - Reservoir', () => { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'avalanche' 13 | const forkBlockNumber = 36275195 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'ReservoirAdapter' 18 | const gasEstimate = 350_000 19 | const adapterArgs = [ 20 | contractName, 21 | reservoir.factory, 22 | reservoir.quoter, 23 | gasEstimate 24 | ] 25 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 26 | }) 27 | 28 | beforeEach(async () => { 29 | testEnv.updateTrader() 30 | }) 31 | 32 | describe('Swapping matches query', async () => { 33 | it('100 USDt -> USDC', async () => { 34 | await ate.checkSwapMatchesQuery('100', tkns.USDt, tkns.USDC) 35 | }) 36 | it('1 USDC -> BTC.b', async () => { 37 | await ate.checkSwapMatchesQuery('10', tkns.USDC, tkns.BTCb) 38 | }) 39 | }) 40 | 41 | it('Query returns zero if tokens not found', async () => { 42 | const supportedTkn = tkns.USDC 43 | await ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 44 | }) 45 | 46 | it ('Query returns something for a valid pair', async () => { 47 | // 1 USDC 48 | const amountOutQuery = await ate.query('1000000', tkns.USDC.address, tkns.USDt.address) 49 | expect(amountOutQuery).gt(0) 50 | }) 51 | 52 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 53 | const options = [ 54 | [ '100', tkns.USDt, tkns.USDC ], 55 | [ '1', tkns.USDC, tkns.BTCb ], 56 | ] 57 | await ate.checkGasEstimateIsSensible(options) 58 | }) 59 | }) 60 | -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/savax.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv } = require('../../../utils/test-env') 2 | 3 | describe('YakAdapter - savax', () => { 4 | 5 | let testEnv 6 | let tkns 7 | let ate // adapter-test-env 8 | 9 | before(async () => { 10 | const networkName = 'avalanche' 11 | const forkBlockNumber = 19595355 12 | testEnv = await setTestEnv(networkName, forkBlockNumber) 13 | tkns = testEnv.supportedTkns 14 | 15 | const contractName = 'SAvaxAdapter' 16 | const adapterArgs = [ 170_000 ] 17 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 18 | }) 19 | 20 | beforeEach(async () => { 21 | testEnv.updateTrader() 22 | }) 23 | 24 | describe('Swapping matches query', async () => { 25 | 26 | it('100 WAVAX -> SAVAX', async () => { 27 | await ate.checkSwapMatchesQuery('100', tkns.WAVAX, tkns.SAVAX) 28 | }) 29 | 30 | }) 31 | 32 | it('Query returns zero if tokens not found', async () => { 33 | const supportedTkn = tkns.WAVAX 34 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 35 | }) 36 | 37 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 38 | const options = [ 39 | [ '1', tkns.WAVAX, tkns.SAVAX ], 40 | ] 41 | await ate.checkGasEstimateIsSensible(options) 42 | }) 43 | 44 | }) -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/solisnek.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { SolisnekFactory } = addresses.avalanche.other 3 | 4 | 5 | describe('YakAdapter - Solisnek', function() { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'avalanche' 13 | const forkBlockNumber = 28898755 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'VelodromeAdapter' 18 | const adapterArgs = [ 'SolisnekAdapter', SolisnekFactory, 4e5 ] 19 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 20 | }) 21 | 22 | beforeEach(async () => { 23 | testEnv.updateTrader() 24 | }) 25 | 26 | describe('Swapping matches query', async () => { 27 | 28 | it('100 USDCe -> USDC', async () => { 29 | await ate.checkSwapMatchesQuery('100', tkns.USDCe, tkns.USDC) 30 | }) 31 | it('100 AVAX -> USDC', async () => { 32 | await ate.checkSwapMatchesQuery('100', tkns.WAVAX, tkns.USDC) 33 | }) 34 | }) 35 | 36 | it('Query returns zero if tokens not found', async () => { 37 | const supportedTkn = tkns.USDC 38 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 39 | }) 40 | 41 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 42 | const options = [ 43 | [ '1', tkns.USDC, tkns.WAVAX ], 44 | [ '1', tkns.USDCe, tkns.USDC ], 45 | ] 46 | await ate.checkGasEstimateIsSensible(options) 47 | }) 48 | 49 | }) -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/swapsicle.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { unilikeFactories } = addresses.avalanche 3 | 4 | describe('YakAdapter - Swapsicle', () => { 5 | 6 | let testEnv 7 | let tkns 8 | let ate // adapter-test-env 9 | 10 | before(async () => { 11 | const networkName = 'avalanche' 12 | const forkBlockNumber = 20587780 13 | testEnv = await setTestEnv(networkName, forkBlockNumber) 14 | tkns = testEnv.supportedTkns 15 | 16 | const contractName = 'UniswapV2Adapter' 17 | const adapterArgs = [ 18 | 'UniswapV2Adapter', 19 | unilikeFactories.swapsicle, 20 | 3, 21 | 170_000 22 | ] 23 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 24 | }) 25 | 26 | beforeEach(async () => { 27 | testEnv.updateTrader() 28 | }) 29 | 30 | describe('Swapping matches query', async () => { 31 | 32 | it('100 USDC -> WAVAX', async () => { 33 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WAVAX) 34 | }) 35 | 36 | it('100 USDCe -> WAVAX', async () => { 37 | await ate.checkSwapMatchesQuery('100', tkns.USDCe, tkns.WAVAX) 38 | }) 39 | 40 | it('100 USDCe -> USDC', async () => { 41 | await ate.checkSwapMatchesQuery('100', tkns.USDCe, tkns.USDC) 42 | }) 43 | 44 | }) 45 | 46 | it('Query returns zero if tokens not found', async () => { 47 | const supportedTkn = tkns.WAVAX 48 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 49 | }) 50 | 51 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 52 | const options = [ 53 | [ '1', tkns.USDC, tkns.WAVAX ], 54 | [ '1', tkns.USDCe, tkns.WAVAX ], 55 | [ '1', tkns.USDCe, tkns.USDC ], 56 | ] 57 | await ate.checkGasEstimateIsSensible(options) 58 | }) 59 | 60 | }) -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/synapse.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { curvelikePools } = addresses.avalanche 3 | 4 | describe('YakAdapter - synapse', () => { 5 | 6 | let testEnv 7 | let tkns 8 | let ate // adapter-test-env 9 | 10 | before(async () => { 11 | const networkName = 'avalanche' 12 | const forkBlockNumber = 19595355 13 | testEnv = await setTestEnv(networkName, forkBlockNumber) 14 | tkns = testEnv.supportedTkns 15 | 16 | const contractName = 'SaddleAdapter' 17 | const adapterArgs = [ 18 | 'SynapseAdapter', 19 | curvelikePools.SynapseDAIeUSDCeUSDTeNUSD, 20 | 320_000 21 | ] 22 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 23 | }) 24 | 25 | beforeEach(async () => { 26 | testEnv.updateTrader() 27 | }) 28 | 29 | describe('Swapping matches query', async () => { 30 | 31 | it('100 USDTe -> DAIe', async () => { 32 | await ate.checkSwapMatchesQuery('100', tkns.USDTe, tkns.DAIe) 33 | }) 34 | it('100 DAIe -> USDCe', async () => { 35 | await ate.checkSwapMatchesQuery('100', tkns.DAIe, tkns.USDCe) 36 | }) 37 | it('100 USDCe -> USDTe', async () => { 38 | await ate.checkSwapMatchesQuery('100', tkns.USDCe, tkns.USDTe) 39 | }) 40 | 41 | }) 42 | 43 | it('Query returns zero if tokens not found', async () => { 44 | const supportedTkn = tkns.USDTe 45 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 46 | }) 47 | 48 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 49 | const options = [ 50 | [ '1', tkns.USDTe, tkns.USDCe ], 51 | [ '1', tkns.USDCe, tkns.DAIe ], 52 | [ '1', tkns.DAIe, tkns.USDTe ], 53 | ] 54 | await ate.checkGasEstimateIsSensible(options) 55 | }) 56 | 57 | }) -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/traderjoe.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { unilikeFactories } = addresses.avalanche 3 | 4 | describe('YakAdapter - TraderJoe', () => { 5 | 6 | let testEnv 7 | let tkns 8 | let ate // adapter-test-env 9 | 10 | before(async () => { 11 | const networkName = 'avalanche' 12 | const forkBlockNumber = 19595355 13 | testEnv = await setTestEnv(networkName, forkBlockNumber) 14 | tkns = testEnv.supportedTkns 15 | 16 | const contractName = 'UniswapV2Adapter' 17 | const adapterArgs = [ 18 | 'UniswapV2Adapter', 19 | unilikeFactories.joe, 20 | 3, 21 | 170_000 22 | ] 23 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 24 | }) 25 | 26 | beforeEach(async () => { 27 | testEnv.updateTrader() 28 | }) 29 | 30 | describe('Swapping matches query', async () => { 31 | 32 | it('100 USDC -> WAVAX', async () => { 33 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WAVAX) 34 | }) 35 | 36 | it('100 WETHe -> WAVAX', async () => { 37 | await ate.checkSwapMatchesQuery('100', tkns.WETHe, tkns.WAVAX) 38 | }) 39 | 40 | it('100 USDCe -> USDC', async () => { 41 | await ate.checkSwapMatchesQuery('100', tkns.USDCe, tkns.USDC) 42 | }) 43 | 44 | }) 45 | 46 | it('Query returns zero if tokens not found', async () => { 47 | const supportedTkn = tkns.WAVAX 48 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 49 | }) 50 | 51 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 52 | const options = [ 53 | [ '1', tkns.USDC, tkns.WAVAX ], 54 | [ '1', tkns.WETHe, tkns.WAVAX ], 55 | [ '1', tkns.USDCe, tkns.USDC ], 56 | ] 57 | await ate.checkGasEstimateIsSensible(options) 58 | }) 59 | 60 | }) -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/wombat.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require("../../../utils/test-env"); 2 | const { wombat } = addresses.avalanche; 3 | 4 | describe("YakAdapter - Wombat", () => { 5 | let testEnv; 6 | let tkns; 7 | let ate; // adapter-test-env 8 | 9 | before(async () => { 10 | const networkName = "avalanche"; 11 | const forkBlockNumber = 38388903; 12 | testEnv = await setTestEnv(networkName, forkBlockNumber); 13 | tkns = testEnv.supportedTkns; 14 | 15 | const contractName = "WombatAdapter"; 16 | const adapterArgs = ["WombatAdapter", 290_000, [wombat.savax, wombat.main, wombat.usdv]]; 17 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 18 | }); 19 | 20 | beforeEach(async () => { 21 | testEnv.updateTrader(); 22 | }); 23 | 24 | describe("Swapping matches query :: savax", async () => { 25 | it("100 SAVAX -> WAVAX", async () => { 26 | await ate.checkSwapMatchesQuery("100", tkns.SAVAX, tkns.WAVAX); 27 | }); 28 | it("100 WAVAX -> SAVAX", async () => { 29 | await ate.checkSwapMatchesQuery("100", tkns.WAVAX, tkns.SAVAX); 30 | }); 31 | }); 32 | 33 | describe("Swapping matches query :: main", async () => { 34 | it("100 USDC -> USDT", async () => { 35 | await ate.checkSwapMatchesQuery("100", tkns.USDC, tkns.USDt); 36 | }); 37 | it("100 USDT -> USDC", async () => { 38 | await ate.checkSwapMatchesQuery("100", tkns.USDt, tkns.USDC); 39 | }); 40 | }); 41 | 42 | describe("Swapping matches query :: usdv", async () => { 43 | it("10 USDT -> USDV", async () => { 44 | await ate.checkSwapMatchesQuery("100", tkns.USDt, tkns.USDV); 45 | }); 46 | }); 47 | 48 | it("Query returns zero if tokens not found", async () => { 49 | const supportedTkn = tkns.USDC; 50 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn); 51 | }); 52 | 53 | it("Gas-estimate is between max-gas-used and 110% max-gas-used", async () => { 54 | const options = [["1", tkns.SAVAX, tkns.WAVAX]]; 55 | await ate.checkGasEstimateIsSensible(options); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /src/test/spec/avalanche/adapters/yyJoe.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require("../../../utils/test-env"); 2 | const { yyJOE, JOE } = addresses.avalanche.assets; 3 | 4 | describe("YakAdapter - yyJoe", () => { 5 | let testEnv; 6 | let tkns; 7 | let ate; // adapter-test-env 8 | 9 | before(async () => { 10 | const networkName = "avalanche"; 11 | const forkBlockNumber = 22110113; 12 | testEnv = await setTestEnv(networkName, forkBlockNumber); 13 | tkns = testEnv.supportedTkns; 14 | 15 | const contractName = "YYDerivativeAdapter"; 16 | const adapterArgs = ["YYDerivativeAdapter", 1_200_000, yyJOE, JOE]; 17 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 18 | }); 19 | 20 | beforeEach(async () => { 21 | testEnv.updateTrader(); 22 | }); 23 | 24 | describe("Swapping matches query", async () => { 25 | it("1 JOE -> yyJOE", async () => { 26 | await ate.checkSwapMatchesQuery("1", tkns.JOE, tkns.yyJOE); 27 | }); 28 | }); 29 | 30 | it("Query returns zero if tokens not found", async () => { 31 | const supportedTkn = tkns.JOE; 32 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn); 33 | }); 34 | 35 | it("Gas-estimate is between max-gas-used and 110% max-gas-used", async () => { 36 | const options = [["1", tkns.JOE, tkns.yyJOE]]; 37 | await ate.checkGasEstimateIsSensible(options); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /src/test/spec/avalanche/erc20Utils.spec.js: -------------------------------------------------------------------------------- 1 | const { expect } = require('chai') 2 | const { 3 | setERC20Bal, 4 | getAccountsGen, 5 | getTknContractsForNetwork 6 | } = require('../../helpers') 7 | 8 | 9 | describe('ERC20-Utils', async () => { 10 | 11 | const NetworkName = 'avalanche' 12 | 13 | let accountsGen 14 | let holder 15 | let tkns 16 | 17 | before(async () => { 18 | accountsGen = await getAccountsGen() 19 | tkns = await getTknContractsForNetwork(NetworkName) 20 | }) 21 | 22 | beforeEach(async () => { 23 | holder = accountsGen.next() 24 | }) 25 | 26 | describe('setERC20Bal', async () => { 27 | 28 | async function checkERC20BalIsSet(token) { 29 | const getHolderBal = () => token.balanceOf(holder.address) 30 | const newBal = ethers.utils.parseUnits('1000') 31 | expect(await getHolderBal()).to.not.eq(newBal) 32 | await setERC20Bal(token.address, holder.address, newBal) 33 | expect(await getHolderBal()).to.eq(newBal) 34 | } 35 | 36 | it('TUSD', async () => { 37 | await checkERC20BalIsSet(tkns.TUSD) 38 | }) 39 | 40 | it('SNX', async () => { 41 | await checkERC20BalIsSet(tkns.TUSD) 42 | }) 43 | 44 | }) 45 | 46 | }) -------------------------------------------------------------------------------- /src/test/spec/mantle/adapters/liquidity-book-2.spec.js: -------------------------------------------------------------------------------- 1 | const { expect } = require("chai"); 2 | const { setTestEnv, addresses } = require("../../../utils/test-env"); 3 | const { liquidityBook } = addresses.mantle; 4 | 5 | describe("YakAdapter - LiquidityBook", function () { 6 | let testEnv; 7 | let tkns; 8 | let ate; // adapter-test-env 9 | 10 | beforeEach(async () => { 11 | const networkName = "mantle"; 12 | const forkBlockNumber = 63521847; 13 | testEnv = await setTestEnv(networkName, forkBlockNumber); 14 | tkns = testEnv.supportedTkns; 15 | 16 | const contractName = "LB2Adapter"; 17 | const gasEstimate = 1_000_000; 18 | const quoteGasLimit = 600_000; 19 | const adapterArgs = ["LiquidityBook2Adapter", gasEstimate, quoteGasLimit, liquidityBook.factoryV2]; 20 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs); 21 | }); 22 | 23 | describe("Swapping matches query", async () => { 24 | it("1000 USDT -> WETH", async () => { 25 | await ate.checkSwapMatchesQuery("1000", tkns.USDT, tkns.WETH); 26 | }); 27 | 28 | it("1000 WETH -> METH", async () => { 29 | await ate.checkSwapMatchesQuery("1", tkns.WETH, tkns.METH); 30 | }); 31 | }); 32 | 33 | it("Swapping too much returns zero", async () => { 34 | const dy = await ate.Adapter.query(ethers.utils.parseUnits("100000000", 6), tkns.USDT.address, tkns.WETH.address); 35 | expect(dy).to.eq(0); 36 | }); 37 | 38 | it("Adapter can only spend max-gas + buffer", async () => { 39 | const gasBuffer = ethers.BigNumber.from("50000"); 40 | const quoteGasLimit = await ate.Adapter.quoteGasLimit(); 41 | const dy = await ate.Adapter.estimateGas.query( 42 | ethers.utils.parseUnits("10000", 6), 43 | tkns.USDT.address, 44 | tkns.WETH.address 45 | ); 46 | expect(dy).to.lt(quoteGasLimit.add(gasBuffer)); 47 | }); 48 | 49 | it("Query returns zero if tokens not found", async () => { 50 | const supportedTkn = tkns.USDT; 51 | await ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn); 52 | }); 53 | 54 | it("Gas-estimate is between max-gas-used and 110% max-gas-used", async () => { 55 | const options = [ 56 | ["1", tkns.WETH, tkns.USDT], 57 | ["1000", tkns.USDT, tkns.WETH], 58 | ]; 59 | await ate.checkGasEstimateIsSensible(options); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /src/test/spec/mantle/adapters/moe.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { unilikeFactories } = addresses.mantle 3 | 4 | describe('YakAdapter - Moe', () => { 5 | 6 | let testEnv 7 | let tkns 8 | let ate // adapter-test-env 9 | 10 | before(async () => { 11 | const networkName = 'mantle' 12 | const forkBlockNumber = 41733921 13 | testEnv = await setTestEnv(networkName, forkBlockNumber) 14 | tkns = testEnv.supportedTkns 15 | 16 | const contractName = 'UniswapV2Adapter' 17 | const adapterArgs = [ 18 | 'UniswapV2Adapter', 19 | unilikeFactories.moe, 20 | 3, 21 | 170_000 22 | ] 23 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 24 | }) 25 | 26 | beforeEach(async () => { 27 | testEnv.updateTrader() 28 | }) 29 | 30 | describe('Swapping matches query', async () => { 31 | 32 | it('100 USDC -> WETH', async () => { 33 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.WETH) 34 | }) 35 | 36 | it('100 WMNT -> WETH', async () => { 37 | await ate.checkSwapMatchesQuery('100', tkns.WMNT, tkns.WETH) 38 | }) 39 | 40 | it('100 USDT -> USDC', async () => { 41 | await ate.checkSwapMatchesQuery('100', tkns.USDT, tkns.USDC) 42 | }) 43 | 44 | }) 45 | 46 | it('Query returns zero if tokens not found', async () => { 47 | const supportedTkn = tkns.WETH 48 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 49 | }) 50 | 51 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 52 | const options = [ 53 | [ '1', tkns.USDC, tkns.WETH ], 54 | [ '1', tkns.WMNT, tkns.WETH ], 55 | [ '1', tkns.USDT, tkns.USDC ], 56 | ] 57 | await ate.checkGasEstimateIsSensible(options) 58 | }) 59 | 60 | }) -------------------------------------------------------------------------------- /src/test/spec/optimism/adapters/curve.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { curve } = addresses.optimism 3 | 4 | 5 | describe('YakAdapter - Curve', () => { 6 | 7 | const MaxDustWei = ethers.utils.parseUnits('1', 'wei') 8 | 9 | let testEnv 10 | let tkns 11 | let ate // adapter-test-env 12 | 13 | before(async () => { 14 | const networkName = 'optimism' 15 | const forkBlockNumber = 74264449 16 | testEnv = await setTestEnv(networkName, forkBlockNumber) 17 | tkns = testEnv.supportedTkns 18 | }) 19 | 20 | beforeEach(async () => { 21 | testEnv.updateTrader() 22 | }) 23 | 24 | describe('wsteth', () => { 25 | 26 | before(async () => { 27 | const contractName = 'CurvePlain128NativeAdapter' 28 | const adapterArgs = [ 29 | 'CurveWstethAdapter', 30 | 250_000, 31 | curve.plain128_native.wsteth_eth, 32 | tkns.WETH.address 33 | ] 34 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 35 | }) 36 | 37 | describe('Swapping matches query', async () => { 38 | 39 | it('20 ETH -> wstETH', async () => { 40 | await ate.checkSwapMatchesQueryWithDust( 41 | '20', 42 | tkns.WETH, 43 | tkns.wstETH, 44 | MaxDustWei 45 | ) 46 | }) 47 | it('134 wstETH -> ETH', async () => { 48 | await ate.checkSwapMatchesQueryWithDust( 49 | '134', 50 | tkns.wstETH, 51 | tkns.WETH, 52 | MaxDustWei 53 | ) 54 | }) 55 | 56 | }) 57 | 58 | it('Query returns zero if tokens not found', async () => { 59 | const supportedTkn = tkns.WETH 60 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 61 | }) 62 | 63 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 64 | const options = [ 65 | [ '1', tkns.WETH, tkns.wstETH ], 66 | [ '1', tkns.wstETH, tkns.WETH ], 67 | [ '1000', tkns.WETH, tkns.wstETH ], 68 | ] 69 | await ate.checkGasEstimateIsSensible(options) 70 | }) 71 | 72 | }) 73 | 74 | }) -------------------------------------------------------------------------------- /src/test/spec/optimism/adapters/velodrome.spec.js: -------------------------------------------------------------------------------- 1 | const { setTestEnv, addresses } = require('../../../utils/test-env') 2 | const { velodrome } = addresses.optimism 3 | 4 | 5 | describe('YakAdapter - Velodrome', function() { 6 | 7 | let testEnv 8 | let tkns 9 | let ate // adapter-test-env 10 | 11 | before(async () => { 12 | const networkName = 'optimism' 13 | const forkBlockNumber = 12932984 14 | testEnv = await setTestEnv(networkName, forkBlockNumber) 15 | tkns = testEnv.supportedTkns 16 | 17 | const contractName = 'VelodromeAdapter' 18 | const adapterArgs = [ 'VelodromeAdapter', velodrome.factory, 2.8e5 ] 19 | ate = await testEnv.setAdapterEnv(contractName, adapterArgs) 20 | }) 21 | 22 | beforeEach(async () => { 23 | testEnv.updateTrader() 24 | }) 25 | 26 | describe('Swapping matches query', async () => { 27 | 28 | it('100 DAI -> USDC', async () => { 29 | await ate.checkSwapMatchesQuery('100', tkns.DAI, tkns.USDC) 30 | }) 31 | it('100 OP -> USDC', async () => { 32 | await ate.checkSwapMatchesQuery('100', tkns.OP, tkns.USDC) 33 | }) 34 | it('100 WETH -> USDC', async () => { 35 | await ate.checkSwapMatchesQuery('1', tkns.WETH, tkns.USDC) 36 | }) 37 | it('100 USDC -> DAI', async () => { 38 | await ate.checkSwapMatchesQuery('100', tkns.USDC, tkns.DAI) 39 | }) 40 | 41 | }) 42 | 43 | it('Query returns zero if tokens not found', async () => { 44 | const supportedTkn = tkns.USDC 45 | ate.checkQueryReturnsZeroForUnsupportedTkns(supportedTkn) 46 | }) 47 | 48 | it('Gas-estimate is between max-gas-used and 110% max-gas-used', async () => { 49 | const options = [ 50 | [ '1', tkns.USDC, tkns.WETH ], 51 | [ '1', tkns.OP, tkns.USDC ], 52 | [ '1', tkns.DAI, tkns.OP ], 53 | ] 54 | await ate.checkGasEstimateIsSensible(options) 55 | }) 56 | 57 | }) -------------------------------------------------------------------------------- /src/test/utils/test-env.js: -------------------------------------------------------------------------------- 1 | const { 2 | getTknContractsForNetwork, 3 | forkGlobalNetwork, 4 | getAccountsGen, 5 | deployContract, 6 | } = require('../helpers') 7 | 8 | const { AdapterTestEnv } = require('./adapter-test-env') 9 | 10 | 11 | module.exports.addresses = require('../../misc/addresses.json') 12 | module.exports.constants = require('../../misc/constants.json') 13 | module.exports.helpers = require('../helpers') 14 | 15 | module.exports.setTestEnv = async (networkName, forkBlockNum) => { 16 | await forkGlobalNetwork(forkBlockNum, networkName) 17 | const supportedTkns = await getTknContractsForNetwork(networkName) 18 | const accountsGen = await getAccountsGen() 19 | const deployer = accountsGen.next() 20 | const testEnv = new TestEnv({supportedTkns, deployer, accountsGen}) 21 | return testEnv 22 | } 23 | 24 | class TestEnv { 25 | 26 | constructor({supportedTkns, deployer, accountsGen}) { 27 | this.supportedTkns = supportedTkns 28 | this.accountsGen = accountsGen 29 | this.deployer = deployer 30 | this.setTrader(accountsGen.next()) 31 | } 32 | 33 | async setAdapterEnv(contractName, args, deployer) { 34 | deployer = deployer || this.deployer 35 | const adapter = await deployContract(contractName, { args, deployer }) 36 | return new AdapterTestEnv(this, adapter, deployer) 37 | } 38 | 39 | updateTrader() { 40 | this.setTrader(this.nextAccount()) 41 | } 42 | 43 | setTrader(newTrader) { 44 | this.trader = newTrader 45 | } 46 | 47 | nextAccount() { 48 | return this.accountsGen.next() 49 | } 50 | 51 | } --------------------------------------------------------------------------------