Skip to content

Commit

Permalink
Merge pull request hummingbot#238 from hummingbot/staging
Browse files Browse the repository at this point in the history
Sync gateway / staging to main gateway 1.22.0
  • Loading branch information
rapcmia authored Nov 27, 2023
2 parents 3c6138f + 11caeb7 commit a5d7f8a
Show file tree
Hide file tree
Showing 79 changed files with 20,293 additions and 6,689 deletions.
56 changes: 28 additions & 28 deletions docs/swagger/definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1445,13 +1445,13 @@ definitions:
example: 'AAVE-USDT'
chain:
type: 'string'
example: 'injective'
example: 'dexalot'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'

ClobMarketResponse:
type: 'object'
Expand Down Expand Up @@ -1483,16 +1483,16 @@ definitions:
properties:
market:
type: 'string'
example: 'AAVE-USDT'
example: 'AVAX-USDC'
chain:
type: 'string'
example: 'injective'
example: 'dexalot'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'

ClobTickerResponse:
type: 'object'
Expand Down Expand Up @@ -1525,16 +1525,16 @@ definitions:
properties:
market:
type: 'string'
example: 'AAVE-USDT'
example: 'AVAX-USDC'
chain:
type: 'string'
example: 'injective'
example: 'dexalot'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'
isDerivative:
type: 'boolean'
example: false
Expand Down Expand Up @@ -1571,19 +1571,19 @@ definitions:
properties:
market:
type: 'string'
example: 'AAVE-USDT'
example: 'AVAX-USDC'
orderId:
type: 'string'
example: 'Buy-21342453'
chain:
type: 'string'
example: 'injective'
example: 'dexalot'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'
address:
type: 'string'
example: '0x...'
Expand Down Expand Up @@ -1624,16 +1624,16 @@ definitions:
properties:
market:
type: 'string'
example: 'AAVE-USDT'
example: 'AVAX-USDC'
chain:
type: 'string'
example: 'injective'
example: 'dexalot'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'
address:
type: 'string'
example: '0x...'
Expand Down Expand Up @@ -1683,16 +1683,16 @@ definitions:
properties:
market:
type: 'string'
example: 'AAVE-USDT'
example: 'AVAX-USDT'
chain:
type: 'string'
example: 'injective'
example: 'dexalot'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'
address:
type: 'string'
example: '0x...'
Expand Down Expand Up @@ -1734,7 +1734,7 @@ definitions:
example: '0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0'
chain:
type: 'string'
example: 'injective'
example: 'ethereum'
network:
type: 'string'
example: 'mainnet'
Expand Down Expand Up @@ -1786,7 +1786,7 @@ definitions:
example: '0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0'
chain:
type: 'string'
example: 'injective'
example: 'ethereum'
network:
type: 'string'
example: 'mainnet'
Expand Down Expand Up @@ -1877,7 +1877,7 @@ definitions:
properties:
chain:
type: 'string'
example: 'injective'
example: 'dexalot'
network:
type: 'string'
example: 'mainnet'
Expand Down Expand Up @@ -1912,13 +1912,13 @@ definitions:
example: 'Buy-21342453'
chain:
type: 'string'
example: 'injective'
example: 'ethereum'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'
address:
type: 'string'
example: '0x...'
Expand All @@ -1940,13 +1940,13 @@ definitions:
example: 'Buy-21342453'
chain:
type: 'string'
example: 'injective'
example: 'ethereum'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'
address:
type: 'string'
example: '0x...'
Expand Down Expand Up @@ -1985,13 +1985,13 @@ definitions:
example: 'INJ-USDT'
chain:
type: 'string'
example: 'injective'
example: 'ethereum'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'

