Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Offboard Swerve Finance and LinkSwap [TKR-356] #469

Merged
merged 6 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/asset-swapper/CHANGELOG.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{
"note": "Remove SnowSwap on mainnet",
"pr": 468
},
{
"note": "Offboard Swerve Finance and LinkSwap",
"pr": 469
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {

if (
this.chainId === ChainId.Mainnet &&
isDirectSwapCompatible(quote, optsWithDefaults, [ERC20BridgeSource.Curve, ERC20BridgeSource.Swerve]) &&
isDirectSwapCompatible(quote, optsWithDefaults, [ERC20BridgeSource.Curve]) &&
// Curve VIP cannot currently support WETH buy/sell as the functionality needs to WITHDRAW or DEPOSIT
// into WETH prior/post the trade.
// ETH buy/sell is supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
SPIRITSWAP_ROUTER_BY_CHAIN_ID,
SPOOKYSWAP_ROUTER_BY_CHAIN_ID,
SUSHISWAP_ROUTER_BY_CHAIN_ID,
SWERVE_MAINNET_INFOS,
SYNAPSE_AVALANCHE_INFOS,
SYNAPSE_BSC_INFOS,
SYNAPSE_FANTOM_INFOS,
Expand Down Expand Up @@ -224,19 +223,6 @@ export function getCurveV2InfosForPair(chainId: ChainId, takerToken: string, mak
}
}

export function getSwerveInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId !== ChainId.Mainnet) {
return [];
}
return Object.values(SWERVE_MAINNET_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 getNerveInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId !== ChainId.BSC) {
return [];
Expand Down Expand Up @@ -479,7 +465,6 @@ export function getCurveLikeInfosForPair(
source:
| ERC20BridgeSource.Curve
| ERC20BridgeSource.CurveV2
| ERC20BridgeSource.Swerve
| ERC20BridgeSource.Nerve
| ERC20BridgeSource.Synapse
| ERC20BridgeSource.Belt
Expand All @@ -500,9 +485,6 @@ export function getCurveLikeInfosForPair(
case ERC20BridgeSource.CurveV2:
pools = getCurveV2InfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.Swerve:
pools = getSwerveInfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.Nerve:
pools = getNerveInfosForPair(chainId, takerToken, makerToken);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.Bancor,
ERC20BridgeSource.MStable,
ERC20BridgeSource.Mooniswap,
ERC20BridgeSource.Swerve,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.Shell,
ERC20BridgeSource.MultiHop,
Expand All @@ -96,7 +95,6 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.Cream,
ERC20BridgeSource.LiquidityProvider,
ERC20BridgeSource.CryptoCom,
ERC20BridgeSource.Linkswap,
ERC20BridgeSource.Lido,
ERC20BridgeSource.MakerPsm,
ERC20BridgeSource.KyberDmm,
Expand Down Expand Up @@ -233,7 +231,6 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.MStable,
ERC20BridgeSource.Mooniswap,
ERC20BridgeSource.Shell,
ERC20BridgeSource.Swerve,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.MultiHop,
ERC20BridgeSource.Dodo,
Expand All @@ -242,7 +239,6 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.Lido,
ERC20BridgeSource.LiquidityProvider,
ERC20BridgeSource.CryptoCom,
ERC20BridgeSource.Linkswap,
ERC20BridgeSource.MakerPsm,
ERC20BridgeSource.KyberDmm,
ERC20BridgeSource.Smoothy,
Expand Down Expand Up @@ -739,10 +735,6 @@ export const CURVE_OPTIMISM_POOLS = {
tri: '0x1337bedc9d22ecbe766df105c9623922a27963ec',
};

export const SWERVE_POOLS = {
y: '0x329239599afb305da0a2ec69c58f8a6697f9f88d',
};

export const SMOOTHY_POOLS = {
syUSD: '0xe5859f4efc09027a9b718781dcb2c6910cac6e91',
};
Expand Down Expand Up @@ -1501,14 +1493,6 @@ export const CURVE_OPTIMISM_INFOS: { [name: string]: CurveInfo } = {
}),
};

export const SWERVE_MAINNET_INFOS: { [name: string]: CurveInfo } = {
[SWERVE_POOLS.y]: createCurveExchangePool({
tokens: [MAINNET_TOKENS.DAI, MAINNET_TOKENS.USDC, MAINNET_TOKENS.USDT, MAINNET_TOKENS.TUSD],
pool: SWERVE_POOLS.y,
gasSchedule: 140e3,
}),
};

export const BELT_BSC_INFOS: { [name: string]: CurveInfo } = {
[BELT_POOLS.vPool]: createCurveExchangeUnderlyingPool({
tokens: [BSC_TOKENS.DAI, BSC_TOKENS.USDC, BSC_TOKENS.USDT, BSC_TOKENS.BUSD],
Expand Down Expand Up @@ -1897,11 +1881,6 @@ export const CRYPTO_COM_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
NULL_ADDRESS,
);

export const LINKSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{ [ChainId.Mainnet]: '0xa7ece0911fe8c60bff9e99f8fafcdbe56e07aff1' },
NULL_ADDRESS,
);

export const SHIBASWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{
[ChainId.Mainnet]: '0x03f7724180aa6b939894b5ca4314783b0b36b329',
Expand Down Expand Up @@ -2397,7 +2376,6 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
[ERC20BridgeSource.Kyber]: () => 450e3,
[ERC20BridgeSource.Curve]: fillData => (fillData as CurveFillData).pool.gasSchedule,
[ERC20BridgeSource.CurveV2]: fillData => (fillData as CurveFillData).pool.gasSchedule,
[ERC20BridgeSource.Swerve]: fillData => (fillData as CurveFillData).pool.gasSchedule,
[ERC20BridgeSource.Nerve]: fillData => (fillData as CurveFillData).pool.gasSchedule,
[ERC20BridgeSource.Synapse]: fillData => (fillData as CurveFillData).pool.gasSchedule,
[ERC20BridgeSource.Belt]: fillData => (fillData as CurveFillData).pool.gasSchedule,
Expand All @@ -2412,7 +2390,6 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
[ERC20BridgeSource.UniswapV2]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.SushiSwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.CryptoCom]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.Linkswap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.ShibaSwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.Balancer]: () => 120e3,
[ERC20BridgeSource.BalancerV2]: (fillData?: FillData) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,12 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
return encodeBridgeSourceId(BridgeProtocol.Shell, 'Shell');
case ERC20BridgeSource.SushiSwap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'SushiSwap');
case ERC20BridgeSource.Swerve:
return encodeBridgeSourceId(BridgeProtocol.Curve, 'Swerve');
case ERC20BridgeSource.Uniswap:
return encodeBridgeSourceId(BridgeProtocol.Uniswap, 'Uniswap');
case ERC20BridgeSource.UniswapV2:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'UniswapV2');
case ERC20BridgeSource.DodoV2:
return encodeBridgeSourceId(BridgeProtocol.DodoV2, 'DodoV2');
case ERC20BridgeSource.Linkswap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'Linkswap');
case ERC20BridgeSource.PancakeSwap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'PancakeSwap');
case ERC20BridgeSource.PancakeSwapV2:
Expand Down Expand Up @@ -230,7 +226,6 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
switch (order.source) {
case ERC20BridgeSource.Curve:
case ERC20BridgeSource.CurveV2:
case ERC20BridgeSource.Swerve:
case ERC20BridgeSource.Nerve:
case ERC20BridgeSource.Synapse:
case ERC20BridgeSource.Belt:
Expand Down Expand Up @@ -277,7 +272,6 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
case ERC20BridgeSource.UniswapV2:
case ERC20BridgeSource.SushiSwap:
case ERC20BridgeSource.CryptoCom:
case ERC20BridgeSource.Linkswap:
case ERC20BridgeSource.PancakeSwap:
case ERC20BridgeSource.PancakeSwapV2:
case ERC20BridgeSource.BakerySwap:
Expand Down Expand Up @@ -487,7 +481,6 @@ export const BRIDGE_ENCODERS: {
// Curve like
[ERC20BridgeSource.Curve]: curveEncoder,
[ERC20BridgeSource.CurveV2]: curveEncoder,
[ERC20BridgeSource.Swerve]: curveEncoder,
[ERC20BridgeSource.Nerve]: curveEncoder,
[ERC20BridgeSource.Synapse]: curveEncoder,
[ERC20BridgeSource.Belt]: curveEncoder,
Expand All @@ -504,7 +497,6 @@ export const BRIDGE_ENCODERS: {
[ERC20BridgeSource.UniswapV2]: routerAddressPathEncoder,
[ERC20BridgeSource.SushiSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.CryptoCom]: routerAddressPathEncoder,
[ERC20BridgeSource.Linkswap]: routerAddressPathEncoder,
[ERC20BridgeSource.ShibaSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.Pangolin]: routerAddressPathEncoder,
[ERC20BridgeSource.TraderJoe]: routerAddressPathEncoder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import {
KYBER_CONFIG_BY_CHAIN_ID,
KYBER_DMM_ROUTER_BY_CHAIN_ID,
LIDO_INFO_BY_CHAIN,
LINKSWAP_ROUTER_BY_CHAIN_ID,
LIQUIDITY_PROVIDER_REGISTRY_BY_CHAIN_ID,
MAINNET_TOKENS,
MAKER_PSM_INFO_BY_CHAIN_ID,
MAX_UINT256,
MOONISWAP_REGISTRIES_BY_CHAIN_ID,
Expand Down Expand Up @@ -1425,7 +1423,6 @@ export class SamplerOperations {
);
case ERC20BridgeSource.Curve:
case ERC20BridgeSource.CurveV2:
case ERC20BridgeSource.Swerve:
case ERC20BridgeSource.Nerve:
case ERC20BridgeSource.Synapse:
case ERC20BridgeSource.Belt:
Expand Down Expand Up @@ -1585,23 +1582,6 @@ export class SamplerOperations {
takerToken,
takerFillAmounts,
);
case ERC20BridgeSource.Linkswap:
if (!isValidAddress(LINKSWAP_ROUTER_BY_CHAIN_ID[this.chainId])) {
return [];
}
return [
[takerToken, makerToken],
...getIntermediateTokens(makerToken, takerToken, {
default: [MAINNET_TOKENS.LINK, MAINNET_TOKENS.WETH],
}).map(t => [takerToken, t, makerToken]),
].map(path =>
this.getUniswapV2SellQuotes(
LINKSWAP_ROUTER_BY_CHAIN_ID[this.chainId],
path,
takerFillAmounts,
ERC20BridgeSource.Linkswap,
),
);
case ERC20BridgeSource.MakerPsm:
const psmInfo = MAKER_PSM_INFO_BY_CHAIN_ID[this.chainId];
if (!isValidAddress(psmInfo.psmAddress)) {
Expand Down Expand Up @@ -1751,7 +1731,6 @@ export class SamplerOperations {
);
case ERC20BridgeSource.Curve:
case ERC20BridgeSource.CurveV2:
case ERC20BridgeSource.Swerve:
case ERC20BridgeSource.Nerve:
case ERC20BridgeSource.Synapse:
case ERC20BridgeSource.Belt:
Expand Down Expand Up @@ -1911,24 +1890,6 @@ export class SamplerOperations {
// Unimplemented
// return this.getBancorBuyQuotes(makerToken, takerToken, makerFillAmounts);
return [];
case ERC20BridgeSource.Linkswap:
if (!isValidAddress(LINKSWAP_ROUTER_BY_CHAIN_ID[this.chainId])) {
return [];
}
return [
[takerToken, makerToken],
// LINK is the base asset in many of the pools on Linkswap
...getIntermediateTokens(makerToken, takerToken, {
default: [MAINNET_TOKENS.LINK, MAINNET_TOKENS.WETH],
}).map(t => [takerToken, t, makerToken]),
].map(path =>
this.getUniswapV2BuyQuotes(
LINKSWAP_ROUTER_BY_CHAIN_ID[this.chainId],
path,
makerFillAmounts,
ERC20BridgeSource.Linkswap,
),
);
case ERC20BridgeSource.MakerPsm:
const psmInfo = MAKER_PSM_INFO_BY_CHAIN_ID[this.chainId];
if (!isValidAddress(psmInfo.psmAddress)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ export enum ERC20BridgeSource {
Mooniswap = 'Mooniswap',
MultiHop = 'MultiHop',
Shell = 'Shell',
Swerve = 'Swerve',
SushiSwap = 'SushiSwap',
Dodo = 'DODO',
DodoV2 = 'DODO_V2',
CryptoCom = 'CryptoCom',
Linkswap = 'Linkswap',
KyberDmm = 'KyberDMM',
Smoothy = 'Smoothy',
Component = 'Component',
Expand Down
12 changes: 0 additions & 12 deletions packages/asset-swapper/test/market_operation_utils_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,17 +349,6 @@ describe('MarketOperationUtils tests', () => {
fromTokenIdx: 0,
toTokenIdx: 1,
},
[ERC20BridgeSource.Swerve]: {
pool: {
poolAddress: randomAddress(),
tokens: [TAKER_TOKEN, MAKER_TOKEN],
exchangeFunctionSelector: hexUtils.random(4),
sellQuoteFunctionSelector: hexUtils.random(4),
buyQuoteFunctionSelector: hexUtils.random(4),
},
fromTokenIdx: 0,
toTokenIdx: 1,
},
[ERC20BridgeSource.Smoothy]: {
pool: {
poolAddress: randomAddress(),
Expand Down Expand Up @@ -393,7 +382,6 @@ describe('MarketOperationUtils tests', () => {
[ERC20BridgeSource.Dodo]: {},
[ERC20BridgeSource.DodoV2]: {},
[ERC20BridgeSource.CryptoCom]: { tokenAddressPath: [] },
[ERC20BridgeSource.Linkswap]: { tokenAddressPath: [] },
[ERC20BridgeSource.Uniswap]: { router: randomAddress() },
[ERC20BridgeSource.Eth2Dai]: { router: randomAddress() },
[ERC20BridgeSource.MakerPsm]: {},
Expand Down