Compare commits

...

15 Commits

Author SHA1 Message Date
Github Actions
e12ed1eddf Publish
- @0x/asset-swapper@16.38.0
2021-11-29 23:23:57 +00:00
Github Actions
ac94023ab3 Updated CHANGELOGS & MD docs 2021-11-29 23:23:54 +00:00
Jacob Evans
281e6acca5 chore: Add ability to capture sampler metrics (#374)
* chore: Add ability to capture sampler metrics

* Added block number metrics
2021-11-30 09:06:05 +10:00
Github Actions
2f1b520409 Publish
- @0x/asset-swapper@16.37.0
2021-11-19 19:15:43 +00:00
Github Actions
21b4eb3d26 Updated CHANGELOGS & MD docs 2021-11-19 19:15:40 +00:00
Noah Khamliche
644f6c7d28 removed comma 2021-11-19 13:46:57 -05:00
Noah Khamliche
0647b9e4f8 Update CHANGELOG.json 2021-11-19 13:46:57 -05:00
Noah Khamliche
82d42eeede address to lowercase 2021-11-19 13:46:57 -05:00
Noah Khamliche
6ef4d95043 Updated Sushiswap router on CELO
Sushi address in the docs was incorrect, this is the correct address `0x1421bDe4B10e8dd459b3BCb598810B1337D56842`.
2021-11-19 13:46:57 -05:00
Github Actions
6044140f86 Publish
- @0x/asset-swapper@16.36.0
2021-11-19 02:59:33 +00:00
Github Actions
4da1ef0f56 Updated CHANGELOGS & MD docs 2021-11-19 02:59:30 +00:00
Jacob Evans
8c668a3918 feat: Specify FEI/TRIBE liquid pool (#371)
* feat: Specify FEI/TRIBE liquid pool

* CHANGELOG

* FXS/FRAX and OHM/FRAX
2021-11-18 15:39:07 +10:00
Github Actions
f1ff1cde39 Publish
- @0x/asset-swapper@16.35.0
2021-11-18 03:31:36 +00:00
Github Actions
1668a24e31 Updated CHANGELOGS & MD docs 2021-11-18 03:31:32 +00:00
Shawn
4b7c376d96 feat: Add Beethoven X, MorpheusSwap and JetSwap on Fantom (#370)
* Rebase to development branch

* add support for MorpheusSwap and JetSwap on Fantom

* fix lint

* modify changelog.json for asset-swapper

* fix the comments

* prettier

* Use BalancerV2PoolsCache for BeethovenX

Co-authored-by: Romain Butteaud <romain.butteaud@gmail.com>
2021-11-17 19:14:01 -08:00
14 changed files with 248 additions and 16 deletions

View File

@@ -1,4 +1,44 @@
[
{
"version": "16.38.0",
"changes": [
{
"note": "Capture sampler metrics",
"pr": 374
}
],
"timestamp": 1638228231
},
{
"version": "16.37.0",
"changes": [
{
"note": "Changed Sushiswap router address",
"pr": 373
}
],
"timestamp": 1637349338
},
{
"version": "16.36.0",
"changes": [
{
"note": "Specify liquid routes for FEI/TRIBE FXS/FRAX and OHM/FRAX",
"pr": 371
}
],
"timestamp": 1637290768
},
{
"version": "16.35.0",
"changes": [
{
"note": "Add Beethoven X, MorpheusSwap and JetSwap to Fantom",
"pr": 370
}
],
"timestamp": 1637206290
},
{
"version": "16.34.0",
"changes": [

View File

@@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v16.38.0 - _November 29, 2021_
* Capture sampler metrics (#374)
## v16.37.0 - _November 19, 2021_
* Changed Sushiswap router address (#373)
## v16.36.0 - _November 19, 2021_
* Specify liquid routes for FEI/TRIBE FXS/FRAX and OHM/FRAX (#371)
## v16.35.0 - _November 18, 2021_
* Add Beethoven X, MorpheusSwap and JetSwap to Fantom (#370)
## v16.34.0 - _November 16, 2021_
* Add support Celo (#367)

View File

@@ -77,4 +77,19 @@ contract UtilitySampler {
assembly { size := extcodesize(account) }
return size > 0;
}
function getGasLeft()
public
returns (uint256)
{
return gasleft();
}
function getBlockNumber()
public
view
returns (uint256)
{
return block.number;
}
}

View File

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

View File

@@ -113,6 +113,7 @@ export {
SwapQuoterError,
SwapQuoterOpts,
SwapQuoterRfqOpts,
SamplerMetrics,
} from './types';
export { affiliateFeeUtils } from './utils/affiliate_fee_utils';
export {

View File

@@ -19,6 +19,7 @@ import {
OptimizedMarketOrder,
TokenAdjacencyGraph,
} from './utils/market_operation_utils/types';
export { SamplerMetrics } from './utils/market_operation_utils/types';
import { ExtendedQuoteReportSources, PriceComparisonsReport, QuoteReport } from './utils/quote_report_generator';
import { MetricsProxy } from './utils/quote_requestor';

View File

@@ -30,6 +30,7 @@ import {
KYBER_BRIDGED_LIQUIDITY_PREFIX,
MAX_DODOV2_POOLS_QUERIED,
MAX_KYBER_RESERVES_QUERIED,
MORPHEUSSWAP_ROUTER_BY_CHAIN_ID,
MSTABLE_POOLS_BY_CHAIN_ID,
NERVE_BSC_INFOS,
NULL_ADDRESS,
@@ -488,6 +489,7 @@ export function uniswapV2LikeRouterAddress(
| ERC20BridgeSource.TraderJoe
| ERC20BridgeSource.Pangolin
| ERC20BridgeSource.UbeSwap
| ERC20BridgeSource.MorpheusSwap
| ERC20BridgeSource.SpookySwap
| ERC20BridgeSource.SpiritSwap,
): string {
@@ -532,6 +534,8 @@ export function uniswapV2LikeRouterAddress(
return TRADER_JOE_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.UbeSwap:
return UBESWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.MorpheusSwap:
return MORPHEUSSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.SpookySwap:
return SPOOKYSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.SpiritSwap:

View File

@@ -171,8 +171,11 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
]),
[ChainId.Fantom]: new SourceFilters([
ERC20BridgeSource.MultiHop,
ERC20BridgeSource.Beethovenx,
ERC20BridgeSource.Curve,
ERC20BridgeSource.CurveV2,
ERC20BridgeSource.JetSwap,
ERC20BridgeSource.MorpheusSwap,
ERC20BridgeSource.SpiritSwap,
ERC20BridgeSource.SpookySwap,
ERC20BridgeSource.SushiSwap,
@@ -294,8 +297,11 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
]),
[ChainId.Fantom]: new SourceFilters([
ERC20BridgeSource.MultiHop,
ERC20BridgeSource.Beethovenx,
ERC20BridgeSource.Curve,
ERC20BridgeSource.CurveV2,
ERC20BridgeSource.JetSwap,
ERC20BridgeSource.MorpheusSwap,
ERC20BridgeSource.SpiritSwap,
ERC20BridgeSource.SpookySwap,
ERC20BridgeSource.SushiSwap,
@@ -422,9 +428,16 @@ export const MAINNET_TOKENS = {
// StableSwap "open pools" (crv.finance)
STABLEx: '0xcd91538b91b4ba7797d39a2f66e63810b50a33d0',
alUSD: '0xbc6da0fe9ad5f3b0d58160288917aa56653660e9',
// Frax ecosystem
FRAX: '0x853d955acef822db058eb8505911ed77f175b99e',
FXS: '0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0',
OHM: '0x383518188c0c6d7730d91b2c03a03c837814a899',
//
LUSD: '0x5f98805a4e8be255a32880fdec7f6728c6568ba0',
// Fei Ecosystem
FEI: '0x956f47f50a910163d8bf957cf5846d573e7f87ca',
TRIBE: '0xc7283b66eb1eb5fb86327f08e1b5816b0720212b',
//
DSU: '0x605d26fbd5be761089281d5cec2ce86eea667109',
ESS: '0x24ae124c4cc33d6791f8e8b63520ed7107ac8b3e',
cvxCRV: '0x62b9c7356a2dc64a1969e19c23e4f579f9810aa7',
@@ -690,6 +703,11 @@ export const DEFAULT_TOKEN_ADJACENCY_GRAPH_BY_CHAIN_ID = valueByChainId<TokenAdj
builder.add(MAINNET_TOKENS.MIR, MAINNET_TOKENS.UST);
// Convex and Curve
builder.add(MAINNET_TOKENS.cvxCRV, MAINNET_TOKENS.CRV).add(MAINNET_TOKENS.CRV, MAINNET_TOKENS.cvxCRV);
// FEI TRIBE liquid in UniV2
builder.add(MAINNET_TOKENS.FEI, MAINNET_TOKENS.TRIBE).add(MAINNET_TOKENS.TRIBE, MAINNET_TOKENS.FEI);
// FRAX ecosystem
builder.add(MAINNET_TOKENS.FRAX, MAINNET_TOKENS.FXS).add(MAINNET_TOKENS.FXS, MAINNET_TOKENS.FRAX);
builder.add(MAINNET_TOKENS.FRAX, MAINNET_TOKENS.OHM).add(MAINNET_TOKENS.OHM, MAINNET_TOKENS.FRAX);
})
// Build
.build(),
@@ -1396,7 +1414,7 @@ export const SUSHISWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
[ChainId.Polygon]: '0x1b02da8cb0d097eb8d57a175b88c7d8b47997506',
[ChainId.Avalanche]: '0x1b02da8cb0d097eb8d57a175b88c7d8b47997506',
[ChainId.Fantom]: '0x1b02da8cb0d097eb8d57a175b88c7d8b47997506',
[ChainId.Celo]: '0x1b02da8cb0d097eb8d57a175b88c7d8b47997506',
[ChainId.Celo]: '0x1421bde4b10e8dd459b3bcb598810b1337d56842',
},
NULL_ADDRESS,
);
@@ -1618,6 +1636,13 @@ export const BALANCER_V2_VAULT_ADDRESS_BY_CHAIN = valueByChainId<string>(
NULL_ADDRESS,
);
export const BEETHOVEN_X_VAULT_ADDRESS_BY_CHAIN = valueByChainId<string>(
{
[ChainId.Fantom]: '0x20dd72ed959b6147912c2e529f0a0c651c33c9ce',
},
NULL_ADDRESS,
);
export const LIDO_INFO_BY_CHAIN = valueByChainId<LidoInfo>(
{
[ChainId.Mainnet]: {
@@ -1642,6 +1667,13 @@ export const BALANCER_V2_SUBGRAPH_URL_BY_CHAIN = valueByChainId<string>(
'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2',
);
export const BEETHOVEN_X_SUBGRAPH_URL_BY_CHAIN = valueByChainId<string>(
{
[ChainId.Fantom]: 'https://graph-node.beets-ftm-node.com/subgraphs/name/beethovenx-v4',
},
'https://graph-node.beets-ftm-node.com/subgraphs/name/beethovenx-v4',
);
export const UNISWAPV3_CONFIG_BY_CHAIN_ID = valueByChainId(
{
[ChainId.Mainnet]: {
@@ -1752,6 +1784,7 @@ export const JETSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{
[ChainId.BSC]: '0xbe65b8f75b9f20f4c522e0067a3887fada714800',
[ChainId.Polygon]: '0x5c6ec38fb0e2609672bdf628b1fd605a523e5923',
[ChainId.Fantom]: '0x845e76a8691423fbc4ecb8dd77556cb61c09ee25',
},
NULL_ADDRESS,
);
@@ -1777,6 +1810,13 @@ export const UBESWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
NULL_ADDRESS,
);
export const MORPHEUSSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{
[ChainId.Fantom]: '0x8ac868293d97761a1fed6d4a01e9ff17c5594aa3',
},
NULL_ADDRESS,
);
export const SPIRITSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{
[ChainId.Fantom]: '0x16327e3fbdaca3bcf7e38f5af2599d2ddc33ae52',
@@ -1950,8 +1990,10 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
//
// Fantom
//
[ERC20BridgeSource.MorpheusSwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.SpiritSwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.SpookySwap]: uniswapV2CloneGasSchedule,
[ERC20BridgeSource.Beethovenx]: () => 100e3,
};
export const DEFAULT_FEE_SCHEDULE: Required<FeeSchedule> = { ...DEFAULT_GAS_SCHEDULE };

View File

@@ -158,6 +158,8 @@ export class MarketOperationUtils {
// Call the sampler contract.
const samplerPromise = this._sampler.executeAsync(
this._sampler.getBlockNumber(),
this._sampler.getGasLeft(),
this._sampler.getTokenDecimals([makerToken, takerToken]),
// Get native order fillable amounts.
this._sampler.getLimitOrderFillableTakerAmounts(nativeOrders, this.contractAddresses.exchangeProxy),
@@ -184,6 +186,7 @@ export class MarketOperationUtils {
takerAmount,
),
this._sampler.isAddressContract(txOrigin),
this._sampler.getGasLeft(),
);
// Refresh the cached pools asynchronously if required
@@ -191,6 +194,8 @@ export class MarketOperationUtils {
const [
[
blockNumber,
gasBefore,
tokenDecimals,
orderFillableTakerAmounts,
outputAmountPerEth,
@@ -198,9 +203,14 @@ export class MarketOperationUtils {
dexQuotes,
rawTwoHopQuotes,
isTxOriginContract,
gasAfter,
],
] = await Promise.all([samplerPromise]);
// Log the gas metrics
_opts.samplerMetrics?.logGasDetails({ gasBefore, gasAfter });
_opts.samplerMetrics?.logBlockNumber(blockNumber);
// Filter out any invalid two hop quotes where we couldn't find a route
const twoHopQuotes = rawTwoHopQuotes.filter(
q => q && q.fillData && q.fillData.firstHopSource && q.fillData.secondHopSource,

View File

@@ -186,10 +186,14 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'TraderJoe');
case ERC20BridgeSource.UbeSwap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'UbeSwap');
case ERC20BridgeSource.Beethovenx:
return encodeBridgeSourceId(BridgeProtocol.BalancerV2, 'Beethovenx');
case ERC20BridgeSource.SpiritSwap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'SpiritSwap');
case ERC20BridgeSource.SpookySwap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'SpookySwap');
case ERC20BridgeSource.MorpheusSwap:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'MorpheusSwap');
default:
throw new Error(AggregationError.NoBridgeForSource);
}
@@ -238,6 +242,7 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
bridgeData = encoder.encode([balancerFillData.poolAddress]);
break;
case ERC20BridgeSource.BalancerV2:
case ERC20BridgeSource.Beethovenx:
const balancerV2FillData = (order as OptimizedMarketBridgeOrder<BalancerV2FillData>).fillData;
const { vault, poolId } = balancerV2FillData;
bridgeData = encoder.encode([vault, poolId]);
@@ -269,6 +274,7 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
case ERC20BridgeSource.UbeSwap:
case ERC20BridgeSource.SpiritSwap:
case ERC20BridgeSource.SpookySwap:
case ERC20BridgeSource.MorpheusSwap:
const uniswapV2FillData = (order as OptimizedMarketBridgeOrder<UniswapV2FillData>).fillData;
bridgeData = encoder.encode([uniswapV2FillData.router, uniswapV2FillData.tokenAddressPath]);
break;
@@ -461,6 +467,7 @@ export const BRIDGE_ENCODERS: {
[ERC20BridgeSource.TraderJoe]: routerAddressPathEncoder,
[ERC20BridgeSource.SpiritSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.SpookySwap]: routerAddressPathEncoder,
[ERC20BridgeSource.MorpheusSwap]: routerAddressPathEncoder,
// Celo
[ERC20BridgeSource.UbeSwap]: routerAddressPathEncoder,
// BSC
@@ -490,6 +497,7 @@ export const BRIDGE_ENCODERS: {
// Custom integrations
[ERC20BridgeSource.MakerPsm]: makerPsmEncoder,
[ERC20BridgeSource.BalancerV2]: balancerV2Encoder,
[ERC20BridgeSource.Beethovenx]: balancerV2Encoder,
[ERC20BridgeSource.UniswapV3]: AbiEncoder.create([
{ name: 'router', type: 'address' },
{ name: 'path', type: 'bytes' },

View File

@@ -130,6 +130,37 @@ export class DexOrderSampler extends SamplerOperations {
BatchedOperationResult<T8>
]>;
// prettier-ignore
public async executeAsync<
T1, T2, T3, T4, T5, T6, T7, T8, T9
>(...ops: [T1, T2, T3, T4, T5, T6, T7, T8, T9]): Promise<[
BatchedOperationResult<T1>,
BatchedOperationResult<T2>,
BatchedOperationResult<T3>,
BatchedOperationResult<T4>,
BatchedOperationResult<T5>,
BatchedOperationResult<T6>,
BatchedOperationResult<T7>,
BatchedOperationResult<T8>,
BatchedOperationResult<T9>
]>;
// prettier-ignore
public async executeAsync<
T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
>(...ops: [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]): Promise<[
BatchedOperationResult<T1>,
BatchedOperationResult<T2>,
BatchedOperationResult<T3>,
BatchedOperationResult<T4>,
BatchedOperationResult<T5>,
BatchedOperationResult<T6>,
BatchedOperationResult<T7>,
BatchedOperationResult<T8>,
BatchedOperationResult<T9>,
BatchedOperationResult<T10>,
]>;
/**
* Run a series of operations from `DexOrderSampler.ops` in a single transaction.
*/

View File

@@ -20,6 +20,8 @@ import {
import {
BALANCER_V2_VAULT_ADDRESS_BY_CHAIN,
BANCOR_REGISTRY_BY_CHAIN_ID,
BEETHOVEN_X_SUBGRAPH_URL_BY_CHAIN,
BEETHOVEN_X_VAULT_ADDRESS_BY_CHAIN,
DODOV1_CONFIG_BY_CHAIN_ID,
DODOV2_FACTORIES_BY_CHAIN_ID,
KYBER_CONFIG_BY_CHAIN_ID,
@@ -122,6 +124,10 @@ export class SamplerOperations {
? poolsCaches
: {
[ERC20BridgeSource.BalancerV2]: new BalancerV2PoolsCache(chainId),
[ERC20BridgeSource.Beethovenx]: new BalancerV2PoolsCache(
chainId,
BEETHOVEN_X_SUBGRAPH_URL_BY_CHAIN[chainId],
),
[ERC20BridgeSource.Balancer]: new BalancerPoolsCache(),
[ERC20BridgeSource.Cream]: new CreamPoolsCache(),
};
@@ -152,6 +158,30 @@ export class SamplerOperations {
};
}
public getGasLeft(): BatchedOperation<BigNumber> {
return {
encodeCall: () => this._samplerContract.getGasLeft().getABIEncodedTransactionData(),
handleCallResults: (callResults: string) =>
this._samplerContract.getABIDecodedReturnData<BigNumber>('getGasLeft', callResults),
handleRevert: () => {
/* should never happen */
throw new Error('Invalid result for getGasLeft');
},
};
}
public getBlockNumber(): BatchedOperation<BigNumber> {
return {
encodeCall: () => this._samplerContract.getBlockNumber().getABIEncodedTransactionData(),
handleCallResults: (callResults: string) =>
this._samplerContract.getABIDecodedReturnData<BigNumber>('getBlockNumber', callResults),
handleRevert: () => {
/* should never happen */
throw new Error('Invalid result for getBlockNumber');
},
};
}
public getLimitOrderFillableTakerAmounts(
orders: SignedNativeOrder[],
exchangeAddress: string,
@@ -1200,6 +1230,7 @@ export class SamplerOperations {
case ERC20BridgeSource.UbeSwap:
case ERC20BridgeSource.SpiritSwap:
case ERC20BridgeSource.SpookySwap:
case ERC20BridgeSource.MorpheusSwap:
const uniLikeRouter = uniswapV2LikeRouterAddress(this.chainId, source);
if (!isValidAddress(uniLikeRouter)) {
return [];
@@ -1301,13 +1332,14 @@ export class SamplerOperations {
),
);
case ERC20BridgeSource.BalancerV2:
case ERC20BridgeSource.Beethovenx:
const poolIds =
this.poolsCaches[ERC20BridgeSource.BalancerV2].getCachedPoolAddressesForPair(
takerToken,
makerToken,
) || [];
this.poolsCaches[source].getCachedPoolAddressesForPair(takerToken, makerToken) || [];
const vault = BALANCER_V2_VAULT_ADDRESS_BY_CHAIN[this.chainId];
const vault =
source === ERC20BridgeSource.BalancerV2
? BALANCER_V2_VAULT_ADDRESS_BY_CHAIN[this.chainId]
: BEETHOVEN_X_VAULT_ADDRESS_BY_CHAIN[this.chainId];
if (vault === NULL_ADDRESS) {
return [];
}
@@ -1317,10 +1349,9 @@ export class SamplerOperations {
makerToken,
takerToken,
takerFillAmounts,
ERC20BridgeSource.BalancerV2,
source,
),
);
case ERC20BridgeSource.Cream:
return (
this.poolsCaches[ERC20BridgeSource.Cream].getCachedPoolAddressesForPair(
@@ -1472,6 +1503,7 @@ export class SamplerOperations {
case ERC20BridgeSource.UbeSwap:
case ERC20BridgeSource.SpiritSwap:
case ERC20BridgeSource.SpookySwap:
case ERC20BridgeSource.MorpheusSwap:
const uniLikeRouter = uniswapV2LikeRouterAddress(this.chainId, source);
if (!isValidAddress(uniLikeRouter)) {
return [];
@@ -1573,13 +1605,14 @@ export class SamplerOperations {
),
);
case ERC20BridgeSource.BalancerV2:
case ERC20BridgeSource.Beethovenx:
const poolIds =
this.poolsCaches[ERC20BridgeSource.BalancerV2].getCachedPoolAddressesForPair(
takerToken,
makerToken,
) || [];
this.poolsCaches[source].getCachedPoolAddressesForPair(takerToken, makerToken) || [];
const vault = BALANCER_V2_VAULT_ADDRESS_BY_CHAIN[this.chainId];
const vault =
source === ERC20BridgeSource.BalancerV2
? BALANCER_V2_VAULT_ADDRESS_BY_CHAIN[this.chainId]
: BEETHOVEN_X_VAULT_ADDRESS_BY_CHAIN[this.chainId];
if (vault === NULL_ADDRESS) {
return [];
}
@@ -1589,7 +1622,7 @@ export class SamplerOperations {
makerToken,
takerToken,
makerFillAmounts,
ERC20BridgeSource.BalancerV2,
source,
),
);
case ERC20BridgeSource.Cream:

View File

@@ -97,8 +97,14 @@ export enum ERC20BridgeSource {
// Fantom
SpiritSwap = 'SpiritSwap',
SpookySwap = 'SpookySwap',
Beethovenx = 'Beethovenx',
MorpheusSwap = 'MorpheusSwap',
}
export type SourcesWithPoolsCache = ERC20BridgeSource.Balancer | ERC20BridgeSource.BalancerV2 | ERC20BridgeSource.Cream;
export type SourcesWithPoolsCache =
| ERC20BridgeSource.Balancer
| ERC20BridgeSource.BalancerV2
| ERC20BridgeSource.Beethovenx
| ERC20BridgeSource.Cream;
// tslint:disable: enum-naming
/**
@@ -463,6 +469,28 @@ export interface GetMarketOrdersOpts {
* Gas price to use for quote
*/
gasPrice: BigNumber;
/**
* Sampler metrics for recording data on the sampler service and operations
*/
samplerMetrics?: SamplerMetrics;
}
export interface SamplerMetrics {
/**
* Logs the gas information performed during a sampler call.
*
* @param data.gasBefore The gas remaining measured before any operations have been performed
* @param data.gasAfter The gas remaining measured after all operations have been performed
*/
logGasDetails(data: { gasBefore: BigNumber; gasAfter: BigNumber }): void;
/**
* Logs the block number
*
* @param blockNumber block number of the sampler call
*/
logBlockNumber(blockNumber: BigNumber): void;
}
/**

View File

@@ -23,6 +23,7 @@ import {
POSITIVE_INF,
SELL_SOURCE_FILTER_BY_CHAIN_ID,
SOURCE_FLAGS,
ZERO_AMOUNT,
} from '../src/utils/market_operation_utils/constants';
import { createFills } from '../src/utils/market_operation_utils/fills';
import { PoolsCache } from '../src/utils/market_operation_utils/pools_cache';
@@ -427,6 +428,8 @@ describe('MarketOperationUtils tests', () => {
getTwoHopSellQuotes: (..._params: any[]) => [],
getTwoHopBuyQuotes: (..._params: any[]) => [],
isAddressContract: (..._params: any[]) => false,
getGasLeft: () => ZERO_AMOUNT,
getBlockNumber: () => ZERO_AMOUNT,
};
const MOCK_SAMPLER = ({