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 development -> staging #348

Merged
merged 86 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
71d3ee6
(feat) celo network
elijahsnoz Apr 20, 2024
823e19a
(feat) celo network
elijahsnoz Apr 20, 2024
2d17d4d
(feat) celo network
elijahsnoz Apr 20, 2024
afdc6e7
(feat) Ethereum avalache integration
isreallee82 Apr 21, 2024
e95c161
Merge branch 'development' into feat/uniswap_avalanche
isreallee82 Apr 21, 2024
28ea387
(feat) celo nft refactor
elijahsnoz Apr 21, 2024
881e10d
(feat) Updated smart-router
isreallee82 Apr 22, 2024
e04d8f4
(feat) test filerefactor
isreallee82 Apr 22, 2024
eb8b6c2
(feat) test filerefactor
isreallee82 Apr 22, 2024
a0ece41
(feat) test filerefactor
isreallee82 Apr 22, 2024
f55e034
update smart-router
isreallee82 Apr 22, 2024
4d7e47b
(fix) update uniswap packages
elijahsnoz Apr 22, 2024
c50671a
(fix) update uniswap packages
elijahsnoz Apr 22, 2024
2323d04
(fix) update uniswap packages
elijahsnoz Apr 23, 2024
621dc44
Merge branch 'development' into feat/celo_chain/network
elijahsnoz Apr 23, 2024
c045cfa
(feat) Add avalance on unswap ethereum network
isreallee82 Apr 26, 2024
8ef1e19
Merge branch 'development' into feat/uniswap_avalanche
isreallee82 Apr 26, 2024
a071bdc
Merge branch 'development' into feat/celo_chain/network
nikspz Apr 29, 2024
59f9054
Merge branch 'development' into feat/uniswap_avalanche
nikspz Apr 29, 2024
d031360
(feat) factory adddress added
isreallee82 May 5, 2024
bd4f891
(feat) Update FactoryAddress impllementation
elijahsnoz May 5, 2024
f721dd8
(feat) Update celo tokenlist
elijahsnoz May 8, 2024
a5d08be
(feat) Update celo tokenlist
elijahsnoz May 8, 2024
1231296
(feat) remove changes to test
elijahsnoz May 8, 2024
cf42853
(fix) uniswap pool address
isreallee82 May 19, 2024
755af3a
(refactor) Uniswap_avalanche on avalanche chain
isreallee82 May 21, 2024
04bf8a0
(refactor) token list
elijahsnoz May 21, 2024
1132790
(refactor) test file
elijahsnoz May 21, 2024
296cf6e
(refactor) token list file
elijahsnoz May 21, 2024
e0334e0
Merge branch 'development' into feat/celo_chain/network
elijahsnoz May 21, 2024
a2b4293
Merge branch 'development' into feat/uniswap_avalanche
nikspz May 21, 2024
8c38756
add BSC to uniswap connector
May 26, 2024
cd4a4db
routes tests
harjas27 May 26, 2024
45eb6b0
fix unit tests
harjas27 May 26, 2024
96e98df
minor refactor
harjas27 May 28, 2024
c8e092b
(fix) revised uniswap-base support
fengtality Jun 2, 2024
4bcf8f2
(clean-up) avalanche factory and javascript cosmetic removal
isreallee82 Jun 3, 2024
fbcefcd
Merge branch 'development' into feat/uniswap_avalanche
isreallee82 Jun 3, 2024
cfd2cda
(fix) poolid inclusion
isreallee82 Jun 3, 2024
e8992ed
(refactor) uniswap sdk to initial version
isreallee82 Jun 3, 2024
288f8de
(clean-up) yarn.lock
isreallee82 Jun 3, 2024
ccb4cc0
(clean-up) uniswap avalanche chain/network
isreallee82 Jun 3, 2024
9382e84
(clean-up) prettier clean-up
isreallee82 Jun 3, 2024
e90dfec
(clean-up) factory address added
isreallee82 Jun 3, 2024
69a1582
(clean-up) test file
isreallee82 Jun 3, 2024
a311bd4
Merge branch 'development' into feat/celo_chain/network
elijahsnoz Jun 3, 2024
cafc86f
(refactor) celo chain
elijahsnoz Jun 3, 2024
3e0d712
Merge branch 'development' into feat/celo_chain/network
elijahsnoz Jun 3, 2024
074f93d
Merge branch 'feat/celo_chain/network' of https://github.com/elijahsn…
elijahsnoz Jun 3, 2024
8185014
(clean-up) uniswapLp avalanche chain/network
isreallee82 Jun 3, 2024
8fbcb2e
(fix) duplicate token
elijahsnoz Jun 27, 2024
2d17a47
update development version 2.0.1
Jul 4, 2024
22fbbe0
Merge pull request #337 from hummingbot/update_version_2.0.1
rapcmia Jul 4, 2024
78d097b
resolve merge conflicts
harjas27 Jul 4, 2024
68528ff
revert
harjas27 Jul 4, 2024
482d10b
TELOS integration
evseevnn Jul 5, 2024
373c577
fix uniswap test
harjas27 Jul 9, 2024
2776ecc
Merge branch 'development' into feat/celo_chain/network
nikspz Jul 22, 2024
9aff42d
(fix) add to templates
fengtality Jul 24, 2024
187c3c6
(fix) handle no router available on base
fengtality Jul 25, 2024
78c55e1
Merge branch 'development' into feat/add-uniswap-base
fengtality Jul 25, 2024
5444cc7
(fix) add sepolia testnet to address failing test
fengtality Jul 25, 2024
d602607
(fix) update chain id
fengtality Jul 25, 2024
0ea7b89
(fix) add more sepolia tokens
fengtality Jul 25, 2024
e5b5f9c
(hack) comment out failing uniswap test
fengtality Jul 25, 2024
5aa12e3
(fix) remove quipuswap
fengtality Jul 25, 2024
a48fe56
Merge branch 'development' into feat/uniswap_avalanche
nikspz Jul 25, 2024
2126514
(fix) prevent alpha router from starting in base
fengtality Jul 25, 2024
70ca18a
Merge pull request #329 from hummingbot/feat/add-uniswap-base
nikspz Jul 25, 2024
1f2795c
(merge) resolved merge conflicts in uniswap BNB
fengtality Jul 25, 2024
68e7797
(feat) add AVAX support for Uniswap
fengtality Jul 25, 2024
1ba268a
(fix) fix tests
fengtality Jul 25, 2024
7a0ca31
(merge) merge in uniswap celo
fengtality Jul 26, 2024
8707dc9
remove extraneous change
fengtality Jul 26, 2024
cca1510
remove extraneous change 2
fengtality Jul 26, 2024
c8cb59d
revert more changes
fengtality Jul 26, 2024
8e4c74c
revert package.json changes
fengtality Jul 26, 2024
7c6842b
revert yarn lock
fengtality Jul 26, 2024
ce21d40
replace yarn.lock dev
fengtality Jul 26, 2024
3db080c
(hack) add list of excluded router chains
fengtality Jul 26, 2024
0cac4ea
(fix) fix uniswap config networks
fengtality Jul 27, 2024
6c55d4f
Merge pull request #338 from enfluxtech/feat/telos-integration
nikspz Jul 29, 2024
e98d888
Merge branch 'development' into harjas27-feat/uniswap_bsc
fengtality Jul 29, 2024
7e565d4
(fix) exclude router on certain chains
fengtality Jul 29, 2024
bd5573e
Merge pull request #342 from hummingbot/harjas27-feat/uniswap_bsc
nikspz Jul 31, 2024
d0b0d12
Merge branch 'staging' into development
rapcmia Aug 15, 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
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
'src/chains/binance-smart-chain/binance-smart-chain.ts',
'src/chains/ethereum/ethereum.ts',
'src/chains/avalanche/avalanche.ts',
'src/chains/celo/celo.ts',
'src/chains/avalanche/pangolin/pangolin.ts',
'src/chains/cosmos/cosmos.ts',
'src/chains/near/near.ts',
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hummingbot-gateway",
"version": "2.0.0",
"version": "dev-2.0.1",
"description": "Middleware that helps Hummingbot clients access standardized DEX API endpoints on different blockchain networks",
"main": "index.js",
"license": "Apache-2.0",
Expand Down Expand Up @@ -100,7 +100,6 @@
"osmojs": "16.5.1",
"promise-retry": "^2.0.1",
"quickswap-sdk": "^3.0.8",
"quipuswap-v3-sdk": "^0.0.7",
"swagger-ui-express": "^4.1.6",
"swap-router-sdk": "^1.21.1",
"tslib": "^2.3.1",
Expand Down
24 changes: 6 additions & 18 deletions src/amm/amm.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ import {
trade as plentyTrade,
estimateGas as plentyEstimateGas,
} from '../connectors/plenty/plenty.controllers';
import {
price as quipuPrice,
trade as quipuTrade,
estimateGas as quipuEstimateGas,
} from '../connectors/quipuswap/quipuswap.controllers';
import {
getInitializedChain,
getConnector,
Expand All @@ -85,7 +80,6 @@ import {
import { Algorand } from '../chains/algorand/algorand';
import { Tinyman } from '../connectors/tinyman/tinyman';
import { Plenty } from '../connectors/plenty/plenty';
import { QuipuSwap } from '../connectors/quipuswap/quipuswap';
import { Osmosis } from '../chains/osmosis/osmosis';
import { Carbonamm } from '../connectors/carbon/carbonAMM';

Expand All @@ -97,17 +91,15 @@ export async function price(req: PriceRequest): Promise<PriceResponse> {
return chain.controller.price(chain as unknown as Osmosis, req);
}

const connector: Uniswapish | RefAMMish | Tinyman | Plenty | QuipuSwap =
await getConnector<Uniswapish | RefAMMish | Tinyman | Plenty | QuipuSwap>(
const connector: Uniswapish | RefAMMish | Tinyman | Plenty =
await getConnector<Uniswapish | RefAMMish | Tinyman | Plenty>(
req.chain,
req.network,
req.connector
);

if (connector instanceof Plenty) {
return plentyPrice(<Tezosish>chain, connector, req);
} else if (connector instanceof QuipuSwap) {
return quipuPrice(<Tezosish>chain, connector, req);
} else if (connector instanceof Carbonamm) {
return carbonPrice(<Ethereumish>chain, connector, req);
} else if ('routerAbi' in connector) {
Expand All @@ -128,17 +120,15 @@ export async function trade(req: TradeRequest): Promise<TradeResponse> {
return chain.controller.trade(chain as unknown as Osmosis, req);
}

const connector: Uniswapish | RefAMMish | Tinyman | Plenty | QuipuSwap =
await getConnector<Uniswapish | RefAMMish | Tinyman | Plenty | QuipuSwap>(
const connector: Uniswapish | RefAMMish | Tinyman | Plenty =
await getConnector<Uniswapish | RefAMMish | Tinyman | Plenty>(
req.chain,
req.network,
req.connector
);

if (connector instanceof Plenty) {
return plentyTrade(<Tezosish>chain, connector, req);
} else if (connector instanceof QuipuSwap) {
return quipuTrade(<Tezosish>chain, connector, req);
} else if (connector instanceof Carbonamm) {
return carbonTrade(<Ethereumish>chain, connector, req);
} else if ('routerAbi' in connector) {
Expand Down Expand Up @@ -238,17 +228,15 @@ export async function estimateGas(
return chain.controller.estimateGas(chain as unknown as Osmosis);
}

const connector: Uniswapish | RefAMMish | Tinyman | Plenty | QuipuSwap =
await getConnector<Uniswapish | RefAMMish | Plenty | QuipuSwap>(
const connector: Uniswapish | RefAMMish | Tinyman | Plenty =
await getConnector<Uniswapish | RefAMMish | Plenty>(
req.chain,
req.network,
req.connector
);

if (connector instanceof Plenty) {
return plentyEstimateGas(<Tezosish>chain, connector);
} else if (connector instanceof QuipuSwap) {
return quipuEstimateGas(<Tezosish>chain, connector);
} else if (connector instanceof Carbonamm) {
return carbonEstimateGas(<Ethereumish>chain, connector);
} else if ('routerAbi' in connector) {
Expand Down
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="2.0.0"
const gateway_version="dev-2.0.1"
if (!ConfigManagerV2.getInstance().get('server.id')) {
ConfigManagerV2.getInstance().set(
'server.id',
Expand Down
10 changes: 9 additions & 1 deletion src/chains/avalanche/avalanche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TraderjoeConfig } from '../../connectors/traderjoe/traderjoe.config';
import { PangolinConfig } from '../../connectors/pangolin/pangolin.config';
import { OpenoceanConfig } from '../../connectors/openocean/openocean.config';
import { Ethereumish } from '../../services/common-interfaces';
import { UniswapConfig } from '../../connectors/uniswap/uniswap.config';
import { SushiswapConfig } from '../../connectors/sushiswap/sushiswap.config';
import { ConfigManagerV2 } from '../../services/config-manager-v2';
import { EVMController } from '../ethereum/evm.controllers';
Expand Down Expand Up @@ -84,7 +85,14 @@ export class Avalanche extends EthereumBase implements Ethereumish {

getSpender(reqSpender: string): string {
let spender: string;
if (reqSpender === 'pangolin') {
if (reqSpender === 'uniswap') {
spender = UniswapConfig.config.uniswapV3SmartOrderRouterAddress(
'avalanche',
this._chain,
);
} else if (reqSpender === 'uniswapLP') {
spender = UniswapConfig.config.uniswapV3NftManagerAddress('avalanche', this._chain);
} else if (reqSpender === 'pangolin') {
spender = PangolinConfig.config.routerAddress(this._chain);
} else if (reqSpender === 'openocean') {
spender = OpenoceanConfig.config.routerAddress('avalanche', this._chain);
Expand Down
4 changes: 3 additions & 1 deletion src/chains/avalanche/avalanche.validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const validateSpender: Validator = mkValidator(

(val) =>
typeof val === 'string' &&
(val === 'pangolin' ||
(val === 'uniswap' ||
val === 'uniswapLP' ||
val === 'pangolin' ||
val === 'traderjoe' ||
val === 'openocean' ||
val === 'sushiswap' ||
Expand Down
8 changes: 8 additions & 0 deletions src/chains/binance-smart-chain/binance-smart-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SushiswapConfig } from '../../connectors/sushiswap/sushiswap.config';
import { ConfigManagerV2 } from '../../services/config-manager-v2';
import { OpenoceanConfig } from '../../connectors/openocean/openocean.config';
import { EVMController } from '../ethereum/evm.controllers';
import {UniswapConfig} from "../../connectors/uniswap/uniswap.config";

export class BinanceSmartChain extends EthereumBase implements Ethereumish {
private static _instances: { [name: string]: BinanceSmartChain };
Expand Down Expand Up @@ -113,6 +114,13 @@ export class BinanceSmartChain extends EthereumBase implements Ethereumish {
'binance-smart-chain',
this._chain
);
} else if (reqSpender === 'uniswap') {
spender = UniswapConfig.config.uniswapV3SmartOrderRouterAddress(
'binance-smart-chain',
this._chain
);
} else if (reqSpender === 'uniswapLP') {
spender = UniswapConfig.config.uniswapV3NftManagerAddress('binance-smart-chain', this._chain);
} else {
spender = reqSpender;
}
Expand Down
130 changes: 130 additions & 0 deletions src/chains/celo/celo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import abi from '../ethereum/ethereum.abi.json';
import { logger } from '../../services/logger';
import { Contract, Transaction, Wallet } from 'ethers';
import { EthereumBase } from '../ethereum/ethereum-base';
import { getEthereumConfig as getCeloConfig } from '../ethereum/ethereum.config';
import { Provider } from '@ethersproject/abstract-provider';
import { Ethereumish } from '../../services/common-interfaces';
import { ConfigManagerV2 } from '../../services/config-manager-v2';
import { EVMController } from '../ethereum/evm.controllers';
import { UniswapConfig } from '../../connectors/uniswap/uniswap.config';

export class Celo extends EthereumBase implements Ethereumish {
private static _instances: { [name: string]: Celo };
private _gasPrice: number;
private _gasPriceRefreshInterval: number | null;
private _nativeTokenSymbol: string;
private _chain: string;
public controller;

private constructor(network: string) {
const config = getCeloConfig('celo', network);
super(
'celo',
config.network.chainID,
config.network.nodeURL,
config.network.tokenListSource,
config.network.tokenListType,
config.manualGasPrice,
config.gasLimitTransaction,
ConfigManagerV2.getInstance().get('server.nonceDbPath'),
ConfigManagerV2.getInstance().get('server.transactionDbPath')
);
this._chain = config.network.name;
this._nativeTokenSymbol = config.nativeCurrencySymbol;

this._gasPrice = config.manualGasPrice;

this._gasPriceRefreshInterval =
config.network.gasPriceRefreshInterval !== undefined
? config.network.gasPriceRefreshInterval
: null;

this.updateGasPrice();
this.controller = EVMController;
}

public static getInstance(network: string): Celo {
if (Celo._instances === undefined) {
Celo._instances = {};
}
if (!(network in Celo._instances)) {
Celo._instances[network] = new Celo(network);
}

return Celo._instances[network];
}

public static getConnectedInstances(): { [name: string]: Celo } {
return Celo._instances;
}

// getters

public get gasPrice(): number {
return this._gasPrice;
}

public get nativeTokenSymbol(): string {
return this._nativeTokenSymbol;
}

public get chain(): string {
return this._chain;
}

getContract(tokenAddress: string, signerOrProvider?: Wallet | Provider) {
return new Contract(tokenAddress, abi.ERC20Abi, signerOrProvider);
}

getSpender(reqSpender: string): string {
let spender: string;
if (reqSpender === 'uniswap') {
spender = UniswapConfig.config.uniswapV3SmartOrderRouterAddress(
'celo',
this._chain,
);
} else if (reqSpender === 'uniswapLP') {
spender = UniswapConfig.config.uniswapV3NftManagerAddress('celo', this._chain);
} else {
spender = reqSpender;
}
return spender;
}

// cancel transaction
async cancelTx(wallet: Wallet, nonce: number): Promise<Transaction> {
logger.info(
'Canceling any existing transaction(s) with nonce number ' + nonce + '.'
);
return super.cancelTxWithGasPrice(wallet, nonce, this._gasPrice * 2);
}

/**
* Automatically update the prevailing gas price on the network.
*/
async updateGasPrice(): Promise<void> {
if (this._gasPriceRefreshInterval === null) {
return;
}

const gasPrice = await this.getGasPrice();
if (gasPrice !== null) {
this._gasPrice = gasPrice;
} else {
logger.info('gasPrice is unexpectedly null.');
}

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

async close() {
await super.close();
if (this._chain in Celo._instances) {
delete Celo._instances[this._chain];
}
}
}
41 changes: 41 additions & 0 deletions src/chains/celo/celo.validators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {
mkRequestValidator,
mkValidator,
RequestValidator,
Validator,
validateAmount,
validateToken,
validateTokenSymbols,
} from '../../services/validators';
import {
isAddress,
validateNonce,
validateAddress,
} from '../ethereum/ethereum.validators';

export const invalidSpenderError: string =
'The spender param is not a valid Celo address (0x followed by 40 hexidecimal characters).';

// given a request, look for a key called spender that is 'uniswap' or an Ethereum address
export const validateSpender: Validator = mkValidator(
'spender',
invalidSpenderError,

(val) =>
typeof val === 'string' &&
(val === 'uniswap' ||
val === 'uniswapLP' ||
isAddress(val))
);

export const validateCeloApproveRequest: RequestValidator =
mkRequestValidator([
validateAddress,
validateSpender,
validateToken,
validateAmount,
validateNonce,
]);

export const validateCeloAllowancesRequest: RequestValidator =
mkRequestValidator([validateAddress, validateSpender, validateTokenSymbols]);
5 changes: 4 additions & 1 deletion src/chains/ethereum/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export class Ethereum extends EthereumBase implements Ethereumish {
let spender: string;
if (reqSpender === 'uniswap') {
spender = UniswapConfig.config.uniswapV3SmartOrderRouterAddress(
this.chainName,
this._chain,
);
} else if (reqSpender === 'pancakeswap') {
Expand All @@ -196,7 +197,9 @@ export class Ethereum extends EthereumBase implements Ethereumish {
this._chain,
);
} else if (reqSpender === 'uniswapLP') {
spender = UniswapConfig.config.uniswapV3NftManagerAddress(this._chain);
spender = UniswapConfig.config.uniswapV3NftManagerAddress(
this.chainName,
this._chain);
} else if (reqSpender === 'carbonamm') {
spender = CarbonConfig.config.carbonContractsConfig(
'ethereum',
Expand Down
3 changes: 2 additions & 1 deletion src/chains/polygon/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ export class Polygon extends EthereumBase implements Ethereumish {
let spender: string;
if (reqSpender === 'uniswap') {
spender = UniswapConfig.config.uniswapV3SmartOrderRouterAddress(
'polygon',
this._chain
);
} else if (reqSpender === 'uniswapLP') {
spender = UniswapConfig.config.uniswapV3NftManagerAddress(this._chain);
spender = UniswapConfig.config.uniswapV3NftManagerAddress('polygon', this._chain);
} else if (reqSpender === 'quickswap') {
spender = QuickswapConfig.config.routerAddress(this._chain);
} else if (reqSpender === 'sushiswap') {
Expand Down
Loading
Loading