Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
feat: use Oneinch v5 and common CrosschainForwarder
Browse files Browse the repository at this point in the history
  • Loading branch information
mncdg committed Feb 9, 2024
1 parent b7b60a9 commit 26dd30b
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 113 deletions.
302 changes: 225 additions & 77 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@debridge-finance/dln-taker",
"version": "3.2.5",
"version": "3.3.0",
"description": "DLN executor is the rule-based daemon service developed to automatically execute orders placed on the deSwap Liquidity Network (DLN) across supported blockchains",
"license": "GPL-3.0-only",
"author": "deBridge",
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"types": "./dist/index.d.ts",
"dependencies": {
"@debridge-finance/dln-client": "8.3.3",
"@debridge-finance/dln-client": "8.3.5",
"@debridge-finance/legacy-dln-profitability": "3.2.0",
"@debridge-finance/solana-utils": "4.2.1",
"@protobuf-ts/plugin": "2.8.1",
Expand Down
7 changes: 7 additions & 0 deletions sample.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ const config: ExecutorLaunchConfig = {
*/
subsidizationRules: [],

oneInchConfig: {
apiServer: 'https://api.1inch.dev/swap',
apiToken: undefined, // obtain one at https://portal.1inch.dev
disablePMMProtocols: true,
disabledProtocols: [],
},

allowSubsidy: false,

tokenPriceService: configurator.tokenPriceService({
Expand Down
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,11 @@ export interface ExecutorLaunchConfig {
maxAccounts?: number;
blacklistedDexes?: Array<string>;
};

oneInchConfig?: {
apiToken?: string;
apiServer?: string;
disablePMMProtocols?: boolean;
disabledProtocols?: string[];
};
}
21 changes: 1 addition & 20 deletions src/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const PRODUCTION: Env = {
pmmSrc: '0xeF4fB24aD0916217251F553c0596F8Edc630EB66',
pmmDst: '0xE7351Fd770A37282b91D153Ee690B63579D6dd7f',
evm: {
forwarderContract: '0xc31fc94F3Fd088eE53ac915D6e8a14fF25a23C47',
forwarderContract: '0x663DC15D3C1aC63ff12E45Ab68FeA3F0a883C251',
},
},
chains: {
Expand All @@ -107,25 +107,6 @@ const PRODUCTION: Env = {
deBridgeContract: '0xc1656B63D9EEBa6d114f6bE19565177893e5bCBF',
pmmSrc: '0xeF4fB24aD0916217251F553c0596F8Edc630EB66',
pmmDst: '0xE7351Fd770A37282b91D153Ee690B63579D6dd7f',
evm: {
forwarderContract: '0x663DC15D3C1aC63ff12E45Ab68FeA3F0a883C251',
},
},
[ChainId.Optimism]: {
deBridgeContract: '0x43dE2d77BF8027e25dBD179B491e8d64f38398aA',
pmmSrc: '0xeF4fB24aD0916217251F553c0596F8Edc630EB66',
pmmDst: '0xE7351Fd770A37282b91D153Ee690B63579D6dd7f',
evm: {
forwarderContract: '0x663DC15D3C1aC63ff12E45Ab68FeA3F0a883C251',
},
},
[ChainId.Linea]: {
deBridgeContract: '0x43dE2d77BF8027e25dBD179B491e8d64f38398aA',
pmmSrc: '0xeF4fB24aD0916217251F553c0596F8Edc630EB66',
pmmDst: '0xE7351Fd770A37282b91D153Ee690B63579D6dd7f',
evm: {
forwarderContract: '0x663DC15D3C1aC63ff12E45Ab68FeA3F0a883C251',
},
},
},
};
Expand Down
4 changes: 1 addition & 3 deletions src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ export class Executor implements IExecutor {

#isInitialized = false;

readonly #url1Inch = 'https://nodes.debridge.finance';

private readonly logger: Logger;

constructor(logger: Logger) {
Expand Down Expand Up @@ -256,7 +254,7 @@ export class Executor implements IExecutor {
this.subsidizationRules = config.subsidizationRules || [];

this.swapConnector = new SwapConnectorImplementationService({
oneInchApi: this.#url1Inch,
oneInchConfig: config.oneInchConfig,
});

this.buckets = Executor.getTokenBuckets(config.buckets);
Expand Down
33 changes: 22 additions & 11 deletions src/processors/swap-connector-implementation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,41 @@ import {
SwapConnectorResult,
} from '@debridge-finance/dln-client';

type OneInchConfig = {
apiToken?: string;
apiServer?: string;
disablePMMProtocols?: boolean;
disabledProtocols?: string[];
};

export class SwapConnectorImplementationService implements SwapConnector {
readonly #connectors: { [key in ChainId]: SwapConnector | null };

constructor(config: { oneInchApi: string }) {
const oneInchV4Connector = new OneInch.OneInchV4Connector(config.oneInchApi);
const oneInchV5Connector = new OneInch.OneInchV5Connector(config.oneInchApi);
constructor(configuration?: { oneInchConfig?: OneInchConfig }) {
const oneInchV5Connector = new OneInch.OneInchV5Connector({
customApiURL: configuration?.oneInchConfig?.apiServer || 'https://api.1inch.dev/swap',
token: configuration?.oneInchConfig?.apiToken,
disablePMMProtocols: configuration?.oneInchConfig?.disablePMMProtocols,
disabledProtocols: configuration?.oneInchConfig?.disabledProtocols,
});

this.#connectors = {
[ChainId.Arbitrum]: oneInchV4Connector,
[ChainId.Arbitrum]: oneInchV5Connector,
[ChainId.ArbitrumTest]: null,
[ChainId.Avalanche]: oneInchV4Connector,
[ChainId.Avalanche]: oneInchV5Connector,
[ChainId.AvalancheTest]: null,
[ChainId.Base]: oneInchV5Connector,
[ChainId.BSC]: oneInchV4Connector,
[ChainId.BSC]: oneInchV5Connector,
[ChainId.BSCTest]: null,
[ChainId.Ethereum]: oneInchV4Connector,
[ChainId.Fantom]: oneInchV4Connector,
[ChainId.Ethereum]: oneInchV5Connector,
[ChainId.Fantom]: oneInchV5Connector,
[ChainId.Heco]: null,
[ChainId.HecoTest]: null,
[ChainId.Kovan]: null,
[ChainId.Linea]: oneInchV4Connector,
[ChainId.Linea]: oneInchV5Connector,
[ChainId.Neon]: null,
[ChainId.Optimism]: oneInchV4Connector,
[ChainId.Polygon]: oneInchV4Connector,
[ChainId.Optimism]: oneInchV5Connector,
[ChainId.Polygon]: oneInchV5Connector,
[ChainId.PolygonTest]: null,
[ChainId.Solana]: null,
};
Expand Down

0 comments on commit 26dd30b

Please sign in to comment.