Skip to content

Commit

Permalink
(fix) resolved yarn.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
fengtality committed Oct 21, 2023
2 parents 82adbc2 + 382b551 commit 886b768
Show file tree
Hide file tree
Showing 17 changed files with 18,960 additions and 210 deletions.
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
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
6 changes: 2 additions & 4 deletions src/chains/chain.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,8 @@ export namespace ChainRoutes {
req: Request<{}, {}, NonceRequest>,
res: Response<NonceResponse | string, {}>
) => {
if (req.body.chain === 'tezos')
validateTezosNonceRequest(req.body);
else
validateNonceRequest(req.body);
if (req.body.chain === 'tezos') validateTezosNonceRequest(req.body);
else validateNonceRequest(req.body);
const chain = await getInitializedChain(
req.body.chain,
req.body.network
Expand Down
8 changes: 8 additions & 0 deletions src/chains/ethereum/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { UniswapConfig } from '../../connectors/uniswap/uniswap.config';
import { Perp } from '../../connectors/perp/perp';
import { SushiswapConfig } from '../../connectors/sushiswap/sushiswap.config';
import { OpenoceanConfig } from '../../connectors/openocean/openocean.config';
import { Curve } from '../../connectors/curve/curve';

// MKR does not match the ERC20 perfectly so we need to use a separate ABI.
const MKR_ADDRESS = '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2';
Expand Down Expand Up @@ -196,6 +197,13 @@ export class Ethereum extends EthereumBase implements Ethereumish {
spender = perp.perp.contracts.vault.address;
} else if (reqSpender === 'openocean') {
spender = OpenoceanConfig.config.routerAddress('ethereum', 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
1 change: 1 addition & 0 deletions src/chains/ethereum/ethereum.validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const validateSpender: Validator = mkValidator(
val === 'vvs' ||
val === 'pancakeswap' ||
val === 'xsswap' ||
val === 'curve' ||
isAddress(val))
);

Expand Down
8 changes: 8 additions & 0 deletions src/chains/polygon/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Ethereumish } from '../../services/common-interfaces';
import { ConfigManagerV2 } from '../../services/config-manager-v2';
import { OpenoceanConfig } from '../../connectors/openocean/openocean.config';
import { EVMController } from '../ethereum/evm.controllers';
import { Curve } from '../../connectors/curve/curve';

export class Polygon extends EthereumBase implements Ethereumish {
private static _instances: { [name: string]: Polygon };
Expand Down Expand Up @@ -86,6 +87,13 @@ export class Polygon extends EthereumBase implements Ethereumish {
);
} else if (reqSpender === 'openocean') {
spender = OpenoceanConfig.config.routerAddress('polygon', 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
7 changes: 7 additions & 0 deletions src/connectors/connectors.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { XsswapConfig } from './xsswap/xsswap.config';
import { ConnectorsResponse } from './connectors.request';
import { DexalotCLOBConfig } from './dexalot/dexalot.clob.config';
import { TinymanConfig } from './tinyman/tinyman.config';
import { CurveConfig } from './curve/curveswap.config';
import { PlentyConfig } from './plenty/plenty.config';
import { KujiraConfig } from './kujira/kujira.config';

Expand Down Expand Up @@ -146,6 +147,12 @@ export namespace ConnectorsRoutes {
chain_type: TinymanConfig.config.chainType,
available_networks: TinymanConfig.config.availableNetworks,
},
{
name: 'curve',
trading_type: CurveConfig.config.tradingTypes,
chain_type: CurveConfig.config.chainType,
available_networks: CurveConfig.config.availableNetworks,
},
{
name: 'plenty',
trading_type: PlentyConfig.config.tradingTypes,
Expand Down
Loading

0 comments on commit 886b768

Please sign in to comment.