Compare commits

...

17 Commits

Author SHA1 Message Date
Noah Khamliche
1fb1a6f52e celo mobius init 2022-02-04 15:10:44 -05:00
Jacob Evans
5d2cdb00c2 fix: slippage inconsistency when recalculated in exchange proxy quote consumer (#412)
* fix: Pass slippage down rather than recalculate due to accuracy

* CHANGELOG
2022-02-04 10:37:38 +10:00
Github Actions
0f701f42d3 Publish
- @0x/asset-swapper@16.49.2
2022-01-31 18:24:47 +00:00
Github Actions
3e3e82d3f7 Updated CHANGELOGS & MD docs 2022-01-31 18:24:44 +00:00
Lawrence Forman
c57bf86273 Fix ABI encoding error with two hop buys due to applying slippage to uint(-1) values (#410)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2022-01-31 12:51:17 -05:00
Github Actions
f470d282ee Publish
- @0x/asset-swapper@16.49.1
2022-01-31 07:20:03 +00:00
Github Actions
b8a2526da5 Updated CHANGELOGS & MD docs 2022-01-31 07:19:59 +00:00
Jacob Evans
97575bbde9 fix: worstCaseQuoteInfo calculating buys incorrectly [TKR-296] (#402)
* fix: WorstCaseQuoteInfo buy encoding

* CHANGELOG
2022-01-31 17:01:17 +10:00
Github Actions
e5ed8b2c81 Publish
- @0x/asset-swapper@16.49.0
2022-01-28 22:11:46 +00:00
Github Actions
61fbae3ae2 Updated CHANGELOGS & MD docs 2022-01-28 22:11:42 +00:00
Shawn
5c2255c841 feat: add curve pools (#409)
* feat: Additional Curve pools

* more pools

* fix the format

* changlog

* lowercase address

Co-authored-by: Jacob Evans <jacob@dekz.net>
2022-01-28 12:08:28 -08:00
Github Actions
e036dee6c5 Publish
- @0x/asset-swapper@16.48.0
2022-01-25 22:00:25 +00:00
Github Actions
8583aab241 Updated CHANGELOGS & MD docs 2022-01-25 22:00:21 +00:00
Jacob Evans
5d05b62821 chore: Use MIM on Fantom as an intermediary asset (#405) 2022-01-26 07:42:29 +10:00
Github Actions
0063e8178f Publish
- @0x/asset-swapper@16.47.0
2022-01-25 18:51:07 +00:00
Github Actions
ec6e5dd517 Updated CHANGELOGS & MD docs 2022-01-25 18:51:04 +00:00
Noah Khamliche
9d08fefa1c Feat/synapse (#400)
* added synapse support
2022-01-25 13:21:07 -05:00
13 changed files with 648 additions and 43 deletions

View File

@@ -1,4 +1,63 @@
[
{
"version": "16.49.3",
"changes": [
{
"note": "Fix `slippage` inconsistency when recalculated in exchange proxy quote consumer",
"pr": 412
}
]
},
{
"version": "16.49.2",
"changes": [
{
"note": "Fix ABI encoding error with two hop buys due to applying slippage to uint(-1) values",
"pr": 410
}
],
"timestamp": 1643653482
},
{
"version": "16.49.1",
"changes": [
{
"note": "Fix WorstCaseQuoteInfo encoding bug",
"pr": 402
}
],
"timestamp": 1643613597
},
{
"version": "16.49.0",
"changes": [
{
"note": "Add more curve pools",
"pr": 409
}
],
"timestamp": 1643407900
},
{
"version": "16.48.0",
"changes": [
{
"note": "Use `MIM` as an intermediate asset on `Fantom`",
"pr": 405
}
],
"timestamp": 1643148019
},
{
"version": "16.47.0",
"changes": [
{
"note": "Adding support for Synapse on all networks",
"pr": 400
}
],
"timestamp": 1643136662
},
{
"version": "16.46.0",
"changes": [

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v16.49.2 - _January 31, 2022_
* Fix ABI encoding error with two hop buys due to applying slippage to uint(-1) values (#410)
## v16.49.1 - _January 31, 2022_
* Fix WorstCaseQuoteInfo encoding bug (#402)
## v16.49.0 - _January 28, 2022_
* Add more curve pools (#409)
## v16.48.0 - _January 25, 2022_
* Use `MIM` as an intermediate asset on `Fantom` (#405)
## v16.47.0 - _January 25, 2022_
* Adding support for Synapse on all networks (#400)
## v16.46.0 - _January 11, 2022_
* Enable `Curve` ETH/CVX pool (#394)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/asset-swapper",
"version": "16.46.0",
"version": "16.49.2",
"engines": {
"node": ">=6.12"
},

View File

@@ -691,7 +691,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
function slipNonNativeOrders(quote: MarketSellSwapQuote | MarketBuySwapQuote): OptimizedMarketOrder[] {
const slippage = getMaxQuoteSlippageRate(quote);
if (!slippage) {
if (slippage === 0) {
return quote.orders;
}
return quote.orders.map(o => {
@@ -701,25 +701,20 @@ function slipNonNativeOrders(quote: MarketSellSwapQuote | MarketBuySwapQuote): O
return {
...o,
...(quote.type === MarketOperation.Sell
? { makerAmount: o.makerAmount.times(1 - slippage).integerValue(BigNumber.ROUND_DOWN) }
: { takerAmount: o.takerAmount.times(1 + slippage).integerValue(BigNumber.ROUND_UP) }),
? {
makerAmount: o.makerAmount.eq(MAX_UINT256)
? MAX_UINT256
: o.makerAmount.times(1 - slippage).integerValue(BigNumber.ROUND_DOWN),
}
: {
takerAmount: o.takerAmount.eq(MAX_UINT256)
? MAX_UINT256
: o.takerAmount.times(1 + slippage).integerValue(BigNumber.ROUND_UP),
}),
};
});
}
function getMaxQuoteSlippageRate(quote: MarketBuySwapQuote | MarketSellSwapQuote): number {
if (quote.type === MarketOperation.Buy) {
// (worstCaseTaker - bestCaseTaker) / bestCaseTaker
// where worstCaseTaker >= bestCaseTaker
return quote.worstCaseQuoteInfo.takerAmount
.minus(quote.bestCaseQuoteInfo.takerAmount)
.div(quote.bestCaseQuoteInfo.takerAmount)
.toNumber();
}
// (bestCaseMaker - worstCaseMaker) / bestCaseMaker
// where bestCaseMaker >= worstCaseMaker
return quote.bestCaseQuoteInfo.makerAmount
.minus(quote.worstCaseQuoteInfo.makerAmount)
.div(quote.bestCaseQuoteInfo.makerAmount)
.toNumber();
return quote.worstCaseQuoteInfo.slippage;
}

View File

@@ -578,8 +578,8 @@ function calculateQuoteInfo(
});
return {
bestCaseQuoteInfo: fillResultsToQuoteInfo(bestCaseFillResult),
worstCaseQuoteInfo: fillResultsToQuoteInfo(worstCaseFillResult),
bestCaseQuoteInfo: fillResultsToQuoteInfo(bestCaseFillResult, 0),
worstCaseQuoteInfo: fillResultsToQuoteInfo(worstCaseFillResult, slippage),
sourceBreakdown: getSwapQuoteOrdersBreakdown(bestCaseFillResult.fillAmountBySource),
};
}
@@ -599,29 +599,33 @@ function calculateTwoHopQuoteInfo(
secondHopSource: _.pick(secondHopFill, 'source', 'fillData'),
}),
).toNumber();
const isSell = operation === MarketOperation.Sell;
return {
bestCaseQuoteInfo: {
makerAmount: operation === MarketOperation.Sell ? secondHopFill.output : secondHopFill.input,
takerAmount: operation === MarketOperation.Sell ? firstHopFill.input : firstHopFill.output,
totalTakerAmount: operation === MarketOperation.Sell ? firstHopFill.input : firstHopFill.output,
makerAmount: isSell ? secondHopFill.output : secondHopFill.input,
takerAmount: isSell ? firstHopFill.input : firstHopFill.output,
totalTakerAmount: isSell ? firstHopFill.input : firstHopFill.output,
feeTakerTokenAmount: constants.ZERO_AMOUNT,
protocolFeeInWeiAmount: constants.ZERO_AMOUNT,
gas,
slippage: 0,
},
// TODO jacob consolidate this with quote simulation worstCase
worstCaseQuoteInfo: {
makerAmount: MarketOperation.Sell
makerAmount: isSell
? secondHopOrder.makerAmount.times(1 - slippage).integerValue()
: secondHopOrder.makerAmount,
takerAmount: MarketOperation.Sell
takerAmount: isSell
? firstHopOrder.takerAmount
: firstHopOrder.takerAmount.times(1 + slippage).integerValue(),
totalTakerAmount: MarketOperation.Sell
: firstHopOrder.takerAmount.times(1 + slippage).integerValue(BigNumber.ROUND_UP),
totalTakerAmount: isSell
? firstHopOrder.takerAmount
: firstHopOrder.takerAmount.times(1 + slippage).integerValue(),
: firstHopOrder.takerAmount.times(1 + slippage).integerValue(BigNumber.ROUND_UP),
feeTakerTokenAmount: constants.ZERO_AMOUNT,
protocolFeeInWeiAmount: constants.ZERO_AMOUNT,
gas,
slippage,
},
sourceBreakdown: {
[ERC20BridgeSource.MultiHop]: {
@@ -647,7 +651,7 @@ function getSwapQuoteOrdersBreakdown(fillAmountBySource: { [source: string]: Big
return breakdown;
}
function fillResultsToQuoteInfo(fr: QuoteFillResult): SwapQuoteInfo {
function fillResultsToQuoteInfo(fr: QuoteFillResult, slippage: number): SwapQuoteInfo {
return {
makerAmount: fr.totalMakerAssetAmount,
takerAmount: fr.takerAssetAmount,
@@ -655,6 +659,7 @@ function fillResultsToQuoteInfo(fr: QuoteFillResult): SwapQuoteInfo {
feeTakerTokenAmount: fr.takerFeeTakerAssetAmount,
protocolFeeInWeiAmount: fr.protocolFeeAmount,
gas: fr.gas,
slippage,
};
}

View File

@@ -208,6 +208,7 @@ export type SwapQuote = MarketBuySwapQuote | MarketSellSwapQuote;
* makerTokenAmount: The amount of makerAsset that will be acquired through the swap.
* protocolFeeInWeiAmount: The amount of ETH to pay (in WEI) as protocol fee to perform the swap for desired asset.
* gas: Amount of estimated gas needed to fill the quote.
* slippage: Amount of slippage to allow for.
*/
export interface SwapQuoteInfo {
feeTakerTokenAmount: BigNumber;
@@ -216,6 +217,7 @@ export interface SwapQuoteInfo {
makerAmount: BigNumber;
protocolFeeInWeiAmount: BigNumber;
gas: number;
slippage: number;
}
/**

View File

@@ -14,6 +14,7 @@ import {
CURVE_AVALANCHE_INFOS,
CURVE_FANTOM_INFOS,
CURVE_MAINNET_INFOS,
CURVE_OPTIMISM_INFOS,
CURVE_POLYGON_INFOS,
CURVE_V2_AVALANCHE_INFOS,
CURVE_V2_FANTOM_INFOS,
@@ -49,6 +50,12 @@ import {
SPOOKYSWAP_ROUTER_BY_CHAIN_ID,
SUSHISWAP_ROUTER_BY_CHAIN_ID,
SWERVE_MAINNET_INFOS,
SYNAPSE_AVALANCHE_INFOS,
SYNAPSE_BSC_INFOS,
SYNAPSE_FANTOM_INFOS,
SYNAPSE_MAINNET_INFOS,
SYNAPSE_OPTIMISM_INFOS,
SYNAPSE_POLYGON_INFOS,
TRADER_JOE_ROUTER_BY_CHAIN_ID,
UBESWAP_ROUTER_BY_CHAIN_ID,
UNISWAPV2_ROUTER_BY_CHAIN_ID,
@@ -159,6 +166,15 @@ export function getCurveInfosForPair(chainId: ChainId, takerToken: string, maker
[makerToken, takerToken].filter(v => c.metaTokens?.includes(v)).length > 0),
),
);
case ChainId.Optimism:
return Object.values(CURVE_OPTIMISM_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),
),
);
default:
return [];
}
@@ -247,6 +263,67 @@ export function getNerveInfosForPair(chainId: ChainId, takerToken: string, maker
);
}
export function getSynapseInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
switch (chainId) {
case ChainId.Mainnet:
return Object.values(SYNAPSE_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),
),
);
case ChainId.Optimism:
return Object.values(SYNAPSE_OPTIMISM_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),
),
);
case ChainId.BSC:
return Object.values(SYNAPSE_BSC_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),
),
);
case ChainId.Polygon:
return Object.values(SYNAPSE_POLYGON_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),
),
);
case ChainId.Fantom:
return Object.values(SYNAPSE_FANTOM_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),
),
);
case ChainId.Avalanche:
return Object.values(SYNAPSE_AVALANCHE_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),
),
);
default:
return [];
}
}
export function getFirebirdOneSwapInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId === ChainId.BSC) {
return Object.values(FIREBIRDONESWAP_BSC_INFOS).filter(c =>
@@ -406,6 +483,7 @@ export function getCurveLikeInfosForPair(
| ERC20BridgeSource.Swerve
| ERC20BridgeSource.SnowSwap
| ERC20BridgeSource.Nerve
| ERC20BridgeSource.Synapse
| ERC20BridgeSource.Belt
| ERC20BridgeSource.Ellipsis
| ERC20BridgeSource.Smoothy
@@ -413,7 +491,8 @@ export function getCurveLikeInfosForPair(
| ERC20BridgeSource.IronSwap
| ERC20BridgeSource.XSigma
| ERC20BridgeSource.FirebirdOneSwap
| ERC20BridgeSource.ACryptos,
| ERC20BridgeSource.ACryptos
| ERC20BridgeSource.MobiusMoney,
): CurveDetailedInfo[] {
let pools: CurveInfo[] = [];
switch (source) {
@@ -432,6 +511,9 @@ export function getCurveLikeInfosForPair(
case ERC20BridgeSource.Nerve:
pools = getNerveInfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.Synapse:
pools = getSynapseInfosForPair(chainId, takerToken, makerToken);
break;
case ERC20BridgeSource.Belt:
pools = getBeltInfosForPair(chainId, takerToken, makerToken);
break;

View File

@@ -104,6 +104,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.CurveV2,
ERC20BridgeSource.ShibaSwap,
ERC20BridgeSource.Synapse,
// TODO: enable after FQT has been redeployed on Ethereum mainnet
// ERC20BridgeSource.AaveV2,
// ERC20BridgeSource.Compound,
@@ -130,6 +131,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.Mooniswap,
ERC20BridgeSource.MultiHop,
ERC20BridgeSource.Nerve,
ERC20BridgeSource.Synapse,
ERC20BridgeSource.PancakeSwap,
ERC20BridgeSource.PancakeSwapV2,
ERC20BridgeSource.SushiSwap,
@@ -167,6 +169,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.IronSwap,
ERC20BridgeSource.AaveV2,
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.Synapse,
]),
[ChainId.Avalanche]: new SourceFilters([
ERC20BridgeSource.MultiHop,
@@ -177,6 +180,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.CurveV2,
ERC20BridgeSource.KyberDmm,
ERC20BridgeSource.AaveV2,
ERC20BridgeSource.Synapse,
]),
[ChainId.Fantom]: new SourceFilters([
ERC20BridgeSource.MultiHop,
@@ -188,13 +192,21 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.SpiritSwap,
ERC20BridgeSource.SpookySwap,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.Synapse,
]),
[ChainId.Celo]: new SourceFilters([
ERC20BridgeSource.UbeSwap,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.MultiHop,
ERC20BridgeSource.MobiusMoney,
]),
[ChainId.Optimism]: new SourceFilters([
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.Synapse,
ERC20BridgeSource.Curve,
ERC20BridgeSource.CurveV2,
ERC20BridgeSource.MultiHop,
]),
[ChainId.Optimism]: new SourceFilters([ERC20BridgeSource.UniswapV3]),
},
new SourceFilters([]),
);
@@ -237,6 +249,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.CurveV2,
ERC20BridgeSource.ShibaSwap,
ERC20BridgeSource.Synapse,
// TODO: enable after FQT has been redeployed on Ethereum mainnet
// ERC20BridgeSource.AaveV2,
// ERC20BridgeSource.Compound,
@@ -277,6 +290,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.JetSwap,
ERC20BridgeSource.ACryptos,
ERC20BridgeSource.KyberDmm,
ERC20BridgeSource.Synapse,
]),
[ChainId.Polygon]: new SourceFilters([
ERC20BridgeSource.SushiSwap,
@@ -300,6 +314,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.IronSwap,
ERC20BridgeSource.AaveV2,
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.Synapse,
]),
[ChainId.Avalanche]: new SourceFilters([
ERC20BridgeSource.MultiHop,
@@ -310,6 +325,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.CurveV2,
ERC20BridgeSource.KyberDmm,
ERC20BridgeSource.AaveV2,
ERC20BridgeSource.Synapse,
]),
[ChainId.Fantom]: new SourceFilters([
ERC20BridgeSource.MultiHop,
@@ -321,13 +337,21 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.SpiritSwap,
ERC20BridgeSource.SpookySwap,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.Synapse,
]),
[ChainId.Celo]: new SourceFilters([
ERC20BridgeSource.UbeSwap,
ERC20BridgeSource.SushiSwap,
ERC20BridgeSource.MultiHop,
ERC20BridgeSource.MobiusMoney,
]),
[ChainId.Optimism]: new SourceFilters([
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.Synapse,
ERC20BridgeSource.Curve,
ERC20BridgeSource.CurveV2,
ERC20BridgeSource.MultiHop,
]),
[ChainId.Optimism]: new SourceFilters([ERC20BridgeSource.UniswapV3]),
},
new SourceFilters([]),
);
@@ -462,7 +486,15 @@ export const MAINNET_TOKENS = {
CRV: '0xd533a949740bb3306d119cc777fa900ba034cd52',
MIM: '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3',
EURT: '0xc581b735a1688071a1746c968e0798d642ede491',
// Synapse ecosystem
nUSD: '0x1b84765de8b7566e4ceaf4d0fd3c5af52d3dde4f',
CVX: '0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b',
UST_WORMHOLE: '0xa693b19d2931d498c5b318df961919bb4aee87a5',
RAI: '0x03ab458634910aad20ef5f1c8ee96f1d6ac54919',
DOLA: '0x865377367054516e17014ccded1e7d814edc9ce4',
OUSD: '0x2a8e1e676ec238d8a992307b495b45b3feaa5e86',
agEUR: '0x1a7e4e63778b4f12a199c062f3efdd288afcbce8',
ibEUR: '0x96e61422b6a9ba0e068b6c5add4ffabc6a4aae27',
};
export const BSC_TOKENS = {
@@ -479,6 +511,7 @@ export const BSC_TOKENS = {
BTCB: '0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c',
renBTC: '0xfce146bf3146100cfe5db4129cf6c82b0ef4ad8c',
pBTC: '0xed28a457a5a76596ac48d87c0f577020f6ea1c4c',
nUSD: '0x23b891e5c62e0955ae2bd185990103928ab817b3',
};
export const POLYGON_TOKENS = {
@@ -496,6 +529,7 @@ export const POLYGON_TOKENS = {
DFYN: '0xc168e40227e4ebd8c1cae80f7a55a4f0e6d66c97',
BANANA: '0x5d47baba0d66083c52009271faf3f50dcc01023c',
WEXPOLY: '0x4c4bf319237d98a30a929a96112effa8da3510eb',
nUSD: '0xb6c473756050de474286bed418b77aeac39b02af',
};
export const AVALANCHE_TOKENS = {
@@ -503,11 +537,18 @@ export const AVALANCHE_TOKENS = {
WETH: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
WBTC: '0x50b7545627a5162f82a992c33b87adc75187b218',
DAI: '0xd586e7f844cea2f87f50152665bcbc2c279d8d70',
// bridged USDC
USDC: '0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664',
// native USDC on Avalanche
nUSDC: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
USDT: '0xc7198437980c041c805a1edcba50c1ce5db95118',
aDAI: '0x47afa96cdc9fab46904a55a6ad4bf6660b53c38a',
aUSDC: '0x46a51127c3ce23fb7ab1de06226147f446e4a857',
aUSDT: '0x532e6537fea298397212f09a61e03311686f548e',
nETH: '0x19e1ae0ee35c0404f835521146206595d37981ae',
nUSD: '0xcfc37a6ab183dd4aed08c204d1c2773c0b1bdf46',
aWETH: '0x53f7c5869a859f0aec3d334ee8b4cf01e3492f21',
MIM: '0x130966628846bfd36ff31a822705796e8cb8c18d',
};
export const CELO_TOKENS = {
@@ -528,6 +569,19 @@ export const CELO_TOKENS = {
mCEUR: '0xe273ad7ee11dcfaa87383ad5977ee1504ac07568',
amCUSD: '0x64defa3544c695db8c535d289d843a189aa26b98',
MOO: '0x17700282592d6917f6a73d0bf8accf4d578c131e',
// Mobius Money
cUSDC: '0x93DB49bE12B864019dA9Cb147ba75cDC0506190e',
cUSDT: '0xcfffe0c89a779c09df3df5624f54cdf7ef5fdd5d',
wBTC: '0xbe50a3013a1c94768a1abb78c3cb79ab28fc1ace',
USDC: '0x2a3684e9dc20b857375ea04235f2f7edbe818fa7',
pUSDC: '0xcc82628f6a8defa1e2b0ad7ed448bef3647f7941',
asUSDC: '0xcd7d7ff64746c1909e44db8e95331f9316478817',
cEUR: '0xd8763cba276a3738e6de85b4b3bf5fded6d6ca73',
pEUR: '0x56072d4832642db29225da12d6fd1290e4744682',
pCELO: '0xe74abf23e1fdf7acbec2f3a30a772ef77f1601e1',
pUSD: '0xb4aa2986622249b1f45eb93f28cfca2b2606d809',
aaUSDC: '0xb70e0a782b058BFdb0d109a3599BEc1f19328E36',
};
export const FANTOM_TOKENS = {
@@ -538,6 +592,13 @@ export const FANTOM_TOKENS = {
fUSDT: '0x049d68029688eabf473097a2fc38ef61633a3c7a',
WBTC: '0x321162cd933e2be498cd2267a90534a804051b11',
renBTC: '0xdbf31df14b66535af65aac99c32e9ea844e14501',
MIM: '0x82f0b8b456c1a451378467398982d4834b6829c1',
nUSD: '0xed2a7edd7413021d440b09d654f3b87712abab66',
nETH: '0x67c10c397dd0ba417329543c1a40eb48aaa7cd00',
gfUSDT: '0x940f41f0ec9ba1a34cf001cc03347ac092f5f6b5',
gUSDC: '0xe578c856933d8e1082740bf7661e379aa2a30b26',
gDAI: '0x07e6332dd090d287d3489245038daf987955dcfb',
FRAX: '0xdc301622e621166bd8e82f2ca0a26c13ad0be355',
};
export const OPTIMISM_TOKENS = {
@@ -546,6 +607,8 @@ export const OPTIMISM_TOKENS = {
USDT: '0x94b008aa00579c1307b0ef2c499ad98a8ce58e58',
DAI: '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1',
WBTC: '0x68f180fcce6836688e9084f035309e29bf0a2095',
nETH: '0x809dc529f07651bd43a172e8db6f4a7a0d771036',
sWETH: '0x121ab82b49b2bc4c7901ca46b8277962b4350204',
};
export const CURVE_POOLS = {
@@ -594,6 +657,15 @@ export const CURVE_POOLS = {
eurt: '0xfd5db7463a3ab53fd211b4af195c5bccc1a03890',
ethcrv: '0x8301ae4fc9c624d1d396cbdaa1ed877821d7c511',
ethcvx: '0xb576491f1e6e5e62f1d8f26062ee822b40b0e0d4',
mimust: '0x55a8a39bc9694714e2874c1ce77aa1e599461e18',
usttri_wormhole: '0xceaf7747579696a2f0bb206a14210e3c9e6fb269',
fei_tri: '0x06cb22615ba53e60d67bf6c341a0fd5e718e1655',
rai_tri: '0x618788357d0ebd8a37e763adab3bc575d54c2c7d',
DOLA_tri: '0xaa5a67c256e27a5d80712c51971408db3370927d',
OUSD_tri: '0x87650d7bbfc3a9f10587d7778206671719d9910d',
d3pool: '0xbaaa1f5dba42c3389bdbc2c9d2de134f5cd0dc89',
triEURpool: '0xb9446c4ef5ebe66268da6700d26f96273de3d571',
ibEURsEUR: '0x19b080fe1ffa0553469d20ca36219f17fcf03859',
};
export const CURVE_V2_POOLS = {
@@ -607,12 +679,13 @@ export const CURVE_POLYGON_POOLS = {
};
export const CURVE_V2_POLYGON_POOLS = {
atricrypto: '0x3fcd5de6a9fc8a99995c406c77dda3ed7e406f81',
atricrypto3: '0x1d8b86e3d88cdb2d34688e87e72f388cb541b7c8',
};
export const CURVE_AVALANCHE_POOLS = {
aave: '0x7f90122bf0700f9e7e1f688fe926940e8839f353',
mim: '0xaea2e71b631fa93683bcf256a8689dfa0e094fcd',
USDC: '0x3a43a5851a3e3e0e25a3c1089670269786be1577',
};
export const CURVE_V2_AVALANCHE_POOLS = {
@@ -623,12 +696,19 @@ export const CURVE_FANTOM_POOLS = {
fUSDT: '0x92d5ebf3593a92888c25c0abef126583d4b5312e',
twoPool: '0x27e611fd27b276acbd5ffd632e5eaebec9761e40',
ren: '0x3ef6a01a0f81d6046290f3e2a8c5b843e738e604',
tri_v2: '0x2dd7c9371965472e5a5fd28fbe165007c61439e1',
geist: '0x0fa949783947bf6c1b171db13aeacbb488845b3f',
FRAX_twoPool: '0x7a656b342e14f745e2b164890e88017e27ae7320',
};
export const CURVE_V2_FANTOM_POOLS = {
tricrypto: '0x3a1659ddcf2339be3aea159ca010979fb49155ff',
};
export const CURVE_OPTIMISM_POOLS = {
tri: '0x1337bedc9d22ecbe766df105c9623922a27963ec',
};
export const SWERVE_POOLS = {
y: '0x329239599afb305da0a2ec69c58f8a6697f9f88d',
};
@@ -663,6 +743,37 @@ export const NERVE_POOLS = {
threePool: '0x1b3771a66ee31180906972580ade9b81afc5fcdc',
};
export const SYNAPSE_MAINNET_POOLS = {
nUSDLP: '0x1116898dda4015ed8ddefb84b6e8bc24528af2d8',
};
export const SYNAPSE_OPTIMISM_POOLS = {
nETHLP: '0xe27bff97ce92c3e1ff7aa9f86781fdd6d48f5ee9',
};
export const SYNAPSE_BSC_POOLS = {
nUSDLP: '0x28ec0b36f0819ecb5005cab836f4ed5a2eca4d13',
};
export const SYNAPSE_POLYGON_POOLS = {
nUSDLP: '0x85fcd7dd0a1e1a9fcd5fd886ed522de8221c3ee5',
};
export const SYNAPSE_FANTOM_POOLS = {
nUSDLP: '0x2913e812cf0dcca30fb28e6cac3d2dcff4497688',
nETHLP: '0x8d9ba570d6cb60c7e3e0f31343efe75ab8e65fb1',
};
export const SYNAPSE_AVALANCHE_POOLS = {
nUSDLP: '0xed2a7edd7413021d440b09d654f3b87712abab66',
nETHLP: '0x77a7e60555bc18b4be44c181b2575eee46212d44',
};
export const SYNAPSE_ARBITRUM_POOLS = {
nUSDLP: '0x0db3fe3b770c95a0b99d1ed6f2627933466c0dd8',
nETHLP: '0xd70a52248e546a3b260849386410c7170c7bd1e9',
};
export const BELT_POOLS = {
vPool: '0xf16d312d119c13dd27fd0dc814b0bcdcaaa62dfd',
};
@@ -690,6 +801,20 @@ export const ACRYPTOS_POOLS = {
acs3btc: '0xbe7caa236544d1b9a0e7f91e94b9f5bfd3b5ca81',
};
export const MOBIUSMONEY_CELO_POOLS = {
cUSD_cUSDC: '0x0ff04189ef135b6541e56f7c638489de92e9c778',
cUSD_cUSDT: '0xd70a52248e546a3b260849386410c7170c7bd1e9',
cETH_WETHv1: '0xe0f2cc70e52f05edb383313393d88df2937da55a',
WBTCv1_wBTC: '0x19260b9b573569ddb105780176547875fe9feda3',
cUSD_USDC: '0xa5037661989789d0310ac2b796fa78f1b01f195d',
cUSD_pUSDC: '0x2080aaa167e2225e1fc9923250ba60e19a180fb2',
cUSD_asUSDC: ' 0x63c1914bf00a9b395a2bf89aada55a5615a3656e',
cEUR_pEUR: '0x382ed834c6b7dbd10e4798b08889eaed1455e820',
CELO_pCELO: '0x413ffcc28e6cdde7e93625ef4742810fe9738578',
cUSD_pUSD: '0x02db089fb09fda92e05e92afcd41d9aafe9c7c7c',
cUSD_aaUSDC: '0x0986b42f5f9c42feeef66fc23eba9ea1164c916d',
};
export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
{
[ChainId.Mainnet]: [
@@ -720,6 +845,7 @@ export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
POLYGON_TOKENS.DAI,
POLYGON_TOKENS.USDT,
POLYGON_TOKENS.WBTC,
POLYGON_TOKENS.nUSD,
],
[ChainId.Avalanche]: [
AVALANCHE_TOKENS.WAVAX,
@@ -727,10 +853,28 @@ export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
AVALANCHE_TOKENS.DAI,
AVALANCHE_TOKENS.USDT,
AVALANCHE_TOKENS.USDC,
AVALANCHE_TOKENS.nUSD,
AVALANCHE_TOKENS.nETH,
AVALANCHE_TOKENS.aWETH,
],
[ChainId.Fantom]: [
FANTOM_TOKENS.WFTM,
FANTOM_TOKENS.WETH,
FANTOM_TOKENS.DAI,
FANTOM_TOKENS.USDC,
FANTOM_TOKENS.nUSD,
FANTOM_TOKENS.nETH,
FANTOM_TOKENS.MIM,
],
[ChainId.Fantom]: [FANTOM_TOKENS.WFTM, FANTOM_TOKENS.WETH, FANTOM_TOKENS.DAI, FANTOM_TOKENS.USDC],
[ChainId.Celo]: [CELO_TOKENS.WCELO, CELO_TOKENS.mCUSD, CELO_TOKENS.WETH, CELO_TOKENS.amCUSD, CELO_TOKENS.WBTC],
[ChainId.Optimism]: [OPTIMISM_TOKENS.WETH, OPTIMISM_TOKENS.DAI, OPTIMISM_TOKENS.USDC],
[ChainId.Optimism]: [
OPTIMISM_TOKENS.WETH,
OPTIMISM_TOKENS.DAI,
OPTIMISM_TOKENS.USDC,
OPTIMISM_TOKENS.USDT,
OPTIMISM_TOKENS.nETH,
OPTIMISM_TOKENS.sWETH,
],
},
[],
);
@@ -763,7 +907,14 @@ export const DEFAULT_TOKEN_ADJACENCY_GRAPH_BY_CHAIN_ID = valueByChainId<TokenAdj
}).build(),
[ChainId.Avalanche]: new TokenAdjacencyGraphBuilder({
default: DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID[ChainId.Avalanche],
}).build(),
})
.tap(builder => {
// Synape nETH/aWETH pool
builder
.add(AVALANCHE_TOKENS.aWETH, AVALANCHE_TOKENS.nETH)
.add(AVALANCHE_TOKENS.nETH, AVALANCHE_TOKENS.aWETH);
})
.build(),
[ChainId.Fantom]: new TokenAdjacencyGraphBuilder({
default: DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID[ChainId.Fantom],
}).build(),
@@ -804,6 +955,7 @@ const CURVE_TRI_POOL_MAINNET_TOKENS = [MAINNET_TOKENS.DAI, MAINNET_TOKENS.USDC,
const CURVE_TRI_BTC_POOL_TOKEN = [MAINNET_TOKENS.RenBTC, MAINNET_TOKENS.WBTC, MAINNET_TOKENS.sBTC];
const CURVE_POLYGON_ATRICRYPTO_UNDERLYING_TOKENS = [POLYGON_TOKENS.DAI, POLYGON_TOKENS.USDC, POLYGON_TOKENS.USDT];
const CURVE_POLYGON_ATRICRYPTO_TOKENS = [POLYGON_TOKENS.amDAI, POLYGON_TOKENS.amUSDC, POLYGON_TOKENS.amUSDT];
const CURVE_FANTOM_TWO_POOL_TOKENS = [FANTOM_TOKENS.DAI, FANTOM_TOKENS.USDC];
const createCurveExchangePool = (info: { tokens: string[]; pool: string; gasSchedule: number }) => ({
exchangeFunctionSelector: CurveFunctionSelectors.exchange,
@@ -845,6 +997,16 @@ const createCurveMetaTriBtcPool = (info: { tokens: string[]; pool: string; gasSc
gasSchedule: info.gasSchedule,
});
const createCurveMetaTwoPoolFantom = (info: { tokens: string[]; pool: string; gasSchedule: number }) => ({
exchangeFunctionSelector: CurveFunctionSelectors.exchange_underlying,
sellQuoteFunctionSelector: CurveFunctionSelectors.get_dy_underlying,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
tokens: [...info.tokens, ...CURVE_FANTOM_TWO_POOL_TOKENS],
metaTokens: info.tokens,
poolAddress: info.pool,
gasSchedule: info.gasSchedule,
});
const createCurveExchangeV2Pool = (info: { tokens: string[]; pool: string; gasSchedule: number }) => ({
exchangeFunctionSelector: CurveFunctionSelectors.exchange_v2,
sellQuoteFunctionSelector: CurveFunctionSelectors.get_dy_v2,
@@ -1086,6 +1248,51 @@ export const CURVE_MAINNET_INFOS: { [name: string]: CurveInfo } = {
sellQuoteFunctionSelector: CurveFunctionSelectors.get_dy_uint256,
exchangeFunctionSelector: CurveFunctionSelectors.exchange_underlying_uint256,
},
[CURVE_POOLS.mimust]: createCurveExchangePool({
tokens: [MAINNET_TOKENS.MIM, MAINNET_TOKENS.UST],
pool: CURVE_POOLS.mimust,
gasSchedule: 105e3,
}),
[CURVE_POOLS.usttri_wormhole]: createCurveMetaTriPool({
tokens: [MAINNET_TOKENS.UST_WORMHOLE],
pool: CURVE_POOLS.usttri_wormhole,
gasSchedule: 340e3,
}),
[CURVE_POOLS.fei_tri]: createCurveMetaTriPool({
tokens: [MAINNET_TOKENS.FEI],
pool: CURVE_POOLS.fei_tri,
gasSchedule: 340e3,
}),
[CURVE_POOLS.rai_tri]: createCurveMetaTriPool({
tokens: [MAINNET_TOKENS.RAI],
pool: CURVE_POOLS.rai_tri,
gasSchedule: 340e3,
}),
[CURVE_POOLS.DOLA_tri]: createCurveMetaTriPool({
tokens: [MAINNET_TOKENS.DOLA],
pool: CURVE_POOLS.DOLA_tri,
gasSchedule: 340e3,
}),
[CURVE_POOLS.OUSD_tri]: createCurveMetaTriPool({
tokens: [MAINNET_TOKENS.OUSD],
pool: CURVE_POOLS.OUSD_tri,
gasSchedule: 340e3,
}),
[CURVE_POOLS.d3pool]: createCurveExchangePool({
tokens: [MAINNET_TOKENS.FRAX, MAINNET_TOKENS.FEI, MAINNET_TOKENS.alUSD],
pool: CURVE_POOLS.d3pool,
gasSchedule: 176e3,
}),
[CURVE_POOLS.triEURpool]: createCurveExchangePool({
tokens: [MAINNET_TOKENS.agEUR, MAINNET_TOKENS.EURT, MAINNET_TOKENS.EURS],
pool: CURVE_POOLS.triEURpool,
gasSchedule: 176e3,
}),
[CURVE_POOLS.ibEURsEUR]: createCurveExchangePool({
tokens: [MAINNET_TOKENS.ibEUR, MAINNET_TOKENS.sEUR],
pool: CURVE_POOLS.ibEURsEUR,
gasSchedule: 176e3,
}),
};
export const CURVE_V2_MAINNET_INFOS: { [name: string]: CurveInfo } = {
@@ -1120,11 +1327,6 @@ export const CURVE_POLYGON_INFOS: { [name: string]: CurveInfo } = {
};
export const CURVE_V2_POLYGON_INFOS: { [name: string]: CurveInfo } = {
[CURVE_V2_POLYGON_POOLS.atricrypto]: createCurveV2MetaTriPool({
tokens: [POLYGON_TOKENS.WBTC, POLYGON_TOKENS.WETH],
pool: CURVE_V2_POLYGON_POOLS.atricrypto,
gasSchedule: 300e3,
}),
[CURVE_V2_POLYGON_POOLS.atricrypto3]: createCurveV2MetaTriPool({
tokens: [POLYGON_TOKENS.WBTC, POLYGON_TOKENS.WETH],
pool: CURVE_V2_POLYGON_POOLS.atricrypto3,
@@ -1143,6 +1345,16 @@ export const CURVE_AVALANCHE_INFOS: { [name: string]: CurveInfo } = {
pool: CURVE_AVALANCHE_POOLS.aave,
gasSchedule: 150e3,
}),
[CURVE_AVALANCHE_POOLS.mim]: createCurveExchangePool({
tokens: [AVALANCHE_TOKENS.MIM, AVALANCHE_TOKENS.USDT, AVALANCHE_TOKENS.USDC],
pool: CURVE_AVALANCHE_POOLS.mim,
gasSchedule: 150e3,
}),
[CURVE_AVALANCHE_POOLS.USDC]: createCurveExchangePool({
tokens: [AVALANCHE_TOKENS.USDC, AVALANCHE_TOKENS.nUSDC],
pool: CURVE_AVALANCHE_POOLS.USDC,
gasSchedule: 150e3,
}),
};
export const CURVE_V2_AVALANCHE_INFOS: { [name: string]: CurveInfo } = {
@@ -1180,6 +1392,26 @@ export const CURVE_FANTOM_INFOS: { [name: string]: CurveInfo } = {
pool: CURVE_FANTOM_POOLS.fUSDT,
gasSchedule: 587e3,
}),
[CURVE_FANTOM_POOLS.tri_v2]: createCurveExchangePool({
tokens: [FANTOM_TOKENS.MIM, FANTOM_TOKENS.fUSDT, FANTOM_TOKENS.USDC],
pool: CURVE_FANTOM_POOLS.tri_v2,
gasSchedule: 176e3,
}),
['geist_exchangeunderlying']: createCurveExchangeUnderlyingPool({
tokens: [FANTOM_TOKENS.DAI, FANTOM_TOKENS.USDC, FANTOM_TOKENS.fUSDT],
pool: CURVE_FANTOM_POOLS.geist,
gasSchedule: 850e3,
}),
['geist_exchange']: createCurveExchangePool({
tokens: [FANTOM_TOKENS.gDAI, FANTOM_TOKENS.gUSDC, FANTOM_TOKENS.gfUSDT],
pool: CURVE_FANTOM_POOLS.geist,
gasSchedule: 150e3,
}),
[CURVE_FANTOM_POOLS.FRAX_twoPool]: createCurveMetaTwoPoolFantom({
tokens: [FANTOM_TOKENS.FRAX],
pool: CURVE_FANTOM_POOLS.FRAX_twoPool,
gasSchedule: 411e3,
}),
};
export const CURVE_V2_FANTOM_INFOS: { [name: string]: CurveInfo } = {
@@ -1190,6 +1422,14 @@ export const CURVE_V2_FANTOM_INFOS: { [name: string]: CurveInfo } = {
}),
};
export const CURVE_OPTIMISM_INFOS: { [name: string]: CurveInfo } = {
[CURVE_OPTIMISM_POOLS.tri]: createCurveExchangePool({
tokens: [OPTIMISM_TOKENS.DAI, OPTIMISM_TOKENS.USDC, OPTIMISM_TOKENS.USDT],
pool: CURVE_OPTIMISM_POOLS.tri,
gasSchedule: 150e3,
}),
};
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],
@@ -1343,6 +1583,87 @@ export const NERVE_BSC_INFOS: { [name: string]: CurveInfo } = {
},
};
export const SYNAPSE_BSC_INFOS: { [name: string]: CurveInfo } = {
[SYNAPSE_BSC_POOLS.nUSDLP]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: SYNAPSE_BSC_POOLS.nUSDLP,
tokens: [BSC_TOKENS.nUSD, BSC_TOKENS.BUSD, BSC_TOKENS.USDC, BSC_TOKENS.USDT],
metaTokens: undefined,
gasSchedule: 140e3,
},
};
export const SYNAPSE_FANTOM_INFOS: { [name: string]: CurveInfo } = {
[SYNAPSE_FANTOM_POOLS.nUSDLP]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: SYNAPSE_FANTOM_POOLS.nUSDLP,
tokens: [FANTOM_TOKENS.nUSD, FANTOM_TOKENS.MIM, FANTOM_TOKENS.USDC, FANTOM_TOKENS.fUSDT],
metaTokens: undefined,
gasSchedule: 140e3,
},
};
export const SYNAPSE_MAINNET_INFOS: { [name: string]: CurveInfo } = {
[SYNAPSE_MAINNET_POOLS.nUSDLP]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: SYNAPSE_MAINNET_POOLS.nUSDLP,
tokens: [MAINNET_TOKENS.DAI, MAINNET_TOKENS.USDC, MAINNET_TOKENS.USDT],
metaTokens: undefined,
gasSchedule: 140e3,
},
};
export const SYNAPSE_OPTIMISM_INFOS: { [name: string]: CurveInfo } = {
[SYNAPSE_OPTIMISM_POOLS.nETHLP]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: SYNAPSE_OPTIMISM_POOLS.nETHLP,
tokens: [OPTIMISM_TOKENS.nETH, OPTIMISM_TOKENS.sWETH],
metaTokens: undefined,
gasSchedule: 140e3,
},
};
export const SYNAPSE_POLYGON_INFOS: { [name: string]: CurveInfo } = {
[SYNAPSE_POLYGON_POOLS.nUSDLP]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: SYNAPSE_POLYGON_POOLS.nUSDLP,
tokens: [POLYGON_TOKENS.nUSD, POLYGON_TOKENS.DAI, POLYGON_TOKENS.USDC, POLYGON_TOKENS.USDT],
metaTokens: undefined,
gasSchedule: 140e3,
},
};
export const SYNAPSE_AVALANCHE_INFOS: { [name: string]: CurveInfo } = {
[SYNAPSE_AVALANCHE_POOLS.nUSDLP]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: SYNAPSE_AVALANCHE_POOLS.nUSDLP,
tokens: [AVALANCHE_TOKENS.nUSD, AVALANCHE_TOKENS.DAI, AVALANCHE_TOKENS.USDC, AVALANCHE_TOKENS.USDT],
metaTokens: undefined,
gasSchedule: 140e3,
},
[SYNAPSE_AVALANCHE_POOLS.nETHLP]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: SYNAPSE_AVALANCHE_POOLS.nETHLP,
tokens: [AVALANCHE_TOKENS.nETH, AVALANCHE_TOKENS.aWETH],
metaTokens: undefined,
gasSchedule: 140e3,
},
};
export const FIREBIRDONESWAP_BSC_INFOS: { [name: string]: CurveInfo } = {
[FIREBIRDONESWAP_BSC_POOLS.oneswap]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
@@ -1405,6 +1726,108 @@ export const ACRYPTOS_BSC_INFOS: { [name: string]: CurveInfo } = {
}),
};
export const MOBIUSMONEY_CELO_INFOS: { [name: string]: CurveInfo } = {
[MOBIUSMONEY_CELO_POOLS.cUSD_cUSDC]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cUSD_cUSDC,
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.cUSDC],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.cUSD_cUSDT]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cUSD_cUSDT,
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.cUSDT],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.cETH_WETHv1]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cETH_WETHv1,
tokens: [CELO_TOKENS.cETH, CELO_TOKENS.WETHv1],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.WBTCv1_wBTC]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.WBTCv1_wBTC,
tokens: [CELO_TOKENS.WBTCv1, CELO_TOKENS.wBTC],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.cUSD_USDC]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cUSD_USDC,
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.USDC],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.cUSD_pUSDC]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cUSD_pUSDC,
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.pUSDC],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.cUSD_asUSDC]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cUSD_asUSDC,
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.asUSDC],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.cEUR_pEUR]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cEUR_pEUR,
tokens: [CELO_TOKENS.cEUR, CELO_TOKENS.pEUR],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.cUSD_aaUSDC]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cUSD_aaUSDC,
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.aaUSDC],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.CELO_pCELO]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.CELO_pCELO,
tokens: [CELO_TOKENS.WCELO, CELO_TOKENS.pCELO],
metaTokens: undefined,
gasSchedule: 140e3,
},
[MOBIUSMONEY_CELO_POOLS.cUSD_pUSD]: {
exchangeFunctionSelector: CurveFunctionSelectors.swap,
sellQuoteFunctionSelector: CurveFunctionSelectors.calculateSwap,
buyQuoteFunctionSelector: CurveFunctionSelectors.None,
poolAddress: MOBIUSMONEY_CELO_POOLS.cUSD_pUSD,
tokens: [CELO_TOKENS.cUSD, CELO_TOKENS.pUSD],
metaTokens: undefined,
gasSchedule: 140e3,
},
};
/**
* Kyber reserve prefixes
* 0xff Fed price reserve
@@ -1982,6 +2405,7 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
[ERC20BridgeSource.Swerve]: fillData => (fillData as CurveFillData).pool.gasSchedule,
[ERC20BridgeSource.SnowSwap]: 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,
[ERC20BridgeSource.Ellipsis]: fillData => (fillData as CurveFillData).pool.gasSchedule,
[ERC20BridgeSource.Smoothy]: fillData => (fillData as CurveFillData).pool.gasSchedule,
@@ -1989,6 +2413,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,

View File

@@ -134,6 +134,8 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'BakerySwap');
case ERC20BridgeSource.Nerve:
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'Nerve');
case ERC20BridgeSource.Synapse:
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'Synapse');
case ERC20BridgeSource.Belt:
return encodeBridgeSourceId(BridgeProtocol.Curve, 'Belt');
case ERC20BridgeSource.Ellipsis:
@@ -200,6 +202,8 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
return encodeBridgeSourceId(BridgeProtocol.AaveV2, 'AaveV2');
case ERC20BridgeSource.Compound:
return encodeBridgeSourceId(BridgeProtocol.Compound, 'Compound');
case ERC20BridgeSource.MobiusMoney:
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'MobiusMoney');
default:
throw new Error(AggregationError.NoBridgeForSource);
}
@@ -226,6 +230,7 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
case ERC20BridgeSource.Swerve:
case ERC20BridgeSource.SnowSwap:
case ERC20BridgeSource.Nerve:
case ERC20BridgeSource.Synapse:
case ERC20BridgeSource.Belt:
case ERC20BridgeSource.Ellipsis:
case ERC20BridgeSource.Smoothy:
@@ -234,6 +239,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,
@@ -463,12 +469,14 @@ export const BRIDGE_ENCODERS: {
[ERC20BridgeSource.Swerve]: curveEncoder,
[ERC20BridgeSource.SnowSwap]: curveEncoder,
[ERC20BridgeSource.Nerve]: curveEncoder,
[ERC20BridgeSource.Synapse]: curveEncoder,
[ERC20BridgeSource.Belt]: curveEncoder,
[ERC20BridgeSource.Ellipsis]: curveEncoder,
[ERC20BridgeSource.Smoothy]: curveEncoder,
[ERC20BridgeSource.Saddle]: curveEncoder,
[ERC20BridgeSource.XSigma]: curveEncoder,
[ERC20BridgeSource.FirebirdOneSwap]: curveEncoder,
[ERC20BridgeSource.MobiusMoney]: curveEncoder,
[ERC20BridgeSource.IronSwap]: curveEncoder,
[ERC20BridgeSource.ACryptos]: curveEncoder,
// UniswapV2 like, (router, address[])

View File

@@ -1342,6 +1342,7 @@ export class SamplerOperations {
case ERC20BridgeSource.Swerve:
case ERC20BridgeSource.SnowSwap:
case ERC20BridgeSource.Nerve:
case ERC20BridgeSource.Synapse:
case ERC20BridgeSource.Belt:
case ERC20BridgeSource.Ellipsis:
case ERC20BridgeSource.Saddle:
@@ -1349,6 +1350,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,
@@ -1647,6 +1649,7 @@ export class SamplerOperations {
case ERC20BridgeSource.Swerve:
case ERC20BridgeSource.SnowSwap:
case ERC20BridgeSource.Nerve:
case ERC20BridgeSource.Synapse:
case ERC20BridgeSource.Belt:
case ERC20BridgeSource.Ellipsis:
case ERC20BridgeSource.Saddle:
@@ -1654,6 +1657,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,

View File

@@ -70,6 +70,7 @@ export enum ERC20BridgeSource {
ShibaSwap = 'ShibaSwap',
AaveV2 = 'Aave_V2',
Compound = 'Compound',
Synapse = 'Synapse',
// BSC only
PancakeSwap = 'PancakeSwap',
PancakeSwapV2 = 'PancakeSwap_V2',
@@ -96,6 +97,7 @@ export enum ERC20BridgeSource {
TraderJoe = 'TraderJoe',
// Celo only
UbeSwap = 'UbeSwap',
MobiusMoney = 'MobiusMoney',
// Fantom
SpiritSwap = 'SpiritSwap',
SpookySwap = 'SpookySwap',
@@ -115,7 +117,7 @@ export type SourcesWithPoolsCache =
export enum CurveFunctionSelectors {
None = '0x00000000',
exchange = '0x3df02124',
exchange_underlying = '0xa6417ed6',
exchange_underlying = '0xa6417ed6', // exchange_underlying(int128 i, int128 j, uint256 dx, uint256 min_dy)
get_dy_underlying = '0x07211ef7',
get_dx_underlying = '0x0e71d1b9',
get_dy = '0x5e0d443f', // get_dy(int128,int128,uint256)
@@ -130,7 +132,7 @@ export enum CurveFunctionSelectors {
// Smoothy
swap_uint256 = '0x5673b02d', // swap(uint256,uint256,uint256,uint256)
get_swap_amount = '0x45cf2ef6', // getSwapAmount(uint256,uint256,uint256)
// Nerve BSC, Saddle Mainnet
// Nerve BSC, Saddle Mainnet, Synapse, MobiusMoney
swap = '0x91695586', // swap(uint8,uint8,uint256,uint256,uint256)
calculateSwap = '0xa95b089f', // calculateSwap(uint8,uint8,uint256)
}

View File

@@ -125,6 +125,7 @@ describe('ExchangeProxySwapQuoteConsumer', () => {
gas: Math.floor(Math.random() * 8e6),
protocolFeeInWeiAmount: getRandomAmount(),
feeTakerTokenAmount: getRandomAmount(),
slippage: 0,
},
worstCaseQuoteInfo: {
makerAmount: makerTokenFillAmount,
@@ -133,6 +134,7 @@ describe('ExchangeProxySwapQuoteConsumer', () => {
gas: Math.floor(Math.random() * 8e6),
protocolFeeInWeiAmount: getRandomAmount(),
feeTakerTokenAmount: getRandomAmount(),
slippage: 0,
},
makerAmountPerEth: getRandomInteger(1, 1e9),
takerAmountPerEth: getRandomInteger(1, 1e9),

View File

@@ -24,6 +24,7 @@ export async function getFullyFillableSwapQuoteWithNoFeesAsync(
totalTakerAmount: takerAmount,
protocolFeeInWeiAmount: protocolFeePerOrder.times(orders.length),
gas: 200e3,
slippage: 0,
};
const breakdown = {