Compare commits
23 Commits
@0x/asset-
...
feat/PTP
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d52d882b14 | ||
|
|
4c8629840b | ||
|
|
feede28293 | ||
|
|
08cf51b101 | ||
|
|
4ba6918e06 | ||
|
|
52a3ffa77c | ||
|
|
afe77a432c | ||
|
|
64c090c4b4 | ||
|
|
e24474f152 | ||
|
|
29fa408256 | ||
|
|
1b94cc68af | ||
|
|
f5b4bb3035 | ||
|
|
afd880f28c | ||
|
|
cd14cdd168 | ||
|
|
c8ff53a75f | ||
|
|
6d08add20b | ||
|
|
29f9c725e3 | ||
|
|
a83453f07f | ||
|
|
ae365ce92c | ||
|
|
77a592e891 | ||
|
|
9a1df67d6b | ||
|
|
4b91411faf | ||
|
|
622a542d57 |
@@ -33,6 +33,7 @@ import "./mixins/MixinCurveV2.sol";
|
||||
import "./mixins/MixinCryptoCom.sol";
|
||||
import "./mixins/MixinDodo.sol";
|
||||
import "./mixins/MixinDodoV2.sol";
|
||||
import "./mixins/MixinGMX.sol";
|
||||
import "./mixins/MixinKyber.sol";
|
||||
import "./mixins/MixinKyberDmm.sol";
|
||||
import "./mixins/MixinLido.sol";
|
||||
@@ -60,6 +61,7 @@ contract BridgeAdapter is
|
||||
MixinCryptoCom,
|
||||
MixinDodo,
|
||||
MixinDodoV2,
|
||||
MixinGMX,
|
||||
MixinKyber,
|
||||
MixinKyberDmm,
|
||||
MixinLido,
|
||||
@@ -87,6 +89,7 @@ contract BridgeAdapter is
|
||||
MixinCryptoCom()
|
||||
MixinDodo()
|
||||
MixinDodoV2()
|
||||
MixinGMX()
|
||||
MixinKyber(weth)
|
||||
MixinLido(weth)
|
||||
MixinMakerPSM()
|
||||
@@ -265,6 +268,12 @@ contract BridgeAdapter is
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.GMX) {
|
||||
boughtAmount = _tradeGMX(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else {
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
|
||||
@@ -52,4 +52,5 @@ library BridgeProtocols {
|
||||
uint128 internal constant CLIPPER = 22; // Not used: Clipper is now using PLP interface
|
||||
uint128 internal constant AAVEV2 = 23;
|
||||
uint128 internal constant COMPOUND = 24;
|
||||
uint128 internal constant GMX = 25;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/*
|
||||
|
||||
Copyright 2020 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
|
||||
import "../IBridgeAdapter.sol";
|
||||
|
||||
/*
|
||||
UniswapV2
|
||||
*/
|
||||
interface IGmxRouter {
|
||||
|
||||
// /// @dev Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path.
|
||||
// /// The first element of path is the input token, the last is the output token, and any intermediate elements represent
|
||||
// /// intermediate pairs to trade through (if, for example, a direct pair does not exist).
|
||||
// /// @param _path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
|
||||
// /// @param _amountIn The amount of input tokens to send.
|
||||
// /// @param _minOut The minimum amount of output tokens that must be received for the transaction not to revert.
|
||||
// /// @param _reciever Recipient of the output tokens.
|
||||
function swap(
|
||||
address[] calldata _path, uint256 _amountIn, uint256 _minOut, address _receiver
|
||||
) external;
|
||||
}
|
||||
|
||||
contract MixinGMX {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
using LibSafeMathV06 for uint256;
|
||||
|
||||
function _tradeGMX(
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
public
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
address _router;
|
||||
address reader;
|
||||
address vault;
|
||||
address[] memory _path;
|
||||
IGmxRouter router;
|
||||
IERC20TokenV06[] memory path;
|
||||
|
||||
{
|
||||
//decode the bridge data
|
||||
(_router, reader, vault, _path) = abi.decode(bridgeData, (address, address, address, address[]));
|
||||
// To get around `abi.decode()` not supporting interface array types.
|
||||
assembly { path := _path }
|
||||
}
|
||||
|
||||
|
||||
require(path.length >= 2, "MixinGMX/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
|
||||
require(
|
||||
path[path.length - 1] == buyToken,
|
||||
"MixinGMX/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
|
||||
);
|
||||
|
||||
//connect to the GMX router
|
||||
router = IGmxRouter(_router);
|
||||
|
||||
// Grant the GMX router an allowance to sell the first token.
|
||||
path[0].approveIfBelow(address(router), sellAmount);
|
||||
|
||||
//track the balance to know how much we bought
|
||||
uint256 beforeBalance = buyToken.balanceOf(address(this));
|
||||
router.swap(
|
||||
// Convert to `buyToken` along this path.
|
||||
_path,
|
||||
// Sell all tokens we hold.
|
||||
sellAmount,
|
||||
// Minimum buy amount.
|
||||
0,
|
||||
// Recipient is `this`.
|
||||
address(this)
|
||||
);
|
||||
|
||||
//calculate the difference in balance from preswap->postswap to find how many tokens out
|
||||
boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance);
|
||||
|
||||
return boughtAmount;
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@
|
||||
"config": {
|
||||
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,BridgeAdapter,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|ERC1155OrdersFeature|ERC165Feature|ERC721OrdersFeature|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinERC1155Spender|FixinERC721Spender|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC1155OrdersFeature|IERC1155Token|IERC165Feature|IERC20Bridge|IERC20Transformer|IERC721OrdersFeature|IERC721Token|IFeature|IFeeRecipient|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|IPropertyValidator|ISimpleFunctionRegistryFeature|IStaking|ITakerCallback|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC1155OrdersStorage|LibERC20Transformer|LibERC721OrdersStorage|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNFTOrder|LibNFTOrdersRichErrors|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinAaveV2|MixinBalancer|MixinBalancerV2|MixinBancor|MixinCoFiX|MixinCompound|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NFTOrders|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFeeRecipient|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC1155Token|TestMintableERC20Token|TestMintableERC721Token|TestMooniswap|TestNFTOrderPresigner|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestPropertyValidator|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|ERC1155OrdersFeature|ERC165Feature|ERC721OrdersFeature|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinERC1155Spender|FixinERC721Spender|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC1155OrdersFeature|IERC1155Token|IERC165Feature|IERC20Bridge|IERC20Transformer|IERC721OrdersFeature|IERC721Token|IFeature|IFeeRecipient|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|IPropertyValidator|ISimpleFunctionRegistryFeature|IStaking|ITakerCallback|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC1155OrdersStorage|LibERC20Transformer|LibERC721OrdersStorage|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNFTOrder|LibNFTOrdersRichErrors|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinAaveV2|MixinBalancer|MixinBalancerV2|MixinBancor|MixinCoFiX|MixinCompound|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinGMX|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NFTOrders|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFeeRecipient|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC1155Token|TestMintableERC20Token|TestMintableERC721Token|TestMooniswap|TestNFTOrderPresigner|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestPropertyValidator|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -109,6 +109,7 @@ import * as MixinCurve from '../test/generated-artifacts/MixinCurve.json';
|
||||
import * as MixinCurveV2 from '../test/generated-artifacts/MixinCurveV2.json';
|
||||
import * as MixinDodo from '../test/generated-artifacts/MixinDodo.json';
|
||||
import * as MixinDodoV2 from '../test/generated-artifacts/MixinDodoV2.json';
|
||||
import * as MixinGMX from '../test/generated-artifacts/MixinGMX.json';
|
||||
import * as MixinKyber from '../test/generated-artifacts/MixinKyber.json';
|
||||
import * as MixinKyberDmm from '../test/generated-artifacts/MixinKyberDmm.json';
|
||||
import * as MixinLido from '../test/generated-artifacts/MixinLido.json';
|
||||
@@ -321,6 +322,7 @@ export const artifacts = {
|
||||
MixinCurveV2: MixinCurveV2 as ContractArtifact,
|
||||
MixinDodo: MixinDodo as ContractArtifact,
|
||||
MixinDodoV2: MixinDodoV2 as ContractArtifact,
|
||||
MixinGMX: MixinGMX as ContractArtifact,
|
||||
MixinKyber: MixinKyber as ContractArtifact,
|
||||
MixinKyberDmm: MixinKyberDmm as ContractArtifact,
|
||||
MixinLido: MixinLido as ContractArtifact,
|
||||
|
||||
@@ -107,6 +107,7 @@ export * from '../test/generated-wrappers/mixin_curve';
|
||||
export * from '../test/generated-wrappers/mixin_curve_v2';
|
||||
export * from '../test/generated-wrappers/mixin_dodo';
|
||||
export * from '../test/generated-wrappers/mixin_dodo_v2';
|
||||
export * from '../test/generated-wrappers/mixin_g_m_x';
|
||||
export * from '../test/generated-wrappers/mixin_kyber';
|
||||
export * from '../test/generated-wrappers/mixin_kyber_dmm';
|
||||
export * from '../test/generated-wrappers/mixin_lido';
|
||||
|
||||
@@ -140,6 +140,7 @@
|
||||
"test/generated-artifacts/MixinCurveV2.json",
|
||||
"test/generated-artifacts/MixinDodo.json",
|
||||
"test/generated-artifacts/MixinDodoV2.json",
|
||||
"test/generated-artifacts/MixinGMX.json",
|
||||
"test/generated-artifacts/MixinKyber.json",
|
||||
"test/generated-artifacts/MixinKyberDmm.json",
|
||||
"test/generated-artifacts/MixinLido.json",
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
"wsrun": "^5.2.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"merkle-patricia-tree": "3.0.0"
|
||||
"merkle-patricia-tree": "3.0.0",
|
||||
"bignumber.js": "9.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
[
|
||||
{
|
||||
"version": "16.52.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Adds support for mobius money on celo",
|
||||
"pr": 423
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "16.51.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added `Curve` `YFI-ETH` pool",
|
||||
"pr": 444
|
||||
}
|
||||
],
|
||||
"timestamp": 1646888282
|
||||
},
|
||||
{
|
||||
"version": "16.50.3",
|
||||
"changes": [
|
||||
|
||||
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v16.51.0 - _March 10, 2022_
|
||||
|
||||
* Added `Curve` `YFI-ETH` pool (#444)
|
||||
|
||||
## v16.50.3 - _March 9, 2022_
|
||||
|
||||
* Routing glue optimization (#439)
|
||||
|
||||
@@ -22,9 +22,9 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IBancor.sol";
|
||||
|
||||
contract CompilerHack {}
|
||||
|
||||
contract BancorSampler is CompilerHack {
|
||||
|
||||
contract BancorSampler {
|
||||
|
||||
/// @dev Base gas limit for Bancor calls.
|
||||
uint256 constant private BANCOR_CALL_GAS = 300e3; // 300k
|
||||
|
||||
@@ -27,6 +27,7 @@ import "./CompoundSampler.sol";
|
||||
import "./CurveSampler.sol";
|
||||
import "./DODOSampler.sol";
|
||||
import "./DODOV2Sampler.sol";
|
||||
import "./GMXSampler.sol";
|
||||
import "./KyberSampler.sol";
|
||||
import "./KyberDmmSampler.sol";
|
||||
import "./LidoSampler.sol";
|
||||
@@ -36,6 +37,7 @@ import "./MultiBridgeSampler.sol";
|
||||
import "./MStableSampler.sol";
|
||||
import "./MooniswapSampler.sol";
|
||||
import "./NativeOrderSampler.sol";
|
||||
import "./PlatypusSampler.sol";
|
||||
import "./ShellSampler.sol";
|
||||
import "./SmoothySampler.sol";
|
||||
import "./TwoHopSampler.sol";
|
||||
@@ -53,6 +55,7 @@ contract ERC20BridgeSampler is
|
||||
CurveSampler,
|
||||
DODOSampler,
|
||||
DODOV2Sampler,
|
||||
GMXSampler,
|
||||
KyberSampler,
|
||||
KyberDmmSampler,
|
||||
LidoSampler,
|
||||
@@ -62,6 +65,7 @@ contract ERC20BridgeSampler is
|
||||
MooniswapSampler,
|
||||
MultiBridgeSampler,
|
||||
NativeOrderSampler,
|
||||
PlatypusSampler,
|
||||
ShellSampler,
|
||||
SmoothySampler,
|
||||
TwoHopSampler,
|
||||
|
||||
99
packages/asset-swapper/contracts/src/GMXSampler.sol
Normal file
99
packages/asset-swapper/contracts/src/GMXSampler.sol
Normal file
@@ -0,0 +1,99 @@
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IGMX.sol";
|
||||
import "./ApproximateBuys.sol";
|
||||
import "./SamplerUtils.sol";
|
||||
|
||||
contract GMXSampler is
|
||||
SamplerUtils,
|
||||
ApproximateBuys
|
||||
{
|
||||
struct GMXInfo {
|
||||
address reader;
|
||||
address vault;
|
||||
address[] path;
|
||||
}
|
||||
// address immutable WAVAX = 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7;
|
||||
// address immutable AVAX = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||
|
||||
function sampleSellsFromGMX(
|
||||
address reader,
|
||||
address vault,
|
||||
address[] memory path,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
try
|
||||
IGMX(reader).getAmountOut(IVault(vault), path[0], path[1], takerTokenAmounts[i])
|
||||
returns (uint256 amountAfterFees, uint256 feeAmount)
|
||||
{
|
||||
makerTokenAmounts[i] = amountAfterFees;
|
||||
// Break early if there are 0 amounts
|
||||
if (makerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sampleBuysFromGMX(
|
||||
address reader,
|
||||
address vault,
|
||||
address[] memory path,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
address[] memory invertBuyPath = new address[](2);
|
||||
invertBuyPath[0] = path[1];
|
||||
invertBuyPath[1] = path[0];
|
||||
return _sampleApproximateBuys(
|
||||
ApproximateBuyQuoteOpts({
|
||||
makerTokenData: abi.encode(reader, vault, invertBuyPath),
|
||||
takerTokenData: abi.encode(reader, vault, path),
|
||||
getSellQuoteCallback: _sampleSellForApproximateBuyFromGMX
|
||||
}),
|
||||
makerTokenAmounts
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function _sampleSellForApproximateBuyFromGMX(
|
||||
bytes memory takerTokenData,
|
||||
bytes memory makerTokenData,
|
||||
uint256 sellAmount
|
||||
)
|
||||
private
|
||||
view
|
||||
returns (uint256 buyAmount)
|
||||
{
|
||||
(address _reader, address _vault, address[] memory _path ) = abi.decode(takerTokenData, (address, address, address[]));
|
||||
|
||||
(bool success, bytes memory resultData) = address(this).staticcall(abi.encodeWithSelector(
|
||||
this.sampleSellsFromGMX.selector,
|
||||
_reader,
|
||||
_vault,
|
||||
_path,
|
||||
_toSingleValueArray(sellAmount)
|
||||
));
|
||||
if(!success) {
|
||||
return 0;
|
||||
}
|
||||
// solhint-disable-next-line indent
|
||||
return abi.decode(resultData, (uint256[]))[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
118
packages/asset-swapper/contracts/src/PlatypusSampler.sol
Normal file
118
packages/asset-swapper/contracts/src/PlatypusSampler.sol
Normal file
@@ -0,0 +1,118 @@
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IPlatypus.sol";
|
||||
import "./ApproximateBuys.sol";
|
||||
import "./SamplerUtils.sol";
|
||||
|
||||
contract PlatypusSampler is
|
||||
SamplerUtils,
|
||||
ApproximateBuys
|
||||
{
|
||||
|
||||
function sampleSellsFromPlatypus(
|
||||
address router,
|
||||
address[] memory path,
|
||||
address[] memory pool,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
try
|
||||
IPlatypus(router).quotePotentialSwaps(path, pool, takerTokenAmounts[i])
|
||||
returns (uint256 amountAfterFees, uint256 feeAmount)
|
||||
{
|
||||
makerTokenAmounts[i] = amountAfterFees;
|
||||
// Break early if there are 0 amounts
|
||||
if (makerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sampleBuysFromPlatypus(
|
||||
address router,
|
||||
address[] memory path,
|
||||
address[] memory pool,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
address[] memory invertBuyPath;
|
||||
address[] memory invertPoolPath;
|
||||
|
||||
if(path.length > 2){
|
||||
|
||||
invertBuyPath = new address[](3);
|
||||
invertPoolPath = new address[](2);
|
||||
|
||||
invertBuyPath[0] = path[2];
|
||||
invertBuyPath[2] = path[0];
|
||||
invertBuyPath[1] = path[1];
|
||||
|
||||
invertPoolPath[0] = pool[1];
|
||||
invertPoolPath[1] = pool[0];
|
||||
}
|
||||
else {
|
||||
|
||||
invertBuyPath = new address[](2);
|
||||
invertPoolPath = new address[](1);
|
||||
|
||||
invertBuyPath[0] = path[1];
|
||||
invertBuyPath[1] = path[0];
|
||||
invertPoolPath[0] = pool[0];
|
||||
}
|
||||
|
||||
uint256[] memory result = _sampleApproximateBuys(
|
||||
ApproximateBuyQuoteOpts({
|
||||
makerTokenData: abi.encode(router, invertBuyPath, invertPoolPath),
|
||||
takerTokenData: abi.encode(router, path, pool),
|
||||
getSellQuoteCallback: _sampleSellForApproximateBuyFromPlatypus
|
||||
}),
|
||||
makerTokenAmounts
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function _sampleSellForApproximateBuyFromPlatypus(
|
||||
bytes memory makerTokenData,
|
||||
bytes memory takerTokenData,
|
||||
uint256 sellAmount
|
||||
)
|
||||
private
|
||||
view
|
||||
returns (uint256 buyAmount)
|
||||
{
|
||||
(address router, address[] memory _path, address[] memory _pool ) = abi.decode(makerTokenData, (address, address[], address[]));
|
||||
|
||||
(bool success, bytes memory resultData) = address(this).staticcall(abi.encodeWithSelector(
|
||||
this.sampleSellsFromPlatypus.selector,
|
||||
router,
|
||||
_path,
|
||||
_pool,
|
||||
_toSingleValueArray(sellAmount)
|
||||
));
|
||||
|
||||
if(!success) {
|
||||
return 0;
|
||||
}
|
||||
// solhint-disable-next-line indent
|
||||
return abi.decode(resultData, (uint256[]))[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
23
packages/asset-swapper/contracts/src/interfaces/IGMX.sol
Normal file
23
packages/asset-swapper/contracts/src/interfaces/IGMX.sol
Normal file
@@ -0,0 +1,23 @@
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
interface IGMX {
|
||||
function getMaxAmountIn(IVault _vault, address _tokenIn, address _tokenOut)
|
||||
external
|
||||
view
|
||||
returns (uint256);
|
||||
|
||||
function getAmountOut(IVault _vault, address _tokenIn, address _tokenOut, uint256 _amountIn)
|
||||
external
|
||||
view
|
||||
returns (uint256, uint256);
|
||||
}
|
||||
|
||||
interface IVault {
|
||||
function getFeeBasisPoints(address _token, uint256 _usdgDelta, uint256 _feeBasisPoints, uint256 _taxBasisPoints, bool _increment) external view returns (uint256);
|
||||
function stableSwapFeeBasisPoints() external view returns (uint256);
|
||||
function stableTokens(address _token) external view returns (bool);
|
||||
function tokenDecimals(address _token) external view returns (uint256);
|
||||
function getMaxPrice(address _token) external view returns (uint256);
|
||||
function getMinPrice(address _token) external view returns (uint256);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
pragma solidity ^0.6;
|
||||
|
||||
interface IPlatypus {
|
||||
function quotePotentialSwaps(
|
||||
address[] memory tokenPath,
|
||||
address[] memory poolPath,
|
||||
uint256 fromAmount
|
||||
) external view returns (uint256 potentialOutcome, uint256 haircut);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/asset-swapper",
|
||||
"version": "16.50.3",
|
||||
"version": "16.51.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -39,7 +39,7 @@
|
||||
"config": {
|
||||
"publicInterfaceContracts": "ERC20BridgeSampler,BalanceChecker,FakeTaker",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BalancerV2Sampler|BancorSampler|CompoundSampler|CurveSampler|DODOSampler|DODOV2Sampler|DummyLiquidityProvider|ERC20BridgeSampler|FakeTaker|IBalancer|IBancor|ICurve|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IShell|ISmoothy|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|KyberSampler|LidoSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|SamplerUtils|ShellSampler|SmoothySampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler).json",
|
||||
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BalancerV2Sampler|BancorSampler|CompoundSampler|CurveSampler|DODOSampler|DODOV2Sampler|DummyLiquidityProvider|ERC20BridgeSampler|FakeTaker|GMXSampler|IBalancer|IBancor|ICurve|IGMX|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IPlatypus|IShell|ISmoothy|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|KyberSampler|LidoSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|PlatypusSampler|SamplerUtils|ShellSampler|SmoothySampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler).json",
|
||||
"postpublish": {
|
||||
"assets": []
|
||||
}
|
||||
@@ -128,5 +128,6 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
|
||||
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56",
|
||||
"resolutions": {}
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ export class SwapQuoter {
|
||||
if (nativeOrders.length === 0) {
|
||||
nativeOrders.push(createDummyOrder(makerToken, takerToken));
|
||||
}
|
||||
|
||||
|
||||
// ** Prepare options for fetching market side liquidity **
|
||||
// Scale fees by gas price.
|
||||
const cloneOpts = _.omit(opts, 'gasPrice') as GetMarketOrdersOpts;
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
KYBER_BRIDGED_LIQUIDITY_PREFIX,
|
||||
MAX_DODOV2_POOLS_QUERIED,
|
||||
MAX_KYBER_RESERVES_QUERIED,
|
||||
MOBIUSMONEY_CELO_INFOS,
|
||||
MORPHEUSSWAP_ROUTER_BY_CHAIN_ID,
|
||||
MSTABLE_POOLS_BY_CHAIN_ID,
|
||||
NERVE_BSC_INFOS,
|
||||
@@ -61,8 +62,9 @@ import {
|
||||
UNISWAPV2_ROUTER_BY_CHAIN_ID,
|
||||
WAULTSWAP_ROUTER_BY_CHAIN_ID,
|
||||
XSIGMA_MAINNET_INFOS,
|
||||
PLATYPUS_AVALANCHE_INFOS,
|
||||
} from './constants';
|
||||
import { CurveInfo, ERC20BridgeSource } from './types';
|
||||
import { CurveInfo, ERC20BridgeSource, PlatypusInfo } from './types';
|
||||
|
||||
/**
|
||||
* Filter Kyber reserves which should not be used (0xbb bridged reserves)
|
||||
@@ -449,6 +451,60 @@ export function getAcryptosInfosForPair(chainId: ChainId, takerToken: string, ma
|
||||
),
|
||||
);
|
||||
}
|
||||
export function getMobiusMoneyInfoForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
|
||||
if (chainId !== ChainId.Celo) {
|
||||
return [];
|
||||
}
|
||||
return Object.values(MOBIUSMONEY_CELO_INFOS).filter(c =>
|
||||
[makerToken, takerToken].every(
|
||||
t =>
|
||||
(c.tokens.includes(t) && c.metaTokens === undefined) ||
|
||||
(c.tokens.includes(t) && [makerToken, takerToken].filter(v => c.metaTokens?.includes(v)).length > 0),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function getPlatypusInfoForPair(chainId: ChainId, takerToken: string, makerToken: string): PlatypusInfo[] {
|
||||
if (chainId !== ChainId.Avalanche) {
|
||||
return [];
|
||||
}
|
||||
let ptpPools: PlatypusInfo[] = [];
|
||||
const makerTokenPool = Object.values(PLATYPUS_AVALANCHE_INFOS).filter(c =>
|
||||
[makerToken].every(
|
||||
t =>
|
||||
c.tokens.includes(t),
|
||||
),
|
||||
);
|
||||
const takerTokenPool = Object.values(PLATYPUS_AVALANCHE_INFOS).filter(c =>
|
||||
[takerToken].every(
|
||||
t =>
|
||||
c.tokens.includes(t),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
if( makerTokenPool[0].tokens.includes(takerToken)){
|
||||
let pool: PlatypusInfo = {
|
||||
gasSchedule: makerTokenPool[0].gasSchedule,
|
||||
poolAddress: [makerTokenPool[0].poolAddress[0]],
|
||||
tokens: [makerToken,takerToken],
|
||||
};
|
||||
ptpPools.push(pool);
|
||||
}
|
||||
else{
|
||||
const intermediateToken = makerTokenPool[0].tokens.filter(element => takerTokenPool[0].tokens.includes(element));
|
||||
//return similar values from two arrays
|
||||
|
||||
let pool: PlatypusInfo = {
|
||||
gasSchedule: makerTokenPool[0].gasSchedule + makerTokenPool[0].gasSchedule,
|
||||
poolAddress: [makerTokenPool[0].poolAddress[0], takerTokenPool[0].poolAddress[0]],
|
||||
tokens: [makerToken,intermediateToken[0],takerToken],
|
||||
};
|
||||
ptpPools.push(pool);
|
||||
}
|
||||
|
||||
return ptpPools;
|
||||
}
|
||||
|
||||
export function getShellLikeInfosForPair(
|
||||
chainId: ChainId,
|
||||
@@ -491,7 +547,8 @@ export function getCurveLikeInfosForPair(
|
||||
| ERC20BridgeSource.IronSwap
|
||||
| ERC20BridgeSource.XSigma
|
||||
| ERC20BridgeSource.FirebirdOneSwap
|
||||
| ERC20BridgeSource.ACryptos,
|
||||
| ERC20BridgeSource.ACryptos
|
||||
| ERC20BridgeSource.MobiusMoney,
|
||||
): CurveDetailedInfo[] {
|
||||
let pools: CurveInfo[] = [];
|
||||
switch (source) {
|
||||
@@ -537,6 +594,9 @@ export function getCurveLikeInfosForPair(
|
||||
case ERC20BridgeSource.ACryptos:
|
||||
pools = getAcryptosInfosForPair(chainId, takerToken, makerToken);
|
||||
break;
|
||||
case ERC20BridgeSource.MobiusMoney:
|
||||
pools = getMobiusMoneyInfoForPair(chainId, takerToken, makerToken);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown Curve like source ${source}`);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import {
|
||||
LiquidityProviderRegistry,
|
||||
MakerPsmFillData,
|
||||
MultiHopFillData,
|
||||
PlatypusFillData,
|
||||
PlatypusInfo,
|
||||
PsmInfo,
|
||||
TokenAdjacencyGraph,
|
||||
UniswapV2FillData,
|
||||
@@ -184,6 +186,8 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.KyberDmm,
|
||||
ERC20BridgeSource.AaveV2,
|
||||
ERC20BridgeSource.Synapse,
|
||||
ERC20BridgeSource.GMX,
|
||||
ERC20BridgeSource.Platypus,
|
||||
]),
|
||||
[ChainId.Fantom]: new SourceFilters([
|
||||
ERC20BridgeSource.MultiHop,
|
||||
@@ -202,6 +206,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.UbeSwap,
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.MultiHop,
|
||||
ERC20BridgeSource.MobiusMoney,
|
||||
]),
|
||||
[ChainId.Optimism]: new SourceFilters([
|
||||
ERC20BridgeSource.UniswapV3,
|
||||
@@ -279,6 +284,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.Mooniswap,
|
||||
ERC20BridgeSource.MultiHop,
|
||||
ERC20BridgeSource.Nerve,
|
||||
ERC20BridgeSource.Synapse,
|
||||
ERC20BridgeSource.PancakeSwap,
|
||||
ERC20BridgeSource.PancakeSwapV2,
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
@@ -329,6 +335,8 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.KyberDmm,
|
||||
ERC20BridgeSource.AaveV2,
|
||||
ERC20BridgeSource.Synapse,
|
||||
ERC20BridgeSource.GMX,
|
||||
ERC20BridgeSource.Platypus,
|
||||
]),
|
||||
[ChainId.Fantom]: new SourceFilters([
|
||||
ERC20BridgeSource.MultiHop,
|
||||
@@ -347,6 +355,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.UbeSwap,
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.MultiHop,
|
||||
ERC20BridgeSource.MobiusMoney,
|
||||
]),
|
||||
[ChainId.Optimism]: new SourceFilters([
|
||||
ERC20BridgeSource.UniswapV3,
|
||||
@@ -500,6 +509,7 @@ export const MAINNET_TOKENS = {
|
||||
OUSD: '0x2a8e1e676ec238d8a992307b495b45b3feaa5e86',
|
||||
agEUR: '0x1a7e4e63778b4f12a199c062f3efdd288afcbce8',
|
||||
ibEUR: '0x96e61422b6a9ba0e068b6c5add4ffabc6a4aae27',
|
||||
YFI: '0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e',
|
||||
};
|
||||
|
||||
export const BSC_TOKENS = {
|
||||
@@ -547,6 +557,7 @@ export const AVALANCHE_TOKENS = {
|
||||
// native USDC on Avalanche
|
||||
nUSDC: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
||||
USDT: '0xc7198437980c041c805a1edcba50c1ce5db95118',
|
||||
USDt: '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7',
|
||||
aDAI: '0x47afa96cdc9fab46904a55a6ad4bf6660b53c38a',
|
||||
aUSDC: '0x46a51127c3ce23fb7ab1de06226147f446e4a857',
|
||||
aUSDT: '0x532e6537fea298397212f09a61e03311686f548e',
|
||||
@@ -554,6 +565,10 @@ export const AVALANCHE_TOKENS = {
|
||||
nUSD: '0xcfc37a6ab183dd4aed08c204d1c2773c0b1bdf46',
|
||||
aWETH: '0x53f7c5869a859f0aec3d334ee8b4cf01e3492f21',
|
||||
MIM: '0x130966628846bfd36ff31a822705796e8cb8c18d',
|
||||
sAVAX: '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be',
|
||||
UST: '0xb599c3590f42f8f995ecfa0f85d2980b76862fc1',
|
||||
FRAX: '0xd24c2ad096400b6fbcd2ad8b24e7acbc21a1da64',
|
||||
|
||||
};
|
||||
|
||||
export const CELO_TOKENS = {
|
||||
@@ -561,11 +576,11 @@ export const CELO_TOKENS = {
|
||||
// Some of these tokens are Optics bridge? tokens which
|
||||
// had an issue and migrated from v1 to v2
|
||||
WETHv1: '0xe919f65739c26a42616b7b8eedc6b5524d1e3ac4',
|
||||
WETH: '0x122013fd7df1c6f636a5bb8f03108e876548b455',
|
||||
oWETH: '0x122013fd7df1c6f636a5bb8f03108e876548b455',
|
||||
WBTC: '0xbaab46e28388d2779e6e31fd00cf0e5ad95e327b',
|
||||
cUSD: '0x765de816845861e75a25fca122bb6898b8b1282a',
|
||||
// ??
|
||||
WBTCv1: '0xd629eb00deced2a080b7ec630ef6ac117e614f1b',
|
||||
cBTC: '0xd629eb00deced2a080b7ec630ef6ac117e614f1b',
|
||||
cETH: '0x2def4285787d58a2f811af24755a8150622f4361',
|
||||
UBE: '0x00be915b9dcf56a3cbe739d9b9c202ca692409ec',
|
||||
// Moolah
|
||||
@@ -574,6 +589,22 @@ export const CELO_TOKENS = {
|
||||
mCEUR: '0xe273ad7ee11dcfaa87383ad5977ee1504ac07568',
|
||||
amCUSD: '0x64defa3544c695db8c535d289d843a189aa26b98',
|
||||
MOO: '0x17700282592d6917f6a73d0bf8accf4d578c131e',
|
||||
|
||||
//
|
||||
wBTC: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
||||
wETH: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
||||
wBTCO: '0xbe50a3013a1c94768a1abb78c3cb79ab28fc1ace',
|
||||
pUSDC: '0xcc82628f6a8defa1e2b0ad7ed448bef3647f7941',
|
||||
cUSDC: '0x2a3684e9dc20b857375ea04235f2f7edbe818fa7',
|
||||
cUSDC_V2: '0xef4229c8c3250c675f21bcefa42f58efbff6002a',
|
||||
pUSDC_V2: '0x1bfc26ce035c368503fae319cc2596716428ca44',
|
||||
pUSD: '0xeadf4a7168a82d30ba0619e64d5bcf5b30b45226',
|
||||
pCELO: '0x301a61d01a63c8d670c2b8a43f37d12ef181f997',
|
||||
aaUSDC: '0xb70e0a782b058bfdb0d109a3599bec1f19328e36',
|
||||
asUSDC: '0xcd7d7ff64746c1909e44db8e95331f9316478817',
|
||||
mcUSDT: '0xcfffe0c89a779c09df3df5624f54cdf7ef5fdd5d',
|
||||
mcUSDC: '0x93db49be12b864019da9cb147ba75cdc0506190e',
|
||||
DAI: '0x90ca507a5d4458a4c6c6249d186b6dcb02a5bccd',
|
||||
};
|
||||
|
||||
export const FANTOM_TOKENS = {
|
||||
@@ -669,6 +700,7 @@ export const CURVE_POOLS = {
|
||||
d3pool: '0xbaaa1f5dba42c3389bdbc2c9d2de134f5cd0dc89',
|
||||
triEURpool: '0xb9446c4ef5ebe66268da6700d26f96273de3d571',
|
||||
ibEURsEUR: '0x19b080fe1ffa0553469d20ca36219f17fcf03859',
|
||||
wethyfi: '0xc26b89a667578ec7b3f11b2f98d6fd15c07c54ba',
|
||||
};
|
||||
|
||||
export const CURVE_V2_POOLS = {
|
||||
@@ -796,6 +828,14 @@ export const FIREBIRDONESWAP_BSC_POOLS = {
|
||||
export const FIREBIRDONESWAP_POLYGON_POOLS = {
|
||||
oneswap: '0x01c9475dbd36e46d1961572c8de24b74616bae9e',
|
||||
};
|
||||
export const MOBIUSMONEY_CELO_POOLS = {
|
||||
usdc_optics_v2: '0x9906589ea8fd27504974b7e8201df5bbde986b03',
|
||||
dai_optics_v2: '0xf3f65dfe0c8c8f2986da0fec159abe6fd4e700b4',
|
||||
weth_optics_v2: '0x74ef28d635c6c5800dd3cd62d4c4f8752daacb09',
|
||||
pusdc_optics_v2: '0xcce0d62ce14fb3e4363eb92db37ff3630836c252',
|
||||
usdc_allbridge_solana: '0x63c1914bf00a9b395a2bf89aada55a5615a3656e',
|
||||
usdc_poly_optics: '0xa2f0e57d4ceacf025e81c76f28b9ad6e9fbe8735',
|
||||
};
|
||||
|
||||
export const ACRYPTOS_POOLS = {
|
||||
acs4usd: '0xb3f0c9ea1f05e312093fdb031e789a756659b0ac',
|
||||
@@ -804,6 +844,14 @@ export const ACRYPTOS_POOLS = {
|
||||
acs3btc: '0xbe7caa236544d1b9a0e7f91e94b9f5bfd3b5ca81',
|
||||
};
|
||||
|
||||
export const PLATYPUS_AVALANCHE_POOLS = {
|
||||
usd: '0x66357dcace80431aee0a7507e2e361b7e2402370',
|
||||
ust: '0xe0d166de15665bc4b7185b2e35e847e51316e126',
|
||||
frax: '0xb8e567fc23c39c94a1f6359509d7b43d1fbed824',
|
||||
mim: '0x30c30d826be87cd0a4b90855c2f38f7fcfe4eaa7',
|
||||
sAVAX: '0x4658ea7e9960d6158a261104aaa160cc953bb6ba',
|
||||
};
|
||||
|
||||
export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
|
||||
{
|
||||
[ChainId.Mainnet]: [
|
||||
@@ -855,7 +903,13 @@ export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
|
||||
FANTOM_TOKENS.nETH,
|
||||
FANTOM_TOKENS.MIM,
|
||||
],
|
||||
[ChainId.Celo]: [CELO_TOKENS.WCELO, CELO_TOKENS.mCUSD, CELO_TOKENS.WETH, CELO_TOKENS.amCUSD, CELO_TOKENS.WBTC],
|
||||
[ChainId.Celo]: [
|
||||
CELO_TOKENS.WCELO,
|
||||
CELO_TOKENS.mCUSD,
|
||||
CELO_TOKENS.WETHv1,
|
||||
CELO_TOKENS.amCUSD,
|
||||
CELO_TOKENS.WBTC,
|
||||
],
|
||||
[ChainId.Optimism]: [
|
||||
OPTIMISM_TOKENS.WETH,
|
||||
OPTIMISM_TOKENS.DAI,
|
||||
@@ -1029,6 +1083,15 @@ const createCurveFactoryCryptoExchangePool = (info: { tokens: string[]; pool: st
|
||||
poolAddress: info.pool,
|
||||
gasSchedule: info.gasSchedule,
|
||||
});
|
||||
const MOBIUSMONEY_CELO_SHARED: CurveInfo = {
|
||||
exchangeFunctionSelector: CurveFunctionSelectors.swap,
|
||||
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
|
||||
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
|
||||
metaTokens: undefined,
|
||||
gasSchedule: 150e3,
|
||||
poolAddress: NULL_ADDRESS,
|
||||
tokens: [],
|
||||
};
|
||||
|
||||
/**
|
||||
* Mainnet Curve configuration
|
||||
@@ -1301,6 +1364,11 @@ export const CURVE_MAINNET_INFOS: { [name: string]: CurveInfo } = {
|
||||
pool: CURVE_POOLS.btrflyweth,
|
||||
gasSchedule: 250e3,
|
||||
}),
|
||||
[CURVE_POOLS.wethyfi]: createCurveFactoryCryptoExchangePool({
|
||||
tokens: [MAINNET_TOKENS.WETH, MAINNET_TOKENS.YFI],
|
||||
pool: CURVE_POOLS.wethyfi,
|
||||
gasSchedule: 250e3,
|
||||
}),
|
||||
};
|
||||
|
||||
export const CURVE_V2_MAINNET_INFOS: { [name: string]: CurveInfo } = {
|
||||
@@ -1696,6 +1764,39 @@ export const FIREBIRDONESWAP_POLYGON_INFOS: { [name: string]: CurveInfo } = {
|
||||
},
|
||||
};
|
||||
|
||||
export const MOBIUSMONEY_CELO_INFOS: { [name: string]: CurveInfo } = {
|
||||
[MOBIUSMONEY_CELO_POOLS.usdc_optics_v2]: {
|
||||
...MOBIUSMONEY_CELO_SHARED,
|
||||
poolAddress: MOBIUSMONEY_CELO_POOLS.usdc_optics_v2,
|
||||
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.cUSDC_V2],
|
||||
},
|
||||
[MOBIUSMONEY_CELO_POOLS.weth_optics_v2]: {
|
||||
...MOBIUSMONEY_CELO_SHARED,
|
||||
poolAddress: MOBIUSMONEY_CELO_POOLS.weth_optics_v2,
|
||||
tokens: [CELO_TOKENS.cETH, CELO_TOKENS.oWETH],
|
||||
},
|
||||
[MOBIUSMONEY_CELO_POOLS.pusdc_optics_v2]: {
|
||||
...MOBIUSMONEY_CELO_SHARED,
|
||||
poolAddress: MOBIUSMONEY_CELO_POOLS.pusdc_optics_v2,
|
||||
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.pUSDC_V2],
|
||||
},
|
||||
[MOBIUSMONEY_CELO_POOLS.usdc_allbridge_solana]: {
|
||||
...MOBIUSMONEY_CELO_SHARED,
|
||||
poolAddress: MOBIUSMONEY_CELO_POOLS.usdc_allbridge_solana,
|
||||
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.asUSDC],
|
||||
},
|
||||
[MOBIUSMONEY_CELO_POOLS.usdc_poly_optics]: {
|
||||
...MOBIUSMONEY_CELO_SHARED,
|
||||
poolAddress: MOBIUSMONEY_CELO_POOLS.usdc_poly_optics,
|
||||
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.pUSD],
|
||||
},
|
||||
[MOBIUSMONEY_CELO_POOLS.dai_optics_v2]: {
|
||||
...MOBIUSMONEY_CELO_SHARED,
|
||||
poolAddress: MOBIUSMONEY_CELO_POOLS.dai_optics_v2,
|
||||
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.DAI],
|
||||
},
|
||||
};
|
||||
|
||||
const ACRYPTOS_ACS4USD_POOL_BSC_TOKENS = [BSC_TOKENS.BUSD, BSC_TOKENS.USDT, BSC_TOKENS.DAI, BSC_TOKENS.USDC];
|
||||
|
||||
const createAcryptosMetaUsdPool = (info: { tokens: string[]; pool: string; gasSchedule: number }) => ({
|
||||
@@ -1734,6 +1835,34 @@ export const ACRYPTOS_BSC_INFOS: { [name: string]: CurveInfo } = {
|
||||
}),
|
||||
};
|
||||
|
||||
export const PLATYPUS_AVALANCHE_INFOS: { [name: string]: PlatypusInfo } = {
|
||||
[PLATYPUS_AVALANCHE_POOLS.usd]: {
|
||||
poolAddress: [PLATYPUS_AVALANCHE_POOLS.usd],
|
||||
tokens: [AVALANCHE_TOKENS.USDT, AVALANCHE_TOKENS.USDC, AVALANCHE_TOKENS.DAI, AVALANCHE_TOKENS.nUSDC, AVALANCHE_TOKENS.USDt],
|
||||
gasSchedule: 350e3,
|
||||
},
|
||||
[PLATYPUS_AVALANCHE_POOLS.ust]: {
|
||||
poolAddress: [PLATYPUS_AVALANCHE_POOLS.ust],
|
||||
tokens: [AVALANCHE_TOKENS.nUSDC, AVALANCHE_TOKENS.UST],
|
||||
gasSchedule: 350e3,
|
||||
},
|
||||
[PLATYPUS_AVALANCHE_POOLS.frax]: {
|
||||
poolAddress: [PLATYPUS_AVALANCHE_POOLS.frax],
|
||||
tokens: [AVALANCHE_TOKENS.nUSDC, AVALANCHE_TOKENS.FRAX], //liq issues
|
||||
gasSchedule: 350e3,
|
||||
},
|
||||
[PLATYPUS_AVALANCHE_POOLS.mim]: {
|
||||
poolAddress: [PLATYPUS_AVALANCHE_POOLS.mim],
|
||||
tokens: [AVALANCHE_TOKENS.MIM, AVALANCHE_TOKENS.nUSDC],
|
||||
gasSchedule: 350e3,
|
||||
},
|
||||
[PLATYPUS_AVALANCHE_POOLS.sAVAX]: {
|
||||
poolAddress: [PLATYPUS_AVALANCHE_POOLS.sAVAX],
|
||||
tokens: [AVALANCHE_TOKENS.WAVAX, AVALANCHE_TOKENS.sAVAX], //add unwrapping
|
||||
gasSchedule: 350e3,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Kyber reserve prefixes
|
||||
* 0xff Fed price reserve
|
||||
@@ -2262,6 +2391,33 @@ export const SPOOKYSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
export const GMX_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.Avalanche]: '0x5f719c2f1095f7b9fc68a68e35b51194f4b6abe8',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const GMX_READER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.Avalanche]: '0x67b789d48c926006f5132bfce4e976f0a7a63d5d',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const GMX_VAULT_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.Avalanche]: '0x9ab2de34a33fb459b538c43f251eb825645e8595',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const PLATYPUS_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
{
|
||||
[ChainId.Avalanche]: '0x73256ec7575d999c360c1eec118ecbefd8da7d12',
|
||||
},
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const VIP_ERC20_BRIDGE_SOURCES_BY_CHAIN_ID = valueByChainId<ERC20BridgeSource[]>(
|
||||
{
|
||||
@@ -2335,6 +2491,7 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
|
||||
[ERC20BridgeSource.IronSwap]: fillData => (fillData as CurveFillData).pool.gasSchedule,
|
||||
[ERC20BridgeSource.XSigma]: fillData => (fillData as CurveFillData).pool.gasSchedule,
|
||||
[ERC20BridgeSource.FirebirdOneSwap]: fillData => (fillData as CurveFillData).pool.gasSchedule,
|
||||
[ERC20BridgeSource.MobiusMoney]: fillData => (fillData as CurveFillData).pool.gasSchedule,
|
||||
[ERC20BridgeSource.MultiBridge]: () => 350e3,
|
||||
[ERC20BridgeSource.UniswapV2]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.SushiSwap]: uniswapV2CloneGasSchedule,
|
||||
@@ -2465,6 +2622,8 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
|
||||
//
|
||||
[ERC20BridgeSource.Pangolin]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.TraderJoe]: uniswapV2CloneGasSchedule,
|
||||
[ERC20BridgeSource.GMX]: () => 450e3,
|
||||
[ERC20BridgeSource.Platypus]: () => 450e3,
|
||||
|
||||
//
|
||||
// Celo
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
FinalUniswapV3FillData,
|
||||
GeistFillData,
|
||||
GenericRouterFillData,
|
||||
GMXFillData,
|
||||
KyberDmmFillData,
|
||||
KyberFillData,
|
||||
LidoFillData,
|
||||
@@ -34,6 +35,7 @@ import {
|
||||
OptimizedMarketOrder,
|
||||
OptimizedMarketOrderBase,
|
||||
OrderDomain,
|
||||
PlatypusFillData,
|
||||
ShellFillData,
|
||||
UniswapV2FillData,
|
||||
UniswapV3FillData,
|
||||
@@ -206,6 +208,12 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
|
||||
return encodeBridgeSourceId(BridgeProtocol.Compound, 'Compound');
|
||||
case ERC20BridgeSource.Geist:
|
||||
return encodeBridgeSourceId(BridgeProtocol.AaveV2, 'Geist');
|
||||
case ERC20BridgeSource.MobiusMoney:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'MobiusMoney');
|
||||
case ERC20BridgeSource.GMX:
|
||||
return encodeBridgeSourceId(BridgeProtocol.GMX, 'GMX');
|
||||
case ERC20BridgeSource.Platypus:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Platypus, 'Platypus');
|
||||
default:
|
||||
throw new Error(AggregationError.NoBridgeForSource);
|
||||
}
|
||||
@@ -241,6 +249,7 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
|
||||
case ERC20BridgeSource.FirebirdOneSwap:
|
||||
case ERC20BridgeSource.IronSwap:
|
||||
case ERC20BridgeSource.ACryptos:
|
||||
case ERC20BridgeSource.MobiusMoney:
|
||||
const curveFillData = (order as OptimizedMarketBridgeOrder<CurveFillData>).fillData;
|
||||
bridgeData = encoder.encode([
|
||||
curveFillData.pool.poolAddress,
|
||||
@@ -364,6 +373,23 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
|
||||
const geistFillData = (order as OptimizedMarketBridgeOrder<GeistFillData>).fillData;
|
||||
bridgeData = encoder.encode([geistFillData.lendingPool, geistFillData.gToken]);
|
||||
break;
|
||||
case ERC20BridgeSource.GMX:
|
||||
const gmxFillData = (order as OptimizedMarketBridgeOrder<GMXFillData>).fillData;
|
||||
bridgeData = encoder.encode([
|
||||
gmxFillData.router,
|
||||
gmxFillData.reader,
|
||||
gmxFillData.vault,
|
||||
gmxFillData.tokenAddressPath,
|
||||
]);
|
||||
break;
|
||||
case ERC20BridgeSource.Platypus:
|
||||
const platypusFillData = (order as OptimizedMarketBridgeOrder<PlatypusFillData>).fillData;
|
||||
bridgeData = encoder.encode([
|
||||
platypusFillData.router,
|
||||
platypusFillData.pool,
|
||||
platypusFillData.tokenAddressPath,
|
||||
]);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(AggregationError.NoBridgeForSource);
|
||||
@@ -449,6 +475,8 @@ const balancerV2Encoder = AbiEncoder.create([
|
||||
{ name: 'poolId', type: 'bytes32' },
|
||||
]);
|
||||
const routerAddressPathEncoder = AbiEncoder.create('(address,address[])');
|
||||
const gmxAddressPathEncoder = AbiEncoder.create('(address,address,address,address[])');
|
||||
const platypusAddressPathEncoder = AbiEncoder.create('(address,address[],address[])');
|
||||
const tokenAddressEncoder = AbiEncoder.create([{ name: 'tokenAddress', type: 'address' }]);
|
||||
|
||||
export const BRIDGE_ENCODERS: {
|
||||
@@ -489,6 +517,7 @@ export const BRIDGE_ENCODERS: {
|
||||
[ERC20BridgeSource.FirebirdOneSwap]: curveEncoder,
|
||||
[ERC20BridgeSource.IronSwap]: curveEncoder,
|
||||
[ERC20BridgeSource.ACryptos]: curveEncoder,
|
||||
[ERC20BridgeSource.MobiusMoney]: curveEncoder,
|
||||
// UniswapV2 like, (router, address[])
|
||||
[ERC20BridgeSource.Bancor]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.UniswapV2]: routerAddressPathEncoder,
|
||||
@@ -501,6 +530,9 @@ export const BRIDGE_ENCODERS: {
|
||||
[ERC20BridgeSource.SpiritSwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.SpookySwap]: routerAddressPathEncoder,
|
||||
[ERC20BridgeSource.MorpheusSwap]: routerAddressPathEncoder,
|
||||
// Avalanche
|
||||
[ERC20BridgeSource.GMX]: gmxAddressPathEncoder,
|
||||
[ERC20BridgeSource.Platypus]: platypusAddressPathEncoder,
|
||||
// Celo
|
||||
[ERC20BridgeSource.UbeSwap]: routerAddressPathEncoder,
|
||||
// BSC
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
getCurveLikeInfosForPair,
|
||||
getDodoV2Offsets,
|
||||
getKyberOffsets,
|
||||
getPlatypusInfoForPair,
|
||||
getShellLikeInfosForPair,
|
||||
isAllowedKyberReserveId,
|
||||
isBadTokenForSource,
|
||||
@@ -30,6 +31,9 @@ import {
|
||||
COMPOUND_API_URL_BY_CHAIN_ID,
|
||||
DODOV1_CONFIG_BY_CHAIN_ID,
|
||||
DODOV2_FACTORIES_BY_CHAIN_ID,
|
||||
GMX_READER_BY_CHAIN_ID,
|
||||
GMX_ROUTER_BY_CHAIN_ID,
|
||||
GMX_VAULT_BY_CHAIN_ID,
|
||||
KYBER_CONFIG_BY_CHAIN_ID,
|
||||
KYBER_DMM_ROUTER_BY_CHAIN_ID,
|
||||
LIDO_INFO_BY_CHAIN,
|
||||
@@ -42,6 +46,7 @@ import {
|
||||
NATIVE_FEE_TOKEN_BY_CHAIN_ID,
|
||||
NULL_ADDRESS,
|
||||
NULL_BYTES,
|
||||
PLATYPUS_ROUTER_BY_CHAIN_ID,
|
||||
SELL_SOURCE_FILTER_BY_CHAIN_ID,
|
||||
UNISWAPV1_ROUTER_BY_CHAIN_ID,
|
||||
UNISWAPV3_CONFIG_BY_CHAIN_ID,
|
||||
@@ -71,6 +76,7 @@ import {
|
||||
GeistFillData,
|
||||
GeistInfo,
|
||||
GenericRouterFillData,
|
||||
GMXFillData,
|
||||
HopInfo,
|
||||
KyberDmmFillData,
|
||||
KyberFillData,
|
||||
@@ -82,6 +88,7 @@ import {
|
||||
MakerPsmFillData,
|
||||
MooniswapFillData,
|
||||
MultiHopFillData,
|
||||
PlatypusFillData,
|
||||
PsmInfo,
|
||||
ShellFillData,
|
||||
SourceQuoteOperation,
|
||||
@@ -1213,6 +1220,65 @@ export class SamplerOperations {
|
||||
params: [cToken, takerToken, makerToken, makerFillAmounts],
|
||||
});
|
||||
}
|
||||
public getGMXSellQuotes(
|
||||
router: string,
|
||||
reader: string,
|
||||
vault: string,
|
||||
tokenAddressPath: string[],
|
||||
takerFillAmounts: BigNumber[],
|
||||
): SourceQuoteOperation<GMXFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.GMX,
|
||||
fillData: { router, reader, vault, tokenAddressPath },
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleSellsFromGMX,
|
||||
params: [reader, vault, tokenAddressPath, takerFillAmounts],
|
||||
});
|
||||
}
|
||||
public getGMXBuyQuotes(
|
||||
router: string,
|
||||
reader: string,
|
||||
vault: string,
|
||||
tokenAddressPath: string[],
|
||||
makerFillAmounts: BigNumber[],
|
||||
): SourceQuoteOperation<GMXFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.GMX,
|
||||
fillData: { router, reader, vault, tokenAddressPath },
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleBuysFromGMX,
|
||||
params: [reader, vault, tokenAddressPath, makerFillAmounts],
|
||||
});
|
||||
}
|
||||
|
||||
public getPlatypusSellQuotes(
|
||||
router: string,
|
||||
pool: string[],
|
||||
tokenAddressPath: string[],
|
||||
takerFillAmounts: BigNumber[],
|
||||
): SourceQuoteOperation<PlatypusFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.Platypus,
|
||||
fillData: { router, pool, tokenAddressPath },
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleSellsFromPlatypus,
|
||||
params: [router, tokenAddressPath, pool, takerFillAmounts],
|
||||
});
|
||||
}
|
||||
public getPlatypusBuyQuotes(
|
||||
router: string,
|
||||
pool: string[],
|
||||
tokenAddressPath: string[],
|
||||
makerFillAmounts: BigNumber[],
|
||||
): SourceQuoteOperation<PlatypusFillData> {
|
||||
return new SamplerContractOperation({
|
||||
source: ERC20BridgeSource.Platypus,
|
||||
fillData: { router, tokenAddressPath, pool },
|
||||
contract: this._samplerContract,
|
||||
function: this._samplerContract.sampleBuysFromPlatypus,
|
||||
params: [router, tokenAddressPath, pool, makerFillAmounts],
|
||||
});
|
||||
}
|
||||
|
||||
public getMedianSellRate(
|
||||
sources: ERC20BridgeSource[],
|
||||
@@ -1383,6 +1449,7 @@ export class SamplerOperations {
|
||||
case ERC20BridgeSource.FirebirdOneSwap:
|
||||
case ERC20BridgeSource.IronSwap:
|
||||
case ERC20BridgeSource.ACryptos:
|
||||
case ERC20BridgeSource.MobiusMoney:
|
||||
return getCurveLikeInfosForPair(this.chainId, takerToken, makerToken, source).map(pool =>
|
||||
this.getCurveSellQuotes(
|
||||
pool,
|
||||
@@ -1604,8 +1671,28 @@ export class SamplerOperations {
|
||||
takerFillAmounts,
|
||||
);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported sell sample source: ${source}`);
|
||||
case ERC20BridgeSource.GMX: {
|
||||
return this.getGMXSellQuotes(
|
||||
GMX_ROUTER_BY_CHAIN_ID[this.chainId],
|
||||
GMX_READER_BY_CHAIN_ID[this.chainId],
|
||||
GMX_VAULT_BY_CHAIN_ID[this.chainId],
|
||||
[takerToken, makerToken],
|
||||
takerFillAmounts,
|
||||
);
|
||||
}
|
||||
case ERC20BridgeSource.Platypus: {
|
||||
return getPlatypusInfoForPair(this.chainId, takerToken, makerToken).map(pool =>
|
||||
this.getPlatypusSellQuotes(
|
||||
PLATYPUS_ROUTER_BY_CHAIN_ID[this.chainId],
|
||||
pool.poolAddress,
|
||||
pool.tokens,
|
||||
takerFillAmounts,
|
||||
),
|
||||
);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported sell sample source: ${source}`);
|
||||
|
||||
}
|
||||
}),
|
||||
);
|
||||
@@ -1696,6 +1783,7 @@ export class SamplerOperations {
|
||||
case ERC20BridgeSource.FirebirdOneSwap:
|
||||
case ERC20BridgeSource.IronSwap:
|
||||
case ERC20BridgeSource.ACryptos:
|
||||
case ERC20BridgeSource.MobiusMoney:
|
||||
return getCurveLikeInfosForPair(this.chainId, takerToken, makerToken, source).map(pool =>
|
||||
this.getCurveBuyQuotes(
|
||||
pool,
|
||||
@@ -1907,6 +1995,25 @@ export class SamplerOperations {
|
||||
}
|
||||
return this.getCompoundBuyQuotes(cToken.tokenAddress, makerToken, takerToken, makerFillAmounts);
|
||||
}
|
||||
case ERC20BridgeSource.GMX: {
|
||||
return this.getGMXBuyQuotes(
|
||||
GMX_ROUTER_BY_CHAIN_ID[this.chainId],
|
||||
GMX_READER_BY_CHAIN_ID[this.chainId],
|
||||
GMX_VAULT_BY_CHAIN_ID[this.chainId],
|
||||
[takerToken, makerToken],
|
||||
makerFillAmounts,
|
||||
);
|
||||
}
|
||||
case ERC20BridgeSource.Platypus: {
|
||||
return getPlatypusInfoForPair(this.chainId, takerToken, makerToken).map(pool =>
|
||||
this.getPlatypusBuyQuotes(
|
||||
PLATYPUS_ROUTER_BY_CHAIN_ID[this.chainId],
|
||||
pool.poolAddress,
|
||||
pool.tokens,
|
||||
makerFillAmounts,
|
||||
),
|
||||
);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unsupported buy sample source: ${source}`);
|
||||
}
|
||||
|
||||
@@ -94,8 +94,12 @@ export enum ERC20BridgeSource {
|
||||
// Avalanche
|
||||
Pangolin = 'Pangolin',
|
||||
TraderJoe = 'TraderJoe',
|
||||
// tslint:disable-next-line: enum-naming
|
||||
GMX = 'GMX',
|
||||
Platypus = 'Platypus',
|
||||
// Celo only
|
||||
UbeSwap = 'UbeSwap',
|
||||
MobiusMoney = 'MobiusMoney',
|
||||
// Fantom
|
||||
SpiritSwap = 'SpiritSwap',
|
||||
SpookySwap = 'SpookySwap',
|
||||
@@ -187,6 +191,11 @@ export interface GeistInfo {
|
||||
underlyingToken: string;
|
||||
}
|
||||
|
||||
export interface PlatypusInfo {
|
||||
poolAddress: string[];
|
||||
tokens: string[];
|
||||
gasSchedule: number;
|
||||
}
|
||||
// Internal `fillData` field for `Fill` objects.
|
||||
export interface FillData {}
|
||||
|
||||
@@ -222,6 +231,19 @@ export interface UniswapV2FillData extends FillData {
|
||||
router: string;
|
||||
}
|
||||
|
||||
export interface GMXFillData extends FillData {
|
||||
router: string;
|
||||
reader: string;
|
||||
vault: string;
|
||||
tokenAddressPath: string[];
|
||||
}
|
||||
|
||||
export interface PlatypusFillData extends FillData {
|
||||
router: string;
|
||||
pool: string[];
|
||||
tokenAddressPath: string[];
|
||||
}
|
||||
|
||||
export interface ShellFillData extends FillData {
|
||||
poolAddress: string;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,16 @@ import * as DODOV2Sampler from '../test/generated-artifacts/DODOV2Sampler.json';
|
||||
import * as DummyLiquidityProvider from '../test/generated-artifacts/DummyLiquidityProvider.json';
|
||||
import * as ERC20BridgeSampler from '../test/generated-artifacts/ERC20BridgeSampler.json';
|
||||
import * as FakeTaker from '../test/generated-artifacts/FakeTaker.json';
|
||||
import * as GMXSampler from '../test/generated-artifacts/GMXSampler.json';
|
||||
import * as IBalancer from '../test/generated-artifacts/IBalancer.json';
|
||||
import * as IBancor from '../test/generated-artifacts/IBancor.json';
|
||||
import * as ICurve from '../test/generated-artifacts/ICurve.json';
|
||||
import * as IGMX from '../test/generated-artifacts/IGMX.json';
|
||||
import * as IKyberNetwork from '../test/generated-artifacts/IKyberNetwork.json';
|
||||
import * as IMooniswap from '../test/generated-artifacts/IMooniswap.json';
|
||||
import * as IMStable from '../test/generated-artifacts/IMStable.json';
|
||||
import * as IMultiBridge from '../test/generated-artifacts/IMultiBridge.json';
|
||||
import * as IPlatypus from '../test/generated-artifacts/IPlatypus.json';
|
||||
import * as IShell from '../test/generated-artifacts/IShell.json';
|
||||
import * as ISmoothy from '../test/generated-artifacts/ISmoothy.json';
|
||||
import * as IUniswapExchangeQuotes from '../test/generated-artifacts/IUniswapExchangeQuotes.json';
|
||||
@@ -37,6 +40,7 @@ import * as MooniswapSampler from '../test/generated-artifacts/MooniswapSampler.
|
||||
import * as MStableSampler from '../test/generated-artifacts/MStableSampler.json';
|
||||
import * as MultiBridgeSampler from '../test/generated-artifacts/MultiBridgeSampler.json';
|
||||
import * as NativeOrderSampler from '../test/generated-artifacts/NativeOrderSampler.json';
|
||||
import * as PlatypusSampler from '../test/generated-artifacts/PlatypusSampler.json';
|
||||
import * as SamplerUtils from '../test/generated-artifacts/SamplerUtils.json';
|
||||
import * as ShellSampler from '../test/generated-artifacts/ShellSampler.json';
|
||||
import * as SmoothySampler from '../test/generated-artifacts/SmoothySampler.json';
|
||||
@@ -59,6 +63,7 @@ export const artifacts = {
|
||||
DODOV2Sampler: DODOV2Sampler as ContractArtifact,
|
||||
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
|
||||
FakeTaker: FakeTaker as ContractArtifact,
|
||||
GMXSampler: GMXSampler as ContractArtifact,
|
||||
KyberDmmSampler: KyberDmmSampler as ContractArtifact,
|
||||
KyberSampler: KyberSampler as ContractArtifact,
|
||||
LidoSampler: LidoSampler as ContractArtifact,
|
||||
@@ -68,6 +73,7 @@ export const artifacts = {
|
||||
MooniswapSampler: MooniswapSampler as ContractArtifact,
|
||||
MultiBridgeSampler: MultiBridgeSampler as ContractArtifact,
|
||||
NativeOrderSampler: NativeOrderSampler as ContractArtifact,
|
||||
PlatypusSampler: PlatypusSampler as ContractArtifact,
|
||||
SamplerUtils: SamplerUtils as ContractArtifact,
|
||||
ShellSampler: ShellSampler as ContractArtifact,
|
||||
SmoothySampler: SmoothySampler as ContractArtifact,
|
||||
@@ -79,10 +85,12 @@ export const artifacts = {
|
||||
IBalancer: IBalancer as ContractArtifact,
|
||||
IBancor: IBancor as ContractArtifact,
|
||||
ICurve: ICurve as ContractArtifact,
|
||||
IGMX: IGMX as ContractArtifact,
|
||||
IKyberNetwork: IKyberNetwork as ContractArtifact,
|
||||
IMStable: IMStable as ContractArtifact,
|
||||
IMooniswap: IMooniswap as ContractArtifact,
|
||||
IMultiBridge: IMultiBridge as ContractArtifact,
|
||||
IPlatypus: IPlatypus as ContractArtifact,
|
||||
IShell: IShell as ContractArtifact,
|
||||
ISmoothy: ISmoothy as ContractArtifact,
|
||||
IUniswapExchangeQuotes: IUniswapExchangeQuotes as ContractArtifact,
|
||||
|
||||
@@ -15,6 +15,7 @@ export * from '../test/generated-wrappers/d_o_d_o_v2_sampler';
|
||||
export * from '../test/generated-wrappers/dummy_liquidity_provider';
|
||||
export * from '../test/generated-wrappers/erc20_bridge_sampler';
|
||||
export * from '../test/generated-wrappers/fake_taker';
|
||||
export * from '../test/generated-wrappers/g_m_x_sampler';
|
||||
export * from '../test/generated-wrappers/i_balancer';
|
||||
export * from '../test/generated-wrappers/i_bancor';
|
||||
export * from '../test/generated-wrappers/i_curve';
|
||||
@@ -22,10 +23,12 @@ export * from '../test/generated-wrappers/i_kyber_network';
|
||||
export * from '../test/generated-wrappers/i_m_stable';
|
||||
export * from '../test/generated-wrappers/i_mooniswap';
|
||||
export * from '../test/generated-wrappers/i_multi_bridge';
|
||||
export * from '../test/generated-wrappers/i_platypus';
|
||||
export * from '../test/generated-wrappers/i_shell';
|
||||
export * from '../test/generated-wrappers/i_smoothy';
|
||||
export * from '../test/generated-wrappers/i_uniswap_exchange_quotes';
|
||||
export * from '../test/generated-wrappers/i_uniswap_v2_router01';
|
||||
export * from '../test/generated-wrappers/igmx';
|
||||
export * from '../test/generated-wrappers/kyber_dmm_sampler';
|
||||
export * from '../test/generated-wrappers/kyber_sampler';
|
||||
export * from '../test/generated-wrappers/lido_sampler';
|
||||
@@ -35,6 +38,7 @@ export * from '../test/generated-wrappers/maker_p_s_m_sampler';
|
||||
export * from '../test/generated-wrappers/mooniswap_sampler';
|
||||
export * from '../test/generated-wrappers/multi_bridge_sampler';
|
||||
export * from '../test/generated-wrappers/native_order_sampler';
|
||||
export * from '../test/generated-wrappers/platypus_sampler';
|
||||
export * from '../test/generated-wrappers/sampler_utils';
|
||||
export * from '../test/generated-wrappers/shell_sampler';
|
||||
export * from '../test/generated-wrappers/smoothy_sampler';
|
||||
|
||||
@@ -18,13 +18,16 @@
|
||||
"test/generated-artifacts/DummyLiquidityProvider.json",
|
||||
"test/generated-artifacts/ERC20BridgeSampler.json",
|
||||
"test/generated-artifacts/FakeTaker.json",
|
||||
"test/generated-artifacts/GMXSampler.json",
|
||||
"test/generated-artifacts/IBalancer.json",
|
||||
"test/generated-artifacts/IBancor.json",
|
||||
"test/generated-artifacts/ICurve.json",
|
||||
"test/generated-artifacts/IGMX.json",
|
||||
"test/generated-artifacts/IKyberNetwork.json",
|
||||
"test/generated-artifacts/IMStable.json",
|
||||
"test/generated-artifacts/IMooniswap.json",
|
||||
"test/generated-artifacts/IMultiBridge.json",
|
||||
"test/generated-artifacts/IPlatypus.json",
|
||||
"test/generated-artifacts/IShell.json",
|
||||
"test/generated-artifacts/ISmoothy.json",
|
||||
"test/generated-artifacts/IUniswapExchangeQuotes.json",
|
||||
@@ -38,6 +41,7 @@
|
||||
"test/generated-artifacts/MooniswapSampler.json",
|
||||
"test/generated-artifacts/MultiBridgeSampler.json",
|
||||
"test/generated-artifacts/NativeOrderSampler.json",
|
||||
"test/generated-artifacts/PlatypusSampler.json",
|
||||
"test/generated-artifacts/SamplerUtils.json",
|
||||
"test/generated-artifacts/ShellSampler.json",
|
||||
"test/generated-artifacts/SmoothySampler.json",
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
[
|
||||
{
|
||||
"version": "1.12.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added Support for GMX liquidity source on Avalanche"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1646225739,
|
||||
"version": "1.11.1",
|
||||
|
||||
@@ -134,6 +134,8 @@ export enum BridgeProtocol {
|
||||
Clipper, // Not used: Clipper is now using PLP interface
|
||||
AaveV2,
|
||||
Compound,
|
||||
GMX,
|
||||
Platypus,
|
||||
}
|
||||
// tslint:enable: enum-naming
|
||||
|
||||
|
||||
15
yarn.lock
15
yarn.lock
@@ -3755,17 +3755,10 @@ bigi@1.4.2, bigi@^1.1.0:
|
||||
version "1.4.2"
|
||||
resolved "https://registry.yarnpkg.com/bigi/-/bigi-1.4.2.tgz#9c665a95f88b8b08fc05cfd731f561859d725825"
|
||||
|
||||
bignumber.js@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f"
|
||||
|
||||
bignumber.js@^9.0.0, bignumber.js@~9.0.0:
|
||||
version "9.0.1"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.1.tgz#8d7ba124c882bfd8e43260c67475518d0689e4e5"
|
||||
|
||||
bignumber.js@~4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1"
|
||||
bignumber.js@7.2.1, bignumber.js@9.0.2, bignumber.js@^9.0.0, bignumber.js@~4.1.0, bignumber.js@~9.0.0:
|
||||
version "9.0.2"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.2.tgz#71c6c6bed38de64e24a65ebe16cfcf23ae693673"
|
||||
integrity sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==
|
||||
|
||||
binary-extensions@^2.0.0:
|
||||
version "2.1.0"
|
||||
|
||||
Reference in New Issue
Block a user