@anywalletkit/protocol-swap2-kyberswap 0.0.0-stage → 0.1.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 +202 -0
- package/README.md +98 -2
- package/dist/activity.cjs +196 -0
- package/dist/activity.cjs.map +1 -0
- package/dist/activity.d.cts +11 -0
- package/dist/activity.d.ts +11 -0
- package/dist/activity.js +10 -0
- package/dist/activity.js.map +1 -0
- package/dist/chunk-DEWODPQQ.js +430 -0
- package/dist/chunk-DEWODPQQ.js.map +1 -0
- package/dist/chunk-FWC6K553.js +21 -0
- package/dist/chunk-FWC6K553.js.map +1 -0
- package/dist/chunk-PIC4PYGN.js +32 -0
- package/dist/chunk-PIC4PYGN.js.map +1 -0
- package/dist/chunk-WOVGN3FL.js +184 -0
- package/dist/chunk-WOVGN3FL.js.map +1 -0
- package/dist/index.cjs +657 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.cjs +635 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.cts +17 -0
- package/dist/protocol.d.ts +17 -0
- package/dist/protocol.js +10 -0
- package/dist/protocol.js.map +1 -0
- package/dist/provider.cjs +613 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +31 -0
- package/dist/provider.d.ts +31 -0
- package/dist/provider.js +11 -0
- package/dist/provider.js.map +1 -0
- package/dist/router.cjs +204 -0
- package/dist/router.cjs.map +1 -0
- package/dist/router.d.cts +180 -0
- package/dist/router.d.ts +180 -0
- package/dist/router.js +39 -0
- package/dist/router.js.map +1 -0
- package/module.json +33 -0
- package/package.json +87 -3
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { RemotePins, QuoteParams, Quote } from '@anywalletkit/protocol-swap2-core/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* KyberSwap MetaAggregationRouterV2 — the only contract a KyberSwap quote may settle through. This file pins the
|
|
5
|
+
* router and its executor per chain and checks the transaction KyberSwap's build endpoint encoded against the request
|
|
6
|
+
* before anything is approved or sent.
|
|
7
|
+
*
|
|
8
|
+
* The router itself guarantees only that the input comes from the caller and that `dstReceiver` gains at least
|
|
9
|
+
* `minReturnAmount` of `dstToken`; the receiver, the tokens, the minimum, the fee receivers and the flags are all
|
|
10
|
+
* the calldata's (KyberSwap's build endpoint encodes whatever `routeSummary` it is sent, fee entries included).
|
|
11
|
+
* So the calldata is decoded strictly, re-encoded byte for byte, and every field that can move value is compared
|
|
12
|
+
* with the request. The route inside `targetData` is opaque; the router reverts below the minimum.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** MetaAggregationRouterV2 — the same address on every chain KyberSwap serves (docs.kyberswap.com, contracts). */
|
|
16
|
+
declare const KYBER_ROUTER_V2 = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5";
|
|
17
|
+
/** AggregationExecutorProxy — the `callTarget` of every swap the build endpoint encodes. */
|
|
18
|
+
declare const KYBER_EXECUTOR = "0x8F10B468b06c6FD214B65F87778827F7D113f996";
|
|
19
|
+
/** KSAggregationRouterV3: deployed on part of the chains, never returned by the API so far. Refused until decoded. */
|
|
20
|
+
declare const KYBER_ROUTER_V3 = "0x6868d319c8c9a78f7d39dc3602c5c917315132d7";
|
|
21
|
+
/** The router's native-coin sentinel; this SDK uses the zero address. */
|
|
22
|
+
declare const KYBER_NATIVE = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
23
|
+
/**
|
|
24
|
+
* Router build on a chain. `generic`: the 2022 build (18.6 KB) with `swapGeneric` and an owner-managed whitelist — its
|
|
25
|
+
* owner can make the router call any whitelisted contract, so an allowance left on it is exposed to that owner.
|
|
26
|
+
* `lite`: the later build (13.7 KB) without `swapGeneric` and without the whitelist. Both share `swap()`.
|
|
27
|
+
* Read on-chain 2026-11-24 (`eth_getCode`, selectors in the bytecode, `owner()`; how-to-project/kyber-data).
|
|
28
|
+
*/
|
|
29
|
+
type KyberRouterBuild = "generic" | "lite";
|
|
30
|
+
/**
|
|
31
|
+
* Every chain this module quotes on: KyberSwap's `supported-chains` list (active, plus Arc "new" and Elysium
|
|
32
|
+
* "provisional") intersected with the SDK's EVM catalog, each with the router and executor code checked on-chain.
|
|
33
|
+
* `slug` is the API's path segment (a chain id there is a 404).
|
|
34
|
+
*/
|
|
35
|
+
declare const KYBER_CHAINS: Readonly<Record<number, {
|
|
36
|
+
slug: string;
|
|
37
|
+
name: string;
|
|
38
|
+
build: KyberRouterBuild;
|
|
39
|
+
}>>;
|
|
40
|
+
/** The chain entry for an id, never an inherited property. */
|
|
41
|
+
declare function kyberChain(chainId: number): (typeof KYBER_CHAINS)[number] | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Whether a swap may take or pay the chain's native coin: only where the token catalog lists one. Arc's gas token is
|
|
44
|
+
* USDC with 18-decimal native accounting, listed only through its 6-decimal ERC-20 interface, so a native leg there
|
|
45
|
+
* would carry amounts 10^12 off the catalog's USDC; it is refused and the ERC-20 swaps instead.
|
|
46
|
+
*/
|
|
47
|
+
declare function kyberNativeSwaps(chainId: number): boolean;
|
|
48
|
+
/** `swap(SwapExecutionParams)` — the one router entry point this module accepts. */
|
|
49
|
+
declare const KYBER_ROUTER_ABI: readonly [{
|
|
50
|
+
readonly name: "swap";
|
|
51
|
+
readonly type: "function";
|
|
52
|
+
readonly stateMutability: "payable";
|
|
53
|
+
readonly inputs: readonly [{
|
|
54
|
+
readonly type: "tuple";
|
|
55
|
+
readonly components: readonly [{
|
|
56
|
+
readonly type: "address";
|
|
57
|
+
readonly name: "callTarget";
|
|
58
|
+
}, {
|
|
59
|
+
readonly type: "address";
|
|
60
|
+
readonly name: "approveTarget";
|
|
61
|
+
}, {
|
|
62
|
+
readonly type: "bytes";
|
|
63
|
+
readonly name: "targetData";
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "desc";
|
|
66
|
+
readonly type: "tuple";
|
|
67
|
+
readonly components: readonly [{
|
|
68
|
+
readonly type: "address";
|
|
69
|
+
readonly name: "srcToken";
|
|
70
|
+
}, {
|
|
71
|
+
readonly type: "address";
|
|
72
|
+
readonly name: "dstToken";
|
|
73
|
+
}, {
|
|
74
|
+
readonly type: "address[]";
|
|
75
|
+
readonly name: "srcReceivers";
|
|
76
|
+
}, {
|
|
77
|
+
readonly type: "uint256[]";
|
|
78
|
+
readonly name: "srcAmounts";
|
|
79
|
+
}, {
|
|
80
|
+
readonly type: "address[]";
|
|
81
|
+
readonly name: "feeReceivers";
|
|
82
|
+
}, {
|
|
83
|
+
readonly type: "uint256[]";
|
|
84
|
+
readonly name: "feeAmounts";
|
|
85
|
+
}, {
|
|
86
|
+
readonly type: "address";
|
|
87
|
+
readonly name: "dstReceiver";
|
|
88
|
+
}, {
|
|
89
|
+
readonly type: "uint256";
|
|
90
|
+
readonly name: "amount";
|
|
91
|
+
}, {
|
|
92
|
+
readonly type: "uint256";
|
|
93
|
+
readonly name: "minReturnAmount";
|
|
94
|
+
}, {
|
|
95
|
+
readonly type: "uint256";
|
|
96
|
+
readonly name: "flags";
|
|
97
|
+
}, {
|
|
98
|
+
readonly type: "bytes";
|
|
99
|
+
readonly name: "permit";
|
|
100
|
+
}];
|
|
101
|
+
}, {
|
|
102
|
+
readonly type: "bytes";
|
|
103
|
+
readonly name: "clientData";
|
|
104
|
+
}];
|
|
105
|
+
readonly name: "execution";
|
|
106
|
+
}];
|
|
107
|
+
readonly outputs: readonly [{
|
|
108
|
+
readonly type: "uint256";
|
|
109
|
+
readonly name: "returnAmount";
|
|
110
|
+
}, {
|
|
111
|
+
readonly type: "uint256";
|
|
112
|
+
readonly name: "gasUsed";
|
|
113
|
+
}];
|
|
114
|
+
}];
|
|
115
|
+
declare const KYBER_SWAP_SELECTOR = "0xe21fd0e9";
|
|
116
|
+
/** Router entry points that are refused by name: `swapGeneric` (owner-whitelisted arbitrary call) and `swapSimpleMode` (no minimum check). */
|
|
117
|
+
declare const KYBER_REFUSED_SELECTORS: Readonly<Record<string, string>>;
|
|
118
|
+
/**
|
|
119
|
+
* The only flag bit accepted: `0x200`, set on every swap the build endpoint encodes (not one of the V2 source's named
|
|
120
|
+
* flags; its meaning is not documented). Partial fill (0x01), extra value (0x02), claim (0x04), burns (0x08/0x10),
|
|
121
|
+
* simple mode (0x20), fee on output (0x40), fee in bps (0x80) and approve-fund (0x100) are refused, as is any other bit.
|
|
122
|
+
*/
|
|
123
|
+
declare const KYBER_FLAGS_ALLOWED = 512n;
|
|
124
|
+
declare class KyberTransactionError extends Error {
|
|
125
|
+
constructor(message: string);
|
|
126
|
+
}
|
|
127
|
+
interface ExpectedKyberSwap {
|
|
128
|
+
chainId: number;
|
|
129
|
+
/** ERC-20 address, or the zero address for the native coin. */
|
|
130
|
+
tokenIn: string;
|
|
131
|
+
tokenOut: string;
|
|
132
|
+
amountIn: bigint;
|
|
133
|
+
/** Who must receive the output (the request's recipient). */
|
|
134
|
+
receiver: string;
|
|
135
|
+
/** The least `minReturnAmount` the calldata may name: the quote's minimum (and the caller's floor). */
|
|
136
|
+
minAmountOut: bigint;
|
|
137
|
+
}
|
|
138
|
+
interface EncodedTx {
|
|
139
|
+
to: string;
|
|
140
|
+
value: bigint;
|
|
141
|
+
data: string;
|
|
142
|
+
}
|
|
143
|
+
interface DecodedKyberSwap {
|
|
144
|
+
srcToken: string;
|
|
145
|
+
dstToken: string;
|
|
146
|
+
dstReceiver: string;
|
|
147
|
+
amount: bigint;
|
|
148
|
+
minReturnAmount: bigint;
|
|
149
|
+
flags: bigint;
|
|
150
|
+
}
|
|
151
|
+
/** Refuses (throws {@link KyberTransactionError}) unless `tx` is exactly the swap the wallet asked for. */
|
|
152
|
+
declare function checkKyberTransaction(tx: EncodedTx, expected: ExpectedKyberSwap): DecodedKyberSwap;
|
|
153
|
+
/**
|
|
154
|
+
* The minimum KyberSwap's build encodes for `amountOut` at `bps` slippage: the expected output less the slippage,
|
|
155
|
+
* rounded down, less one more unit — the build endpoint always lands exactly one base unit under the plain
|
|
156
|
+
* `floor(amountOut × (10000 − bps) / 10000)` (18 chains, 2026-11-24). The quote shows this value, so the dry quote,
|
|
157
|
+
* the build and the check agree to the unit.
|
|
158
|
+
*/
|
|
159
|
+
declare function kyberMinimum(amountOut: bigint, bps: number): bigint;
|
|
160
|
+
/**
|
|
161
|
+
* The slippage to ask KyberSwap for so that its minimum — one unit under the plain floor ({@link kyberMinimum}) — still
|
|
162
|
+
* meets the engine's floor for the slippage the user chose, `floor(amountOut × (10000 − bps) / 10000)`. One basis point
|
|
163
|
+
* less for most outputs; more for a tiny output (a $1 WBTC buy is a few thousand units, where 1 bps is under one unit).
|
|
164
|
+
* Null when no positive slippage does (an output too small to carry a minimum).
|
|
165
|
+
*/
|
|
166
|
+
declare function kyberApiSlippage(amountOut: bigint, bps: number): number | null;
|
|
167
|
+
/**
|
|
168
|
+
* The app's own check of a KyberSwap quote (behind `remoteProvider`, or on any quote): one chain, the exact input,
|
|
169
|
+
* a minimum at or under the expected output and at or above the caller's floor; an execution quote's transaction must
|
|
170
|
+
* pass {@link checkKyberTransaction} against this app's request. A dry quote carries no transaction. The reason it fails, or null.
|
|
171
|
+
*/
|
|
172
|
+
declare function kyberVerifyQuote(params: QuoteParams, quote: Quote): string | null;
|
|
173
|
+
/**
|
|
174
|
+
* The router a KyberSwap swap calls and approves, and {@link kyberVerifyQuote}: the app's side of
|
|
175
|
+
* `remoteProvider({name: "kyberswap", baseUrl, ...kyberPins})`, so a backend's quote is checked against the pinned
|
|
176
|
+
* router and the app's own request, never against itself.
|
|
177
|
+
*/
|
|
178
|
+
declare const kyberPins: RemotePins;
|
|
179
|
+
|
|
180
|
+
export { type DecodedKyberSwap, type EncodedTx, type ExpectedKyberSwap, KYBER_CHAINS, KYBER_EXECUTOR, KYBER_FLAGS_ALLOWED, KYBER_NATIVE, KYBER_REFUSED_SELECTORS, KYBER_ROUTER_ABI, KYBER_ROUTER_V2, KYBER_ROUTER_V3, KYBER_SWAP_SELECTOR, type KyberRouterBuild, KyberTransactionError, checkKyberTransaction, kyberApiSlippage, kyberChain, kyberMinimum, kyberNativeSwaps, kyberPins, kyberVerifyQuote };
|
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { RemotePins, QuoteParams, Quote } from '@anywalletkit/protocol-swap2-core/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* KyberSwap MetaAggregationRouterV2 — the only contract a KyberSwap quote may settle through. This file pins the
|
|
5
|
+
* router and its executor per chain and checks the transaction KyberSwap's build endpoint encoded against the request
|
|
6
|
+
* before anything is approved or sent.
|
|
7
|
+
*
|
|
8
|
+
* The router itself guarantees only that the input comes from the caller and that `dstReceiver` gains at least
|
|
9
|
+
* `minReturnAmount` of `dstToken`; the receiver, the tokens, the minimum, the fee receivers and the flags are all
|
|
10
|
+
* the calldata's (KyberSwap's build endpoint encodes whatever `routeSummary` it is sent, fee entries included).
|
|
11
|
+
* So the calldata is decoded strictly, re-encoded byte for byte, and every field that can move value is compared
|
|
12
|
+
* with the request. The route inside `targetData` is opaque; the router reverts below the minimum.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** MetaAggregationRouterV2 — the same address on every chain KyberSwap serves (docs.kyberswap.com, contracts). */
|
|
16
|
+
declare const KYBER_ROUTER_V2 = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5";
|
|
17
|
+
/** AggregationExecutorProxy — the `callTarget` of every swap the build endpoint encodes. */
|
|
18
|
+
declare const KYBER_EXECUTOR = "0x8F10B468b06c6FD214B65F87778827F7D113f996";
|
|
19
|
+
/** KSAggregationRouterV3: deployed on part of the chains, never returned by the API so far. Refused until decoded. */
|
|
20
|
+
declare const KYBER_ROUTER_V3 = "0x6868d319c8c9a78f7d39dc3602c5c917315132d7";
|
|
21
|
+
/** The router's native-coin sentinel; this SDK uses the zero address. */
|
|
22
|
+
declare const KYBER_NATIVE = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
23
|
+
/**
|
|
24
|
+
* Router build on a chain. `generic`: the 2022 build (18.6 KB) with `swapGeneric` and an owner-managed whitelist — its
|
|
25
|
+
* owner can make the router call any whitelisted contract, so an allowance left on it is exposed to that owner.
|
|
26
|
+
* `lite`: the later build (13.7 KB) without `swapGeneric` and without the whitelist. Both share `swap()`.
|
|
27
|
+
* Read on-chain 2026-11-24 (`eth_getCode`, selectors in the bytecode, `owner()`; how-to-project/kyber-data).
|
|
28
|
+
*/
|
|
29
|
+
type KyberRouterBuild = "generic" | "lite";
|
|
30
|
+
/**
|
|
31
|
+
* Every chain this module quotes on: KyberSwap's `supported-chains` list (active, plus Arc "new" and Elysium
|
|
32
|
+
* "provisional") intersected with the SDK's EVM catalog, each with the router and executor code checked on-chain.
|
|
33
|
+
* `slug` is the API's path segment (a chain id there is a 404).
|
|
34
|
+
*/
|
|
35
|
+
declare const KYBER_CHAINS: Readonly<Record<number, {
|
|
36
|
+
slug: string;
|
|
37
|
+
name: string;
|
|
38
|
+
build: KyberRouterBuild;
|
|
39
|
+
}>>;
|
|
40
|
+
/** The chain entry for an id, never an inherited property. */
|
|
41
|
+
declare function kyberChain(chainId: number): (typeof KYBER_CHAINS)[number] | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Whether a swap may take or pay the chain's native coin: only where the token catalog lists one. Arc's gas token is
|
|
44
|
+
* USDC with 18-decimal native accounting, listed only through its 6-decimal ERC-20 interface, so a native leg there
|
|
45
|
+
* would carry amounts 10^12 off the catalog's USDC; it is refused and the ERC-20 swaps instead.
|
|
46
|
+
*/
|
|
47
|
+
declare function kyberNativeSwaps(chainId: number): boolean;
|
|
48
|
+
/** `swap(SwapExecutionParams)` — the one router entry point this module accepts. */
|
|
49
|
+
declare const KYBER_ROUTER_ABI: readonly [{
|
|
50
|
+
readonly name: "swap";
|
|
51
|
+
readonly type: "function";
|
|
52
|
+
readonly stateMutability: "payable";
|
|
53
|
+
readonly inputs: readonly [{
|
|
54
|
+
readonly type: "tuple";
|
|
55
|
+
readonly components: readonly [{
|
|
56
|
+
readonly type: "address";
|
|
57
|
+
readonly name: "callTarget";
|
|
58
|
+
}, {
|
|
59
|
+
readonly type: "address";
|
|
60
|
+
readonly name: "approveTarget";
|
|
61
|
+
}, {
|
|
62
|
+
readonly type: "bytes";
|
|
63
|
+
readonly name: "targetData";
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "desc";
|
|
66
|
+
readonly type: "tuple";
|
|
67
|
+
readonly components: readonly [{
|
|
68
|
+
readonly type: "address";
|
|
69
|
+
readonly name: "srcToken";
|
|
70
|
+
}, {
|
|
71
|
+
readonly type: "address";
|
|
72
|
+
readonly name: "dstToken";
|
|
73
|
+
}, {
|
|
74
|
+
readonly type: "address[]";
|
|
75
|
+
readonly name: "srcReceivers";
|
|
76
|
+
}, {
|
|
77
|
+
readonly type: "uint256[]";
|
|
78
|
+
readonly name: "srcAmounts";
|
|
79
|
+
}, {
|
|
80
|
+
readonly type: "address[]";
|
|
81
|
+
readonly name: "feeReceivers";
|
|
82
|
+
}, {
|
|
83
|
+
readonly type: "uint256[]";
|
|
84
|
+
readonly name: "feeAmounts";
|
|
85
|
+
}, {
|
|
86
|
+
readonly type: "address";
|
|
87
|
+
readonly name: "dstReceiver";
|
|
88
|
+
}, {
|
|
89
|
+
readonly type: "uint256";
|
|
90
|
+
readonly name: "amount";
|
|
91
|
+
}, {
|
|
92
|
+
readonly type: "uint256";
|
|
93
|
+
readonly name: "minReturnAmount";
|
|
94
|
+
}, {
|
|
95
|
+
readonly type: "uint256";
|
|
96
|
+
readonly name: "flags";
|
|
97
|
+
}, {
|
|
98
|
+
readonly type: "bytes";
|
|
99
|
+
readonly name: "permit";
|
|
100
|
+
}];
|
|
101
|
+
}, {
|
|
102
|
+
readonly type: "bytes";
|
|
103
|
+
readonly name: "clientData";
|
|
104
|
+
}];
|
|
105
|
+
readonly name: "execution";
|
|
106
|
+
}];
|
|
107
|
+
readonly outputs: readonly [{
|
|
108
|
+
readonly type: "uint256";
|
|
109
|
+
readonly name: "returnAmount";
|
|
110
|
+
}, {
|
|
111
|
+
readonly type: "uint256";
|
|
112
|
+
readonly name: "gasUsed";
|
|
113
|
+
}];
|
|
114
|
+
}];
|
|
115
|
+
declare const KYBER_SWAP_SELECTOR = "0xe21fd0e9";
|
|
116
|
+
/** Router entry points that are refused by name: `swapGeneric` (owner-whitelisted arbitrary call) and `swapSimpleMode` (no minimum check). */
|
|
117
|
+
declare const KYBER_REFUSED_SELECTORS: Readonly<Record<string, string>>;
|
|
118
|
+
/**
|
|
119
|
+
* The only flag bit accepted: `0x200`, set on every swap the build endpoint encodes (not one of the V2 source's named
|
|
120
|
+
* flags; its meaning is not documented). Partial fill (0x01), extra value (0x02), claim (0x04), burns (0x08/0x10),
|
|
121
|
+
* simple mode (0x20), fee on output (0x40), fee in bps (0x80) and approve-fund (0x100) are refused, as is any other bit.
|
|
122
|
+
*/
|
|
123
|
+
declare const KYBER_FLAGS_ALLOWED = 512n;
|
|
124
|
+
declare class KyberTransactionError extends Error {
|
|
125
|
+
constructor(message: string);
|
|
126
|
+
}
|
|
127
|
+
interface ExpectedKyberSwap {
|
|
128
|
+
chainId: number;
|
|
129
|
+
/** ERC-20 address, or the zero address for the native coin. */
|
|
130
|
+
tokenIn: string;
|
|
131
|
+
tokenOut: string;
|
|
132
|
+
amountIn: bigint;
|
|
133
|
+
/** Who must receive the output (the request's recipient). */
|
|
134
|
+
receiver: string;
|
|
135
|
+
/** The least `minReturnAmount` the calldata may name: the quote's minimum (and the caller's floor). */
|
|
136
|
+
minAmountOut: bigint;
|
|
137
|
+
}
|
|
138
|
+
interface EncodedTx {
|
|
139
|
+
to: string;
|
|
140
|
+
value: bigint;
|
|
141
|
+
data: string;
|
|
142
|
+
}
|
|
143
|
+
interface DecodedKyberSwap {
|
|
144
|
+
srcToken: string;
|
|
145
|
+
dstToken: string;
|
|
146
|
+
dstReceiver: string;
|
|
147
|
+
amount: bigint;
|
|
148
|
+
minReturnAmount: bigint;
|
|
149
|
+
flags: bigint;
|
|
150
|
+
}
|
|
151
|
+
/** Refuses (throws {@link KyberTransactionError}) unless `tx` is exactly the swap the wallet asked for. */
|
|
152
|
+
declare function checkKyberTransaction(tx: EncodedTx, expected: ExpectedKyberSwap): DecodedKyberSwap;
|
|
153
|
+
/**
|
|
154
|
+
* The minimum KyberSwap's build encodes for `amountOut` at `bps` slippage: the expected output less the slippage,
|
|
155
|
+
* rounded down, less one more unit — the build endpoint always lands exactly one base unit under the plain
|
|
156
|
+
* `floor(amountOut × (10000 − bps) / 10000)` (18 chains, 2026-11-24). The quote shows this value, so the dry quote,
|
|
157
|
+
* the build and the check agree to the unit.
|
|
158
|
+
*/
|
|
159
|
+
declare function kyberMinimum(amountOut: bigint, bps: number): bigint;
|
|
160
|
+
/**
|
|
161
|
+
* The slippage to ask KyberSwap for so that its minimum — one unit under the plain floor ({@link kyberMinimum}) — still
|
|
162
|
+
* meets the engine's floor for the slippage the user chose, `floor(amountOut × (10000 − bps) / 10000)`. One basis point
|
|
163
|
+
* less for most outputs; more for a tiny output (a $1 WBTC buy is a few thousand units, where 1 bps is under one unit).
|
|
164
|
+
* Null when no positive slippage does (an output too small to carry a minimum).
|
|
165
|
+
*/
|
|
166
|
+
declare function kyberApiSlippage(amountOut: bigint, bps: number): number | null;
|
|
167
|
+
/**
|
|
168
|
+
* The app's own check of a KyberSwap quote (behind `remoteProvider`, or on any quote): one chain, the exact input,
|
|
169
|
+
* a minimum at or under the expected output and at or above the caller's floor; an execution quote's transaction must
|
|
170
|
+
* pass {@link checkKyberTransaction} against this app's request. A dry quote carries no transaction. The reason it fails, or null.
|
|
171
|
+
*/
|
|
172
|
+
declare function kyberVerifyQuote(params: QuoteParams, quote: Quote): string | null;
|
|
173
|
+
/**
|
|
174
|
+
* The router a KyberSwap swap calls and approves, and {@link kyberVerifyQuote}: the app's side of
|
|
175
|
+
* `remoteProvider({name: "kyberswap", baseUrl, ...kyberPins})`, so a backend's quote is checked against the pinned
|
|
176
|
+
* router and the app's own request, never against itself.
|
|
177
|
+
*/
|
|
178
|
+
declare const kyberPins: RemotePins;
|
|
179
|
+
|
|
180
|
+
export { type DecodedKyberSwap, type EncodedTx, type ExpectedKyberSwap, KYBER_CHAINS, KYBER_EXECUTOR, KYBER_FLAGS_ALLOWED, KYBER_NATIVE, KYBER_REFUSED_SELECTORS, KYBER_ROUTER_ABI, KYBER_ROUTER_V2, KYBER_ROUTER_V3, KYBER_SWAP_SELECTOR, type KyberRouterBuild, KyberTransactionError, checkKyberTransaction, kyberApiSlippage, kyberChain, kyberMinimum, kyberNativeSwaps, kyberPins, kyberVerifyQuote };
|
package/dist/router.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
KYBER_CHAINS,
|
|
3
|
+
KYBER_EXECUTOR,
|
|
4
|
+
KYBER_FLAGS_ALLOWED,
|
|
5
|
+
KYBER_NATIVE,
|
|
6
|
+
KYBER_REFUSED_SELECTORS,
|
|
7
|
+
KYBER_ROUTER_ABI,
|
|
8
|
+
KYBER_ROUTER_V2,
|
|
9
|
+
KYBER_ROUTER_V3,
|
|
10
|
+
KYBER_SWAP_SELECTOR,
|
|
11
|
+
KyberTransactionError,
|
|
12
|
+
checkKyberTransaction,
|
|
13
|
+
kyberApiSlippage,
|
|
14
|
+
kyberChain,
|
|
15
|
+
kyberMinimum,
|
|
16
|
+
kyberNativeSwaps,
|
|
17
|
+
kyberPins,
|
|
18
|
+
kyberVerifyQuote
|
|
19
|
+
} from "./chunk-WOVGN3FL.js";
|
|
20
|
+
export {
|
|
21
|
+
KYBER_CHAINS,
|
|
22
|
+
KYBER_EXECUTOR,
|
|
23
|
+
KYBER_FLAGS_ALLOWED,
|
|
24
|
+
KYBER_NATIVE,
|
|
25
|
+
KYBER_REFUSED_SELECTORS,
|
|
26
|
+
KYBER_ROUTER_ABI,
|
|
27
|
+
KYBER_ROUTER_V2,
|
|
28
|
+
KYBER_ROUTER_V3,
|
|
29
|
+
KYBER_SWAP_SELECTOR,
|
|
30
|
+
KyberTransactionError,
|
|
31
|
+
checkKyberTransaction,
|
|
32
|
+
kyberApiSlippage,
|
|
33
|
+
kyberChain,
|
|
34
|
+
kyberMinimum,
|
|
35
|
+
kyberNativeSwaps,
|
|
36
|
+
kyberPins,
|
|
37
|
+
kyberVerifyQuote
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/module.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anywalletkit/protocol-swap2-kyberswap",
|
|
3
|
+
"type": "swap2",
|
|
4
|
+
"chains": [
|
|
5
|
+
"eip155:1",
|
|
6
|
+
"eip155:10",
|
|
7
|
+
"eip155:130",
|
|
8
|
+
"eip155:137",
|
|
9
|
+
"eip155:143",
|
|
10
|
+
"eip155:146",
|
|
11
|
+
"eip155:42161",
|
|
12
|
+
"eip155:43114",
|
|
13
|
+
"eip155:4326",
|
|
14
|
+
"eip155:4663",
|
|
15
|
+
"eip155:5042",
|
|
16
|
+
"eip155:56",
|
|
17
|
+
"eip155:59144",
|
|
18
|
+
"eip155:80094",
|
|
19
|
+
"eip155:8453",
|
|
20
|
+
"eip155:9745",
|
|
21
|
+
"eip155:999",
|
|
22
|
+
"eip155:99901"
|
|
23
|
+
],
|
|
24
|
+
"tier": "core",
|
|
25
|
+
"maintainers": [
|
|
26
|
+
"@ultratestbro"
|
|
27
|
+
],
|
|
28
|
+
"conformance": "0.x",
|
|
29
|
+
"repo": "https://github.com/ultratestbro/anywalletkit",
|
|
30
|
+
"path": "packages/protocol-swap2-kyberswap",
|
|
31
|
+
"description": "KyberSwap Aggregator same-chain swaps: keyless public API (or the gateway with a key), settled through MetaAggregationRouterV2 only; the build's calldata decoded strictly and re-encoded byte for byte, router, executor, tokens, amounts, receiver, minimum, fee receivers and flags checked against the request, simulated before signing. No integrator fee.",
|
|
32
|
+
"addedAt": "2026-11-24"
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,90 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anywalletkit/protocol-swap2-kyberswap",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "KyberSwap Aggregator same-chain swaps for Any Wallet Kit: exact-input routes on 18 EVM chains, settled through MetaAggregationRouterV2, with the encoded transaction decoded strictly and checked against the request before signing.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://docs.anywallet.tech",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/ultratestbro/anywalletkit/issues"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/ultratestbro/anywalletkit.git",
|
|
13
|
+
"directory": "packages/protocol-swap2-kyberswap"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22"
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./provider": {
|
|
30
|
+
"types": "./dist/provider.d.ts",
|
|
31
|
+
"import": "./dist/provider.js",
|
|
32
|
+
"require": "./dist/provider.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./router": {
|
|
35
|
+
"types": "./dist/router.d.ts",
|
|
36
|
+
"import": "./dist/router.js",
|
|
37
|
+
"require": "./dist/router.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./activity": {
|
|
40
|
+
"types": "./dist/activity.d.ts",
|
|
41
|
+
"import": "./dist/activity.js",
|
|
42
|
+
"require": "./dist/activity.cjs"
|
|
43
|
+
},
|
|
44
|
+
"./protocol": {
|
|
45
|
+
"types": "./dist/protocol.d.ts",
|
|
46
|
+
"import": "./dist/protocol.js",
|
|
47
|
+
"require": "./dist/protocol.cjs"
|
|
48
|
+
},
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"README.md",
|
|
54
|
+
"module.json"
|
|
55
|
+
],
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"viem": "^2.57.2",
|
|
58
|
+
"@anywalletkit/protocol-swap2-core": "0.17.0",
|
|
59
|
+
"@anywalletkit/swap2-assets": "0.3.0",
|
|
60
|
+
"@anywalletkit/protocol-swap2-wrap": "0.4.8"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@anywalletkit/core": "0.9.0"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/node": "^22",
|
|
67
|
+
"vitest": "^5.1.0",
|
|
68
|
+
"@anywalletkit/conformance": "0.6.1",
|
|
69
|
+
"@anywalletkit/core": "0.9.0"
|
|
70
|
+
},
|
|
71
|
+
"keywords": [
|
|
72
|
+
"swap2",
|
|
73
|
+
"swap",
|
|
74
|
+
"dex-aggregator",
|
|
75
|
+
"kyberswap",
|
|
76
|
+
"kyber",
|
|
77
|
+
"evm",
|
|
78
|
+
"anywalletkit"
|
|
79
|
+
],
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public",
|
|
82
|
+
"provenance": true
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "tsup",
|
|
86
|
+
"typecheck": "tsc --noEmit",
|
|
87
|
+
"test": "vitest run",
|
|
88
|
+
"lint": "eslint src"
|
|
89
|
+
}
|
|
6
90
|
}
|