@spicenet-io/spiceflow-core 0.2.0 → 0.3.1
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/README.md +82 -0
- package/dist/abis/index.d.ts +1 -0
- package/dist/abis/index.d.ts.map +1 -1
- package/dist/abis/uniV3.d.ts +93 -0
- package/dist/abis/uniV3.d.ts.map +1 -0
- package/dist/index.cjs +391 -30
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +386 -30
- package/dist/logos.d.ts +1 -0
- package/dist/logos.d.ts.map +1 -1
- package/dist/swap.d.ts +31 -0
- package/dist/swap.d.ts.map +1 -0
- package/dist/tokens/index.d.ts +7 -5
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/list.d.ts +2 -2
- package/dist/tokens/list.d.ts.map +1 -1
- package/dist/tokens/types.d.ts +2 -2
- package/dist/tokens/types.d.ts.map +1 -1
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @spicenet-io/spiceflow-core
|
|
2
|
+
|
|
3
|
+
Single source of truth for chain configs, token lists, logos, ABIs, and shared utilities across spiceflow repos.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @spicenet-io/spiceflow-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What's in here
|
|
12
|
+
|
|
13
|
+
### Chains
|
|
14
|
+
|
|
15
|
+
`CHAINS` is a record of all supported chains keyed by chain ID. Each entry has id, name, display name, network (mainnet/testnet), native currency, delegate contract address, block explorer, rpc url, and logo.
|
|
16
|
+
|
|
17
|
+
Helper functions: `getChainMeta(chainId)`, `getChainsByNetwork(network)`, `getChainIdsByNetwork(network)`, `getMainnetChains()`, `getTestnetChains()`, `getDelegateContract(chainId)`.
|
|
18
|
+
|
|
19
|
+
### Tokens
|
|
20
|
+
|
|
21
|
+
`TOKENS` is the official token list. Each token has symbol, name, equivalence group, logo, and deployments across chains (address, decimals, network per chain).
|
|
22
|
+
|
|
23
|
+
Helper functions: `getTokensForChain(chainId)`, `getTokenByAddress(address, chainId)`, `getEquivalentAddresses(tokenAddress)`, `areEquivalent(a, b)`, `isUsdDenominated(address)`, `isBtcDenominated(address)`.
|
|
24
|
+
|
|
25
|
+
### Logos
|
|
26
|
+
|
|
27
|
+
All chain and token logos are bundled as base64 data URIs in the package. They work directly in img src attributes with no network requests. To add a new logo, drop the PNG in `logos/` and reference it in the chain or token list. `npm run build` auto generates the base64 file.
|
|
28
|
+
|
|
29
|
+
### Utilities
|
|
30
|
+
|
|
31
|
+
`isNativeToken(address)` checks if an address is a native token (zero address, 0x0, or 0xeee...eee).
|
|
32
|
+
|
|
33
|
+
`normalizeNativeTokenAddress(address)` normalizes any native token address to the zero address.
|
|
34
|
+
|
|
35
|
+
`convertAmountBetweenDecimals(amount, fromDecimals, toDecimals)` converts token amounts between different decimal precisions.
|
|
36
|
+
|
|
37
|
+
`formatTokenAmount(amount, decimals)` formats a bigint token amount into a human readable string.
|
|
38
|
+
|
|
39
|
+
`truncateAddress(address)` shortens an address for display.
|
|
40
|
+
|
|
41
|
+
`withRetry(fn, maxRetries, delayMs)` retries an async function with exponential backoff.
|
|
42
|
+
|
|
43
|
+
Constants: `NATIVE_TOKEN_ADDRESS`, `ZERO_ADDRESS`, `ESCROW_ADDRESS`.
|
|
44
|
+
|
|
45
|
+
### ABIs
|
|
46
|
+
|
|
47
|
+
`DELEGATE_ABI`, `ERC20_ABI`, `WCBTC_ABI`.
|
|
48
|
+
|
|
49
|
+
### Authorization
|
|
50
|
+
|
|
51
|
+
`hashChainBatches(chainCalls)` hashes chain call batches for intent signing.
|
|
52
|
+
|
|
53
|
+
`getIntentHash(signatureType, nbf, exp, chainBatches)` computes the intent hash.
|
|
54
|
+
|
|
55
|
+
`getAccountNonce(address, publicClient)` gets the account nonce from chain.
|
|
56
|
+
|
|
57
|
+
### Core SDK
|
|
58
|
+
|
|
59
|
+
`SpiceFlowCore` class for building and submitting intents. Handles delegation signing, chain batch construction, intent signing, and transaction submission.
|
|
60
|
+
|
|
61
|
+
### HTTP
|
|
62
|
+
|
|
63
|
+
`fetchWithRetry(url, init, opts)` is a fetch wrapper with retry and exponential backoff.
|
|
64
|
+
|
|
65
|
+
`submitTransaction(baseUrl, request)` submits a transaction to the relayer API.
|
|
66
|
+
|
|
67
|
+
`getIntentStepStatus(txApiUrl, intentId, stepId)` checks intent execution status.
|
|
68
|
+
|
|
69
|
+
`prepareRFQT(txApiUrl, request)` prepares an RFQT quote.
|
|
70
|
+
|
|
71
|
+
## Adding a token
|
|
72
|
+
|
|
73
|
+
1. Drop the logo PNG in `logos/`
|
|
74
|
+
2. Add the token entry in `src/tokens/list.ts` with symbol, name, equivalence group, logo reference, and deployments
|
|
75
|
+
3. `npm run build` and publish
|
|
76
|
+
|
|
77
|
+
## Adding a chain
|
|
78
|
+
|
|
79
|
+
1. Drop the logo PNG in `logos/` if it's a new chain logo
|
|
80
|
+
2. Add the chain entry in `src/chains/list.ts`
|
|
81
|
+
3. Add token deployments on that chain in `src/tokens/list.ts`
|
|
82
|
+
4. `npm run build` and publish
|
package/dist/abis/index.d.ts
CHANGED
package/dist/abis/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export declare const uniV3QuoterV2Abi: readonly [{
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly components: readonly [{
|
|
4
|
+
readonly internalType: "address";
|
|
5
|
+
readonly name: "tokenIn";
|
|
6
|
+
readonly type: "address";
|
|
7
|
+
}, {
|
|
8
|
+
readonly internalType: "address";
|
|
9
|
+
readonly name: "tokenOut";
|
|
10
|
+
readonly type: "address";
|
|
11
|
+
}, {
|
|
12
|
+
readonly internalType: "uint256";
|
|
13
|
+
readonly name: "amountIn";
|
|
14
|
+
readonly type: "uint256";
|
|
15
|
+
}, {
|
|
16
|
+
readonly internalType: "uint24";
|
|
17
|
+
readonly name: "fee";
|
|
18
|
+
readonly type: "uint24";
|
|
19
|
+
}, {
|
|
20
|
+
readonly internalType: "uint160";
|
|
21
|
+
readonly name: "sqrtPriceLimitX96";
|
|
22
|
+
readonly type: "uint160";
|
|
23
|
+
}];
|
|
24
|
+
readonly internalType: "struct IQuoterV2.QuoteExactInputSingleParams";
|
|
25
|
+
readonly name: "params";
|
|
26
|
+
readonly type: "tuple";
|
|
27
|
+
}];
|
|
28
|
+
readonly name: "quoteExactInputSingle";
|
|
29
|
+
readonly outputs: readonly [{
|
|
30
|
+
readonly internalType: "uint256";
|
|
31
|
+
readonly name: "amountOut";
|
|
32
|
+
readonly type: "uint256";
|
|
33
|
+
}, {
|
|
34
|
+
readonly internalType: "uint160";
|
|
35
|
+
readonly name: "sqrtPriceX96After";
|
|
36
|
+
readonly type: "uint160";
|
|
37
|
+
}, {
|
|
38
|
+
readonly internalType: "uint32";
|
|
39
|
+
readonly name: "initializedTicksCrossed";
|
|
40
|
+
readonly type: "uint32";
|
|
41
|
+
}, {
|
|
42
|
+
readonly internalType: "uint256";
|
|
43
|
+
readonly name: "gasEstimate";
|
|
44
|
+
readonly type: "uint256";
|
|
45
|
+
}];
|
|
46
|
+
readonly stateMutability: "nonpayable";
|
|
47
|
+
readonly type: "function";
|
|
48
|
+
}];
|
|
49
|
+
export declare const uniV3SwapRouterAbi: readonly [{
|
|
50
|
+
readonly inputs: readonly [{
|
|
51
|
+
readonly components: readonly [{
|
|
52
|
+
readonly internalType: "address";
|
|
53
|
+
readonly name: "tokenIn";
|
|
54
|
+
readonly type: "address";
|
|
55
|
+
}, {
|
|
56
|
+
readonly internalType: "address";
|
|
57
|
+
readonly name: "tokenOut";
|
|
58
|
+
readonly type: "address";
|
|
59
|
+
}, {
|
|
60
|
+
readonly internalType: "uint24";
|
|
61
|
+
readonly name: "fee";
|
|
62
|
+
readonly type: "uint24";
|
|
63
|
+
}, {
|
|
64
|
+
readonly internalType: "address";
|
|
65
|
+
readonly name: "recipient";
|
|
66
|
+
readonly type: "address";
|
|
67
|
+
}, {
|
|
68
|
+
readonly internalType: "uint256";
|
|
69
|
+
readonly name: "amountIn";
|
|
70
|
+
readonly type: "uint256";
|
|
71
|
+
}, {
|
|
72
|
+
readonly internalType: "uint256";
|
|
73
|
+
readonly name: "amountOutMinimum";
|
|
74
|
+
readonly type: "uint256";
|
|
75
|
+
}, {
|
|
76
|
+
readonly internalType: "uint160";
|
|
77
|
+
readonly name: "sqrtPriceLimitX96";
|
|
78
|
+
readonly type: "uint160";
|
|
79
|
+
}];
|
|
80
|
+
readonly internalType: "struct IV3SwapRouter.ExactInputSingleParams";
|
|
81
|
+
readonly name: "params";
|
|
82
|
+
readonly type: "tuple";
|
|
83
|
+
}];
|
|
84
|
+
readonly name: "exactInputSingle";
|
|
85
|
+
readonly outputs: readonly [{
|
|
86
|
+
readonly internalType: "uint256";
|
|
87
|
+
readonly name: "amountOut";
|
|
88
|
+
readonly type: "uint256";
|
|
89
|
+
}];
|
|
90
|
+
readonly stateMutability: "payable";
|
|
91
|
+
readonly type: "function";
|
|
92
|
+
}];
|
|
93
|
+
//# sourceMappingURL=uniV3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniV3.d.ts","sourceRoot":"","sources":["../../src/abis/uniV3.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCnB,CAAC;AAIX,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCrB,CAAC"}
|