PerpClobFundingInfoResponse:
type: 'object'
Expand Down Expand Up @@ -2051,13 +2051,13 @@ definitions:
properties:
chain:
type: 'string'
example: 'injective'
example: 'ethereum'
network:
type: 'string'
example: 'mainnet'
connector:
type: 'string'
example: 'injective'
example: 'dexalot'
address:
type: 'string'
example: '0x...'
Expand Down
2 changes: 0 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ module.exports = {
'src/chains/avalanche/avalanche.ts',
'src/chains/avalanche/pangolin/pangolin.ts',
'src/chains/cosmos/cosmos.ts',
'src/chains/injective/injective.ts',
'src/chains/near/near.ts',
'src/chains/near/near.base.ts',
'src/connectors/uniswap/uniswap.config.ts',
'src/connectors/uniswap/uniswap.ts',
'src/connectors/uniswap/uniswap.lp.helper.ts',
'src/connectors/openocean/openocean.ts',
'src/connectors/pangolin/pangolin.ts',
'src/chains/injective/injective.mappers.ts',
'src/connectors/quickswap/quickswap.ts',
'src/connectors/sushiswap/sushiswap.ts',
'src/connectors/traderjoe/traderjoe.ts',
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hummingbot-gateway",
"version": "1.21.0",
"version": "1.22.0",
"description": "Middleware that helps Hummingbot clients access standardized DEX API endpoints on different blockchain networks",
"main": "index.js",
"license": "Apache-2.0",
Expand All @@ -23,22 +23,19 @@
"test:scripts": "jest -i --verbose ./test-scripts/*.test.ts"
},
"dependencies": {
"@cosmjs/proto-signing": "^0.30.1",
"@cosmjs/stargate": "^0.30.1",
"@cosmjs/proto-signing": "^0.31.1",
"@cosmjs/stargate": "^0.31.1",
"@crocswap/sdk": "^2.4.5",
"@ethersproject/abstract-provider": "5.7.0",
"@ethersproject/address": "5.7.0",
"@ethersproject/contracts": "5.7.0",
"@ethersproject/networks": "5.7.0",
"@ethersproject/providers": "5.7.0",
"@ethersproject/solidity": "5.7.0",
"@injectivelabs/sdk-ts": "^1.10.58",
"@harmony-js/core": "^0.1.57",
"@harmony-js/utils": "^0.1.56",
"@improbable-eng/grpc-web": "^0.13.0",
"@injectivelabs/networks": "^1.10.8",
"@injectivelabs/sdk-ts": "^1.10.58",
"@injectivelabs/ts-types": "^1.0.29",
"@injectivelabs/wallet-ts": "^1.10.63",
"@pancakeswap/sdk": "^2.4.5",
"@pangolindex/sdk": "^1.1.0",
"@perp/sdk-curie": "^1.16.0",
Expand Down Expand Up @@ -79,7 +76,7 @@
"http-status-codes": "2.2.0",
"immutable": "^4.2.4",
"js-yaml": "^4.1.0",
"kujira.js": "^0.8.145",
"kujira.js": "0.9.6",
"level": "^8.0.0",
"lodash": "^4.17.21",
"lru-cache": "^7.14.1",
Expand Down
53 changes: 31 additions & 22 deletions src/amm/amm.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ import {
trade as plentyTrade,
estimateGas as plentyEstimateGas,
} from '../connectors/plenty/plenty.controllers';
import { getInitializedChain, getConnector } from '../services/connection-manager';
import {
getInitializedChain,
getConnector,
} from '../services/connection-manager';
import {
Chain as Ethereumish,
Nearish,
Expand All @@ -74,13 +77,15 @@ import { Tinyman } from '../connectors/tinyman/tinyman';
import { Plenty } from '../connectors/plenty/plenty';

export async function price(req: PriceRequest): Promise<PriceResponse> {
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish | Tezosish>(
req.chain,
req.network
);
const connector: Uniswapish | RefAMMish | Tinyman | Plenty = await getConnector<
Uniswapish | RefAMMish | Tinyman | Plenty
>(req.chain, req.network, req.connector);
const chain = await getInitializedChain<
Algorand | Ethereumish | Nearish | Tezosish
>(req.chain, req.network);
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);
Expand All @@ -95,13 +100,15 @@ export async function price(req: PriceRequest): Promise<PriceResponse> {
}

export async function trade(req: TradeRequest): Promise<TradeResponse> {
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish | Tezosish>(
req.chain,
req.network
);
const connector: Uniswapish | RefAMMish | Tinyman | Plenty = await getConnector<
Uniswapish | RefAMMish | Tinyman | Plenty
>(req.chain, req.network, req.connector);
const chain = await getInitializedChain<
Algorand | Ethereumish | Nearish | Tezosish
>(req.chain, req.network);
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);
Expand Down Expand Up @@ -180,13 +187,15 @@ export async function poolPrice(
export async function estimateGas(
req: NetworkSelectionRequest
): Promise<EstimateGasResponse> {
const chain = await getInitializedChain<Algorand | Ethereumish | Nearish | Tezosish>(
req.chain,
req.network
);
const connector: Uniswapish | RefAMMish | Tinyman | Plenty = await getConnector<
Uniswapish | RefAMMish | Plenty
>(req.chain, req.network, req.connector);
const chain = await getInitializedChain<
Algorand | Ethereumish | Nearish | Tezosish
>(req.chain, req.network);
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);
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="1.21.0"; // gateway version
const gateway_version="1.22.0"; // gateway version
if (!ConfigManagerV2.getInstance().get('server.id')) {
ConfigManagerV2.getInstance().set(
'server.id',
Expand Down
9 changes: 8 additions & 1 deletion src/chains/algorand/algorand.validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ import {
invalidAddressError,
validateNetwork,
} from '../ethereum/ethereum.validators';
import { validateTxHash } from '../injective/injective.validators';
import { invalidChainError } from '../near/near.validators';

const invalidTxHashError: string = 'The txHash param must be a string.';

const validateTxHash: Validator = mkValidator(
'txHash',
invalidTxHashError,
(val) => typeof val === 'string'
);

const validateAlgorandChain: Validator = mkValidator(
'chain',
invalidChainError,
Expand Down
8 changes: 8 additions & 0 deletions src/chains/avalanche/avalanche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Ethereumish } from '../../services/common-interfaces';
import { SushiswapConfig } from '../../connectors/sushiswap/sushiswap.config';
import { ConfigManagerV2 } from '../../services/config-manager-v2';
import { EVMController } from '../ethereum/evm.controllers';
import { Curve } from '../../connectors/curve/curve';

export class Avalanche extends EthereumBase implements Ethereumish {
private static _instances: { [name: string]: Avalanche };
Expand Down Expand Up @@ -93,6 +94,13 @@ export class Avalanche extends EthereumBase implements Ethereumish {
'avalanche',
this._chain
);
} else if (reqSpender === 'curve') {
const curve = Curve.getInstance('ethereum', this._chain);
if (!curve.ready()) {
curve.init();
throw Error('Curve not ready');
}
spender = curve.router;
} else {
spender = reqSpender;
}
Expand Down
Loading

0 comments on commit a5d7f8a

Please sign in to comment.