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

Feat/pancake swap v3 #247

Merged
merged 12 commits into from
Dec 13, 2023
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"@harmony-js/utils": "^0.1.56",
"@improbable-eng/grpc-web": "^0.13.0",
"@pancakeswap/sdk": "^2.4.5",
"@pancakeswap/swap-sdk-core": "^1.0.0",
"@pancakeswap/v3-core": "^1.0.2",
"@pancakeswap/v3-periphery": "^1.0.2",
"@pancakeswap/v3-sdk": "^3.7.0",
"@pangolindex/sdk": "^1.1.0",
"@perp/sdk-curie": "^1.16.0",
"@sushiswap/sdk": "^5.0.0-canary.116",
Expand Down Expand Up @@ -148,7 +152,7 @@
"supertest": "^6.1.6",
"ts-jest": "^27.0.5",
"ts-node": "^10.0.0",
"typescript": "^4.3.2",
"typescript": "^5.3.2",
"viem": "^0.3.x"
},
"resolutions": {
Expand Down
4 changes: 4 additions & 0 deletions src/chains/binance-smart-chain/binance-smart-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export class BinanceSmartChain extends EthereumBase implements Ethereumish {
let spender: string;
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(
'binance-smart-chain',
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 @@ -60,6 +60,7 @@ export const validateSpender: Validator = mkValidator(
val === 'mad_meerkat' ||
val === 'vvs' ||
val === 'pancakeswap' ||
val === 'pancakeswapLP' ||
val === 'xsswap' ||
val === 'curve' ||
isAddress(val))
Expand Down
9 changes: 8 additions & 1 deletion src/connectors/connectors.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,17 @@ export namespace ConnectorsRoutes {
},
{
name: 'pancakeswap',
trading_type: PancakeSwapConfig.config.tradingTypes,
trading_type: PancakeSwapConfig.config.tradingTypes('swap'),
chain_type: PancakeSwapConfig.config.chainType,
available_networks: PancakeSwapConfig.config.availableNetworks,
},
{
name: 'pancakeswapLP',
trading_type: PancakeSwapConfig.config.tradingTypes('LP'),
chain_type: PancakeSwapConfig.config.chainType,
available_networks: PancakeSwapConfig.config.availableNetworks,
additional_spenders: ['pancakeswap'],
},
{
name: 'xswap',
trading_type: XsswapConfig.config.tradingTypes,
Expand Down
37 changes: 35 additions & 2 deletions src/connectors/pancakeswap/pancakeswap.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
import { buildConfig, NetworkConfig } from '../../network/network.utils';
import {
buildConfig,
NetworkConfig as V2NetworkConfig,
} from '../../network/network.utils';
import { ConfigManagerV2 } from '../../services/config-manager-v2';

export namespace PancakeSwapConfig {
export const config: NetworkConfig = buildConfig(
export interface NetworkConfig extends Omit<V2NetworkConfig, 'tradingTypes'> {
maximumHops: number;
pancakeswapV3SmartOrderRouterAddress: (network: string) => string;
pancakeswapV3NftManagerAddress: (network: string) => string;
tradingTypes: (type: string) => Array<string>;
useRouter?: boolean;
feeTier?: string;
}

export const v2Config: V2NetworkConfig = buildConfig(
'pancakeswap',
['AMM'],
[{ chain: 'binance-smart-chain', networks: ['mainnet', 'testnet'] }],
'EVM'
);

export const config: NetworkConfig = {
...v2Config,
...{
maximumHops: ConfigManagerV2.getInstance().get(`pancakeswap.maximumHops`),
pancakeswapV3SmartOrderRouterAddress: (network: string) =>
ConfigManagerV2.getInstance().get(
`pancakeswap.contractAddresses.${network}.pancakeswapV3SmartOrderRouterAddress`
),
pancakeswapV3NftManagerAddress: (network: string) =>
ConfigManagerV2.getInstance().get(
`pancakeswap.contractAddresses.${network}.pancakeswapV3NftManagerAddress`
),
tradingTypes: (type: string) => {
return type === 'swap' ? ['AMM'] : ['AMM_LP'];
},
useRouter: ConfigManagerV2.getInstance().get(`pancakeswap.useRouter`),
feeTier: ConfigManagerV2.getInstance().get(`pancakeswap.feeTier`),
},
};
}
Loading
Loading