@lifi/types 1.0.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 +635 -0
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/api.d.ts +176 -0
- package/dist/api.js +50 -0
- package/dist/apiErrors.d.ts +9 -0
- package/dist/apiErrors.js +2 -0
- package/dist/base.d.ts +204 -0
- package/dist/base.js +174 -0
- package/dist/bridges.d.ts +34 -0
- package/dist/bridges.js +170 -0
- package/dist/chains/Chain.d.ts +15 -0
- package/dist/chains/Chain.js +8 -0
- package/dist/chains/EVMChain.d.ts +19 -0
- package/dist/chains/EVMChain.js +8 -0
- package/dist/chains/SolanaChain.d.ts +2 -0
- package/dist/chains/SolanaChain.js +2 -0
- package/dist/chains/chain.utils.d.ts +4 -0
- package/dist/chains/chain.utils.js +30 -0
- package/dist/chains/index.d.ts +5 -0
- package/dist/chains/index.js +21 -0
- package/dist/chains/supported.chains.d.ts +5 -0
- package/dist/chains/supported.chains.js +1172 -0
- package/dist/coins.d.ts +9 -0
- package/dist/coins.js +1334 -0
- package/dist/exchanges.d.ts +51 -0
- package/dist/exchanges.js +1047 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +24 -0
- package/dist/multicall.d.ts +3 -0
- package/dist/multicall.js +61 -0
- package/dist/step.d.ts +103 -0
- package/dist/step.js +19 -0
- package/package.json +77 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -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,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.multicallAddresses = void 0;
|
|
5
|
+
var _1 = require(".");
|
|
6
|
+
// based on:
|
|
7
|
+
// - https://github.com/mds1/multicall#deployments
|
|
8
|
+
// - https://github.com/sushiswap/sushiswap-sdk/blob/canary/src/constants/addresses.ts#L323
|
|
9
|
+
// - https://github.com/joshstevens19/ethereum-multicall#multicall-contracts
|
|
10
|
+
// '0xcA11bde05977b3631167028862bE2a173976CA11' is a Multicall3 contract
|
|
11
|
+
exports.multicallAddresses = (_a = {},
|
|
12
|
+
// Mainnet
|
|
13
|
+
_a[_1.ChainId.ETH] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
14
|
+
_a[_1.ChainId.POL] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
15
|
+
_a[_1.ChainId.BSC] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
16
|
+
_a[_1.ChainId.DAI] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
17
|
+
_a[_1.ChainId.OKT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
18
|
+
_a[_1.ChainId.FTM] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
19
|
+
_a[_1.ChainId.AVA] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
20
|
+
_a[_1.ChainId.ARB] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
21
|
+
_a[_1.ChainId.HEC] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
22
|
+
_a[_1.ChainId.OPT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
23
|
+
_a[_1.ChainId.ONE] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
24
|
+
_a[_1.ChainId.FSN] = '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F',
|
|
25
|
+
_a[_1.ChainId.MOR] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
26
|
+
_a[_1.ChainId.CEL] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
27
|
+
_a[_1.ChainId.FUS] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
28
|
+
_a[_1.ChainId.CRO] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
29
|
+
_a[_1.ChainId.BOB] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
30
|
+
_a[_1.ChainId.MOO] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
31
|
+
_a[_1.ChainId.MAM] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
32
|
+
_a[_1.ChainId.AUR] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
33
|
+
_a[_1.ChainId.EVM] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
34
|
+
// [ChainId.EXP]: '', // TODO
|
|
35
|
+
// [ChainId.TCH]: '', // TODO
|
|
36
|
+
// [ChainId.UBQ]: '', // TODO
|
|
37
|
+
// [ChainId.MET]: '', // TODO
|
|
38
|
+
// [ChainId.DIO]: '', // TODO
|
|
39
|
+
// [ChainId.TLO]: '', // TODO
|
|
40
|
+
// [ChainId.SHI]: '', // TODO
|
|
41
|
+
// [ChainId.GL1]: '', // TODO
|
|
42
|
+
// [ChainId.RSK]: '', // TODO
|
|
43
|
+
// [ChainId.TBW]: '', // TODO
|
|
44
|
+
// [ChainId.VEL]: '', // TODO
|
|
45
|
+
// [ChainId.PALM]: '0x0769fd68dFb93167989C6f7254cd0D766Fb2841F',
|
|
46
|
+
// [ChainId.TELOS]: '0xdDCbf776dF3dE60163066A5ddDF2277cB445E0F3',
|
|
47
|
+
// Testnet
|
|
48
|
+
_a[_1.ChainId.ROP] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
49
|
+
_a[_1.ChainId.RIN] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
50
|
+
_a[_1.ChainId.GOR] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
51
|
+
_a[_1.ChainId.KOV] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
52
|
+
_a[_1.ChainId.MUM] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
53
|
+
_a[_1.ChainId.ARBT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
54
|
+
_a[_1.ChainId.BSCT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
55
|
+
_a[_1.ChainId.ONET] = '0xdDCbf776dF3dE60163066A5ddDF2277cB445E0F3',
|
|
56
|
+
_a[_1.ChainId.AVAT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
57
|
+
_a[_1.ChainId.OPTT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
58
|
+
_a[_1.ChainId.EVMT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
59
|
+
_a[_1.ChainId.MORT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
60
|
+
_a[_1.ChainId.FTMT] = '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
61
|
+
_a);
|
package/dist/step.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
}
|
|
69
|
+
export declare const emptyExecution: Execution;
|
|
70
|
+
export declare type StepType = 'swap' | 'cross' | 'lifi';
|
|
71
|
+
export declare type StepTool = string;
|
|
72
|
+
export interface StepBase {
|
|
73
|
+
id: string;
|
|
74
|
+
type: StepType;
|
|
75
|
+
tool: StepTool;
|
|
76
|
+
toolDetails: Pick<ExchangeAggregator | Exchange | Bridge, 'key' | 'name' | 'logoURI'>;
|
|
77
|
+
integrator?: string;
|
|
78
|
+
referrer?: string;
|
|
79
|
+
action: Action;
|
|
80
|
+
estimate?: Estimate;
|
|
81
|
+
execution?: Execution;
|
|
82
|
+
transactionRequest?: providers.TransactionRequest;
|
|
83
|
+
}
|
|
84
|
+
export interface SwapStep extends StepBase {
|
|
85
|
+
type: 'swap';
|
|
86
|
+
action: Action;
|
|
87
|
+
estimate: Estimate;
|
|
88
|
+
}
|
|
89
|
+
export declare function isSwapStep(step: Step): step is SwapStep;
|
|
90
|
+
export interface CrossStep extends StepBase {
|
|
91
|
+
type: 'cross';
|
|
92
|
+
action: Action;
|
|
93
|
+
estimate: Estimate;
|
|
94
|
+
}
|
|
95
|
+
export declare function isCrossStep(step: Step): step is CrossStep;
|
|
96
|
+
export interface LifiStep extends StepBase {
|
|
97
|
+
type: 'lifi';
|
|
98
|
+
action: Action;
|
|
99
|
+
estimate: Estimate;
|
|
100
|
+
includedSteps: Step[];
|
|
101
|
+
}
|
|
102
|
+
export declare function isLifiStep(step: Step): step is LifiStep;
|
|
103
|
+
export declare type Step = SwapStep | CrossStep | LifiStep;
|
package/dist/step.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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;
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lifi/types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Types for the LI.FI stack",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"install": "node -e \"if (!require('fs').existsSync('./dist')){process.exit(1)}\" || npm run build",
|
|
9
|
+
"watch": "tsc -w -p ./tsconfig.json",
|
|
10
|
+
"build": "node tools/cleanup types && tsc -p ./tsconfig.json",
|
|
11
|
+
"clean": "node tools/cleanup",
|
|
12
|
+
"package": "npm run build && npm pack",
|
|
13
|
+
"test": "jest --no-cache --runInBand",
|
|
14
|
+
"test:cov": "jest --coverage --no-cache --runInBand",
|
|
15
|
+
"addscope": "node tools/packagejson name @lifi/types",
|
|
16
|
+
"pre-commit": "lint-staged",
|
|
17
|
+
"pre-push": "yarn build && yarn test",
|
|
18
|
+
"lint:fix": "eslint --ext .tsx --ext .ts ./src --fix",
|
|
19
|
+
"prettier:fix": "prettier --write ./src/.",
|
|
20
|
+
"use:npmReadme": "mv 'README.md' 'git.README.md' && mv 'npm.README.md' 'README.md'",
|
|
21
|
+
"use:gitReadme": "mv 'README.md' 'npm.README.md' && mv 'git.README.md' 'README.md'",
|
|
22
|
+
"prepublishOnly": "run-s build use:npmReadme && pinst --enable",
|
|
23
|
+
"postpublish": "npm run use:gitReadme && pinst --enable",
|
|
24
|
+
"prepare": "husky install",
|
|
25
|
+
"release": "standard-version"
|
|
26
|
+
},
|
|
27
|
+
"lint-staged": {
|
|
28
|
+
"src/**/*.{ts,tsx}": [
|
|
29
|
+
"yarn run lint:fix",
|
|
30
|
+
"yarn run prettier:fix"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"author": "LI.FI <github@li.finanace>",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"homepage": "https://github.com/lifinance/types",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+ssh://git@github.com/lifinance/types.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/lifinance/types"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"ethers": "^5.6.9"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@commitlint/cli": "^17.0.3",
|
|
54
|
+
"@commitlint/config-conventional": "^17.0.3",
|
|
55
|
+
"@types/jest": "^28.1.4",
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^5.30.6",
|
|
57
|
+
"@typescript-eslint/parser": "^5.30.6",
|
|
58
|
+
"eslint": "^8.19.0",
|
|
59
|
+
"eslint-config-prettier": "^8.5.0",
|
|
60
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
61
|
+
"husky": "^8.0.1",
|
|
62
|
+
"jest": "^28.1.2",
|
|
63
|
+
"lint-staged": ">=13.0.3",
|
|
64
|
+
"npm-run-all": "^4.1.5",
|
|
65
|
+
"pinst": "^3.0.0",
|
|
66
|
+
"prettier": "^2.7.1",
|
|
67
|
+
"standard-version": "^9.5.0",
|
|
68
|
+
"ts-jest": "^28.0.5",
|
|
69
|
+
"ts-loader": "^9.3.1",
|
|
70
|
+
"typescript": "^4.7.4",
|
|
71
|
+
"webpack": "^5.73.0",
|
|
72
|
+
"webpack-cli": "^4.10.0"
|
|
73
|
+
},
|
|
74
|
+
"directories": {
|
|
75
|
+
"test": "test"
|
|
76
|
+
}
|
|
77
|
+
}
|