@gibs/bridge-sdk 1.12.0 → 1.13.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/LICENSE +15 -0
- package/README.md +234 -432
- package/dist/abis.d.ts +1 -0
- package/dist/bridge-limits.d.ts +103 -0
- package/dist/bridge-limits.js +84 -0
- package/dist/chain-info.d.ts +169 -0
- package/dist/chain-info.js +410 -0
- package/dist/chain-names.d.ts +160 -0
- package/dist/chain-names.js +200 -0
- package/dist/chains.d.ts +65 -0
- package/dist/chains.js +284 -0
- package/dist/config.d.ts +216 -0
- package/dist/config.js +493 -0
- package/dist/consolidated-quote.d.ts +554 -0
- package/dist/consolidated-quote.js +773 -0
- package/dist/destination-calldata.d.ts +118 -0
- package/dist/destination-calldata.js +152 -0
- package/dist/ecosystems.d.ts +217 -0
- package/dist/ecosystems.js +288 -0
- package/dist/fee-type.d.ts +10 -0
- package/dist/fee-type.js +9 -0
- package/dist/hyperliquid-execution.d.ts +152 -0
- package/dist/hyperliquid-execution.js +168 -0
- package/dist/image-links.d.ts +117 -0
- package/dist/image-links.js +142 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/lifi-execution-guard.d.ts +199 -0
- package/dist/lifi-execution-guard.js +400 -0
- package/dist/near-intents-conformance.d.ts +85 -0
- package/dist/near-intents-conformance.js +329 -0
- package/dist/near-intents-route.d.ts +47 -0
- package/dist/near-intents-route.js +265 -0
- package/dist/near-intents.d.ts +524 -0
- package/dist/near-intents.js +1055 -0
- package/dist/origin-deposit.d.ts +326 -0
- package/dist/origin-deposit.js +68 -0
- package/dist/pre-quote.d.ts +198 -0
- package/dist/pre-quote.js +175 -0
- package/dist/prices.d.ts +107 -0
- package/dist/prices.js +162 -0
- package/dist/providers.d.ts +221 -0
- package/dist/providers.js +157 -0
- package/dist/quote-fees.d.ts +102 -0
- package/dist/quote-fees.js +195 -0
- package/dist/referral.d.ts +77 -0
- package/dist/referral.js +72 -0
- package/dist/relay-currencies.d.ts +47 -0
- package/dist/relay-currencies.js +89 -0
- package/dist/relay-quote.d.ts +301 -0
- package/dist/relay-quote.js +983 -0
- package/dist/route-steps.d.ts +138 -0
- package/dist/route-steps.js +305 -0
- package/dist/routing/amounts.d.ts +80 -0
- package/dist/routing/amounts.js +120 -0
- package/dist/routing/candidate-route.d.ts +43 -0
- package/dist/routing/candidate-route.js +45 -0
- package/dist/routing/candidate.d.ts +237 -0
- package/dist/routing/candidate.js +96 -0
- package/dist/routing/carriers/ask-answer.d.ts +58 -0
- package/dist/routing/carriers/ask-answer.js +1 -0
- package/dist/routing/carriers/omnibridge.d.ts +137 -0
- package/dist/routing/carriers/omnibridge.js +419 -0
- package/dist/routing/carriers/pulsex.d.ts +111 -0
- package/dist/routing/carriers/pulsex.js +404 -0
- package/dist/routing/carriers/wrap.d.ts +25 -0
- package/dist/routing/carriers/wrap.js +115 -0
- package/dist/routing/composed-route-quality.d.ts +103 -0
- package/dist/routing/composed-route-quality.js +108 -0
- package/dist/routing/entry-chain-anchor.d.ts +88 -0
- package/dist/routing/entry-chain-anchor.js +55 -0
- package/dist/routing/format.d.ts +31 -0
- package/dist/routing/format.js +58 -0
- package/dist/routing/index.d.ts +34 -0
- package/dist/routing/index.js +42 -0
- package/dist/routing/producers.d.ts +770 -0
- package/dist/routing/producers.js +1564 -0
- package/dist/routing/providers.d.ts +26 -0
- package/dist/routing/providers.js +38 -0
- package/dist/routing/route-data.d.ts +355 -0
- package/dist/routing/route-data.js +1 -0
- package/dist/routing/search/compose.d.ts +168 -0
- package/dist/routing/search/compose.js +98 -0
- package/dist/routing/search/graph.d.ts +639 -0
- package/dist/routing/search/graph.js +445 -0
- package/dist/routing/search/plan-route-data.d.ts +244 -0
- package/dist/routing/search/plan-route-data.js +767 -0
- package/dist/routing/search/score.d.ts +324 -0
- package/dist/routing/search/score.js +400 -0
- package/dist/routing/usd-value.d.ts +17 -0
- package/dist/routing/usd-value.js +25 -0
- package/dist/settings.d.ts +692 -0
- package/dist/settings.js +909 -0
- package/dist/ton-execution.d.ts +117 -0
- package/dist/ton-execution.js +247 -0
- package/dist/tron-execution.d.ts +146 -0
- package/dist/tron-execution.js +239 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.js +1 -0
- package/package.json +203 -23
- package/src/chain-info.test.ts +0 -968
- package/src/chain-info.ts +0 -498
- package/src/chains.test.ts +0 -123
- package/src/chains.ts +0 -88
- package/src/config.test.ts +0 -679
- package/src/config.ts +0 -500
- package/src/fee-type.test.ts +0 -45
- package/src/fee-type.ts +0 -14
- package/src/image-links.test.ts +0 -160
- package/src/image-links.ts +0 -65
- package/src/index.ts +0 -8
- package/src/settings.test.ts +0 -2754
- package/src/settings.ts +0 -875
- package/src/types.ts +0 -48
- package/tsconfig.json +0 -17
- package/vitest.config.ts +0 -13
- /package/{src/abis.ts → dist/abis.js} +0 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { type ComposedPathBasis, type HopCarrier, type RoutePlan } from './graph.js';
|
|
2
|
+
/**
|
|
3
|
+
* What a quote's CLAIMED duration costs it in the ranking, as a share of the
|
|
4
|
+
* transfer in parts per million. It ramps linearly to
|
|
5
|
+
* {@link WAIT_PENALTY_PPM_PER_MINUTE} at {@link WAIT_PENALTY_CEILING_SECONDS}
|
|
6
|
+
* and stops there.
|
|
7
|
+
*
|
|
8
|
+
* THE DURATION IS A CLAIM AND IS TREATED AS ONE. The route that prompted
|
|
9
|
+
* this ran about seventy-five times its provider's own estimate, so the
|
|
10
|
+
* figure cannot be trusted as a measurement of anything. It is still the
|
|
11
|
+
* only signal there is, and it is informative in one direction: a provider
|
|
12
|
+
* that says it will take longer is not going to turn out faster, and a
|
|
13
|
+
* claimed wait understates the real one far more often than it overstates
|
|
14
|
+
* it. So the penalty is used to demand a real price advantage before ANY
|
|
15
|
+
* extra claimed wait is accepted — never to predict a settlement time, and
|
|
16
|
+
* never to produce a number shown to the reader. Nothing on screen is
|
|
17
|
+
* adjusted by this; only the order is.
|
|
18
|
+
*
|
|
19
|
+
* The ceiling is what keeps the rule from becoming a speed preference. Past
|
|
20
|
+
* a minute the penalty stops growing, so a route that is genuinely worth
|
|
21
|
+
* waiting for still wins on the strength of its price.
|
|
22
|
+
*
|
|
23
|
+
* @param durationSeconds - the provider's own claimed execution duration
|
|
24
|
+
* @returns the penalty as parts per million of the transfer, 0 for a missing claim
|
|
25
|
+
*/
|
|
26
|
+
export declare const waitPenaltyPpm: (durationSeconds: number | null | undefined) => number;
|
|
27
|
+
/**
|
|
28
|
+
* The share of the transfer charged for EACH reader action beyond the first,
|
|
29
|
+
* in parts per million — see {@link signaturePenaltyUsd}.
|
|
30
|
+
*
|
|
31
|
+
* THIS IS A PROPOSAL, NOT A MEASUREMENT. Unlike {@link WAIT_PENALTY_PPM_PER_MINUTE},
|
|
32
|
+
* which is calibrated against two logged, live crossings, no comparable
|
|
33
|
+
* signature-count measurement exists yet. 2,500 ppm (0.25% of the delivered
|
|
34
|
+
* amount) is a starting point sized to sit BELOW the wait penalty's own
|
|
35
|
+
* ceiling (5,000 ppm) — a second signature should cost less than the worst
|
|
36
|
+
* wait penalty already accepted, since a signature is a moment of the
|
|
37
|
+
* reader's attention, not twenty-five minutes of theirs. The owner is meant
|
|
38
|
+
* to calibrate this against real reader behavior once it ships.
|
|
39
|
+
*/
|
|
40
|
+
export declare const SIGNATURE_PENALTY_PPM = 2500;
|
|
41
|
+
/**
|
|
42
|
+
* SUPERSEDED FOR THE SEARCH ENGINE'S OWN RANKING — see
|
|
43
|
+
* {@link compareRoutePlansByGasAdjustedDeliveredAmount}, below, which
|
|
44
|
+
* `waves.ts` now uses in place of {@link compareRoutePlansByScoreAdjustedDeliveredAmount}
|
|
45
|
+
* once real gas data exists. A flat parts-per-million guess cannot tell a
|
|
46
|
+
* cheap chain from an expensive one, and it charges nothing for gas at all —
|
|
47
|
+
* the owner's own instruction: "it's custom for each provider ... gather the
|
|
48
|
+
* logic around how much a user is about to be charged." This constant, and
|
|
49
|
+
* {@link GAS_TOPUP_PENALTY_PPM} below, are KEPT UNCHANGED because
|
|
50
|
+
* {@link scoreRoutePlan} and every existing United States dollar-based
|
|
51
|
+
* caller of it (`plan-route-data.ts`, `producers.ts`, the user interface's
|
|
52
|
+
* own single-candidate scoring) still read them — migrating those callers to
|
|
53
|
+
* a real gas-cost model is FLAGGED HERE as follow-up work outside this
|
|
54
|
+
* module's own owned scope, not done silently in this change.
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* The minimum a signature is ever charged, in United States dollars — see
|
|
58
|
+
* {@link signaturePenaltyUsd}.
|
|
59
|
+
*
|
|
60
|
+
* THIS IS A PROPOSAL, NOT A MEASUREMENT. Without a floor, {@link SIGNATURE_PENALTY_PPM}
|
|
61
|
+
* charges almost nothing on a small transfer (0.25% of ten dollars is two and
|
|
62
|
+
* a half cents), which would let a route add a whole extra signature for a
|
|
63
|
+
* fraction of a cent. One dollar is a guess at what a reader's own time and
|
|
64
|
+
* attention for one extra wallet prompt is worth, floored so it cannot be
|
|
65
|
+
* bought away by a large delivered amount either — the floor and the rate are
|
|
66
|
+
* a `max`, so whichever is larger applies. The owner is meant to calibrate
|
|
67
|
+
* this once real reader behavior is observed.
|
|
68
|
+
*/
|
|
69
|
+
export declare const SIGNATURE_PENALTY_FLOOR_USD = 1;
|
|
70
|
+
/**
|
|
71
|
+
* The share of the transfer charged for EACH intermediate chain where the
|
|
72
|
+
* reader holds no gas, in parts per million — see {@link gasTopUpPenaltyUsd}.
|
|
73
|
+
*
|
|
74
|
+
* THIS IS A PROPOSAL, NOT A MEASUREMENT. Sized larger than
|
|
75
|
+
* {@link SIGNATURE_PENALTY_PPM} because a gas top-up is not a moment of
|
|
76
|
+
* attention like a signature — it is a SEPARATE errand: acquire the
|
|
77
|
+
* intermediate chain's native coin, by another bridge or a purchase, before
|
|
78
|
+
* the planned hop can even be signed. That errand risks stranding the
|
|
79
|
+
* transfer mid-route if the reader does not complete it, which the
|
|
80
|
+
* "stranded funds" risk in the route-search design's section 10 names
|
|
81
|
+
* directly. The owner is meant to calibrate this once real reader behavior
|
|
82
|
+
* is observed.
|
|
83
|
+
*/
|
|
84
|
+
export declare const GAS_TOPUP_PENALTY_PPM = 10000;
|
|
85
|
+
/**
|
|
86
|
+
* The minimum a gas top-up is ever charged, in United States dollars — see
|
|
87
|
+
* {@link gasTopUpPenaltyUsd}.
|
|
88
|
+
*
|
|
89
|
+
* THIS IS A PROPOSAL, NOT A MEASUREMENT. Set higher than
|
|
90
|
+
* {@link SIGNATURE_PENALTY_FLOOR_USD} for the same reason
|
|
91
|
+
* {@link GAS_TOPUP_PENALTY_PPM} is: this penalty stands in for a separate
|
|
92
|
+
* errand with its own real cost (buying gas on a chain the reader was not
|
|
93
|
+
* already using), not a moment of attention. The owner is meant to calibrate
|
|
94
|
+
* this once real reader behavior is observed.
|
|
95
|
+
*/
|
|
96
|
+
export declare const GAS_TOPUP_PENALTY_FLOOR_USD = 3;
|
|
97
|
+
/**
|
|
98
|
+
* What {@link scoreRoutePlan} needs to rank one priced route plan.
|
|
99
|
+
*
|
|
100
|
+
* EVERY FIELD IS A PLAIN, ALREADY-COMPUTED VALUE — never a {@link RoutePlan}
|
|
101
|
+
* itself. A route plan (`graph.ts`) names the STRUCTURE of a path; it carries
|
|
102
|
+
* no dollar price and no wallet gas balance, because pricing needs a live
|
|
103
|
+
* quote or a price feed and a gas balance needs a connected wallet, neither
|
|
104
|
+
* of which this pure module has access to. The caller — Phase 1's
|
|
105
|
+
* `plan-route-data.ts`, or today's `producers.ts` once it adopts this
|
|
106
|
+
* function — is responsible for turning a priced `RoutePlan` into these
|
|
107
|
+
* fields:
|
|
108
|
+
*
|
|
109
|
+
* - {@link deliveredUsd}, {@link paidUsd}, {@link outsideFeesUsd} come from
|
|
110
|
+
* the same valuation `producers.ts` already performs per candidate
|
|
111
|
+
* (`candidateDeliveredUsd`, `candidatePaidUsd`, `candidateOutsideFeesUsd`),
|
|
112
|
+
* generalized to the plan's LAST hop and FIRST hop respectively;
|
|
113
|
+
* - {@link legClaimedDurationsSeconds} is one entry per hop, in hop order,
|
|
114
|
+
* holding each hop's own carrier-claimed execution duration;
|
|
115
|
+
* - {@link readerActionCount} is `plan.signatures.length` for a
|
|
116
|
+
* `RoutePlan` built by `graph.ts`'s `groupHopsBySignature` — that
|
|
117
|
+
* function's own doc is explicit that a pay-by-hand hop starts a group
|
|
118
|
+
* exactly like a signing hop does, which is what makes the group COUNT
|
|
119
|
+
* already equal the reader ACTION count design section 4 calls `A`;
|
|
120
|
+
* - {@link gaslessIntermediateChainCount} is `G` from design section 4 — the
|
|
121
|
+
* count of intermediate chains where the connected account holds no gas —
|
|
122
|
+
* which needs a multi-chain wallet balance read this module cannot
|
|
123
|
+
* perform itself.
|
|
124
|
+
*/
|
|
125
|
+
export type RouteScoreInputs = {
|
|
126
|
+
/**
|
|
127
|
+
* What the route delivers at the destination, in United States dollars —
|
|
128
|
+
* `D` in the route-search design's section 4 formula. Generalizes
|
|
129
|
+
* `candidateDeliveredUsd` (`../producers.js`) from one candidate to a
|
|
130
|
+
* plan's final hop.
|
|
131
|
+
*/
|
|
132
|
+
readonly deliveredUsd: number;
|
|
133
|
+
/**
|
|
134
|
+
* What the reader pays for the route's origin leg, in United States
|
|
135
|
+
* dollars — `P` in the design formula. Generalizes `candidatePaidUsd`
|
|
136
|
+
* (`../producers.js`, there private as `candidatePaidUsd`) to a plan's
|
|
137
|
+
* first hop.
|
|
138
|
+
*/
|
|
139
|
+
readonly paidUsd: number;
|
|
140
|
+
/**
|
|
141
|
+
* Every charge levied outside the origin amount, in United States dollars
|
|
142
|
+
* — `F` in the design formula. Generalizes `candidateOutsideFeesUsd`
|
|
143
|
+
* (`../producers.js`).
|
|
144
|
+
*/
|
|
145
|
+
readonly outsideFeesUsd: number;
|
|
146
|
+
/**
|
|
147
|
+
* Each hop's own carrier-claimed execution duration, in seconds, in hop
|
|
148
|
+
* order — one entry per hop in the plan, whatever the hop's carrier or
|
|
149
|
+
* signature group. `null`/`undefined` entries are hops with no claimed
|
|
150
|
+
* duration, exactly as {@link waitPenaltyPpm} already treats a missing
|
|
151
|
+
* claim: zero penalty, not the worst case.
|
|
152
|
+
*/
|
|
153
|
+
readonly legClaimedDurationsSeconds: readonly (number | null | undefined)[];
|
|
154
|
+
/**
|
|
155
|
+
* How many separate actions the reader performs to carry out this plan —
|
|
156
|
+
* `A` in the design formula. A signature and a pay-by-hand deposit each
|
|
157
|
+
* count as one action; see this type's own doc for how to derive it from a
|
|
158
|
+
* `RoutePlan`.
|
|
159
|
+
*/
|
|
160
|
+
readonly readerActionCount: number;
|
|
161
|
+
/**
|
|
162
|
+
* How many of the plan's intermediate chains the connected account holds
|
|
163
|
+
* no gas on — `G` in the design formula.
|
|
164
|
+
*/
|
|
165
|
+
readonly gaslessIntermediateChainCount: number;
|
|
166
|
+
/**
|
|
167
|
+
* PHASE 3 — what grounds {@link deliveredUsd}: the plan's own
|
|
168
|
+
* {@link ComposedPathBasis} (`graph.ts`), the WORST basis across every hop
|
|
169
|
+
* composed — build it with `planComposedBasis` (`graph.ts`) rather than by
|
|
170
|
+
* hand. REQUIRED, not optional: a caller building `RouteScoreInputs` from a
|
|
171
|
+
* `RoutePlan` always has this, and letting it be omitted would silently
|
|
172
|
+
* reopen the exact defect PHASE 3 closes elsewhere in this search — a
|
|
173
|
+
* `deliveredUsd` computed from an `'unpriced'` figure (see
|
|
174
|
+
* `EstimateBasis`'s own doc, `graph.ts`: "a bare decimal rescale... with no
|
|
175
|
+
* value behind it") scored and compared as if it meant something. See
|
|
176
|
+
* {@link scoreRoutePlan}'s own doc for what it does with this.
|
|
177
|
+
*/
|
|
178
|
+
readonly basis: ComposedPathBasis;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Orders two RANKABLE plans (both pass `graph.ts`'s `planIsRankable`) by
|
|
182
|
+
* their {@link signaturePenaltyAdjustedDeliveredAmount} rather than their raw
|
|
183
|
+
* `deliveredAmount` — the STRUCTURAL counterpart to `graph.ts`'s
|
|
184
|
+
* {@link @gibs/bridge-sdk/routing/search/graph!compareRoutePlansByDeliveredAmount},
|
|
185
|
+
* reusing every one of that function's rules (rankable beats unrankable,
|
|
186
|
+
* `compareUnrankablePlans`'s tiebreak among two unrankable plans) and adding
|
|
187
|
+
* exactly one more: within two RANKABLE plans, a plan needing more
|
|
188
|
+
* signatures than another must clear {@link SIGNATURE_PENALTY_PPM} of
|
|
189
|
+
* "extra" delivered value per extra signature before it is allowed to win,
|
|
190
|
+
* not merely `> 0`.
|
|
191
|
+
*
|
|
192
|
+
* THE DEFECT THIS CLOSES. `SIGNATURE_PENALTY_PPM` and `GAS_TOPUP_PENALTY_PPM`
|
|
193
|
+
* existed in this module as constants `scoreRoutePlan` charges — but nothing
|
|
194
|
+
* in the actual ranking path called `scoreRoutePlan` at all:
|
|
195
|
+
* `enumerate.ts`'s cut, `waves.ts`'s between-wave re-ranking, and
|
|
196
|
+
* `useRouteSearch.ts`'s final sort all imported `graph.ts`'s plain
|
|
197
|
+
* delivered-amount comparator directly, so a route needing a second
|
|
198
|
+
* signature for a fractional gain (measured: 0.006% more, needing one more
|
|
199
|
+
* wallet prompt) always won outright. Sorting on
|
|
200
|
+
* {@link signaturePenaltyAdjustedDeliveredAmount} instead is what makes that
|
|
201
|
+
* lose to the one-signature alternative: the extra signature's proportional
|
|
202
|
+
* cost (0.25% per {@link SIGNATURE_PENALTY_PPM}) outweighs a 0.006% edge by
|
|
203
|
+
* roughly forty times.
|
|
204
|
+
*
|
|
205
|
+
* WHY NOT `GAS_TOPUP_PENALTY_PPM` HERE TOO. A gasless-intermediate-chain
|
|
206
|
+
* charge needs to know whether the connected account holds gas on a chain in
|
|
207
|
+
* the middle of the plan — a live wallet balance read `RoutePlan` has no way
|
|
208
|
+
* to name. Applying it here would require guessing, which this comparator
|
|
209
|
+
* refuses to do; `GAS_TOPUP_PENALTY_PPM` is still applied wherever a caller
|
|
210
|
+
* has that balance and reaches for `scoreRoutePlan` directly (`plan-route-data.ts`
|
|
211
|
+
* onward). Left as an OWNER DECISION whether a structural ranking site should
|
|
212
|
+
* ever get gas-balance context of its own.
|
|
213
|
+
*
|
|
214
|
+
* @param a - one plan being compared
|
|
215
|
+
* @param b - the other
|
|
216
|
+
* @returns negative when `a` ranks ahead of `b`, positive when `b` ranks
|
|
217
|
+
* ahead of `a`, zero when they tie
|
|
218
|
+
*/
|
|
219
|
+
export declare const compareRoutePlansByScoreAdjustedDeliveredAmount: (a: RoutePlan, b: RoutePlan) => number;
|
|
220
|
+
export declare const scoreRoutePlan: (inputs: RouteScoreInputs) => number;
|
|
221
|
+
/**
|
|
222
|
+
* What one signature (one wallet prompt, or one pay-by-hand deposit that
|
|
223
|
+
* still needs the chain's own gas to have been acquired first) costs beyond
|
|
224
|
+
* what the route's own steps already net out — already converted into the
|
|
225
|
+
* PLAN'S OWN destination token's base units, so it can be subtracted straight
|
|
226
|
+
* from a `RoutePlan`'s last-hop `deliveredAmount` alongside every other
|
|
227
|
+
* signature's own cost.
|
|
228
|
+
*/
|
|
229
|
+
export type GasCostQuote = {
|
|
230
|
+
/**
|
|
231
|
+
* Gas units × gas price × native price, for the chain this signature
|
|
232
|
+
* broadcasts on, converted into the destination token. Charged for EVERY
|
|
233
|
+
* signature, never only the extra ones — the owner's own instruction: "gas
|
|
234
|
+
* for every signature," not a discount for the first one the way
|
|
235
|
+
* {@link SIGNATURE_PENALTY_PPM} discounts only signatures beyond the first.
|
|
236
|
+
*/
|
|
237
|
+
readonly gasAmount: bigint;
|
|
238
|
+
/**
|
|
239
|
+
* The cost of acquiring native gas first, when the signer holds none on
|
|
240
|
+
* this chain — a small aggregator or PulseX step to native, or a
|
|
241
|
+
* provider's own refuel field. Zero when no top-up is needed.
|
|
242
|
+
*
|
|
243
|
+
* NEVER A REASON TO WITHHOLD THE ROUTE. The owner: "it should be scored, if
|
|
244
|
+
* the user needs gas, then they should get it" — a gasless intermediate
|
|
245
|
+
* chain is modelled as ONE MORE CHARGE against the route, exactly like the
|
|
246
|
+
* gas itself, never as a refusal or an exclusion from the ranking.
|
|
247
|
+
*/
|
|
248
|
+
readonly refuelAmount: bigint;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Supplies the REAL cost of signing one step, for the chain it broadcasts on
|
|
252
|
+
* and the carrier performing it — gas units × gas price × native price,
|
|
253
|
+
* converted into the plan's own destination token, plus a refuel cost when
|
|
254
|
+
* the signer holds no native gas there yet. PLUGGABLE ON PURPOSE: this
|
|
255
|
+
* module has no gas-price oracle, no native-token price feed, and no wallet
|
|
256
|
+
* balance read of its own — the caller (which has all three, and the plan's
|
|
257
|
+
* own destination-token price to convert into) is the one place that can
|
|
258
|
+
* answer this, exactly as `waves.ts`'s own `AskEdge` is caller-supplied for
|
|
259
|
+
* the same reason. `sender` is the {@link HopCarrier} performing the
|
|
260
|
+
* signature's own FIRST hop — structurally the same vocabulary
|
|
261
|
+
* `@gibs/quotes`'s `CarrierSender`/`Carrier.id` already carry, passed as a
|
|
262
|
+
* plain string here (not imported) for the same circular-package-dependency
|
|
263
|
+
* reason `search/carriers/omnibridge.ts`'s own head doc explains: this
|
|
264
|
+
* caller-supplied function is free to look the carrier up in its own
|
|
265
|
+
* registry and pick a gas-unit model "per sender kind" from there (an
|
|
266
|
+
* omnibridge entry call, a PulseX swap, and an aggregator's own executed
|
|
267
|
+
* transaction each cost a genuinely different amount of gas).
|
|
268
|
+
*
|
|
269
|
+
* @param chainId - the chain this signature is broadcast on — the signing
|
|
270
|
+
* hop's `from.chainId`
|
|
271
|
+
* @param sender - the carrier performing the signature's first hop
|
|
272
|
+
* @returns the signature's real cost, in the plan's destination token's base units
|
|
273
|
+
*/
|
|
274
|
+
export type GasCostFor = (chainId: number, sender: HopCarrier) => GasCostQuote;
|
|
275
|
+
/**
|
|
276
|
+
* A PLACEHOLDER {@link GasCostFor} that charges nothing — preserves the
|
|
277
|
+
* behaviour of ranking on raw delivered amount for a caller that has not yet
|
|
278
|
+
* wired a real gas-price and native-price source. NOT A PRODUCTION DEFAULT:
|
|
279
|
+
* unlike {@link WAIT_PENALTY_PPM_PER_MINUTE}'s two logged, live crossings, no
|
|
280
|
+
* per-chain gas figure here would be a measurement — it would be a guess
|
|
281
|
+
* dressed up as one, exactly what Rule 13 of this codebase's own working
|
|
282
|
+
* principles warns against. A host should always supply its own
|
|
283
|
+
* {@link GasCostFor} once it has gas-price and native-price feeds to build
|
|
284
|
+
* one from; this export exists only so `waves.ts`'s own default comparator
|
|
285
|
+
* has something total to call when nobody has.
|
|
286
|
+
*/
|
|
287
|
+
export declare const zeroGasCostFor: GasCostFor;
|
|
288
|
+
/**
|
|
289
|
+
* `plan`'s last-hop `deliveredAmount`, minus the REAL cost of every
|
|
290
|
+
* signature it needs — `gasCostFor` charged ONCE per signature group
|
|
291
|
+
* (`plan.signatures`, built by `groupHopsBySignature`), on the chain and
|
|
292
|
+
* carrier of that group's FIRST hop, which is the hop the reader actually
|
|
293
|
+
* signs (or deposits by hand) for that group. Floored at zero: a plan whose
|
|
294
|
+
* gas costs exceed its own delivered amount is worth nothing, never negative.
|
|
295
|
+
*
|
|
296
|
+
* @param plan - the plan to charge
|
|
297
|
+
* @param gasCostFor - supplies each signature's real cost; see {@link GasCostFor}
|
|
298
|
+
* @returns the gas-adjusted delivered amount, in the plan's destination token's base units
|
|
299
|
+
*/
|
|
300
|
+
export declare const gasAdjustedDeliveredAmount: (plan: RoutePlan, gasCostFor: GasCostFor) => bigint;
|
|
301
|
+
/**
|
|
302
|
+
* Orders two plans by {@link gasAdjustedDeliveredAmount} rather than raw
|
|
303
|
+
* `deliveredAmount` or {@link signaturePenaltyAdjustedDeliveredAmount}'s flat
|
|
304
|
+
* ppm guess — the structural ranking `waves.ts` uses once Round A/B have real
|
|
305
|
+
* gas data to charge, replacing {@link SIGNATURE_PENALTY_PPM}/
|
|
306
|
+
* {@link GAS_TOPUP_PENALTY_PPM} at that one site per the owner's own
|
|
307
|
+
* instruction (see both constants' updated docs). A CURRIED FACTORY, not a
|
|
308
|
+
* plain comparator, because the real cost this needs — {@link GasCostFor} —
|
|
309
|
+
* is caller-supplied and cannot be a module-level default the way
|
|
310
|
+
* {@link compareRoutePlansByScoreAdjustedDeliveredAmount} is; call it once
|
|
311
|
+
* per search with the caller's own `gasCostFor`, then pass the returned
|
|
312
|
+
* comparator wherever a plan-to-plan comparison is needed.
|
|
313
|
+
*
|
|
314
|
+
* KEEPS THE SAME RANKABLE-BEFORE-UNRANKABLE RULE `compareRoutePlansByScoreAdjustedDeliveredAmount`
|
|
315
|
+
* ALREADY APPLIES, unchanged, including its `compareRoutePlansByDeliveredAmount`
|
|
316
|
+
* tiebreak among two unrankable plans — only the tiebreak among two RANKABLE
|
|
317
|
+
* plans changes, from a proportional signature-count discount to the route's
|
|
318
|
+
* own real charges.
|
|
319
|
+
*
|
|
320
|
+
* @param gasCostFor - supplies each signature's real cost; see {@link GasCostFor}
|
|
321
|
+
* @returns a comparator: negative when `a` ranks ahead of `b`, positive when
|
|
322
|
+
* `b` ranks ahead of `a`, zero when they tie
|
|
323
|
+
*/
|
|
324
|
+
export declare const compareRoutePlansByGasAdjustedDeliveredAmount: (gasCostFor: GasCostFor) => (a: RoutePlan, b: RoutePlan) => number;
|