@lifi/types 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/api.d.ts +1 -0
- package/dist/api.js +6 -15
- package/dist/apiErrors.js +1 -2
- package/dist/base.d.ts +2 -0
- package/dist/base.js +8 -9
- package/dist/bridges.js +3 -6
- package/dist/chains/Chain.js +2 -5
- package/dist/chains/EVMChain.js +3 -7
- package/dist/chains/SolanaChain.js +1 -2
- package/dist/chains/chain.utils.js +10 -20
- package/dist/chains/index.js +5 -21
- package/dist/chains/supported.chains.js +273 -253
- package/dist/cjs/api.d.ts +219 -0
- package/dist/cjs/api.js +46 -0
- package/dist/cjs/apiErrors.d.ts +9 -0
- package/dist/cjs/apiErrors.js +2 -0
- package/dist/cjs/base.d.ts +206 -0
- package/dist/cjs/base.js +176 -0
- package/dist/cjs/bridges.d.ts +34 -0
- package/dist/cjs/bridges.js +170 -0
- package/dist/cjs/chains/Chain.d.ts +15 -0
- package/dist/cjs/chains/Chain.js +8 -0
- package/dist/cjs/chains/EVMChain.d.ts +19 -0
- package/dist/cjs/chains/EVMChain.js +8 -0
- package/dist/cjs/chains/SolanaChain.d.ts +2 -0
- package/dist/cjs/chains/SolanaChain.js +2 -0
- package/dist/cjs/chains/chain.utils.d.ts +4 -0
- package/dist/cjs/chains/chain.utils.js +25 -0
- package/dist/cjs/chains/index.d.ts +5 -0
- package/dist/cjs/chains/index.js +21 -0
- package/dist/cjs/chains/supported.chains.d.ts +5 -0
- package/dist/cjs/chains/supported.chains.js +1195 -0
- package/dist/cjs/coins.d.ts +9 -0
- package/dist/cjs/coins.js +1421 -0
- package/dist/cjs/exchanges.d.ts +51 -0
- package/dist/cjs/exchanges.js +1067 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/multicall.d.ts +3 -0
- package/dist/cjs/multicall.js +67 -0
- package/dist/cjs/step.d.ts +117 -0
- package/dist/cjs/step.js +23 -0
- package/dist/coins.js +402 -391
- package/dist/exchanges.js +230 -214
- package/dist/index.js +8 -24
- package/dist/multicall.js +44 -41
- package/dist/step.d.ts +2 -0
- package/dist/step.js +5 -12
- package/package.json +26 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base"), exports);
|
|
18
|
+
__exportStar(require("./bridges"), exports);
|
|
19
|
+
__exportStar(require("./chains"), exports);
|
|
20
|
+
__exportStar(require("./coins"), exports);
|
|
21
|
+
__exportStar(require("./exchanges"), exports);
|
|
22
|
+
__exportStar(require("./step"), exports);
|
|
23
|
+
__exportStar(require("./api"), exports);
|
|
24
|
+
__exportStar(require("./multicall"), exports);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.multicallAddresses = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
// based on:
|
|
6
|
+
// - https://github.com/mds1/multicall#deployments
|
|
7
|
+
// - https://github.com/sushiswap/sushiswap-sdk/blob/canary/src/constants/addresses.ts#L323
|
|
8
|
+
// - https://github.com/joshstevens19/ethereum-multicall#multicall-contracts
|
|
9
|
+
// '0xcA11bde05977b3631167028862bE2a173976CA11' is a Multicall3 contract
|
|
10
|
+
exports.multicallAddresses = {
|
|
11
|
+
// Mainnet
|
|
12
|
+
[_1.ChainId.ETH]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
13
|
+
[_1.ChainId.POL]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
14
|
+
[_1.ChainId.BSC]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
15
|
+
[_1.ChainId.DAI]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
16
|
+
[_1.ChainId.OKT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
17
|
+
[_1.ChainId.FTM]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
18
|
+
[_1.ChainId.AVA]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
19
|
+
[_1.ChainId.ARB]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
20
|
+
[_1.ChainId.HEC]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
21
|
+
[_1.ChainId.OPT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
22
|
+
[_1.ChainId.ONE]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
23
|
+
[_1.ChainId.FSN]: '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F',
|
|
24
|
+
[_1.ChainId.MOR]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
25
|
+
[_1.ChainId.CEL]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
26
|
+
[_1.ChainId.FUS]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
27
|
+
[_1.ChainId.CRO]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
28
|
+
[_1.ChainId.BOB]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
29
|
+
[_1.ChainId.MOO]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
30
|
+
[_1.ChainId.MAM]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
31
|
+
[_1.ChainId.AUR]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
32
|
+
[_1.ChainId.EVM]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
33
|
+
// [ChainId.EXP]: '', // TODO
|
|
34
|
+
// [ChainId.TCH]: '', // TODO
|
|
35
|
+
// [ChainId.UBQ]: '', // TODO
|
|
36
|
+
// [ChainId.MET]: '', // TODO
|
|
37
|
+
// [ChainId.DIO]: '', // TODO
|
|
38
|
+
// [ChainId.TLO]: '', // TODO
|
|
39
|
+
// [ChainId.SHI]: '', // TODO
|
|
40
|
+
// [ChainId.GL1]: '', // TODO
|
|
41
|
+
// [ChainId.RSK]: '', // TODO
|
|
42
|
+
// [ChainId.TBW]: '', // TODO
|
|
43
|
+
// [ChainId.VEL]: '', // TODO
|
|
44
|
+
// [ChainId.PALM]: '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F',
|
|
45
|
+
// [ChainId.TELOS]: '0xdDCbf776dF3dE60163066A5ddDF2277cB445E0F3',
|
|
46
|
+
// Testnet
|
|
47
|
+
[_1.ChainId.ROP]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
48
|
+
[_1.ChainId.RIN]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
49
|
+
[_1.ChainId.GOR]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
50
|
+
[_1.ChainId.KOV]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
51
|
+
[_1.ChainId.MUM]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
52
|
+
[_1.ChainId.ARBT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
53
|
+
[_1.ChainId.BSCT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
54
|
+
[_1.ChainId.ONET]: '0xdDCbf776dF3dE60163066A5ddDF2277cB445E0F3',
|
|
55
|
+
[_1.ChainId.AVAT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
56
|
+
[_1.ChainId.OPTT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
57
|
+
[_1.ChainId.OPTG]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
58
|
+
[_1.ChainId.EVMT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
59
|
+
[_1.ChainId.MORT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
60
|
+
[_1.ChainId.FTMT]: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
61
|
+
// [ChainId.METT]: '', // TODO
|
|
62
|
+
// [ChainId.DIOT]: '', // TODO
|
|
63
|
+
// [ChainId.HECT]: '', // TODO
|
|
64
|
+
// [ChainId.FUST]: '', // TODO
|
|
65
|
+
// [ChainId.TLOT]: '', // TODO
|
|
66
|
+
// [ChainId.RSKT]: '', // TODO
|
|
67
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { providers } from 'ethers';
|
|
2
|
+
import { Token } from './base';
|
|
3
|
+
import { Bridge } from './bridges';
|
|
4
|
+
import { Exchange, ExchangeAggregator } from './exchanges';
|
|
5
|
+
export interface FeeCost {
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
percentage: string;
|
|
9
|
+
token: Token;
|
|
10
|
+
amount: string;
|
|
11
|
+
amountUSD?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface GasCost {
|
|
14
|
+
type: 'SUM' | 'APPROVE' | 'SEND';
|
|
15
|
+
price?: string;
|
|
16
|
+
estimate?: string;
|
|
17
|
+
limit?: string;
|
|
18
|
+
amount: string;
|
|
19
|
+
amountUSD?: string;
|
|
20
|
+
token: Token;
|
|
21
|
+
}
|
|
22
|
+
export interface Action {
|
|
23
|
+
fromChainId: number;
|
|
24
|
+
fromAmount: string;
|
|
25
|
+
fromToken: Token;
|
|
26
|
+
fromAddress?: string;
|
|
27
|
+
toChainId: number;
|
|
28
|
+
toToken: Token;
|
|
29
|
+
toAddress?: string;
|
|
30
|
+
slippage: number;
|
|
31
|
+
}
|
|
32
|
+
export interface Estimate {
|
|
33
|
+
fromAmount: string;
|
|
34
|
+
fromAmountUSD?: string;
|
|
35
|
+
toAmount: string;
|
|
36
|
+
toAmountMin: string;
|
|
37
|
+
toAmountUSD?: string;
|
|
38
|
+
approvalAddress: string;
|
|
39
|
+
feeCosts?: FeeCost[];
|
|
40
|
+
gasCosts?: GasCost[];
|
|
41
|
+
executionDuration: number;
|
|
42
|
+
data?: any;
|
|
43
|
+
}
|
|
44
|
+
export declare type Status = 'NOT_STARTED' | 'STARTED' | 'ACTION_REQUIRED' | 'CHAIN_SWITCH_REQUIRED' | 'PENDING' | 'FAILED' | 'DONE' | 'RESUME' | 'CANCELLED';
|
|
45
|
+
export declare type ProcessType = 'TOKEN_ALLOWANCE' | 'SWITCH_CHAIN' | 'SWAP' | 'CROSS_CHAIN' | 'RECEIVING_CHAIN' | 'TRANSACTION';
|
|
46
|
+
export interface Process {
|
|
47
|
+
startedAt: number;
|
|
48
|
+
doneAt?: number;
|
|
49
|
+
failedAt?: number;
|
|
50
|
+
type: ProcessType;
|
|
51
|
+
status: Status;
|
|
52
|
+
message?: string;
|
|
53
|
+
txHash?: string;
|
|
54
|
+
txLink?: string;
|
|
55
|
+
error?: {
|
|
56
|
+
code: string | number;
|
|
57
|
+
message: string;
|
|
58
|
+
htmlMessage?: string;
|
|
59
|
+
};
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
}
|
|
62
|
+
export interface Execution {
|
|
63
|
+
status: Status;
|
|
64
|
+
process: Array<Process>;
|
|
65
|
+
fromAmount?: string;
|
|
66
|
+
toAmount?: string;
|
|
67
|
+
toToken?: Token;
|
|
68
|
+
gasUsed?: string;
|
|
69
|
+
gasPrice?: string;
|
|
70
|
+
}
|
|
71
|
+
export declare const emptyExecution: Execution;
|
|
72
|
+
export declare type StepType = 'swap' | 'cross' | 'lifi' | 'custom';
|
|
73
|
+
export declare type StepTool = string;
|
|
74
|
+
export interface StepBase {
|
|
75
|
+
id: string;
|
|
76
|
+
type: StepType;
|
|
77
|
+
tool: StepTool;
|
|
78
|
+
toolDetails: Pick<ExchangeAggregator | Exchange | Bridge, 'key' | 'name' | 'logoURI'>;
|
|
79
|
+
integrator?: string;
|
|
80
|
+
referrer?: string;
|
|
81
|
+
action: Action;
|
|
82
|
+
estimate?: Estimate;
|
|
83
|
+
execution?: Execution;
|
|
84
|
+
transactionRequest?: providers.TransactionRequest;
|
|
85
|
+
}
|
|
86
|
+
export interface SwapStep extends StepBase {
|
|
87
|
+
type: 'swap';
|
|
88
|
+
action: Action;
|
|
89
|
+
estimate: Estimate;
|
|
90
|
+
}
|
|
91
|
+
export declare function isSwapStep(step: Step): step is SwapStep;
|
|
92
|
+
export interface CrossStep extends StepBase {
|
|
93
|
+
type: 'cross';
|
|
94
|
+
action: Action;
|
|
95
|
+
estimate: Estimate;
|
|
96
|
+
}
|
|
97
|
+
export declare function isCrossStep(step: Step): step is CrossStep;
|
|
98
|
+
export interface LifiStep extends StepBase {
|
|
99
|
+
type: 'lifi';
|
|
100
|
+
action: Action;
|
|
101
|
+
estimate: Estimate;
|
|
102
|
+
includedSteps: Step[];
|
|
103
|
+
}
|
|
104
|
+
export declare function isLifiStep(step: Step): step is LifiStep;
|
|
105
|
+
export interface CustomStep extends StepBase {
|
|
106
|
+
type: 'custom';
|
|
107
|
+
action: Action;
|
|
108
|
+
estimate: Estimate;
|
|
109
|
+
destinationCallInfo: {
|
|
110
|
+
toContractAddress: string;
|
|
111
|
+
toContractCallData: string;
|
|
112
|
+
toFallbackAddress: string;
|
|
113
|
+
callDataGasLimit: string;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export declare function isCustomStep(step: Step): step is CustomStep;
|
|
117
|
+
export declare type Step = SwapStep | CrossStep | LifiStep | CustomStep;
|
package/dist/cjs/step.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCustomStep = exports.isLifiStep = exports.isCrossStep = exports.isSwapStep = exports.emptyExecution = void 0;
|
|
4
|
+
exports.emptyExecution = {
|
|
5
|
+
status: 'NOT_STARTED',
|
|
6
|
+
process: [],
|
|
7
|
+
};
|
|
8
|
+
function isSwapStep(step) {
|
|
9
|
+
return step.type === 'swap';
|
|
10
|
+
}
|
|
11
|
+
exports.isSwapStep = isSwapStep;
|
|
12
|
+
function isCrossStep(step) {
|
|
13
|
+
return step.type === 'cross';
|
|
14
|
+
}
|
|
15
|
+
exports.isCrossStep = isCrossStep;
|
|
16
|
+
function isLifiStep(step) {
|
|
17
|
+
return step.type === 'lifi';
|
|
18
|
+
}
|
|
19
|
+
exports.isLifiStep = isLifiStep;
|
|
20
|
+
function isCustomStep(step) {
|
|
21
|
+
return step.type === 'custom';
|
|
22
|
+
}
|
|
23
|
+
exports.isCustomStep = isCustomStep;
|