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

Commit

Permalink
feat: Linea chain added (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeychr authored Jul 20, 2023
1 parent 4ab1248 commit 6d19687
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 70 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ The [`sample.config.ts` file](./sample.config.ts) already defines all blockchain
1. Avalanche
1. BNB Chain
1. Ethereum
1. Fantom
1. Linea
1. Polygon
1. Solana
1. Fantom

so you don't have to describe them explicitly. However, the sample config uses references to the environment variables (via the `${process.env.*}` notation) where sensitive or private data is involved: for example, an API key to access deBridge-managed websocket, or private keys to wallets with reserve funds for order fulfillment are designed to be accessed by the configuration file as environment variables.

Expand Down Expand Up @@ -138,7 +139,7 @@ The core on-chain DLN protocol is designed to work with arbitrary tokens on eith

As for now, deBridge uses two buckets of tokens for asset routing:
1. the USDC token, emitted by Circle Inc. on every DLN supported chain, and
1. the ETH coin, on Ethereum and Arbitrum, and
1. the ETH coin, on Ethereum, Arbitrum and Linea, and
1. the wETH token, on Avalanche, BNB Chain and Polygon

Both buckets are explicitly defined in the sample configuration file [here](./sample.config.ts)), so every taker is required to **load theirs address with enough USDC and ETH on every chain you are willing to fulfill orders on**.
Expand All @@ -148,7 +149,7 @@ Both buckets are explicitly defined in the sample configuration file [here](./sa
For every chain you as a taker would like to support:
- Register the reserves-keeping address (its private key must be set as a `takerPrivateKey` in the configuration file) and load it with:
- a given amount of USDC tokens (e.g., 100,000 USDC),
- a given amount of ETH (e.g. 60 ETH) on Ethereum and Arbitrum,
- a given amount of ETH (e.g. 60 ETH) on Ethereum, Arbitrum and Linea,
- a given amount of wETH tokens (e.g. 60 wETH) on Avalanche, BNB Chain and Polygon,
- a reasonable amount of native blockchain currency (e.g., 1 ETH on Ethereum) to pay gas for fulfillment transactions.
- Register the unlock authority address (its private key must be set as an `unlockAuthorityPrivateKey` in the configuration file) and load it with:
Expand All @@ -167,6 +168,7 @@ Executing cross-chain transactions is all about managing risks properly: no one
| BNB Chain | 12 |
| Ethereum | 12 |
| Fantom | 12 |
| Linea | 12 |
| Polygon | 256 |
| Solana | Finalized status |

Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ services:
- ETHEREUM_TAKER_PRIVATE_KEY=${ETHEREUM_TAKER_PRIVATE_KEY}
- ETHEREUM_UNLOCK_AUTHORITY_PRIVATE_KEY=${ETHEREUM_UNLOCK_AUTHORITY_PRIVATE_KEY}

- LINEA_RPC=${LINEA_RPC}
- LINEA_BENEFICIARY=${LINEA_BENEFICIARY}
- LINEA_TAKER_PRIVATE_KEY=${LINEA_TAKER_PRIVATE_KEY}
- LINEA_UNLOCK_AUTHORITY_PRIVATE_KEY=${LINEA_UNLOCK_AUTHORITY_PRIVATE_KEY}

- POLYGON_RPC=${POLYGON_RPC}
- POLYGON_BENEFICIARY=${POLYGON_BENEFICIARY}
- POLYGON_TAKER_PRIVATE_KEY=${POLYGON_TAKER_PRIVATE_KEY}
Expand Down
103 changes: 49 additions & 54 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@debridge-finance/dln-executor",
"description": "DLN executor is the rule-based daemon service developed to automatically execute orders placed on the deSwap Liquidity Network (DLN) across supported blockchains",
"version": "2.6.2",
"version": "2.7.0",
"author": "deBridge",
"license": "GPL-3.0-only",
"homepage": "https://debridge.finance",
Expand Down Expand Up @@ -39,7 +39,7 @@
"tslint-plugin-prettier": "2.3.0"
},
"dependencies": {
"@debridge-finance/dln-client": "5.5.0",
"@debridge-finance/dln-client": "5.8.2",
"@debridge-finance/solana-utils": "4.1.0",
"@protobuf-ts/plugin": "2.8.1",
"@solana/web3.js": "1.66.2",
Expand Down
24 changes: 17 additions & 7 deletions sample.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
CachePriceFeed,
ChainId,
CoingeckoPriceFeed,
TokensBucket,
} from "@debridge-finance/dln-client";

