Skip to content

Commit

Permalink
feat/add MeshSwap on Polygon [TKR-374] (#491)
Browse files Browse the repository at this point in the history
* Added MeshSwap on Polygon

* Updated changelog
  • Loading branch information
fluffypill0w authored and Noah Khamliche committed Jun 15, 2022
1 parent 0f2078e commit 2a2bb53
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/asset-swapper/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
{
"note": "Offboard/clean up Oasis, CoFix, and legacy Kyber",
"pr": 482
},
{
"note": "Add MeshSwap on Polygon",
"pr": 491
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
JETSWAP_ROUTER_BY_CHAIN_ID,
JULSWAP_ROUTER_BY_CHAIN_ID,
MAX_DODOV2_POOLS_QUERIED,
MESHSWAP_ROUTER_BY_CHAIN_ID,
MOBIUSMONEY_CELO_INFOS,
MORPHEUSSWAP_ROUTER_BY_CHAIN_ID,
MSTABLE_POOLS_BY_CHAIN_ID,
Expand Down Expand Up @@ -543,7 +544,8 @@ export function uniswapV2LikeRouterAddress(
| ERC20BridgeSource.SpookySwap
| ERC20BridgeSource.SpiritSwap
| ERC20BridgeSource.BiSwap
| ERC20BridgeSource.Yoshi,
| ERC20BridgeSource.Yoshi
| ERC20BridgeSource.MeshSwap,
): string {
switch (source) {
case ERC20BridgeSource.UniswapV2:
Expand Down Expand Up @@ -596,6 +598,8 @@ export function uniswapV2LikeRouterAddress(
return BISWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.Yoshi:
return YOSHI_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.MeshSwap:
return MESHSWAP_ROUTER_BY_CHAIN_ID[chainId];
default:
throw new Error(`Unknown UniswapV2 like source ${source}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.AaveV2,
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.Synapse,
ERC20BridgeSource.MeshSwap,
]),
[ChainId.Avalanche]: new SourceFilters([
ERC20BridgeSource.MultiHop,
Expand Down Expand Up @@ -304,6 +305,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.AaveV2,
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.Synapse,
ERC20BridgeSource.MeshSwap,
]),
[ChainId.Avalanche]: new SourceFilters([
ERC20BridgeSource.MultiHop,
Expand Down Expand Up @@ -2281,6 +2283,13 @@ export const POLYDEX_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
NULL_ADDRESS,
);

export const MESHSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{
[ChainId.Polygon]: '0x10f4a785f458bc144e3706575924889954946639',
},
NULL_ADDRESS,
);

export const JETSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{
[ChainId.BSC]: '0xbe65b8f75b9f20f4c522e0067a3887fada714800',
Expand Down Expand Up @@ -2572,6 +2581,7 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
[ERC20BridgeSource.Dfyn]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.Polydex]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.JetSwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.MeshSwap]: uniswapV2CloneGasSchedule,

//
// Avalanche
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
return encodeBridgeSourceId(BridgeProtocol.GMX, 'GMX');
case ERC20BridgeSource.Platypus:
return encodeBridgeSourceId(BridgeProtocol.Platypus, 'Platypus');
case ERC20BridgeSource.MeshSwap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'MeshSwap');
default:
throw new Error(AggregationError.NoBridgeForSource);
}
Expand Down Expand Up @@ -268,6 +270,7 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
case ERC20BridgeSource.MorpheusSwap:
case ERC20BridgeSource.BiSwap:
case ERC20BridgeSource.Yoshi:
case ERC20BridgeSource.MeshSwap:
const uniswapV2FillData = (order as OptimizedMarketBridgeOrder<UniswapV2FillData>).fillData;
bridgeData = encoder.encode([uniswapV2FillData.router, uniswapV2FillData.tokenAddressPath]);
break;
Expand Down Expand Up @@ -456,6 +459,7 @@ export const BRIDGE_ENCODERS: {
[ERC20BridgeSource.MorpheusSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.BiSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.Yoshi]: routerAddressPathEncoder,
[ERC20BridgeSource.MeshSwap]: routerAddressPathEncoder,
// Avalanche
[ERC20BridgeSource.GMX]: gmxAddressPathEncoder,
[ERC20BridgeSource.Platypus]: platypusAddressPathEncoder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ export class SamplerOperations {
case ERC20BridgeSource.Yoshi:
case ERC20BridgeSource.MorpheusSwap:
case ERC20BridgeSource.BiSwap:
case ERC20BridgeSource.MeshSwap:
const uniLikeRouter = uniswapV2LikeRouterAddress(this.chainId, source);
if (!isValidAddress(uniLikeRouter)) {
return [];
Expand Down Expand Up @@ -1748,6 +1749,7 @@ export class SamplerOperations {
case ERC20BridgeSource.Yoshi:
case ERC20BridgeSource.MorpheusSwap:
case ERC20BridgeSource.BiSwap:
case ERC20BridgeSource.MeshSwap:
const uniLikeRouter = uniswapV2LikeRouterAddress(this.chainId, source);
if (!isValidAddress(uniLikeRouter)) {
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export enum ERC20BridgeSource {
FirebirdOneSwap = 'FirebirdOneSwap',
JetSwap = 'JetSwap',
IronSwap = 'IronSwap',
MeshSwap = 'MeshSwap',
// Avalanche
Pangolin = 'Pangolin',
TraderJoe = 'TraderJoe',
Expand Down

0 comments on commit 2a2bb53

Please sign in to comment.