aegis-swap-widget 0.3.2 → 0.3.4
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 +37 -0
- package/README.md +114 -43
- package/dist/abis.d.ts +0 -73
- package/dist/aegis-swap-widget.js +3468 -2344
- package/dist/config/chains.d.ts +11 -0
- package/dist/config/constants.d.ts +8 -0
- package/dist/config/contracts.d.ts +6 -0
- package/dist/config/createMarket.d.ts +3 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/markets.d.ts +3 -0
- package/dist/config/tokens.d.ts +11 -0
- package/dist/{config.d.ts → config/types.d.ts} +5 -26
- package/dist/core.d.ts +3 -15
- package/dist/core.js +4 -64
- package/dist/encoding.d.ts +0 -29
- package/dist/hooks/useSubmitSwap.d.ts +11 -29
- package/dist/hooks/useSwapQuote.d.ts +3 -2
- package/dist/index.d.ts +3 -1
- package/dist/markets-LIeOtFf_.js +229 -0
- package/dist/permit.d.ts +1 -47
- package/dist/quote/aggregatedSwapQuote.d.ts +5 -0
- package/dist/services/kyberSwap.d.ts +84 -0
- package/dist/styles.css +1 -1
- package/dist/types/aggregatedSwap.d.ts +29 -0
- package/dist/widget/AegisAggregatedSwapWidget.d.ts +3 -0
- package/dist/widget/AmountField.d.ts +5 -1
- package/dist/widget/SwapWidgetShell.d.ts +51 -0
- package/dist/widget/TokenSelector.d.ts +13 -0
- package/dist/widget/types.d.ts +23 -2
- package/dist/widget/useAggregatedSwapController.d.ts +74 -0
- package/dist/widget/useRailAutoReset.d.ts +11 -0
- package/dist/widget/useStatusSurface.d.ts +32 -0
- package/dist/widget/useSwapController.d.ts +13 -14
- package/dist/widget/useWidgetStyle.d.ts +13 -0
- package/dist/widget/viewState.d.ts +21 -1
- package/package.json +23 -21
- package/dist/polling-BI4pZg8Z.js +0 -1252
- package/dist/swap/authorizePermit.d.ts +0 -30
- package/dist/swap/executeSwapTransaction.d.ts +0 -39
- package/dist/swap/types.d.ts +0 -7
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Hex } from 'viem';
|
|
2
|
+
import type { AegisSwapChainConfig, AegisSwapChainConfigInput } from './types';
|
|
3
|
+
export declare function getExplorerUrl(hash: Hex, chain: AegisSwapChainConfig): string;
|
|
4
|
+
export declare const AEGIS_SWAP_DEFAULT_RPC_URLS: string[];
|
|
5
|
+
export declare const AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT = "https://aegis.markets/graphql/meta";
|
|
6
|
+
export declare const AEGIS_SWAP_MAINNET_CHAIN: AegisSwapChainConfig;
|
|
7
|
+
export declare const AEGIS_SWAP_CHAINS: Record<number, AegisSwapChainConfig>;
|
|
8
|
+
export declare function createAegisSwapChainConfig(input: AegisSwapChainConfigInput & {
|
|
9
|
+
chainId: number;
|
|
10
|
+
}, base?: AegisSwapChainConfig): AegisSwapChainConfig;
|
|
11
|
+
export declare function createAegisSwapChains(chains?: Partial<Record<number, AegisSwapChainConfigInput>>): Record<number, AegisSwapChainConfig>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const AEGIS_SWAP_CHAIN_ID = 1;
|
|
2
|
+
export declare const AEGIS_SWAP_ROUTER: `0x${string}`;
|
|
3
|
+
export declare const AEGIS_SWAP_HOOK: `0x${string}`;
|
|
4
|
+
export declare const AEGIS_DYNAMIC_FEE_FLAG = 8388608;
|
|
5
|
+
export declare const AEGIS_SWAP_DEFAULT_FEE_BPS = 50;
|
|
6
|
+
export declare const AEGIS_SWAP_DEFAULT_FEE_RECIPIENT: `0x${string}`;
|
|
7
|
+
export declare const AGGREGATED_SWAP_FEE_BPS = 50;
|
|
8
|
+
export declare const AGGREGATED_SWAP_FEE_RECIPIENT: `0x${string}`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AegisSwapUniswapV4Contracts, AegisSwapUniswapV4ContractsInput } from './types';
|
|
2
|
+
export declare function createAegisSwapUniswapV4Contracts(input: AegisSwapUniswapV4ContractsInput): AegisSwapUniswapV4Contracts;
|
|
3
|
+
export declare const UNISWAP_V4_CONTRACTS_BY_CHAIN: Record<number, AegisSwapUniswapV4Contracts>;
|
|
4
|
+
export declare const AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS: AegisSwapUniswapV4Contracts;
|
|
5
|
+
export declare const AEGIS_SWAP_PERMIT2: `0x${string}`;
|
|
6
|
+
export declare const AEGIS_SWAP_V4_QUOTER: `0x${string}`;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AegisSwapChainConfig, AegisSwapMarket, AegisSwapPoolConfig } from './types';
|
|
2
|
+
export declare function createAegisSwapPoolMarket(input: AegisSwapPoolConfig, chains?: Record<number, AegisSwapChainConfig>): AegisSwapMarket;
|
|
3
|
+
export declare function createAegisSwapMarketsFromPools(pools: AegisSwapPoolConfig[] | undefined, chains?: Record<number, AegisSwapChainConfig>): Record<string, AegisSwapMarket>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AegisSwapBuiltInTokenSymbol, AegisSwapToken, AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken, AggregatedSwapWolfGameTokenSymbol } from './types';
|
|
2
|
+
export declare const AEGIS_SWAP_TOKENS: Record<AegisSwapBuiltInTokenSymbol, AegisSwapToken>;
|
|
3
|
+
export declare const AGGREGATED_SWAP_DEFAULT_TOKENS: Record<AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken>;
|
|
4
|
+
export declare const AGGREGATED_SWAP_WOLFGAME_TOKENS: Record<AggregatedSwapWolfGameTokenSymbol, AggregatedSwapToken>;
|
|
5
|
+
export declare const AGGREGATED_SWAP_DEFAULT_TOKEN_LIST: AegisSwapToken[];
|
|
6
|
+
export declare const AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST: AegisSwapToken[];
|
|
7
|
+
export declare const AGGREGATED_SWAP_TOKEN_PRESETS: {
|
|
8
|
+
readonly default: AegisSwapToken[];
|
|
9
|
+
readonly wolfgame: AegisSwapToken[];
|
|
10
|
+
};
|
|
11
|
+
export declare const AGGREGATED_SWAP_CURATED_TOKENS: Record<AggregatedSwapDefaultTokenSymbol, AegisSwapToken>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Address, Chain, Hex } from 'viem';
|
|
2
2
|
export type AegisSwapBuiltInTokenSymbol = 'USDC' | 'WATER' | 'WOOD' | 'GRASS' | 'STONE';
|
|
3
3
|
export type AegisSwapBuiltInAssetSymbol = Exclude<AegisSwapBuiltInTokenSymbol, 'USDC'>;
|
|
4
4
|
export type AegisSwapBuiltInMarketId = 'WATER_USDC' | 'WOOD_USDC' | 'GRASS_USDC' | 'STONE_USDC';
|
|
@@ -64,7 +64,6 @@ export type AegisSwapChainConfigInput = Partial<Omit<AegisSwapChainConfig, 'chai
|
|
|
64
64
|
chainId?: number;
|
|
65
65
|
v4Contracts?: AegisSwapUniswapV4ContractsInput;
|
|
66
66
|
};
|
|
67
|
-
export declare function getExplorerUrl(hash: Hex, chain: AegisSwapChainConfig): string;
|
|
68
67
|
export type AegisSwapPoolConfig = {
|
|
69
68
|
id: string;
|
|
70
69
|
symbol?: AegisSwapTokenSymbol;
|
|
@@ -78,27 +77,7 @@ export type AegisSwapPoolConfig = {
|
|
|
78
77
|
quoter?: Address;
|
|
79
78
|
label?: string;
|
|
80
79
|
};
|
|
81
|
-
export
|
|
82
|
-
export
|
|
83
|
-
export
|
|
84
|
-
export
|
|
85
|
-
export declare const AEGIS_SWAP_DEFAULT_FEE_BPS = 50;
|
|
86
|
-
export declare const AEGIS_SWAP_DEFAULT_FEE_RECIPIENT: `0x${string}`;
|
|
87
|
-
export declare function createAegisSwapUniswapV4Contracts(input: AegisSwapUniswapV4ContractsInput): AegisSwapUniswapV4Contracts;
|
|
88
|
-
export declare const UNISWAP_V4_CONTRACTS_BY_CHAIN: Record<number, AegisSwapUniswapV4Contracts>;
|
|
89
|
-
export declare const AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS: AegisSwapUniswapV4Contracts;
|
|
90
|
-
export declare const AEGIS_SWAP_PERMIT2: `0x${string}`;
|
|
91
|
-
export declare const AEGIS_SWAP_V4_QUOTER: `0x${string}`;
|
|
92
|
-
export declare const AEGIS_SWAP_DEFAULT_RPC_URLS: string[];
|
|
93
|
-
export declare const AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT = "https://aegis.markets/graphql/meta";
|
|
94
|
-
export declare const AEGIS_SWAP_MAINNET_CHAIN: AegisSwapChainConfig;
|
|
95
|
-
export declare const AEGIS_SWAP_CHAINS: Record<number, AegisSwapChainConfig>;
|
|
96
|
-
export declare const AEGIS_SWAP_TOKENS: Record<AegisSwapBuiltInTokenSymbol, AegisSwapToken>;
|
|
97
|
-
export declare const AEGIS_SWAP_MARKETS: Record<AegisSwapBuiltInMarketId, AegisSwapMarket>;
|
|
98
|
-
export declare const AEGIS_SWAP_DEFAULT_POOL_IDS: AegisSwapBuiltInMarketId[];
|
|
99
|
-
export declare function createAegisSwapChainConfig(input: AegisSwapChainConfigInput & {
|
|
100
|
-
chainId: number;
|
|
101
|
-
}, base?: AegisSwapChainConfig): AegisSwapChainConfig;
|
|
102
|
-
export declare function createAegisSwapChains(chains?: Partial<Record<number, AegisSwapChainConfigInput>>): Record<number, AegisSwapChainConfig>;
|
|
103
|
-
export declare function createAegisSwapPoolMarket(input: AegisSwapPoolConfig, chains?: Record<number, AegisSwapChainConfig>): AegisSwapMarket;
|
|
104
|
-
export declare function createAegisSwapMarketsFromPools(pools: AegisSwapPoolConfig[] | undefined, chains?: Record<number, AegisSwapChainConfig>): Record<string, AegisSwapMarket>;
|
|
80
|
+
export type AggregatedSwapToken = AegisSwapToken;
|
|
81
|
+
export type AggregatedSwapDefaultTokenSymbol = 'USDC' | 'USDT' | 'WETH' | 'ETH' | 'WBTC' | 'STETH';
|
|
82
|
+
export type AggregatedSwapWolfGameTokenSymbol = AegisSwapBuiltInTokenSymbol | 'ETH';
|
|
83
|
+
export type AggregatedSwapTokenSymbol = AggregatedSwapDefaultTokenSymbol | AggregatedSwapWolfGameTokenSymbol;
|
package/dist/core.d.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
4
|
-
export type { BuiltSwapTransaction, ExecutionBatch, PermitBatch, PermitDetails, SignedPermitBatch, SwapOutputFee } from './encoding';
|
|
5
|
-
export { fetchDirectSwapQuote, getZeroForOne, outputFeeForQuote, quoteSpendAmount, reconcileSubmitQuote, sameQuote } from './quote';
|
|
6
|
-
export type { DirectSwapQuote, ReconciledSubmitQuote, SwapQuoteMode } from './quote';
|
|
7
|
-
export { approveErc20ToPermit2, approvePermit2ToRouter, buildSignedPermitBatch, DEFAULT_PERMIT_EXPIRATION_SECONDS, MAX_UINT160, MAX_UINT256, PERMIT2_FAR_FUTURE_EXPIRATION, readPermit2RouterAllowance, SWAP_TX_DEADLINE_SECONDS } from './permit';
|
|
8
|
-
export { fetchGlobalTokenMetadata, getIchiIconGuess, resolveTokenIconUrl } from './metadata';
|
|
9
|
-
export type { AegisSwapGlobalTokenMetadata, TokenMetadataByAddress } from './metadata';
|
|
10
|
-
export { createSwapPublicClient, getInjectedProvider, getProviderAccount, getProviderChainId, isEip1193Provider, normalizeAccount, normalizeWalletConnection, requestProviderAccount, subscribeProvider, switchProviderChain } from './wallet';
|
|
11
|
-
export type { AegisSwapProviderResolver, AegisSwapWalletConnection, Eip1193Provider, ProviderChainConfig } from './wallet';
|
|
12
|
-
export { errorMessage, isUserRejectedError } from './errors';
|
|
13
|
-
export { isBusy, transactionProgressView } from './transactionProgress';
|
|
14
|
-
export type { AegisSwapStatusSnapshot, AegisSwapWalletPromptProgress, SubmitStatus, TransactionProgressState, TransactionProgressView } from './transactionProgress';
|
|
15
|
-
export { isDocumentVisible, pollUntil, retryOnError } from './polling';
|
|
1
|
+
export * from '@aegis-engine/core';
|
|
2
|
+
export { AEGIS_SWAP_DEFAULT_POOL_IDS, AEGIS_SWAP_MARKETS } from './config';
|
|
3
|
+
export type { AegisSwapBuiltInMarketId } from './config';
|
package/dist/core.js
CHANGED
|
@@ -1,66 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "@aegis-engine/core";
|
|
2
|
+
import { A as o, a as r } from "./markets-LIeOtFf_.js";
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
r as AEGIS_SWAP_CHAIN_ID,
|
|
6
|
-
_ as AEGIS_SWAP_DEFAULT_FEE_BPS,
|
|
7
|
-
t as AEGIS_SWAP_DEFAULT_FEE_RECIPIENT,
|
|
8
|
-
o as AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT,
|
|
9
|
-
S as AEGIS_SWAP_DEFAULT_POOL_IDS,
|
|
10
|
-
E as AEGIS_SWAP_DEFAULT_RPC_URLS,
|
|
11
|
-
i as AEGIS_SWAP_HOOK,
|
|
12
|
-
I as AEGIS_SWAP_MAINNET_CHAIN,
|
|
13
|
-
P as AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS,
|
|
14
|
-
n as AEGIS_SWAP_MARKETS,
|
|
15
|
-
c as AEGIS_SWAP_PERMIT2,
|
|
16
|
-
T as AEGIS_SWAP_ROUTER,
|
|
17
|
-
l as AEGIS_SWAP_TOKENS,
|
|
18
|
-
u as AEGIS_SWAP_V4_QUOTER,
|
|
19
|
-
N as DEFAULT_PERMIT_EXPIRATION_SECONDS,
|
|
20
|
-
U as MAX_UINT128,
|
|
21
|
-
p as MAX_UINT160,
|
|
22
|
-
C as MAX_UINT256,
|
|
23
|
-
G as PERMIT2_FAR_FUTURE_EXPIRATION,
|
|
24
|
-
R as SWAP_TX_DEADLINE_SECONDS,
|
|
25
|
-
W as UNISWAP_V4_CONTRACTS_BY_CHAIN,
|
|
26
|
-
d as approveErc20ToPermit2,
|
|
27
|
-
D as approvePermit2ToRouter,
|
|
28
|
-
O as assertUint128,
|
|
29
|
-
F as buildExactInSwapTransaction,
|
|
30
|
-
g as buildExactOutSwapTransaction,
|
|
31
|
-
M as buildSignedPermitBatch,
|
|
32
|
-
m as computePoolId,
|
|
33
|
-
w as createAegisSwapChainConfig,
|
|
34
|
-
v as createAegisSwapChains,
|
|
35
|
-
L as createAegisSwapMarketsFromPools,
|
|
36
|
-
b as createAegisSwapPoolMarket,
|
|
37
|
-
h as createAegisSwapUniswapV4Contracts,
|
|
38
|
-
V as createSwapPublicClient,
|
|
39
|
-
X as errorMessage,
|
|
40
|
-
H as fetchDirectSwapQuote,
|
|
41
|
-
Q as fetchGlobalTokenMetadata,
|
|
42
|
-
f as getExplorerUrl,
|
|
43
|
-
k as getIchiIconGuess,
|
|
44
|
-
x as getInjectedProvider,
|
|
45
|
-
B as getProviderAccount,
|
|
46
|
-
K as getProviderChainId,
|
|
47
|
-
j as getZeroForOne,
|
|
48
|
-
q as isBusy,
|
|
49
|
-
y as isDocumentVisible,
|
|
50
|
-
z as isEip1193Provider,
|
|
51
|
-
Y as isUserRejectedError,
|
|
52
|
-
Z as normalizeAccount,
|
|
53
|
-
J as normalizeWalletConnection,
|
|
54
|
-
$ as outputFeeForQuote,
|
|
55
|
-
aa as pollUntil,
|
|
56
|
-
sa as quoteSpendAmount,
|
|
57
|
-
ea as readPermit2RouterAllowance,
|
|
58
|
-
Aa as reconcileSubmitQuote,
|
|
59
|
-
ra as requestProviderAccount,
|
|
60
|
-
_a as resolveTokenIconUrl,
|
|
61
|
-
ta as retryOnError,
|
|
62
|
-
oa as sameQuote,
|
|
63
|
-
Sa as subscribeProvider,
|
|
64
|
-
Ea as switchProviderChain,
|
|
65
|
-
ia as transactionProgressView
|
|
4
|
+
o as AEGIS_SWAP_DEFAULT_POOL_IDS,
|
|
5
|
+
r as AEGIS_SWAP_MARKETS
|
|
66
6
|
};
|
package/dist/encoding.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { type Address, type Hex } from 'viem';
|
|
2
2
|
import type { AegisPoolKey } from './config';
|
|
3
|
-
export type ExecutionBatch = {
|
|
4
|
-
requiresV4Unlock: boolean;
|
|
5
|
-
actions: Hex;
|
|
6
|
-
params: Hex[];
|
|
7
|
-
};
|
|
8
3
|
export type PermitDetails = {
|
|
9
4
|
token: Address;
|
|
10
5
|
amount: bigint;
|
|
@@ -28,30 +23,6 @@ export type SwapOutputFee = {
|
|
|
28
23
|
recipient: Address;
|
|
29
24
|
amount: bigint;
|
|
30
25
|
};
|
|
31
|
-
export type BuiltSwapTransaction = {
|
|
32
|
-
calldata: Hex;
|
|
33
|
-
value: bigint;
|
|
34
|
-
};
|
|
35
26
|
export declare const MAX_UINT128: bigint;
|
|
36
27
|
export declare function assertUint128(value: bigint, label?: string): void;
|
|
37
28
|
export declare function computePoolId(poolKey: AegisPoolKey): Hex;
|
|
38
|
-
export declare function buildExactInSwapTransaction(args: {
|
|
39
|
-
poolKey: AegisPoolKey;
|
|
40
|
-
zeroForOne: boolean;
|
|
41
|
-
amountIn: bigint;
|
|
42
|
-
amountOutMinimum: bigint;
|
|
43
|
-
recipient: Address;
|
|
44
|
-
deadline: bigint;
|
|
45
|
-
permit?: SignedPermitBatch | null;
|
|
46
|
-
fee?: SwapOutputFee | null;
|
|
47
|
-
}): BuiltSwapTransaction;
|
|
48
|
-
export declare function buildExactOutSwapTransaction(args: {
|
|
49
|
-
poolKey: AegisPoolKey;
|
|
50
|
-
zeroForOne: boolean;
|
|
51
|
-
amountOut: bigint;
|
|
52
|
-
amountInMaximum: bigint;
|
|
53
|
-
recipient: Address;
|
|
54
|
-
deadline: bigint;
|
|
55
|
-
permit?: SignedPermitBatch | null;
|
|
56
|
-
fee?: SwapOutputFee | null;
|
|
57
|
-
}): BuiltSwapTransaction;
|
|
@@ -1,39 +1,22 @@
|
|
|
1
|
+
import { type AegisSwapApprovalMode, type AegisSwapReceiptSummary, type AegisSwapSubmitDetails, type SubmitStatus } from '@aegis-engine/core';
|
|
1
2
|
import { type Address, type Hex, type PublicClient } from 'viem';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { type Eip1193Provider } from '../wallet';
|
|
3
|
+
import type { AegisSwapChainConfig, AegisSwapFeeConfig, AegisSwapMarket, AegisSwapToken } from '../config';
|
|
4
|
+
import type { DirectSwapQuote, SwapQuoteMode } from '../quote';
|
|
5
|
+
import type { Eip1193Provider } from '../wallet';
|
|
6
6
|
import type { ResolvedWalletConnection } from './useWalletConnection';
|
|
7
|
-
|
|
8
|
-
* ERC-20 → Permit2 approval sizing. `'exact'` approves only the current quote's
|
|
9
|
-
* spend; `'max'` approves an unlimited allowance so future swaps skip approval.
|
|
10
|
-
*/
|
|
11
|
-
export type AegisSwapApprovalMode = 'exact' | 'max';
|
|
12
|
-
/**
|
|
13
|
-
* Swap context attached to `onSubmitted`/`onSuccess` so hosts get
|
|
14
|
-
* analytics-grade data without extra wiring. Amounts are raw base units.
|
|
15
|
-
*/
|
|
16
|
-
export type AegisSwapSubmitDetails = {
|
|
17
|
-
mode: SwapQuoteMode;
|
|
18
|
-
inputSymbol: string;
|
|
19
|
-
outputSymbol: string;
|
|
20
|
-
amountIn: bigint;
|
|
21
|
-
amountOut: bigint;
|
|
22
|
-
feeAmount: bigint;
|
|
23
|
-
feeBps: number;
|
|
24
|
-
};
|
|
7
|
+
export type { AegisSwapApprovalMode, AegisSwapSubmitDetails } from '@aegis-engine/core';
|
|
25
8
|
type ApprovalProgress = {
|
|
26
9
|
required: boolean;
|
|
27
10
|
done: boolean;
|
|
28
11
|
};
|
|
29
12
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
13
|
+
* React state wrapper around the shared core direct-pool action.
|
|
14
|
+
*
|
|
15
|
+
* The core package owns quote reconciliation, ERC-20 approval, Permit2
|
|
16
|
+
* authorization, transaction submission, replacement tracking, and receipt
|
|
17
|
+
* summarization. This hook keeps the widget-specific state/callback contract.
|
|
35
18
|
*/
|
|
36
|
-
export declare function useSubmitSwap({ publicClient, activeChain, market, inputToken, outputToken, quoteMode, activeAmount, slippageBps, feeConfig, quote, setQuote, owner, getActiveProvider, connectWallet, setWalletChainId,
|
|
19
|
+
export declare function useSubmitSwap({ publicClient, activeChain, market, inputToken, outputToken, quoteMode, activeAmount, slippageBps, feeConfig, quote, setQuote, owner, getActiveProvider, connectWallet, setWalletChainId, approvalMode, refreshBalances, refreshAllowances, onSubmitted, onSuccess, onError }: {
|
|
37
20
|
publicClient: PublicClient;
|
|
38
21
|
activeChain: AegisSwapChainConfig;
|
|
39
22
|
market: AegisSwapMarket | null;
|
|
@@ -74,4 +57,3 @@ export declare function useSubmitSwap({ publicClient, activeChain, market, input
|
|
|
74
57
|
/** Settlement facts (gas, block, fee) once the swap mines; null until then. */
|
|
75
58
|
receiptSummary: AegisSwapReceiptSummary | null;
|
|
76
59
|
};
|
|
77
|
-
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Address, PublicClient } from 'viem';
|
|
2
|
-
import type { AegisSwapFeeConfig, AegisSwapMarket, AegisSwapToken } from '../config';
|
|
2
|
+
import type { AegisSwapChainConfig, AegisSwapFeeConfig, AegisSwapMarket, AegisSwapToken } from '../config';
|
|
3
3
|
import { type DirectSwapQuote, type SwapQuoteMode } from '../quote';
|
|
4
|
-
export declare function useSwapQuote({ publicClient, owner, market, inputToken, outputToken, quoteMode, activeAmount, slippageBps, feeConfig, onQuote, pausedRef }: {
|
|
4
|
+
export declare function useSwapQuote({ publicClient, owner, activeChain, market, inputToken, outputToken, quoteMode, activeAmount, slippageBps, feeConfig, onQuote, pausedRef }: {
|
|
5
5
|
publicClient: PublicClient;
|
|
6
6
|
owner: Address | null;
|
|
7
|
+
activeChain: AegisSwapChainConfig;
|
|
7
8
|
market: AegisSwapMarket | null;
|
|
8
9
|
inputToken: AegisSwapToken;
|
|
9
10
|
outputToken: AegisSwapToken;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './styles.css';
|
|
2
2
|
export { AegisDirectSwapWidget, AegisSwapWidget, default } from './widget/AegisDirectSwapWidget';
|
|
3
|
-
export
|
|
3
|
+
export { AegisAggregatedSwapWidget } from './widget/AegisAggregatedSwapWidget';
|
|
4
|
+
export type { AegisDirectSwapWidgetProps, AegisAggregatedSwapWidgetProps, AegisSwapNetworkIcon, AegisSwapNetworkOption, AegisSwapStatusSurface, AegisSwapWidgetDirection, AegisSwapWidgetProps, AegisSwapWidgetStyle } from './widget/types';
|
|
4
5
|
export { AegisSwapProgressRail } from './widget/ProgressRail';
|
|
5
6
|
export type { AegisSwapProgressRailProps } from './widget/ProgressRail';
|
|
6
7
|
export { AegisSwapToaster } from './toast/Toaster';
|
|
@@ -10,4 +11,5 @@ export type { AegisToastPromiseMessage, AegisToastPromiseMessages } from './toas
|
|
|
10
11
|
export type { AegisToastAction, AegisToastOptions, AegisToastPosition, AegisToastType } from './toast/state';
|
|
11
12
|
export type { AegisSwapWidgetTheme } from './hooks/useResolvedTheme';
|
|
12
13
|
export type { AegisSwapApprovalMode, AegisSwapSubmitDetails } from './hooks/useSubmitSwap';
|
|
14
|
+
export type { AegisSwapStatusSnapshot, AegisSwapWalletPromptProgress, SubmitStatus, TransactionProgressState } from './transactionProgress';
|
|
13
15
|
export * from './core';
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { getAddress as a } from "viem";
|
|
2
|
+
const d = 1, A = a("0x00581261a1200956ea05d1810fF28ffd66D8E254"), n = a("0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"), D = 8388608, U = 50, F = a(
|
|
3
|
+
"0x8ea2C7de60ef1Cd4dcE64ea2DDDe2f99F0127eFC"
|
|
4
|
+
);
|
|
5
|
+
function f(c) {
|
|
6
|
+
return c ? a(c) : void 0;
|
|
7
|
+
}
|
|
8
|
+
function s(c) {
|
|
9
|
+
if (!c.permit2 || !c.quoter)
|
|
10
|
+
throw new Error("Missing Permit2 or V4 Quoter contract address.");
|
|
11
|
+
return {
|
|
12
|
+
permit2: a(c.permit2),
|
|
13
|
+
quoter: a(c.quoter),
|
|
14
|
+
poolManager: f(c.poolManager),
|
|
15
|
+
positionDescriptor: f(c.positionDescriptor),
|
|
16
|
+
positionManager: f(c.positionManager),
|
|
17
|
+
stateView: f(c.stateView),
|
|
18
|
+
universalRouter: f(c.universalRouter),
|
|
19
|
+
universalRouterV2_1_1: f(c.universalRouterV2_1_1)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const _ = {
|
|
23
|
+
1: s({
|
|
24
|
+
poolManager: "0x000000000004444c5dc75cB358380D2e3dE08A90",
|
|
25
|
+
positionDescriptor: "0xd1428ba554f4c8450b763a0b2040a4935c63f06c",
|
|
26
|
+
positionManager: "0xbd216513d74c8cf14cf4747e6aaa6420ff64ee9e",
|
|
27
|
+
quoter: "0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",
|
|
28
|
+
stateView: "0x7ffe42c4a5deea5b0fec41c94c136cf115597227",
|
|
29
|
+
universalRouter: "0x66a9893cc07d91d95644aedd05d03f95e1dba8af",
|
|
30
|
+
universalRouterV2_1_1: "0x4c82d1fbfe28c977cbb58d8c7ff8fcf9f70a2cca",
|
|
31
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
32
|
+
}),
|
|
33
|
+
10: s({
|
|
34
|
+
poolManager: "0x9a13f98cb987694c9f086b1f5eb990eea8264ec3",
|
|
35
|
+
positionDescriptor: "0xedd81496169c46df161b8513a52ffecaaaa66743",
|
|
36
|
+
positionManager: "0x3c3ea4b57a46241e54610e5f022e5c45859a1017",
|
|
37
|
+
quoter: "0x1f3131a13296fb91c90870043742c3cdbff1a8d7",
|
|
38
|
+
stateView: "0xc18a3169788f4f75a170290584eca6395c75ecdb",
|
|
39
|
+
universalRouter: "0x851116d9223fabed8e56c0e6b8ad0c31d98b3507",
|
|
40
|
+
universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
|
|
41
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
42
|
+
}),
|
|
43
|
+
130: s({
|
|
44
|
+
poolManager: "0x1f98400000000000000000000000000000000004",
|
|
45
|
+
positionDescriptor: "0x9fb28449a191cd8c03a1b7abfb0f5996ecf7f722",
|
|
46
|
+
positionManager: "0x4529a01c7a0410167c5740c487a8de60232617bf",
|
|
47
|
+
quoter: "0x333e3c607b141b18ff6de9f258db6e77fe7491e0",
|
|
48
|
+
stateView: "0x86e8631a016f9068c3f085faf484ee3f5fdee8f2",
|
|
49
|
+
universalRouter: "0xef740bf23acae26f6492b10de645d6b98dc8eaf3",
|
|
50
|
+
universalRouterV2_1_1: "0xfdf682f51fe81aa4898f0ae2163d8a55c127fbc7",
|
|
51
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
52
|
+
}),
|
|
53
|
+
137: s({
|
|
54
|
+
poolManager: "0x67366782805870060151383f4bbff9dab53e5cd6",
|
|
55
|
+
positionDescriptor: "0x0892771f0c1b78ad6013d6e5536007e1c16e6794",
|
|
56
|
+
positionManager: "0x1ec2ebf4f37e7363fdfe3551602425af0b3ceef9",
|
|
57
|
+
quoter: "0xb3d5c3dfc3a7aebff71895a7191796bffc2c81b9",
|
|
58
|
+
stateView: "0x5ea1bd7974c8a611cbab0bdcafcb1d9cc9b3ba5a",
|
|
59
|
+
universalRouter: "0x1095692a6237d83c6a72f3f5efedb9a670c49223",
|
|
60
|
+
universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
|
|
61
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
62
|
+
}),
|
|
63
|
+
8453: s({
|
|
64
|
+
poolManager: "0x498581ff718922c3f8e6a244956af099b2652b2b",
|
|
65
|
+
positionDescriptor: "0x25d093633990dc94bedeed76c8f3cdaa75f3e7d5",
|
|
66
|
+
positionManager: "0x7c5f5a4bbd8fd63184577525326123b519429bdc",
|
|
67
|
+
quoter: "0x0d5e0f971ed27fbff6c2837bf31316121532048d",
|
|
68
|
+
stateView: "0xa3c0c9b65bad0b08107aa264b0f3db444b867a71",
|
|
69
|
+
universalRouter: "0x6ff5693b99212da76ad316178a184ab56d299b43",
|
|
70
|
+
universalRouterV2_1_1: "0xfdf682f51fe81aa4898f0ae2163d8a55c127fbc7",
|
|
71
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
72
|
+
}),
|
|
73
|
+
42161: s({
|
|
74
|
+
poolManager: "0x360e68faccca8ca495c1b759fd9eee466db9fb32",
|
|
75
|
+
positionDescriptor: "0xe2023f3fa515cf070e07fd9d51c1d236e07843f4",
|
|
76
|
+
positionManager: "0xd88f38f930b7952f2db2432cb002e7abbf3dd869",
|
|
77
|
+
quoter: "0x3972c00f7ed4885e145823eb7c655375d275a1c5",
|
|
78
|
+
stateView: "0x76fd297e2d437cd7f76d50f01afe6160f86e9990",
|
|
79
|
+
universalRouter: "0xa51afafe0263b40edaef0df8781ea9aa03e381a3",
|
|
80
|
+
universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
|
|
81
|
+
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
82
|
+
})
|
|
83
|
+
}, r = _[d], C = r.permit2, x = r.quoter, e = {
|
|
84
|
+
USDC: {
|
|
85
|
+
chainId: d,
|
|
86
|
+
address: a("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
|
|
87
|
+
name: "USD Coin",
|
|
88
|
+
symbol: "USDC",
|
|
89
|
+
decimals: 6
|
|
90
|
+
},
|
|
91
|
+
WATER: {
|
|
92
|
+
chainId: d,
|
|
93
|
+
address: a("0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6"),
|
|
94
|
+
name: "WATER",
|
|
95
|
+
symbol: "WATER",
|
|
96
|
+
decimals: 18
|
|
97
|
+
},
|
|
98
|
+
WOOD: {
|
|
99
|
+
chainId: d,
|
|
100
|
+
address: a("0x670AfdD7226e73d3CC55B5cd83933E46aF22DECd"),
|
|
101
|
+
name: "WOOD",
|
|
102
|
+
symbol: "WOOD",
|
|
103
|
+
decimals: 18
|
|
104
|
+
},
|
|
105
|
+
GRASS: {
|
|
106
|
+
chainId: d,
|
|
107
|
+
address: a("0xF06Ad052b0d8D511D0B6f00100b8e402639209EF"),
|
|
108
|
+
name: "GRASS",
|
|
109
|
+
symbol: "GRASS",
|
|
110
|
+
decimals: 18
|
|
111
|
+
},
|
|
112
|
+
STONE: {
|
|
113
|
+
chainId: d,
|
|
114
|
+
address: a("0xCabcc33D9Ff7e24F413d939773D232C0d50dCc7f"),
|
|
115
|
+
name: "STONE",
|
|
116
|
+
symbol: "STONE",
|
|
117
|
+
decimals: 18,
|
|
118
|
+
// STONE's ichi asset is logo_256_stone_2.svg, not the symbol-derived
|
|
119
|
+
// logo_256_stone.svg that getIchiIconGuess('STONE') produces. Pin it so the
|
|
120
|
+
// mark stays correct even when the metadata service is unreachable.
|
|
121
|
+
iconUrl: "https://ichi-images.s3.us-east-1.amazonaws.com/tokens/logo_256_stone_2.svg"
|
|
122
|
+
}
|
|
123
|
+
}, T = {
|
|
124
|
+
USDC: e.USDC,
|
|
125
|
+
USDT: {
|
|
126
|
+
address: a("0xdAC17F958D2ee523a2206206994597C13D831ec7")
|
|
127
|
+
},
|
|
128
|
+
WETH: {
|
|
129
|
+
address: a("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
|
|
130
|
+
},
|
|
131
|
+
ETH: {
|
|
132
|
+
chainId: d,
|
|
133
|
+
address: a("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"),
|
|
134
|
+
name: "Ether",
|
|
135
|
+
symbol: "ETH",
|
|
136
|
+
decimals: 18
|
|
137
|
+
},
|
|
138
|
+
WBTC: {
|
|
139
|
+
address: a("0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599")
|
|
140
|
+
},
|
|
141
|
+
STETH: {
|
|
142
|
+
address: a("0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84")
|
|
143
|
+
}
|
|
144
|
+
}, R = {
|
|
145
|
+
USDC: e.USDC,
|
|
146
|
+
ETH: T.ETH,
|
|
147
|
+
WATER: e.WATER,
|
|
148
|
+
WOOD: e.WOOD,
|
|
149
|
+
GRASS: e.GRASS,
|
|
150
|
+
STONE: e.STONE
|
|
151
|
+
}, m = Object.values(
|
|
152
|
+
R
|
|
153
|
+
);
|
|
154
|
+
function o(c, b, t, E, S, i) {
|
|
155
|
+
return {
|
|
156
|
+
id: c,
|
|
157
|
+
chainId: d,
|
|
158
|
+
symbol: b,
|
|
159
|
+
poolId: t,
|
|
160
|
+
poolKey: {
|
|
161
|
+
currency0: E,
|
|
162
|
+
currency1: S,
|
|
163
|
+
fee: D,
|
|
164
|
+
tickSpacing: i,
|
|
165
|
+
hooks: n
|
|
166
|
+
},
|
|
167
|
+
token: e[b],
|
|
168
|
+
counterToken: e.USDC,
|
|
169
|
+
router: A,
|
|
170
|
+
permit2: C,
|
|
171
|
+
quoter: x,
|
|
172
|
+
label: `${e.USDC.symbol} / ${b}`
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const O = o(
|
|
176
|
+
"WATER_USDC",
|
|
177
|
+
"WATER",
|
|
178
|
+
"0x01409fc6f1bf49e20bf05df5d4dcb96ed3977ea717bc4a135e9deacd92ebc0af",
|
|
179
|
+
e.WATER.address,
|
|
180
|
+
e.USDC.address,
|
|
181
|
+
60
|
|
182
|
+
), u = o(
|
|
183
|
+
"WOOD_USDC",
|
|
184
|
+
"WOOD",
|
|
185
|
+
"0x0f8a98e3fdb7ea4438a3f7342f040cbc9d1eced1b90a876d38f3453100243356",
|
|
186
|
+
e.WOOD.address,
|
|
187
|
+
e.USDC.address,
|
|
188
|
+
60
|
|
189
|
+
), l = o(
|
|
190
|
+
"GRASS_USDC",
|
|
191
|
+
"GRASS",
|
|
192
|
+
"0xc516dba7bd70aa2dcb986bb1c27208ea29ecd097fa0ce636611e88e54ae4444d",
|
|
193
|
+
e.USDC.address,
|
|
194
|
+
e.GRASS.address,
|
|
195
|
+
30
|
|
196
|
+
), W = o(
|
|
197
|
+
"STONE_USDC",
|
|
198
|
+
"STONE",
|
|
199
|
+
"0x3fa06e44e4bee9539887681eab6b608b646784e2027ea6292198cde0690aff54",
|
|
200
|
+
e.USDC.address,
|
|
201
|
+
e.STONE.address,
|
|
202
|
+
60
|
|
203
|
+
), G = {
|
|
204
|
+
WATER_USDC: O,
|
|
205
|
+
WOOD_USDC: u,
|
|
206
|
+
GRASS_USDC: l,
|
|
207
|
+
STONE_USDC: W
|
|
208
|
+
}, I = [
|
|
209
|
+
"WATER_USDC",
|
|
210
|
+
"WOOD_USDC",
|
|
211
|
+
"GRASS_USDC",
|
|
212
|
+
"STONE_USDC"
|
|
213
|
+
];
|
|
214
|
+
export {
|
|
215
|
+
I as A,
|
|
216
|
+
_ as U,
|
|
217
|
+
G as a,
|
|
218
|
+
F as b,
|
|
219
|
+
U as c,
|
|
220
|
+
r as d,
|
|
221
|
+
x as e,
|
|
222
|
+
C as f,
|
|
223
|
+
A as g,
|
|
224
|
+
d as h,
|
|
225
|
+
s as i,
|
|
226
|
+
e as j,
|
|
227
|
+
m as k,
|
|
228
|
+
T as l
|
|
229
|
+
};
|
package/dist/permit.d.ts
CHANGED
|
@@ -1,31 +1,5 @@
|
|
|
1
|
-
import { type Address, type
|
|
2
|
-
import type { Eip1193Provider } from './wallet';
|
|
3
|
-
import type { SignedPermitBatch } from './encoding';
|
|
4
|
-
export declare const MAX_UINT160: bigint;
|
|
5
|
-
export declare const MAX_UINT256: bigint;
|
|
1
|
+
import { type Address, type PublicClient } from 'viem';
|
|
6
2
|
export declare const SWAP_TX_DEADLINE_SECONDS = 600;
|
|
7
|
-
export declare const DEFAULT_PERMIT_EXPIRATION_SECONDS: number;
|
|
8
|
-
export declare const PERMIT2_FAR_FUTURE_EXPIRATION: number;
|
|
9
|
-
export declare function approveErc20ToPermit2(args: {
|
|
10
|
-
provider: Eip1193Provider;
|
|
11
|
-
publicClient: PublicClient;
|
|
12
|
-
account: Address;
|
|
13
|
-
chain: Chain;
|
|
14
|
-
token: Address;
|
|
15
|
-
permit2: Address;
|
|
16
|
-
amount?: bigint;
|
|
17
|
-
}): Promise<Hex>;
|
|
18
|
-
export declare function approvePermit2ToRouter(args: {
|
|
19
|
-
provider: Eip1193Provider;
|
|
20
|
-
publicClient: PublicClient;
|
|
21
|
-
account: Address;
|
|
22
|
-
chain: Chain;
|
|
23
|
-
token: Address;
|
|
24
|
-
permit2: Address;
|
|
25
|
-
router: Address;
|
|
26
|
-
amount?: bigint;
|
|
27
|
-
expiration?: number;
|
|
28
|
-
}): Promise<Hex>;
|
|
29
3
|
export declare function readPermit2RouterAllowance(args: {
|
|
30
4
|
publicClient: PublicClient;
|
|
31
5
|
permit2: Address;
|
|
@@ -33,23 +7,3 @@ export declare function readPermit2RouterAllowance(args: {
|
|
|
33
7
|
token: Address;
|
|
34
8
|
router: Address;
|
|
35
9
|
}): Promise<readonly [amount: bigint, expiration: number, nonce: number]>;
|
|
36
|
-
export declare function buildSignedPermitBatch(args: {
|
|
37
|
-
provider: Eip1193Provider;
|
|
38
|
-
publicClient: PublicClient;
|
|
39
|
-
account: Address;
|
|
40
|
-
chainId: number;
|
|
41
|
-
chain: Chain;
|
|
42
|
-
permit2: Address;
|
|
43
|
-
router: Address;
|
|
44
|
-
token: Address;
|
|
45
|
-
amount: bigint;
|
|
46
|
-
/**
|
|
47
|
-
* 'max' signs a MAX_UINT160 permit (still expiring in 30 minutes) so quick
|
|
48
|
-
* follow-up swaps reuse it instead of prompting for a new signature each
|
|
49
|
-
* time — Permit2 decrements exact-sized permits to zero on transfer.
|
|
50
|
-
* Defaults to 'exact'.
|
|
51
|
-
*/
|
|
52
|
-
sizing?: 'exact' | 'max';
|
|
53
|
-
/** Pre-started readPermit2RouterAllowance result to overlap with other RPC work. */
|
|
54
|
-
allowanceRead?: ReturnType<typeof readPermit2RouterAllowance>;
|
|
55
|
-
}): Promise<SignedPermitBatch | null>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Address, type PublicClient } from 'viem';
|
|
2
|
+
import { type AegisSwapToken } from '../config';
|
|
3
|
+
import type { AggregatedSwapQuote } from '../types/aggregatedSwap';
|
|
4
|
+
export declare function aggregatedSwapErrorMessage(error: unknown, fallbackMessage: string): string;
|
|
5
|
+
export declare function fetchAggregatedSwapQuote(inputToken: AegisSwapToken, outputToken: AegisSwapToken, amount: bigint, slippageBps: number, mode?: 'exactIn' | 'exactOut', account?: Address | null, signal?: AbortSignal, _publicClient?: PublicClient): Promise<AggregatedSwapQuote>;
|