@lifi/types 0.0.0-preview-97f0520
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/LICENSE.md +201 -0
- package/README.md +59 -0
- package/package.json +46 -0
- package/src/_cjs/api.js +99 -0
- package/src/_cjs/api.js.map +1 -0
- package/src/_cjs/balance/index.js +18 -0
- package/src/_cjs/balance/index.js.map +1 -0
- package/src/_cjs/balance/wallet.js +3 -0
- package/src/_cjs/balance/wallet.js.map +1 -0
- package/src/_cjs/bridges.js +3 -0
- package/src/_cjs/bridges.js.map +1 -0
- package/src/_cjs/chains/Chain.js +13 -0
- package/src/_cjs/chains/Chain.js.map +1 -0
- package/src/_cjs/chains/EVMChain.js +3 -0
- package/src/_cjs/chains/EVMChain.js.map +1 -0
- package/src/_cjs/chains/MVMChain.js +3 -0
- package/src/_cjs/chains/MVMChain.js.map +1 -0
- package/src/_cjs/chains/STLChain.js +3 -0
- package/src/_cjs/chains/STLChain.js.map +1 -0
- package/src/_cjs/chains/SVMChain.js +3 -0
- package/src/_cjs/chains/SVMChain.js.map +1 -0
- package/src/_cjs/chains/TVMChain.js +3 -0
- package/src/_cjs/chains/TVMChain.js.map +1 -0
- package/src/_cjs/chains/UTXOChain.js +3 -0
- package/src/_cjs/chains/UTXOChain.js.map +1 -0
- package/src/_cjs/chains/base.js +196 -0
- package/src/_cjs/chains/base.js.map +1 -0
- package/src/_cjs/chains/index.js +25 -0
- package/src/_cjs/chains/index.js.map +1 -0
- package/src/_cjs/earn.js +3 -0
- package/src/_cjs/earn.js.map +1 -0
- package/src/_cjs/errors.js +21 -0
- package/src/_cjs/errors.js.map +1 -0
- package/src/_cjs/exchanges.js +3 -0
- package/src/_cjs/exchanges.js.map +1 -0
- package/src/_cjs/index.js +28 -0
- package/src/_cjs/index.js.map +1 -0
- package/src/_cjs/package.json +1 -0
- package/src/_cjs/routeSlippage.js +13 -0
- package/src/_cjs/routeSlippage.js.map +1 -0
- package/src/_cjs/step.js +28 -0
- package/src/_cjs/step.js.map +1 -0
- package/src/_cjs/tokens/base.js +137 -0
- package/src/_cjs/tokens/base.js.map +1 -0
- package/src/_cjs/tokens/index.js +19 -0
- package/src/_cjs/tokens/index.js.map +1 -0
- package/src/_cjs/tokens/token.js +12 -0
- package/src/_cjs/tokens/token.js.map +1 -0
- package/src/_cjs/typed-data.js +3 -0
- package/src/_cjs/typed-data.js.map +1 -0
- package/src/_esm/api.js +126 -0
- package/src/_esm/api.js.map +1 -0
- package/src/_esm/balance/index.js +2 -0
- package/src/_esm/balance/index.js.map +1 -0
- package/src/_esm/balance/wallet.js +2 -0
- package/src/_esm/balance/wallet.js.map +1 -0
- package/src/_esm/bridges.js +2 -0
- package/src/_esm/bridges.js.map +1 -0
- package/src/_esm/chains/Chain.js +15 -0
- package/src/_esm/chains/Chain.js.map +1 -0
- package/src/_esm/chains/EVMChain.js +2 -0
- package/src/_esm/chains/EVMChain.js.map +1 -0
- package/src/_esm/chains/MVMChain.js +2 -0
- package/src/_esm/chains/MVMChain.js.map +1 -0
- package/src/_esm/chains/STLChain.js +2 -0
- package/src/_esm/chains/STLChain.js.map +1 -0
- package/src/_esm/chains/SVMChain.js +2 -0
- package/src/_esm/chains/SVMChain.js.map +1 -0
- package/src/_esm/chains/TVMChain.js +2 -0
- package/src/_esm/chains/TVMChain.js.map +1 -0
- package/src/_esm/chains/UTXOChain.js +2 -0
- package/src/_esm/chains/UTXOChain.js.map +1 -0
- package/src/_esm/chains/base.js +209 -0
- package/src/_esm/chains/base.js.map +1 -0
- package/src/_esm/chains/index.js +9 -0
- package/src/_esm/chains/index.js.map +1 -0
- package/src/_esm/earn.js +9 -0
- package/src/_esm/earn.js.map +1 -0
- package/src/_esm/errors.js +19 -0
- package/src/_esm/errors.js.map +1 -0
- package/src/_esm/exchanges.js +2 -0
- package/src/_esm/exchanges.js.map +1 -0
- package/src/_esm/index.js +12 -0
- package/src/_esm/index.js.map +1 -0
- package/src/_esm/package.json +1 -0
- package/src/_esm/routeSlippage.js +54 -0
- package/src/_esm/routeSlippage.js.map +1 -0
- package/src/_esm/step.js +25 -0
- package/src/_esm/step.js.map +1 -0
- package/src/_esm/tokens/base.js +144 -0
- package/src/_esm/tokens/base.js.map +1 -0
- package/src/_esm/tokens/index.js +3 -0
- package/src/_esm/tokens/index.js.map +1 -0
- package/src/_esm/tokens/token.js +10 -0
- package/src/_esm/tokens/token.js.map +1 -0
- package/src/_esm/typed-data.js +2 -0
- package/src/_esm/typed-data.js.map +1 -0
- package/src/_types/api.d.ts +891 -0
- package/src/_types/api.d.ts.map +1 -0
- package/src/_types/balance/index.d.ts +2 -0
- package/src/_types/balance/index.d.ts.map +1 -0
- package/src/_types/balance/wallet.d.ts +97 -0
- package/src/_types/balance/wallet.d.ts.map +1 -0
- package/src/_types/bridges.d.ts +29 -0
- package/src/_types/bridges.d.ts.map +1 -0
- package/src/_types/chains/Chain.d.ts +21 -0
- package/src/_types/chains/Chain.d.ts.map +1 -0
- package/src/_types/chains/EVMChain.d.ts +23 -0
- package/src/_types/chains/EVMChain.d.ts.map +1 -0
- package/src/_types/chains/MVMChain.d.ts +6 -0
- package/src/_types/chains/MVMChain.d.ts.map +1 -0
- package/src/_types/chains/STLChain.d.ts +6 -0
- package/src/_types/chains/STLChain.d.ts.map +1 -0
- package/src/_types/chains/SVMChain.d.ts +10 -0
- package/src/_types/chains/SVMChain.d.ts.map +1 -0
- package/src/_types/chains/TVMChain.d.ts +7 -0
- package/src/_types/chains/TVMChain.d.ts.map +1 -0
- package/src/_types/chains/UTXOChain.d.ts +6 -0
- package/src/_types/chains/UTXOChain.d.ts.map +1 -0
- package/src/_types/chains/base.d.ts +191 -0
- package/src/_types/chains/base.d.ts.map +1 -0
- package/src/_types/chains/index.d.ts +9 -0
- package/src/_types/chains/index.d.ts.map +1 -0
- package/src/_types/earn.d.ts +137 -0
- package/src/_types/earn.d.ts.map +1 -0
- package/src/_types/errors.d.ts +17 -0
- package/src/_types/errors.d.ts.map +1 -0
- package/src/_types/exchanges.d.ts +25 -0
- package/src/_types/exchanges.d.ts.map +1 -0
- package/src/_types/index.d.ts +12 -0
- package/src/_types/index.d.ts.map +1 -0
- package/src/_types/routeSlippage.d.ts +85 -0
- package/src/_types/routeSlippage.d.ts.map +1 -0
- package/src/_types/step.d.ts +218 -0
- package/src/_types/step.d.ts.map +1 -0
- package/src/_types/tokens/base.d.ts +133 -0
- package/src/_types/tokens/base.d.ts.map +1 -0
- package/src/_types/tokens/index.d.ts +3 -0
- package/src/_types/tokens/index.d.ts.map +1 -0
- package/src/_types/tokens/token.d.ts +54 -0
- package/src/_types/tokens/token.d.ts.map +1 -0
- package/src/_types/typed-data.d.ts +31 -0
- package/src/_types/typed-data.d.ts.map +1 -0
- package/src/api.ts +1185 -0
- package/src/balance/index.ts +1 -0
- package/src/balance/wallet.ts +102 -0
- package/src/bridges.ts +30 -0
- package/src/chains/Chain.ts +28 -0
- package/src/chains/EVMChain.ts +28 -0
- package/src/chains/MVMChain.ts +6 -0
- package/src/chains/STLChain.ts +6 -0
- package/src/chains/SVMChain.ts +11 -0
- package/src/chains/TVMChain.ts +7 -0
- package/src/chains/UTXOChain.ts +6 -0
- package/src/chains/base.ts +221 -0
- package/src/chains/index.ts +8 -0
- package/src/earn.ts +158 -0
- package/src/errors.ts +17 -0
- package/src/exchanges.ts +27 -0
- package/src/index.ts +11 -0
- package/src/routeSlippage.ts +97 -0
- package/src/step.ts +281 -0
- package/src/tokens/base.ts +152 -0
- package/src/tokens/index.ts +2 -0
- package/src/tokens/token.ts +63 -0
- package/src/typed-data.ts +34 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route-wide slippage: the public contract of the opt-in `slippageScope: 'route'`.
|
|
3
|
+
*
|
|
4
|
+
* With step scope (the default, and today's behaviour) `slippage` seeds every
|
|
5
|
+
* step's local tolerance and the route's `toAmountMin` is the per-step fold, so
|
|
6
|
+
* two 2.5 % legs compound to a 4.94 % worst case. With route scope `slippage`
|
|
7
|
+
* is the total budget `S` for the whole route and the route promises one floor
|
|
8
|
+
* `M = ceil(Q0 × (1 − S))` on the expected net final output `Q0`. Every build,
|
|
9
|
+
* rebuild, retry and resume enforces at least `M`; lowering it needs a new
|
|
10
|
+
* quote the user approves.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Scope of the `slippage` request parameter.
|
|
15
|
+
*
|
|
16
|
+
* - `'step'` (and an omitted scope): existing behaviour, per-step slippage.
|
|
17
|
+
* Omitted and explicit `'step'` are identical.
|
|
18
|
+
* - `'route'`: opt-in route-wide protection. Requires an explicit `slippage`
|
|
19
|
+
* in `[0, 1)` with at most 8 decimals; there is no default. Exact-input
|
|
20
|
+
* `/quote` and `/advanced/routes` only; other surfaces reject `'route'`
|
|
21
|
+
* instead of silently downgrading to step scope.
|
|
22
|
+
*/
|
|
23
|
+
export const SlippageScopes = ['step', 'route'] as const
|
|
24
|
+
export type SlippageScope = (typeof SlippageScopes)[number]
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Canonical decimal proportion string for the route budget `S`: `'0'`, or
|
|
28
|
+
* `'0.'` followed by 1–8 digits with no trailing zero (e.g. `'0.025'` for 2.5 %).
|
|
29
|
+
*/
|
|
30
|
+
export type RouteSlippageDecimal = string
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* How a protected route settles when execution cannot meet `M`:
|
|
34
|
+
* - `'atomic'`: one transaction; delivery below `M` reverts and the user keeps
|
|
35
|
+
* the input minus gas.
|
|
36
|
+
* - `'conditional'`: cross-chain; the source leg may finalize while the
|
|
37
|
+
* destination is pending, and a failure yields recovery (refund, bridge
|
|
38
|
+
* asset), which is reported but is never fulfilment.
|
|
39
|
+
*/
|
|
40
|
+
export const RouteSlippageSettlements = ['atomic', 'conditional'] as const
|
|
41
|
+
export type RouteSlippageSettlement = (typeof RouteSlippageSettlements)[number]
|
|
42
|
+
|
|
43
|
+
/** A floor enforced at an execution-group boundary, in base units of `tokenAddress`. */
|
|
44
|
+
export interface RouteSlippageCheckpoint {
|
|
45
|
+
stepId: string
|
|
46
|
+
chainId: number
|
|
47
|
+
tokenAddress: string
|
|
48
|
+
minimumAmount: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The commitment attached to a route admitted with `slippageScope: 'route'`
|
|
53
|
+
* and mirrored onto each participating root step. Round-trip it unchanged to
|
|
54
|
+
* `/v1/advanced/stepTransaction` and through SDK resume; the server validates
|
|
55
|
+
* it and only ever refuses to build below `minimumToAmount`. Absent on
|
|
56
|
+
* step-scope routes.
|
|
57
|
+
*/
|
|
58
|
+
export interface RouteSlippageCommitment {
|
|
59
|
+
scope: 'route'
|
|
60
|
+
/** `S`, canonical decimal. */
|
|
61
|
+
slippage: RouteSlippageDecimal
|
|
62
|
+
/** `Q0`: expected net final output, integer base units of the terminal token. */
|
|
63
|
+
referenceToAmount: string
|
|
64
|
+
/** `M = ceil(Q0 × (1 − S))`, integer base units of the terminal token. */
|
|
65
|
+
minimumToAmount: string
|
|
66
|
+
toChainId: number
|
|
67
|
+
toTokenAddress: string
|
|
68
|
+
/** Designated recipient the delivery is measured at, when bound. */
|
|
69
|
+
toAddress?: string
|
|
70
|
+
settlement: RouteSlippageSettlement
|
|
71
|
+
checkpoints: RouteSlippageCheckpoint[]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Machine-readable route-slippage failure reasons, carried as a stable prefix
|
|
76
|
+
* of the error `message` and of a filtered route's `reason`:
|
|
77
|
+
*
|
|
78
|
+
* - `ROUTE_SLIPPAGE_UNSUPPORTED`: the endpoint, path family or tool cannot
|
|
79
|
+
* enforce a route-wide floor. No fallback to step scope.
|
|
80
|
+
* - `ROUTE_SLIPPAGE_UNAVAILABLE`: route protection is switched off (globally
|
|
81
|
+
* or for this integrator).
|
|
82
|
+
* - `ROUTE_SLIPPAGE_INVALID_SLIPPAGE`: route scope without an explicit
|
|
83
|
+
* canonical `slippage` in `[0, 1)`.
|
|
84
|
+
* - `ROUTE_SLIPPAGE_FLOOR_UNREACHABLE`: no quoted flow meets `M`; request a
|
|
85
|
+
* fresh quote — `M` is never lowered to fit.
|
|
86
|
+
* - `ROUTE_SLIPPAGE_COMMITMENT_INVALID`: a posted step carries a malformed or
|
|
87
|
+
* inconsistent commitment.
|
|
88
|
+
*/
|
|
89
|
+
export const RouteSlippageErrorReasons = [
|
|
90
|
+
'ROUTE_SLIPPAGE_UNSUPPORTED',
|
|
91
|
+
'ROUTE_SLIPPAGE_UNAVAILABLE',
|
|
92
|
+
'ROUTE_SLIPPAGE_INVALID_SLIPPAGE',
|
|
93
|
+
'ROUTE_SLIPPAGE_FLOOR_UNREACHABLE',
|
|
94
|
+
'ROUTE_SLIPPAGE_COMMITMENT_INVALID',
|
|
95
|
+
] as const
|
|
96
|
+
export type RouteSlippageErrorReason =
|
|
97
|
+
(typeof RouteSlippageErrorReasons)[number]
|
package/src/step.ts
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TypedData,
|
|
3
|
+
TransactionRequest,
|
|
4
|
+
SignedTypedData,
|
|
5
|
+
ExecutionType,
|
|
6
|
+
} from './api.js'
|
|
7
|
+
import type { RouteSlippageCommitment } from './routeSlippage.js'
|
|
8
|
+
import type { Token } from './tokens/index.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* How a fee was calculated / the role of the recipient in the split.
|
|
12
|
+
*
|
|
13
|
+
* - `FIXED` — a fixed LI.FI cut applied alongside the integrator's own fee.
|
|
14
|
+
* - `SHARED` — a single shared pool divided between LI.FI and the integrator.
|
|
15
|
+
* - `DYNAMIC` — fee resolved at quote time from configured rules (e.g. dynamic
|
|
16
|
+
* stablecoin pricing).
|
|
17
|
+
* - `INTERMEDIARY` — a third-party recipient that carves a configured share
|
|
18
|
+
* from the integrator pool (e.g. a widget or aggregator).
|
|
19
|
+
* - `DISTRIBUTION` — a partner-specified extra recipient added in parallel to
|
|
20
|
+
* the integrator/intermediary split via the `distributionFees` request param.
|
|
21
|
+
*
|
|
22
|
+
* The union is expected to grow over time. When pattern-matching with a
|
|
23
|
+
* `switch`, always include a `default` branch so adding a new value remains
|
|
24
|
+
* a non-breaking minor for consumers.
|
|
25
|
+
*/
|
|
26
|
+
export type FeeSplitType =
|
|
27
|
+
| 'FIXED'
|
|
28
|
+
| 'SHARED'
|
|
29
|
+
| 'DYNAMIC'
|
|
30
|
+
| 'INTERMEDIARY'
|
|
31
|
+
| 'DISTRIBUTION'
|
|
32
|
+
|
|
33
|
+
export interface FeeRecipient {
|
|
34
|
+
/** Recipient identifier. Polymorphic — interpret in conjunction with `type`:
|
|
35
|
+
* - `'lifi'` for the LI.FI platform recipient,
|
|
36
|
+
* - the integrator id (e.g. `'jumper'`) for the integrator recipient,
|
|
37
|
+
* - the intermediary id (e.g. `'mesh'`) when `type === 'INTERMEDIARY'`,
|
|
38
|
+
* - the recipient wallet address when `type === 'DISTRIBUTION'`.
|
|
39
|
+
*
|
|
40
|
+
* Do not display this value directly in user-facing UI without
|
|
41
|
+
* `type`-aware formatting — for `DISTRIBUTION` rows the value is a
|
|
42
|
+
* raw hex address. */
|
|
43
|
+
name: string
|
|
44
|
+
|
|
45
|
+
/** Absolute fee amount, a big number in source token base units (string-encoded). */
|
|
46
|
+
fee: string
|
|
47
|
+
|
|
48
|
+
/** Fee calculation type. Absent when not statically determinable (e.g.
|
|
49
|
+
* an integrator entry whose `feeType` could not be resolved from the
|
|
50
|
+
* matching planned fee cost). Consumers should null-check before reading. */
|
|
51
|
+
type?: FeeSplitType
|
|
52
|
+
|
|
53
|
+
/** Recipient wallet address on the source chain. */
|
|
54
|
+
walletAddress?: string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface FeeSplit {
|
|
58
|
+
/** LI.FI's slice of THIS `FeeCost.amount`. */
|
|
59
|
+
lifiFee: string
|
|
60
|
+
|
|
61
|
+
/** The integrator's slice of THIS `FeeCost.amount` — the integrator's
|
|
62
|
+
* portion only, NOT including any intermediary or distribution amounts. */
|
|
63
|
+
integratorFee: string
|
|
64
|
+
|
|
65
|
+
/** The intermediary's slice of THIS `FeeCost.amount` when an intermediary
|
|
66
|
+
* participates in the split. Absent otherwise. */
|
|
67
|
+
intermediaryFee?: string
|
|
68
|
+
|
|
69
|
+
/** Per-recipient breakdown of THIS `FeeCost.amount`. Source of truth for
|
|
70
|
+
* new consumers — the aggregate fields above are disjoint slices kept
|
|
71
|
+
* for backward compatibility with 2-recipient consumers.
|
|
72
|
+
*
|
|
73
|
+
* Note: partner-specified distribution recipients are aggregated into a
|
|
74
|
+
* single `FeeCost` entry (`name: "Distributions"`) whose `amount` is the
|
|
75
|
+
* total distributed and whose `recipients[]` lists each receiver. This
|
|
76
|
+
* entry sits beside the integrator/LI.FI/intermediary entry, with the same
|
|
77
|
+
* shape on quote, route, and status responses. */
|
|
78
|
+
recipients?: FeeRecipient[]
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface FeeCost {
|
|
82
|
+
name: string
|
|
83
|
+
description: string
|
|
84
|
+
percentage: string
|
|
85
|
+
token: Token
|
|
86
|
+
amount: string
|
|
87
|
+
amountUSD: string
|
|
88
|
+
included: boolean
|
|
89
|
+
|
|
90
|
+
feeSplit?: FeeSplit
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface GasCost {
|
|
94
|
+
type: 'SUM' | 'APPROVE' | 'SEND' | 'FEE'
|
|
95
|
+
price: string // suggested current standard price for chain
|
|
96
|
+
estimate: string // estimate how much gas will be needed
|
|
97
|
+
limit: string // suggested gas limit (estimate +25%)
|
|
98
|
+
amount: string // estimate * price = amount of tokens that will be needed
|
|
99
|
+
amountUSD: string // usd value of token amount
|
|
100
|
+
token: Token // the used gas token
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ACTION
|
|
104
|
+
export interface Action {
|
|
105
|
+
fromChainId: number
|
|
106
|
+
fromAmount: string
|
|
107
|
+
fromToken: Token
|
|
108
|
+
fromAddress?: string
|
|
109
|
+
|
|
110
|
+
toChainId: number
|
|
111
|
+
toToken: Token
|
|
112
|
+
toAddress?: string
|
|
113
|
+
/** Recipient of source-chain bridge principal refunds, not destination swap/call recovery. */
|
|
114
|
+
refundAddress?: string
|
|
115
|
+
|
|
116
|
+
slippage?: number
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ESTIMATE
|
|
120
|
+
export interface Estimate {
|
|
121
|
+
tool: string
|
|
122
|
+
fromAmount: string
|
|
123
|
+
fromAmountUSD?: string
|
|
124
|
+
toAmount: string
|
|
125
|
+
toAmountMin: string
|
|
126
|
+
toAmountUSD?: string
|
|
127
|
+
approvalAddress: string
|
|
128
|
+
feeCosts?: FeeCost[]
|
|
129
|
+
/** This is a list to account for approval gas costs and transaction gas costs. However, approval gas costs are not integrated yet. */
|
|
130
|
+
gasCosts?: GasCost[]
|
|
131
|
+
/** Estimated duration in seconds */
|
|
132
|
+
executionDuration: number
|
|
133
|
+
/** Optional flag to indicate approval reset requirement for legacy ERC-20 tokens */
|
|
134
|
+
approvalReset?: boolean
|
|
135
|
+
/** Optional flag to skip approval in the cases where we only need to sign the message (e.g. Hyperliquid)*/
|
|
136
|
+
skipApproval?: boolean
|
|
137
|
+
/** Optional flag to skip permit usage when the tx doesn't include diamond interaction (some HyperEVM txs) */
|
|
138
|
+
skipPermit?: boolean
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// STEP
|
|
142
|
+
export const _StepType = [
|
|
143
|
+
'lifi',
|
|
144
|
+
'swap',
|
|
145
|
+
'cross',
|
|
146
|
+
'protocol',
|
|
147
|
+
'custom',
|
|
148
|
+
] as const
|
|
149
|
+
export type StepType = (typeof _StepType)[number]
|
|
150
|
+
export type StepTool = string
|
|
151
|
+
export type StepToolDetails = {
|
|
152
|
+
key: string
|
|
153
|
+
name: string
|
|
154
|
+
logoURI: string
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
type StepInformationBase = {
|
|
158
|
+
tool: string
|
|
159
|
+
type: string
|
|
160
|
+
action: Action
|
|
161
|
+
estimate: Estimate
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type StepInformation = StepInformationBase & {
|
|
165
|
+
createdAt: Date
|
|
166
|
+
gasLimit: string
|
|
167
|
+
stepId: string
|
|
168
|
+
transactionId: string
|
|
169
|
+
intermediateActions: StepInformationBase[]
|
|
170
|
+
integrator?: string
|
|
171
|
+
relatedLifiSteps?: string[]
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface StepBase {
|
|
175
|
+
id: string
|
|
176
|
+
type: StepType
|
|
177
|
+
tool: StepTool
|
|
178
|
+
toolDetails: StepToolDetails
|
|
179
|
+
integrator?: string
|
|
180
|
+
/** Intermediary identifier set when the route was generated with a multi-party fee split.
|
|
181
|
+
* Threaded through to /stepTransaction so the same split can be reproduced at tx-generation time. */
|
|
182
|
+
intermediary?: string
|
|
183
|
+
referrer?: string
|
|
184
|
+
action: Action
|
|
185
|
+
estimate?: Estimate
|
|
186
|
+
executionType?: ExecutionType
|
|
187
|
+
transactionRequest?: TransactionRequest
|
|
188
|
+
transactionId?: string
|
|
189
|
+
/**
|
|
190
|
+
* EIP-712 Typed Data
|
|
191
|
+
* @link https://eips.ethereum.org/EIPS/eip-712
|
|
192
|
+
*/
|
|
193
|
+
typedData?: TypedData[]
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface DestinationCallInfo {
|
|
197
|
+
toContractAddress: string
|
|
198
|
+
toContractCallData: string
|
|
199
|
+
toFallbackAddress: string
|
|
200
|
+
callDataGasLimit: string
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export type CallAction = Action & DestinationCallInfo
|
|
204
|
+
|
|
205
|
+
export interface SwapStep extends StepBase {
|
|
206
|
+
type: 'swap'
|
|
207
|
+
action: Action
|
|
208
|
+
estimate: Estimate
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface CrossStep extends StepBase {
|
|
212
|
+
type: 'cross'
|
|
213
|
+
action: Action
|
|
214
|
+
estimate: Estimate
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface ProtocolStep extends StepBase {
|
|
218
|
+
type: 'protocol'
|
|
219
|
+
action: Action
|
|
220
|
+
estimate: Estimate
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface CustomStep extends StepBase {
|
|
224
|
+
type: 'custom'
|
|
225
|
+
action: CallAction
|
|
226
|
+
estimate: Estimate
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export type Step = SwapStep | CrossStep | CustomStep | ProtocolStep
|
|
230
|
+
|
|
231
|
+
/** Destination-side actions the Smart Deposits lane can execute once the
|
|
232
|
+
* bridged funds land. A closed set: the kind is the forward-compatibility
|
|
233
|
+
* axis, so a new action ships as a new literal rather than a free-form string. */
|
|
234
|
+
export const DESTINATION_ACTION_KINDS = ['erc4626_deposit'] as const
|
|
235
|
+
|
|
236
|
+
export type DestinationActionKind = (typeof DESTINATION_ACTION_KINDS)[number]
|
|
237
|
+
|
|
238
|
+
/** One destination-side action, executed by the Smart Deposits lane on the
|
|
239
|
+
* destination chain after the bridge leg. The vault address is forwarded
|
|
240
|
+
* verbatim — the Intent Factory's curated allowlist is the enforcement point. */
|
|
241
|
+
export interface DestinationAction {
|
|
242
|
+
kind: DestinationActionKind
|
|
243
|
+
vault: string
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface LiFiStep extends Omit<Step, 'type'> {
|
|
247
|
+
type: 'lifi'
|
|
248
|
+
includedSteps: Step[]
|
|
249
|
+
|
|
250
|
+
/** Present on Smart Deposits steps whose route was requested with a
|
|
251
|
+
* destination action. Round-trip the step unchanged to
|
|
252
|
+
* `/v1/advanced/stepTransaction` — a step posted without it prepares a
|
|
253
|
+
* plain bundle that delivers the raw token instead of the action's output. */
|
|
254
|
+
destinationAction?: DestinationAction
|
|
255
|
+
|
|
256
|
+
/** Present iff the step belongs to a route admitted with
|
|
257
|
+
* `slippageScope: 'route'`. Same object as `Route.routeSlippage` — round-trip
|
|
258
|
+
* it unchanged to `/v1/advanced/stepTransaction` and through SDK resume; the
|
|
259
|
+
* server validates it and refuses to build below its floor. */
|
|
260
|
+
routeSlippage?: RouteSlippageCommitment
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface SignedLiFiStep extends LiFiStep {
|
|
264
|
+
typedData: SignedTypedData[]
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export function isSwapStep(step: Step): step is SwapStep {
|
|
268
|
+
return step.type === 'swap'
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function isCrossStep(step: Step): step is CrossStep {
|
|
272
|
+
return step.type === 'cross'
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export function isProtocolStep(step: Step): step is ProtocolStep {
|
|
276
|
+
return step.type === 'protocol'
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export function isCustomStep(step: Step): step is CustomStep {
|
|
280
|
+
return step.type === 'custom'
|
|
281
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export enum CoinKey {
|
|
2
|
+
ETH = 'ETH',
|
|
3
|
+
MATIC = 'MATIC',
|
|
4
|
+
POL = 'POL',
|
|
5
|
+
BNB = 'BNB',
|
|
6
|
+
DAI = 'DAI',
|
|
7
|
+
FTM = 'FTM',
|
|
8
|
+
AVAX = 'AVAX',
|
|
9
|
+
ONE = 'ONE',
|
|
10
|
+
FSN = 'FSN',
|
|
11
|
+
MOVR = 'MOVR',
|
|
12
|
+
CELO = 'CELO',
|
|
13
|
+
FUSE = 'FUSE',
|
|
14
|
+
TLOS = 'TLOS',
|
|
15
|
+
CRO = 'CRO',
|
|
16
|
+
RBTC = 'RBTC',
|
|
17
|
+
VLX = 'VLX',
|
|
18
|
+
GLMR = 'GLMR',
|
|
19
|
+
METIS = 'METIS',
|
|
20
|
+
EVM = 'EVM',
|
|
21
|
+
MNT = 'MNT',
|
|
22
|
+
SEI = 'SEI',
|
|
23
|
+
G = 'G',
|
|
24
|
+
IMX = 'IMX',
|
|
25
|
+
KAIA = 'KAIA',
|
|
26
|
+
OKB = 'OKB',
|
|
27
|
+
WLD = 'WLD', // World Coin Token
|
|
28
|
+
LSK = 'LSK', // Lisk Token
|
|
29
|
+
BERA = 'BERA', // Berachain Token
|
|
30
|
+
S = 'S', // Sonic Token
|
|
31
|
+
APE = 'APE', // ApeCoin
|
|
32
|
+
GHO = 'GHO', // Lens
|
|
33
|
+
WGHO = 'WGHO', // Lens
|
|
34
|
+
XTZ = 'XTZ', // Etherlink Native
|
|
35
|
+
HYPE = 'HYPE', // HyperEVM native
|
|
36
|
+
XDC = 'XDC', // XDC native
|
|
37
|
+
VIC = 'VIC', // Viction native
|
|
38
|
+
FLR = 'FLR', // Flare native
|
|
39
|
+
VAN = 'VAN', // Vana native
|
|
40
|
+
RON = 'RON', // Ronin native
|
|
41
|
+
PLU = 'PLUME', // Plume native
|
|
42
|
+
NIBI = 'NIBI', // Nibiru native
|
|
43
|
+
XPL = 'XPL', // Plasma native
|
|
44
|
+
FLOW = 'FLOW', // Flow native
|
|
45
|
+
MON = 'MON', // Monad native
|
|
46
|
+
GUSDT = 'GUSDT', // Stable native (Gas USDT)
|
|
47
|
+
ZEROG = '0G', // 0G native
|
|
48
|
+
PROS = 'PROS', // Pharos native
|
|
49
|
+
WPROS = 'WPROS', // Wrapped Pharos
|
|
50
|
+
SOMI = 'SOMI', // Somnia native
|
|
51
|
+
WSOMI = 'WSOMI', // Somnia Wrapped Native
|
|
52
|
+
INJ = 'INJ', // Injective native
|
|
53
|
+
|
|
54
|
+
// SVM
|
|
55
|
+
SOL = 'SOL',
|
|
56
|
+
WSOL = 'wSOL',
|
|
57
|
+
|
|
58
|
+
// Fogo
|
|
59
|
+
FOGO = 'FOGO',
|
|
60
|
+
WFOGO = 'wFOGO',
|
|
61
|
+
|
|
62
|
+
// MVM
|
|
63
|
+
SUI = 'SUI',
|
|
64
|
+
|
|
65
|
+
// UTXO
|
|
66
|
+
BTC = 'BTC',
|
|
67
|
+
BCH = 'BCH',
|
|
68
|
+
LTC = 'LTC',
|
|
69
|
+
DOGE = 'DOGE',
|
|
70
|
+
ZEC = 'ZEC',
|
|
71
|
+
|
|
72
|
+
// Tron
|
|
73
|
+
TRX = 'TRX',
|
|
74
|
+
WTRX = 'WTRX',
|
|
75
|
+
|
|
76
|
+
// Stellar
|
|
77
|
+
XLM = 'XLM',
|
|
78
|
+
|
|
79
|
+
// Tether Gold
|
|
80
|
+
XAUt = 'XAUt',
|
|
81
|
+
|
|
82
|
+
// Hemi chain token
|
|
83
|
+
HEMI = 'HEMI',
|
|
84
|
+
|
|
85
|
+
// Stable coins
|
|
86
|
+
USDT = 'USDT',
|
|
87
|
+
USDC = 'USDC',
|
|
88
|
+
BUSD = 'BUSD',
|
|
89
|
+
USDCe = 'USDCe',
|
|
90
|
+
USDCs = 'USDCs', // Wormhole bridged USDC from Solana to Fogo
|
|
91
|
+
USDCn = 'USDCn',
|
|
92
|
+
USDe = 'USDe',
|
|
93
|
+
USDB = 'USDB', // Blast native stablecoin
|
|
94
|
+
FRAX = 'FRAX', // Fraxtal stablecoin
|
|
95
|
+
AXLUSDC = 'axlUSDC', // Axelar Wrapped USDC
|
|
96
|
+
FDUSD = 'FDUSD', // First Digital USD
|
|
97
|
+
HONEY = 'HONEY', // Stablecoin on Berachain
|
|
98
|
+
BYUSD = 'BYUSD', // Stablecoin on Berachain
|
|
99
|
+
APEUSD = 'APEUSD', // Stablecoin on ApeChain
|
|
100
|
+
FEUSD = 'FEUSD', // Stablecoin on HyperEVM
|
|
101
|
+
USDT0 = 'USDT0', // Bridged USDT offered by LayerZero
|
|
102
|
+
USDF = 'USDF', // Stablecoin on Flow: USD Flow
|
|
103
|
+
USDm = 'USDm', // Stablecoin on MegaETH: MegaUSD
|
|
104
|
+
USD1 = 'USD1', // World Liberty Financial USD
|
|
105
|
+
PathUSD = 'PathUSD', // Stablecoin on Tempo chain
|
|
106
|
+
frxUSD = 'frxUSD', // Stablecoin on Fraxtal chain
|
|
107
|
+
EURC = 'EURC', // Stablecoin for Euro
|
|
108
|
+
USDG = 'USDG', // Global Dollar stablecoin on Outlaw chain
|
|
109
|
+
|
|
110
|
+
// Other tokens
|
|
111
|
+
WBTC = 'WBTC',
|
|
112
|
+
WETH = 'WETH',
|
|
113
|
+
LINK = 'LINK', // Chainlink Token
|
|
114
|
+
SUSHI = 'SUSHI',
|
|
115
|
+
DODO = 'DODO',
|
|
116
|
+
MCB = 'MCB',
|
|
117
|
+
CELR = 'CELR',
|
|
118
|
+
IF = 'IF',
|
|
119
|
+
RUNE = 'RUNE',
|
|
120
|
+
WMNT = 'WMNT', // Wrapped MNT Token
|
|
121
|
+
frxETH = 'frxETH',
|
|
122
|
+
wfrxETH = 'wfrxETH', // Wrapped frxETH Token
|
|
123
|
+
WSEI = 'WSEI', // Wrapped SEI Token
|
|
124
|
+
WG = 'WG', // Wrapped G Token on Gravity chain
|
|
125
|
+
WIMX = 'WIMX', // Wrapped IMX Token
|
|
126
|
+
WPOL = 'WPOL', // Wrapped POL Token
|
|
127
|
+
WKAIA = 'WKAIA', // Wrapped KAIA Token
|
|
128
|
+
WOKB = 'WOKB', // Wrapped OKB Token
|
|
129
|
+
WBNB = 'WBNB', // Wrapped BNB Token
|
|
130
|
+
WCRO = 'WCRO', // Wrapped CRO Token
|
|
131
|
+
WBERA = 'WBERA', // Wrapped BERA Token
|
|
132
|
+
wS = 'wS', // Wrapped Sonic Token
|
|
133
|
+
WAPE = 'WAPE', // Wrapped ApeCoin
|
|
134
|
+
WXTZ = 'WXTZ', // Etherlink Wrapped Native
|
|
135
|
+
WHYPE = 'WHYPE', // HyperEVM Wrapped Native
|
|
136
|
+
WXDC = 'WXDC', // XDC Wrapped Native
|
|
137
|
+
WVIC = 'WVIC', // Viction Wrapped Native
|
|
138
|
+
WFLR = 'WFLR', // Flare Wrapped Native
|
|
139
|
+
WVAN = 'WVAN', // Vana Wrapped Native
|
|
140
|
+
WRON = 'WRON', // Ronin Wrapped Native
|
|
141
|
+
WPLU = 'WPLUME', // Plume Wrapped Native
|
|
142
|
+
WNIBI = 'WNIBI', // Nibiru Wrapped Native
|
|
143
|
+
WFRAX = 'WFRAX', // Fraxtal Wrapped Native
|
|
144
|
+
WXPL = 'WXPL', // Plasma Wrapped Native
|
|
145
|
+
WFLOW = 'WFLOW', // Flow Wrapped Native
|
|
146
|
+
WMON = 'WMON', // Monad Wrapped Native
|
|
147
|
+
pBTC = 'pBTC', // Botanix Pegged Bitcoin — deployed on STA / TLO / ETH / BSC, not Botanix-only
|
|
148
|
+
WTLOS = 'WTLOS', // Telos Wrapped Native
|
|
149
|
+
W0G = 'W0G', // 0G Wrapped Native
|
|
150
|
+
cirBTC = 'cirBTC', // Arc Circulating BTC
|
|
151
|
+
WINJ = 'WINJ', // Injective Wrapped Native
|
|
152
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ChainId } from '../chains/base.js'
|
|
2
|
+
import type { CoinKey } from './base.js'
|
|
3
|
+
|
|
4
|
+
export type VerificationStatus = 'verified' | 'unverified' | 'flagged'
|
|
5
|
+
|
|
6
|
+
export type VerificationStatusBreakdown = {
|
|
7
|
+
provider: string
|
|
8
|
+
result: VerificationStatus
|
|
9
|
+
providerResult?: string
|
|
10
|
+
reason?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BaseToken {
|
|
14
|
+
chainId: ChainId
|
|
15
|
+
address: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface StaticToken extends BaseToken {
|
|
19
|
+
symbol: string
|
|
20
|
+
decimals: number
|
|
21
|
+
name: string
|
|
22
|
+
coinKey?: CoinKey
|
|
23
|
+
logoURI?: string
|
|
24
|
+
tags?: TokenTag[]
|
|
25
|
+
verificationStatus?: VerificationStatus
|
|
26
|
+
verificationStatusBreakdown?: VerificationStatusBreakdown[]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Token extends StaticToken {
|
|
30
|
+
priceUSD: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TokenExtended extends Token {
|
|
34
|
+
marketCapUSD?: number | null
|
|
35
|
+
volumeUSD24H?: number | null
|
|
36
|
+
fdvUSD?: number | null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TokenAmount extends Token {
|
|
40
|
+
amount?: bigint
|
|
41
|
+
blockNumber?: bigint
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TokenAmountExtended extends TokenExtended, TokenAmount {}
|
|
45
|
+
|
|
46
|
+
export interface Coin {
|
|
47
|
+
key: CoinKey
|
|
48
|
+
name: string
|
|
49
|
+
logoURI: string
|
|
50
|
+
verified: boolean
|
|
51
|
+
chains: {
|
|
52
|
+
[ChainId: string]: StaticToken
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export enum TokenTag {
|
|
57
|
+
STABLECOIN = 'stablecoin',
|
|
58
|
+
MAJOR_ASSET = 'major_asset',
|
|
59
|
+
RWA = 'rwa',
|
|
60
|
+
// Legacy tags
|
|
61
|
+
SUPERTOKEN = 'supertoken',
|
|
62
|
+
TESTNET = 'testnet',
|
|
63
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hex-encoded string (e.g. `0xabc...`).
|
|
3
|
+
*/
|
|
4
|
+
export type Hex = `0x${string}`
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 20-byte Ethereum address as a hex string.
|
|
8
|
+
*/
|
|
9
|
+
export type Address = `0x${string}`
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 32-byte hash as a hex string.
|
|
13
|
+
*/
|
|
14
|
+
export type Hash = `0x${string}`
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* EIP-712 typed-data domain separator.
|
|
18
|
+
* @link https://eips.ethereum.org/EIPS/eip-712
|
|
19
|
+
*/
|
|
20
|
+
export type TypedDataDomain = {
|
|
21
|
+
chainId?: number | bigint | undefined
|
|
22
|
+
name?: string | undefined
|
|
23
|
+
salt?: Hex | undefined
|
|
24
|
+
verifyingContract?: Address | undefined
|
|
25
|
+
version?: string | undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* EIP-712 typed-data parameter (single field in a struct).
|
|
30
|
+
*/
|
|
31
|
+
export type TypedDataParameter = {
|
|
32
|
+
name: string
|
|
33
|
+
type: string
|
|
34
|
+
}
|