Expand All @@ -10,6 +8,7 @@ import { CURRENT_ENVIRONMENT as environment } from "./src/environments";
import { WsNextOrder } from "./src/orderFeeds/ws.order.feed";
import * as processors from "./src/processors";
import * as filters from "./src/filters";
import configurator from "./src/configurator";

// sanity check to ensure that .env file is supplied
if (process.env.WS_API_KEY === undefined)
Expand All @@ -27,8 +26,8 @@ const config: ExecutorLaunchConfig = {
// Setting the USDC bucket (all tokens are emitted by Circle Inc on every DLN supported chain)
//
new TokensBucket({
[ChainId.Avalanche]: ["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],
[ChainId.Arbitrum]: ["0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"],
[ChainId.Avalanche]: ["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],
[ChainId.BSC]: ["0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d"],
[ChainId.Ethereum]: ["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"],
[ChainId.Polygon]: ["0x2791bca1f2de4661ed88a30c99a7a9449aa84174"],
Expand All @@ -42,14 +41,14 @@ const config: ExecutorLaunchConfig = {
[ChainId.Avalanche]: ['0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB'],
[ChainId.BSC]: ['0x2170Ed0880ac9A755fd29B2688956BD959F933F8'],
[ChainId.Ethereum]: ['0x0000000000000000000000000000000000000000'],
[ChainId.Linea]: ['0x0000000000000000000000000000000000000000'],
[ChainId.Polygon]: ['0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619']
}),
],

tokenPriceService: new CachePriceFeed(
new CoingeckoPriceFeed(process?.env?.COINGECKO_API_KEY),
60 * 5 // 5min cache
),
tokenPriceService: configurator.tokenPriceService({
coingeckoApiKey: process?.env?.COINGECKO_API_KEY
}),

orderProcessor: processors.universalProcessor({
// desired profitability. Setting a higher value would prevent dln-taker from fulfilling most orders because
Expand Down Expand Up @@ -212,6 +211,17 @@ const config: ExecutorLaunchConfig = {
takerPrivateKey: `${process.env.POLYGON_TAKER_PRIVATE_KEY}`,
unlockAuthorityPrivateKey: `${process.env.POLYGON_UNLOCK_AUTHORITY_PRIVATE_KEY}`,
},

{
chain: ChainId.Linea,
chainRpc: `${process.env.LINEA_RPC}`,

constraints: {},

beneficiary: `${process.env.LINEA_BENEFICIARY}`,
takerPrivateKey: `${process.env.LINEA_TAKER_PRIVATE_KEY}`,
unlockAuthorityPrivateKey: `${process.env.LINEA_UNLOCK_AUTHORITY_PRIVATE_KEY}`,
}
],
};

Expand Down
6 changes: 6 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ FANTOM_TAKER_PRIVATE_KEY=
FANTOM_UNLOCK_AUTHORITY_PRIVATE_KEY=
FANTOM_BENEFICIARY=0x...

# Linea
LINEA_RPC=https://
LINEA_TAKER_PRIVATE_KEY=
LINEA_UNLOCK_AUTHORITY_PRIVATE_KEY=
LINEA_BENEFICIARY=0x...

# Solana
SOLANA_RPC=https://
SOLANA_TAKER_PRIVATE_KEY=
Expand Down
5 changes: 3 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import { HookHandler } from "./hooks/HookHandler";
type address = string;

export enum SupportedChain {
Avalanche = ChainId.Avalanche,
Arbitrum = ChainId.Arbitrum,
Avalanche = ChainId.Avalanche,
BSC = ChainId.BSC,
Ethereum = ChainId.Ethereum,
Fantom = ChainId.Fantom,
Linea = ChainId.Linea,
Polygon = ChainId.Polygon,
Solana = ChainId.Solana,
Fantom = ChainId.Fantom
}

export class EvmRebroadcastAdapterOpts {
Expand Down
9 changes: 9 additions & 0 deletions src/configurator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { tokenPriceService } from "./tokenPriceService";

export {
tokenPriceService
}

export default {
tokenPriceService
}
Loading

0 comments on commit 6d19687

Please sign in to comment.