Skip to content

Commit

Permalink
Merge pull request #867 from paraswap/aburkut/back-1798-bebop-auth-name
Browse files Browse the repository at this point in the history
Aburkut/back 1798 bebop auth name
  • Loading branch information
KanievskyiDanylo authored Dec 27, 2024
2 parents 559779a + caccc72 commit dec7b3b
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 44 deletions.
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@ HTTP_PROVIDER_43114=

TENDERLY_TOKEN=
TENDERLY_ACCOUNT_ID=
TENDERLY_PROJECT=
TENDERLY_PROJECT=


API_KEY_BEBOP_AUTH_NAME=paraswap
API_KEY_BEBOP_AUTH_TOKEN=test
API_KEY_HASHFLOW_AUTH_TOKEN=test
API_KEY_SWAAP_V2_AUTH_TOKEN=test
API_KEY_DEXALOT_AUTH_TOKEN=test
API_KEY_SMARDEX_SUBGRAPH=test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paraswap/dex-lib",
"version": "4.0.12",
"version": "4.0.13",
"main": "build/index.js",
"types": "build/index.d.ts",
"repository": "https://github.com/paraswap/paraswap-dex-lib",
Expand Down
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type BaseConfig = {
idleDaoAuthToken?: string;
swaapV2AuthToken?: string;
dexalotAuthToken?: string;
bebopAuthName?: string;
bebopAuthToken?: string;
forceRpcFallbackDexs: string[];
};
Expand Down Expand Up @@ -74,6 +75,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
rpcPollingBlocksBackToTriggerUpdate: 0,
swaapV2AuthToken: process.env.API_KEY_SWAAP_V2_AUTH_TOKEN || '',
hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
bebopAuthName: process.env.API_KEY_BEBOP_AUTH_NAME || '',
bebopAuthToken: process.env.API_KEY_BEBOP_AUTH_TOKEN || '',
idleDaoAuthToken: process.env.API_KEY_IDLEDAO_AUTH_TOKEN || '',
hashFlowDisabledMMs:
Expand Down Expand Up @@ -147,6 +149,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
multicallV2Address: '0xC50F4c1E81c873B2204D7eFf7069Ffec6Fbe136D',
privateHttpProvider: process.env.HTTP_PROVIDER_56,
augustusV6Address: '0x6a000f20005980200259b80c5102003040001068',
bebopAuthName: process.env.API_KEY_BEBOP_AUTH_NAME || '',
bebopAuthToken: process.env.API_KEY_BEBOP_AUTH_TOKEN || '',
executorsAddresses: {
Executor01: '0x000010036C0190E009a000d0fc3541100A07380A',
Expand Down Expand Up @@ -301,6 +304,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
Executor03: '0xe009F00e200A090090fC70e02d70B232000c0802',
},
dexalotAuthToken: process.env.API_KEY_DEXALOT_AUTH_TOKEN || '',
bebopAuthName: process.env.API_KEY_BEBOP_AUTH_NAME || '',
bebopAuthToken: process.env.API_KEY_BEBOP_AUTH_TOKEN || '',
adapterAddresses: {
ArbitrumAdapter01: '0x369A2FDb910d432f0a07381a5E3d27572c876713',
Expand Down Expand Up @@ -348,6 +352,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
uniswapV2ExchangeRouterAddress:
'0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
uniswapV3EventLoggingSampleRate: 0,
bebopAuthName: process.env.API_KEY_BEBOP_AUTH_NAME || '',
bebopAuthToken: process.env.API_KEY_BEBOP_AUTH_TOKEN || '',
rfqConfigs: {},
rpcPollingMaxAllowedStateDelayInBlocks: 5,
Expand Down Expand Up @@ -431,6 +436,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
multicallV2Address: '0xeDF6D2a16e8081F777eB623EeB4411466556aF3d',
privateHttpProvider: process.env.HTTP_PROVIDER_8453,
dexalotAuthToken: process.env.API_KEY_DEXALOT_AUTH_TOKEN || '',
bebopAuthName: process.env.API_KEY_BEBOP_AUTH_NAME || '',
bebopAuthToken: process.env.API_KEY_BEBOP_AUTH_TOKEN || '',
hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
swaapV2AuthToken: process.env.API_KEY_SWAAP_V2_AUTH_TOKEN || '',
Expand Down Expand Up @@ -528,6 +534,7 @@ export function generateConfig(network: number): Config {
idleDaoAuthToken: baseConfig.idleDaoAuthToken,
swaapV2AuthToken: baseConfig.swaapV2AuthToken,
dexalotAuthToken: baseConfig.dexalotAuthToken,
bebopAuthName: baseConfig.bebopAuthName,
bebopAuthToken: baseConfig.bebopAuthToken,
hashFlowDisabledMMs: baseConfig.hashFlowDisabledMMs,
forceRpcFallbackDexs: baseConfig.forceRpcFallbackDexs,
Expand Down
70 changes: 35 additions & 35 deletions src/dex/bebop/bebop-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function testForNetwork(
const nativeTokenSymbol = NativeTokenSymbols[network];

const sideToContractMethods = new Map([
// [SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
[SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
[SwapSide.BUY, [ContractMethod.swapExactAmountOut]],
]);

Expand All @@ -56,40 +56,40 @@ function testForNetwork(
100,
);
});
// it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
// await testE2E(
// tokens[tokenASymbol],
// tokens[nativeTokenSymbol],
// holders[tokenASymbol],
// side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
// side,
// dexKey,
// contractMethod,
// network,
// provider,
// undefined,
// undefined,
// undefined,
// 100,
// );
// });
// it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
// await testE2E(
// tokens[tokenASymbol],
// tokens[tokenBSymbol],
// holders[tokenASymbol],
// side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
// side,
// dexKey,
// contractMethod,
// network,
// provider,
// undefined,
// undefined,
// undefined,
// 100,
// );
// });
it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
await testE2E(
tokens[tokenASymbol],
tokens[nativeTokenSymbol],
holders[tokenASymbol],
side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
side,
dexKey,
contractMethod,
network,
provider,
undefined,
undefined,
undefined,
100,
);
});
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
await testE2E(
tokens[tokenASymbol],
tokens[tokenBSymbol],
holders[tokenASymbol],
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
side,
dexKey,
contractMethod,
network,
provider,
undefined,
undefined,
undefined,
100,
);
});
});
});
}),
Expand Down
22 changes: 16 additions & 6 deletions src/dex/bebop/bebop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { Interface } from 'ethers/lib/utils';
import { RateFetcher } from './rate-fetcher';
import {
BEBOP_API_URL,
BEBOP_AUTH_NAME,
BEBOP_ERRORS_CACHE_KEY,
BEBOP_GAS_COST,
BEBOP_INIT_TIMEOUT_MS,
Expand Down Expand Up @@ -77,6 +76,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
private tokensAddrCacheKey: string;

private bebopAuthToken: string;
private bebopAuthName: string;

logger: Logger;

Expand All @@ -94,9 +94,19 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
this.pricesCacheKey = `prices`;
this.tokensAddrCacheKey = `tokens_addr`;
const token = this.dexHelper.config.data.bebopAuthToken;
if (!token) {
throw new Error('Bebop auth token is not set');
}
const name = this.dexHelper.config.data.bebopAuthName;

assert(
token !== undefined,
'Bebop auth token is not specified with env variable',
);

assert(
name !== undefined,
'Bebop auth name is not specified with env variable',
);

this.bebopAuthName = name;
this.bebopAuthToken = token;

this.rateFetcher = new RateFetcher(
Expand All @@ -122,7 +132,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
BEBOP_WS_API_URL +
`/pmm/${BebopConfig['Bebop'][network].chainName}/v3/pricing?format=protobuf`,
headers: {
name: BEBOP_AUTH_NAME,
name: this.bebopAuthName,
authorization: this.bebopAuthToken,
},
},
Expand Down Expand Up @@ -703,7 +713,7 @@ export class Bebop extends SimpleExchange implements IDex<BebopData> {
receiver_address: utils.getAddress(options.recipient),
gasless: false,
skip_validation: true,
source: BEBOP_AUTH_NAME,
source: this.bebopAuthName,
};

try {
Expand Down
1 change: 0 additions & 1 deletion src/dex/bebop/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export const BEBOP_TOKENS_POLLING_INTERVAL_MS = 30 * 1000;
export const BEBOP_API_URL = 'https://api.bebop.xyz';
export const BEBOP_WS_API_URL = 'wss://api.bebop.xyz';
export const BEBOP_GAS_COST = 120_000;
export const BEBOP_AUTH_NAME = 'paraswap';
export const BEBOP_QUOTE_TIMEOUT_MS = 3000;
export const BEBOP_ERRORS_CACHE_KEY = 'errors';
export const BEBOP_RESTRICTED_CACHE_KEY = 'restricted';
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ export type Config = {
uniswapV3EventLoggingSampleRate?: number;
swaapV2AuthToken?: string;
dexalotAuthToken?: string;
bebopAuthName?: string;
bebopAuthToken?: string;
idleDaoAuthToken?: string;
forceRpcFallbackDexs: string[];
Expand Down

0 comments on commit dec7b3b

Please sign in to comment.