Skip to content

Commit effbc77

Browse files
committed
feat: add li.fi swap provider
1 parent 519816a commit effbc77

7 files changed

Lines changed: 595 additions & 0 deletions

File tree

759 Bytes
Loading

packages/swap/src/configs.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import changellyIcon from "./common/icons/changelly-logo.png";
1414
import jupiterIcon from "./common/icons/jupiter-logo.png";
1515
import okxIcon from "./common/icons/okx-logo.png";
1616
import rangoIcon from "./common/icons/rango-logo.png";
17+
import lifiIcon from "./common/icons/li.fi.png";
1718

1819
export type SwapFeeConfig = {
1920
referrer: string;
@@ -57,6 +58,10 @@ const PROVIDER_INFO: Record<
5758
name: ProviderNameProper.changelly,
5859
icon: changellyIcon,
5960
},
61+
[ProviderName.lifi]: {
62+
name: ProviderNameProper.lifi,
63+
icon: lifiIcon,
64+
},
6065
};
6166

6267
const FEE_CONFIGS: Partial<
@@ -136,6 +141,13 @@ const FEE_CONFIGS: Partial<
136141
fee: 0.01,
137142
},
138143
},
144+
// Add this address in https://portal.li.fi/integrations to collect fees
145+
[ProviderName.lifi]: {
146+
[WalletIdentifier.enkrypt]: {
147+
referrer: "0x8f1c0185bb6276638774b9e94985d69d3cdb444a",
148+
fee: 0.002,
149+
},
150+
},
139151
};
140152

141153
const TOKEN_LISTS: {
@@ -188,6 +200,10 @@ const GAS_LIMITS = {
188200
Wrap: numberToHex(70000),
189201
};
190202
const NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
203+
const NATIVE_TOKEN_ADDRESS_SOLANA = "11111111111111111111111111111111";
204+
205+
// li.fi integrator Id defined in https://portal.li.fi/integrations
206+
const LIFI_INTEGRATOR_ID = 'encrypt-wallet';
191207

192208
/** 0.5% (unit: 0-100 percentage) */
193209
const DEFAULT_SLIPPAGE = "0.5";
@@ -196,6 +212,8 @@ export {
196212
FEE_CONFIGS,
197213
GAS_LIMITS,
198214
NATIVE_TOKEN_ADDRESS,
215+
NATIVE_TOKEN_ADDRESS_SOLANA,
216+
LIFI_INTEGRATOR_ID,
199217
TOKEN_LISTS,
200218
CHANGELLY_LIST,
201219
TOP_TOKEN_INFO_LIST,

packages/swap/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { sortByRank, sortNativeToFront } from "./utils/common";
5757
import SwapToken from "./swapToken";
5858
import { Jupiter } from "./providers/jupiter";
5959
import { OKX } from "./providers/okx";
60+
import LiFi from "./providers/lifi";
6061

6162
class Swap extends EventEmitter {
6263
network: SupportedNetworkName;
@@ -154,6 +155,7 @@ class Swap extends EventEmitter {
154155
new Rango(this.api as Web3Solana, this.network),
155156
new Changelly(this.api, this.network),
156157
new OKX(this.api as Web3Solana, this.network),
158+
new LiFi(this.api as Web3Eth, this.network),
157159
];
158160
break;
159161
default:
@@ -165,6 +167,7 @@ class Swap extends EventEmitter {
165167
new Changelly(this.api, this.network),
166168
new ZeroX(this.api as Web3Eth, this.network),
167169
new Rango(this.api as Web3Eth, this.network),
170+
new LiFi(this.api as Web3Eth, this.network),
168171
];
169172
break;
170173
}

0 commit comments

Comments
 (0)