Skip to content

Commit

Permalink
Merge branch 'development' into feat/arbitrum_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
isreallee82 committed Aug 3, 2023
2 parents 54c7bc8 + b89018d commit 47b7990
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 38 deletions.
46 changes: 23 additions & 23 deletions postman/collections/Gateway API.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"id": "c2a569af-9bf2-4afd-86c6-57b52b4205a8"
},
{
"name": "network",
"name": "chain",
"item": [
{
"name": "status",
Expand All @@ -103,11 +103,11 @@
"urlencoded": []
},
"url": {
"raw": "https://{{host}}:{{port}}/network/status",
"raw": "https://{{host}}:{{port}}/chain/status",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["network", "status"]
"path": ["chain", "status"]
}
},
"response": []
Expand All @@ -126,11 +126,11 @@
"urlencoded": []
},
"url": {
"raw": "https://{{host}}:{{port}}/network/config",
"raw": "https://{{host}}:{{port}}/chain/config",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["network", "config"]
"path": ["chain", "config"]
}
},
"response": []
Expand All @@ -154,11 +154,11 @@
}
},
"url": {
"raw": "https://{{host}}:{{port}}/network/balances",
"raw": "https://{{host}}:{{port}}/chain/balances",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["network", "balances"]
"path": ["chain", "balances"]
}
},
"response": []
Expand All @@ -182,11 +182,11 @@
}
},
"url": {
"raw": "https://{{host}}:{{port}}/network/poll",
"raw": "https://{{host}}:{{port}}/chain/poll",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["network", "poll"]
"path": ["chain", "poll"]
}
},
"response": []
Expand All @@ -205,19 +205,19 @@
"raw": ""
},
"url": {
"raw": "https://{{host}}:{{port}}/network/tokens?chain={{chain}}&network={{network}}&tokenSymbols[]=UNI&tokenSymbols[]=WETH&tokenSymbols[]=LINK",
"raw": "https://{{host}}:{{port}}/chain/tokens?chain={{chain}}&network={{network}}&tokenSymbols[]=UNI&tokenSymbols[]=WETH&tokenSymbols[]=LINK",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["network", "tokens"],
"path": ["chain", "tokens"],
"query": [
{
"key": "chain",
"value": "{{chain}}"
},
{
"key": "network",
"value": "{{network}}"
"key": "chain",
"value": "{{chain}}"
},
{
"key": "tokenSymbols[]",
Expand Down Expand Up @@ -357,11 +357,11 @@
}
},
"url": {
"raw": "https://{{host}}:{{port}}/evm/nonce",
"raw": "https://{{host}}:{{port}}/chain/nonce",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["evm", "nonce"]
"path": ["chain", "nonce"]
}
},
"response": []
Expand All @@ -385,11 +385,11 @@
}
},
"url": {
"raw": "https://{{host}}:{{port}}/evm/nextNonce",
"raw": "https://{{host}}:{{port}}/chain/nextNonce",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["evm", "nextNonce"]
"path": ["chain", "nextNonce"]
}
},
"response": []
Expand Down Expand Up @@ -444,11 +444,11 @@
}
},
"url": {
"raw": "https://{{host}}:{{port}}/evm/allowances",
"raw": "https://{{host}}:{{port}}/chain/allowances",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["evm", "allowances"]
"path": ["chain", "allowances"]
}
},
"response": []
Expand All @@ -472,11 +472,11 @@
}
},
"url": {
"raw": "https://{{host}}:{{port}}/evm/approve",
"raw": "https://{{host}}:{{port}}/chain/approve",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["evm", "approve"]
"path": ["chain", "approve"]
}
},
"response": []
Expand All @@ -500,11 +500,11 @@
}
},
"url": {
"raw": "https://{{host}}:{{port}}/evm/cancel",
"raw": "https://{{host}}:{{port}}/chain/cancel",
"protocol": "https",
"host": ["{{host}}"],
"port": "{{port}}",
"path": ["evm", "cancel"]
"path": ["chain", "cancel"]
}
},
"response": []
Expand Down
2 changes: 2 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ export const startSwagger = async () => {

export const startGateway = async () => {
const port = ConfigManagerV2.getInstance().get('server.port');
const gateway_version="dev-1.19.0"; // gateway version
if (!ConfigManagerV2.getInstance().get('server.id')) {
ConfigManagerV2.getInstance().set(
'server.id',
Math.random().toString(16).substr(2, 14)
);
}
logger.info(`Gateway Version: ${gateway_version}`) // display gateway version
logger.info(`⚡️ Starting Gateway API on port ${port}...`);
if (ConfigManagerV2.getInstance().get('server.unsafeDevModeWithHTTP')) {
logger.info('Running in UNSAFE HTTP! This could expose private keys.');
Expand Down
9 changes: 7 additions & 2 deletions src/chains/ethereum/ethereum-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import fse from 'fs-extra';
import { ConfigManagerCertPassphrase } from '../../services/config-manager-cert-passphrase';
import { logger } from '../../services/logger';
import { ReferenceCountingCloseable } from '../../services/refcounting-closeable';
import { getAddress } from 'ethers/lib/utils';

// information about an Ethereum token
export interface TokenInfo {
Expand Down Expand Up @@ -153,15 +154,19 @@ export class EthereumBase {
tokenListSource: string,
tokenListType: TokenListType
): Promise<TokenInfo[]> {
let tokens;
let tokens: TokenInfo[];
if (tokenListType === 'URL') {
({
data: { tokens },
} = await axios.get(tokenListSource));
} else {
({ tokens } = JSON.parse(await fs.readFile(tokenListSource, 'utf8')));
}
return tokens;
const mappedTokens: TokenInfo[] = tokens.map((token) => {
token.address = getAddress(token.address);
return token;
});
return mappedTokens;
}

public get nonceManager() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/defira/defira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { logger } from '../../services/logger';
import { percentRegexp } from '../../services/config-manager-v2';
import { Harmony } from '../../chains/harmony/harmony';
import { ExpectedTrade, Uniswapish } from '../../services/common-interfaces';
import { getAddress } from 'ethers/lib/utils';

export class Defira implements Uniswapish {
private static _instances: { [name: string]: Defira };
Expand Down Expand Up @@ -65,7 +66,7 @@ export class Defira implements Uniswapish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/openocean/openocean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
UNKNOWN_ERROR_ERROR_CODE,
UNKNOWN_ERROR_MESSAGE,
} from '../../services/error-handler';
import { getAddress } from 'ethers/lib/utils';

export function newFakeTrade(
tokenIn: Token,
Expand Down Expand Up @@ -110,7 +111,7 @@ export class Openocean implements Uniswapish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/pancakeswap/pancakeswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { logger } from '../../services/logger';
import { isFractionString } from '../../services/validators';
import { PancakeSwapConfig } from './pancakeswap.config';
import routerAbi from './pancakeswap_router_abi.json';
import { getAddress } from 'ethers/lib/utils';

export class PancakeSwap implements Uniswapish {
private static _instances: { [name: string]: PancakeSwap };
Expand Down Expand Up @@ -91,7 +92,7 @@ export class PancakeSwap implements Uniswapish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/pangolin/pangolin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { logger } from '../../services/logger';
import { Avalanche } from '../../chains/avalanche/avalanche';
import { ExpectedTrade, Uniswapish } from '../../services/common-interfaces';
import { getAddress } from 'ethers/lib/utils';

export class Pangolin implements Uniswapish {
private static _instances: { [name: string]: Pangolin };
Expand Down Expand Up @@ -63,7 +64,7 @@ export class Pangolin implements Uniswapish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/perp/perp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { logger } from '../../services/logger';
import { percentRegexp } from '../../services/config-manager-v2';
import { Ethereum } from '../../chains/ethereum/ethereum';
import { Perpish } from '../../services/common-interfaces';
import { getAddress } from 'ethers/lib/utils';

export interface PerpPosition {
positionAmt: string;
Expand Down Expand Up @@ -88,7 +89,7 @@ export class Perp implements Perpish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/quickswap/quickswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { logger } from '../../services/logger';
import { Polygon } from '../../chains/polygon/polygon';
import { ExpectedTrade, Uniswapish } from '../../services/common-interfaces';
import { getAddress } from 'ethers/lib/utils';

export class Quickswap implements Uniswapish {
private static _instances: { [name: string]: Quickswap };
Expand Down Expand Up @@ -62,7 +63,7 @@ export class Quickswap implements Uniswapish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/sushiswap/sushiswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
} from 'ethers';
import { percentRegexp } from '../../services/config-manager-v2';
import { logger } from '../../services/logger';
import { getAddress } from 'ethers/lib/utils';

export class Sushiswap implements Uniswapish {
private static _instances: { [name: string]: Sushiswap };
Expand Down Expand Up @@ -83,7 +84,7 @@ export class Sushiswap implements Uniswapish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/traderjoe/traderjoe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
import { EVMTxBroadcaster } from '../../chains/ethereum/evm.broadcaster';
import { createPublicClient, http } from 'viem';
import { avalanche, avalancheFuji } from 'viem/chains';
import { getAddress } from 'ethers/lib/utils';

const MAX_HOPS = 2;
const BASES = ['USDT', 'USDC', 'WAVAX'];
Expand Down Expand Up @@ -71,7 +72,7 @@ export class Traderjoe implements Uniswapish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/uniswap/uniswap.lp.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ReduceLiquidityData,
} from './uniswap.lp.interfaces';
import * as math from 'mathjs';
import { getAddress } from 'ethers/lib/utils';

export class UniswapLPHelper {
protected ethereum: Ethereum;
Expand Down Expand Up @@ -96,7 +97,7 @@ export class UniswapLPHelper {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/uniswap/uniswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { percentRegexp } from '../../services/config-manager-v2';
import { Ethereum } from '../../chains/ethereum/ethereum';
import { Polygon } from '../../chains/polygon/polygon';
import { ExpectedTrade, Uniswapish } from '../../services/common-interfaces';
import { getAddress } from 'ethers/lib/utils';

export class Uniswap implements Uniswapish {
private static _instances: { [name: string]: Uniswap };
Expand Down Expand Up @@ -107,7 +108,7 @@ export class Uniswap implements Uniswapish {
* @param address Token address
*/
public getTokenByAddress(address: string): Token {
return this.tokenList[address];
return this.tokenList[getAddress(address)];
}

public async init() {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16944,9 +16944,9 @@ winston@^3.3.3:
winston-transport "^4.5.0"

word-wrap@^1.2.3, word-wrap@~1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
version "1.2.4"
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f"
integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==

workerpool@6.2.1:
version "6.2.1"
Expand Down

0 comments on commit 47b7990

Please sign in to comment.