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

sync gateway / staging -> master for Hummingbot gateway version 1.27.0 #315

Merged
merged 29 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3da3d35
(feat) pancakeswap mainnet
isreallee82 Mar 20, 2024
f8a9222
(feat) pancakeswap mainnet
isreallee82 Mar 21, 2024
907cde5
(fix) eth subgraph
isreallee82 Mar 21, 2024
7228915
fix-upd-version-to-dev-1.27.0
nikspz Mar 26, 2024
7f83a79
Update package.json
nikspz Mar 26, 2024
ee9dbcf
Merge pull request #301 from hummingbot/fix-upd-version-to-dev-1.27.0
nikspz Mar 26, 2024
76d8007
Merge branch 'development' into feat/pancakeswap_mainnet_chain
nikspz Mar 27, 2024
3e13b19
(clean-up) uniswap test file
isreallee82 Mar 21, 2024
1c9a077
(feat) arbitrum
isreallee82 Mar 30, 2024
ea22760
(feat) zksync
isreallee82 Apr 1, 2024
765a118
(feat) ethereum_zksync integration
isreallee82 Apr 1, 2024
c17fe52
(refactor) Added arbitrum and zksync router addressess
isreallee82 Apr 2, 2024
f57de40
(refactor) fix zksync connection
isreallee82 Apr 4, 2024
e812844
(feat) approve tokens for pancakeswap ethereum chain
isreallee82 Apr 4, 2024
109a98d
(feat) arbitrum subgrph api
isreallee82 Apr 4, 2024
6640380
(feat) arbitrum studio subgrph api
isreallee82 Apr 5, 2024
6506c90
add poolId with unit test.
vic-en Apr 6, 2024
7a6ec9d
(clean-up) dynamic chain instances
isreallee82 Apr 10, 2024
0fe8449
Merge pull request #306 from vic-en/feat/add_poolId
nikspz Apr 11, 2024
e7e3146
Merge branch 'development' into feat/pancakeswap_mainnet_chain
nikspz Apr 11, 2024
343793c
Merge pull request #299 from isreallee82/feat/pancakeswap_mainnet_chain
rapcmia Apr 15, 2024
0c41ffe
(fix) remove non-Ethereum network tests
fengtality Apr 17, 2024
a161ee4
Merge pull request #311 from hummingbot/fix/remove-tests
fengtality Apr 18, 2024
83613ad
Merge branch 'staging' into development
rapcmia Apr 22, 2024
244fd2f
Merge pull request #312 from hummingbot/development
rapcmia Apr 23, 2024
caa9c2f
fix Update version gateway on staging 1.27.0
nikspz Apr 25, 2024
75a91a5
Update app.ts
nikspz Apr 25, 2024
5259dae
Merge pull request #314 from hummingbot/fix-Update-version-gateway-on…
rapcmia Apr 25, 2024
8368283
Merge branch 'main' into staging
nikspz Apr 26, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hummingbot-gateway",
"version": "1.26.0",
"version": "1.27.0",
"description": "Middleware that helps Hummingbot clients access standardized DEX API endpoints on different blockchain networks",
"main": "index.js",
"license": "Apache-2.0",
Expand Down
4 changes: 4 additions & 0 deletions src/amm/amm.requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface PriceRequest extends NetworkSelectionRequest {
amount: string;
side: Side;
allowedSlippage?: string;
poolId?: string;
}

export interface PriceResponse {
Expand All @@ -41,6 +42,7 @@ export interface PoolPriceRequest extends NetworkSelectionRequest {
fee?: string;
period?: number;
interval?: number;
poolId?: string;
}

export interface PoolPriceResponse {
Expand All @@ -67,6 +69,7 @@ export interface TradeRequest extends NetworkSelectionRequest {
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
allowedSlippage?: string;
poolId?: string;
}

export interface TradeResponse {
Expand Down Expand Up @@ -106,6 +109,7 @@ export interface AddLiquidityRequest extends NetworkSelectionRequest { // now al
maxFeePerGas?: string;
maxPriorityFeePerGas?: string;
allowedSlippage?: string; // COSMOS: used to calc TokenMinAmount
poolId?: string;
}

export interface AddLiquidityResponse {
Expand Down
14 changes: 14 additions & 0 deletions src/amm/amm.validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export const invalidDecreasePercentError: string =
export const invalidAllowedSlippageError: string =
'The allowedSlippage param may be null or a string of a fraction.';

export const invalidPoolIdError: string =
'PoolId(if supplied) must be a string.';

export const validateConnector: Validator = mkValidator(
'connector',
invalidConnectorError,
Expand Down Expand Up @@ -194,6 +197,13 @@ export const validateAllowedSlippage: Validator = mkValidator(
true
);

export const validatePoolId: Validator = mkValidator(
'poolId',
invalidPoolIdError,
(val) => typeof val === 'string' && val.length !== 0,
true
);

export const validatePriceRequest: RequestValidator = mkRequestValidator([
validateConnector,
validateChain,
Expand All @@ -203,6 +213,7 @@ export const validatePriceRequest: RequestValidator = mkRequestValidator([
validateAmount,
validateSide,
validateAllowedSlippage,
validatePoolId,
]);

export const validateTradeRequest: RequestValidator = mkRequestValidator([
Expand All @@ -218,6 +229,7 @@ export const validateTradeRequest: RequestValidator = mkRequestValidator([
validateMaxFeePerGas,
validateMaxPriorityFeePerGas,
validateAllowedSlippage,
validatePoolId,
]);

export const validatePerpPositionRequest: RequestValidator = mkRequestValidator(
Expand Down Expand Up @@ -302,6 +314,7 @@ export const validateAddLiquidityRequest: RequestValidator = mkRequestValidator(
validateNonce,
validateMaxFeePerGas,
validateMaxPriorityFeePerGas,
validatePoolId,
]
);

Expand Down Expand Up @@ -345,4 +358,5 @@ export const validatePoolPriceRequest: RequestValidator = mkRequestValidator([
validateFee,
validateInterval,
validatePeriod,
validatePoolId,
]);
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const startSwagger = async () => {

export const startGateway = async () => {
const port = ConfigManagerV2.getInstance().get('server.port');
const gateway_version="1.26.0"; // gateway version
const gateway_version="1.27.0"
if (!ConfigManagerV2.getInstance().get('server.id')) {
ConfigManagerV2.getInstance().set(
'server.id',
Expand Down
27 changes: 17 additions & 10 deletions src/chains/ethereum/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { logger } from '../../services/logger';
import { BigNumber, Contract, Transaction, Wallet } from 'ethers';
import { EthereumBase } from './ethereum-base';
import { getEthereumConfig } from './ethereum.config';
import { PancakeSwapConfig } from '../../connectors/pancakeswap/pancakeswap.config';
import { Provider } from '@ethersproject/abstract-provider';
import { ConfigManagerV2 } from '../../services/config-manager-v2';
// import { throttleRetryWrapper } from '../../services/retry';
Expand Down Expand Up @@ -48,7 +49,7 @@ export class Ethereum extends EthereumBase implements Ethereumish {
config.manualGasPrice,
config.gasLimitTransaction,
ConfigManagerV2.getInstance().get('server.nonceDbPath'),
ConfigManagerV2.getInstance().get('server.transactionDbPath')
ConfigManagerV2.getInstance().get('server.transactionDbPath'),
);
this._chain = network;
this._nativeTokenSymbol = config.nativeCurrencySymbol;
Expand All @@ -66,7 +67,7 @@ export class Ethereum extends EthereumBase implements Ethereumish {
this.onDebugMessage(this.requestCounter.bind(this));
this._metricTimer = setInterval(
this.metricLogger.bind(this),
this.metricsLogInterval
this.metricsLogInterval,
);
this.controller = EVMController;
}
Expand Down Expand Up @@ -95,7 +96,7 @@ export class Ethereum extends EthereumBase implements Ethereumish {
this.requestCount +
' request(s) sent in last ' +
this.metricsLogInterval / 1000 +
' seconds.'
' seconds.',
);
this._requestCount = 0; // reset
}
Expand Down Expand Up @@ -146,7 +147,7 @@ export class Ethereum extends EthereumBase implements Ethereumish {

setTimeout(
this.updateGasPrice.bind(this),
this._gasPriceRefreshInterval * 1000
this._gasPriceRefreshInterval * 1000,
);
}

Expand All @@ -159,15 +160,15 @@ export class Ethereum extends EthereumBase implements Ethereumish {
let priorityFee: BigNumber = BigNumber.from('0');
if (this._chain === 'mainnet') {
priorityFee = BigNumber.from(
await this.provider.send('eth_maxPriorityFeePerGas', [])
await this.provider.send('eth_maxPriorityFeePerGas', []),
);
}
return baseFee.add(priorityFee).toNumber() * 1e-9;
}

getContract(
tokenAddress: string,
signerOrProvider?: Wallet | Provider
signerOrProvider?: Wallet | Provider,
): Contract {
return tokenAddress === MKR_ADDRESS
? new Contract(tokenAddress, abi.MKRAbi, signerOrProvider)
Expand All @@ -180,19 +181,25 @@ export class Ethereum extends EthereumBase implements Ethereumish {
let spender: string;
if (reqSpender === 'uniswap') {
spender = UniswapConfig.config.uniswapV3SmartOrderRouterAddress(
this._chain
this._chain,
);
} else if (reqSpender === 'pancakeswap') {
spender = PancakeSwapConfig.config.routerAddress(this._chain);
} else if (reqSpender === 'pancakeswapLP') {
spender = PancakeSwapConfig.config.pancakeswapV3NftManagerAddress(
this._chain,
);
} else if (reqSpender === 'sushiswap') {
spender = SushiswapConfig.config.sushiswapRouterAddress(
this.chainName,
this._chain
this._chain,
);
} else if (reqSpender === 'uniswapLP') {
spender = UniswapConfig.config.uniswapV3NftManagerAddress(this._chain);
} else if (reqSpender === 'carbonamm') {
spender = CarbonConfig.config.carbonContractsConfig(
'ethereum',
this._chain
this._chain,
).carbonControllerAddress;
} else if (reqSpender === 'perp') {
const perp = Perp.getInstance(this._chain, 'optimism');
Expand All @@ -219,7 +226,7 @@ export class Ethereum extends EthereumBase implements Ethereumish {
// cancel transaction
async cancelTx(wallet: Wallet, nonce: number): Promise<Transaction> {
logger.info(
'Canceling any existing transaction(s) with nonce number ' + nonce + '.'
'Canceling any existing transaction(s) with nonce number ' + nonce + '.',
);
return this.cancelTxWithGasPrice(wallet, nonce, this._gasPrice * 2);
}
Expand Down
11 changes: 7 additions & 4 deletions src/connectors/pancakeswap/pancakeswap.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export namespace PancakeSwapConfig {
export const v2Config: V2NetworkConfig = buildConfig(
'pancakeswap',
['AMM'],
[{ chain: 'binance-smart-chain', networks: ['mainnet', 'testnet'] }],
'EVM'
[
{ chain: 'binance-smart-chain', networks: ['mainnet', 'testnet'] },
{ chain: 'ethereum', networks: ['mainnet', 'arbitrum', 'zksync'] },
],
'EVM',
);

export const config: NetworkConfig = {
Expand All @@ -27,11 +30,11 @@ export namespace PancakeSwapConfig {
maximumHops: ConfigManagerV2.getInstance().get(`pancakeswap.maximumHops`),
pancakeswapV3SmartOrderRouterAddress: (network: string) =>
ConfigManagerV2.getInstance().get(
`pancakeswap.contractAddresses.${network}.pancakeswapV3SmartOrderRouterAddress`
`pancakeswap.contractAddresses.${network}.pancakeswapV3SmartOrderRouterAddress`,
),
pancakeswapV3NftManagerAddress: (network: string) =>
ConfigManagerV2.getInstance().get(
`pancakeswap.contractAddresses.${network}.pancakeswapV3NftManagerAddress`
`pancakeswap.contractAddresses.${network}.pancakeswapV3NftManagerAddress`,
),
tradingTypes: (type: string) => {
return type === 'swap' ? ['AMM'] : ['AMM_LP'];
Expand Down
Loading
Loading