@inco/shield-js 0.1.0 → 0.2.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/README.md +52 -308
- package/dist/contracts/abi.d.ts +2000 -4513
- package/dist/contracts/abi.js +2400 -5651
- package/dist/contracts/index.d.ts +2 -2
- package/dist/contracts/index.js +2 -2
- package/dist/contracts/utils.d.ts +5 -24
- package/dist/contracts/utils.js +13 -24
- package/dist/errors.d.ts +16 -47
- package/dist/errors.js +6 -53
- package/dist/generated/inco/shield/v2/conductor_pb.d.ts +77 -0
- package/dist/generated/inco/shield/v2/conductor_pb.js +6 -0
- package/dist/generated/inco/shield/v2/deposit_pb.d.ts +12 -103
- package/dist/generated/inco/shield/v2/deposit_pb.js +4 -141
- package/dist/generated/inco/shield/v2/drafting_pb.d.ts +45 -269
- package/dist/generated/inco/shield/v2/drafting_pb.js +8 -361
- package/dist/generated/inco/shield/v2/types_pb.d.ts +47 -166
- package/dist/generated/inco/shield/v2/types_pb.js +12 -261
- package/dist/index.d.ts +1 -7
- package/dist/index.js +1 -14
- package/dist/shield/abi.d.ts +5 -0
- package/dist/shield/abi.js +28 -0
- package/dist/shield/client.d.ts +27 -51
- package/dist/shield/client.js +73 -65
- package/dist/shield/convert.d.ts +2 -14
- package/dist/shield/convert.js +39 -115
- package/dist/shield/encryption.d.ts +0 -67
- package/dist/shield/encryption.js +0 -67
- package/dist/shield/envelope.d.ts +10 -11
- package/dist/shield/envelope.js +15 -14
- package/dist/shield/fee.d.ts +24 -0
- package/dist/shield/fee.js +151 -0
- package/dist/shield/index.d.ts +9 -3
- package/dist/shield/index.js +7 -2
- package/dist/shield/intent.d.ts +20 -933
- package/dist/shield/intent.js +92 -112
- package/dist/shield/permission-status.d.ts +9 -0
- package/dist/shield/permission-status.js +8 -0
- package/dist/shield/rpc.d.ts +50 -49
- package/dist/shield/rpc.js +207 -354
- package/dist/shield/shield.eip712.gen.d.ts +1096 -43
- package/dist/shield/shield.eip712.gen.js +572 -62
- package/dist/shield/types.d.ts +7 -102
- package/dist/shield/types.js +1 -4
- package/dist/shield/userop/gas-estimation.d.ts +7 -22
- package/dist/shield/userop/gas-estimation.js +100 -137
- package/dist/shield/userop/paymaster.d.ts +15 -0
- package/dist/shield/userop/paymaster.js +17 -0
- package/dist/shield/userop/token-exchange.d.ts +5 -52
- package/dist/shield/userop/token-exchange.js +41 -149
- package/dist/shield/userop/types.d.ts +2 -27
- package/dist/shield/userop/types.js +0 -3
- package/dist/shield/userop/userOp.d.ts +0 -19
- package/dist/shield/userop/userOp.js +4 -22
- package/dist/shield/utils/chain.d.ts +1 -0
- package/dist/shield/utils/chain.js +3 -0
- package/dist/shield/validate-withdrawal-split.d.ts +13 -0
- package/dist/shield/validate-withdrawal-split.js +93 -0
- package/package.json +18 -27
- package/dist/generated/inco/shield/v2/conductor_connect.d.ts +0 -137
- package/dist/generated/inco/shield/v2/conductor_connect.js +0 -141
- package/dist/generated/inco/shield/v2/permission_pb.d.ts +0 -443
- package/dist/generated/inco/shield/v2/permission_pb.js +0 -639
- package/dist/generated/inco/shield/v2/query_pb.d.ts +0 -103
- package/dist/generated/inco/shield/v2/query_pb.js +0 -141
- package/dist/shield/userop/index.d.ts +0 -1
- package/dist/shield/userop/index.js +0 -1
- package/dist/uniswap-adapter/config.d.ts +0 -34
- package/dist/uniswap-adapter/config.js +0 -45
- package/dist/uniswap-adapter/find-pools.d.ts +0 -91
- package/dist/uniswap-adapter/find-pools.js +0 -108
- package/dist/uniswap-adapter/index.d.ts +0 -10
- package/dist/uniswap-adapter/index.js +0 -13
- package/dist/uniswap-adapter/swap.d.ts +0 -344
- package/dist/uniswap-adapter/swap.js +0 -309
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
|
|
2
|
-
import { Message, proto3 } from "@bufbuild/protobuf";
|
|
3
|
-
import { Address, AssetId, Bytes32, Handle, Uint256 } from "./types_pb.js";
|
|
4
|
-
/**
|
|
5
|
-
* GetBalanceRequest is the envelope payload for GetBalance.
|
|
6
|
-
* Account ownership is proven by eip712_signature.
|
|
7
|
-
* Response is AEAD-encrypted with response_key.
|
|
8
|
-
*
|
|
9
|
-
* @generated from message inco.shield.v2.GetBalanceRequest
|
|
10
|
-
*/
|
|
11
|
-
export declare class GetBalanceRequest extends Message<GetBalanceRequest> {
|
|
12
|
-
/**
|
|
13
|
-
* The account to query.
|
|
14
|
-
*
|
|
15
|
-
* @generated from field: inco.shield.v2.Address address = 1;
|
|
16
|
-
*/
|
|
17
|
-
address?: Address;
|
|
18
|
-
/**
|
|
19
|
-
* The asset to query.
|
|
20
|
-
*
|
|
21
|
-
* @generated from field: inco.shield.v2.AssetId asset_id = 2;
|
|
22
|
-
*/
|
|
23
|
-
assetId?: AssetId;
|
|
24
|
-
/**
|
|
25
|
-
* Optional: query balance at a specific block (0 = latest).
|
|
26
|
-
*
|
|
27
|
-
* @generated from field: uint64 at_block = 3;
|
|
28
|
-
*/
|
|
29
|
-
atBlock: bigint;
|
|
30
|
-
/**
|
|
31
|
-
* Symmetric key for AEAD-encrypting the response.
|
|
32
|
-
*
|
|
33
|
-
* @generated from field: bytes response_key = 4;
|
|
34
|
-
*/
|
|
35
|
-
responseKey: Uint8Array<ArrayBuffer>;
|
|
36
|
-
/**
|
|
37
|
-
* EIP-712 signature proving ownership of the queried address.
|
|
38
|
-
*
|
|
39
|
-
* @generated from field: bytes eip712_signature = 5;
|
|
40
|
-
*/
|
|
41
|
-
eip712Signature: Uint8Array<ArrayBuffer>;
|
|
42
|
-
/**
|
|
43
|
-
* Unix timestamp (seconds) the client signed into the BalanceQuery digest;
|
|
44
|
-
* the enclave verifies against this exact value.
|
|
45
|
-
*
|
|
46
|
-
* @generated from field: uint64 query_timestamp = 6;
|
|
47
|
-
*/
|
|
48
|
-
queryTimestamp: bigint;
|
|
49
|
-
constructor(data?: PartialMessage<GetBalanceRequest>);
|
|
50
|
-
static readonly runtime: typeof proto3;
|
|
51
|
-
static readonly typeName = "inco.shield.v2.GetBalanceRequest";
|
|
52
|
-
static readonly fields: FieldList;
|
|
53
|
-
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetBalanceRequest;
|
|
54
|
-
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetBalanceRequest;
|
|
55
|
-
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetBalanceRequest;
|
|
56
|
-
static equals(a: GetBalanceRequest | PlainMessage<GetBalanceRequest> | undefined, b: GetBalanceRequest | PlainMessage<GetBalanceRequest> | undefined): boolean;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* GetBalanceResponse returns the account's balance breakdown.
|
|
60
|
-
* Serialized and AEAD-encrypted into an EncryptedResponse.
|
|
61
|
-
*
|
|
62
|
-
* @generated from message inco.shield.v2.GetBalanceResponse
|
|
63
|
-
*/
|
|
64
|
-
export declare class GetBalanceResponse extends Message<GetBalanceResponse> {
|
|
65
|
-
/**
|
|
66
|
-
* Balance from settled transfers.
|
|
67
|
-
*
|
|
68
|
-
* @generated from field: inco.shield.v2.Uint256 confirmed_balance = 1;
|
|
69
|
-
*/
|
|
70
|
-
confirmedBalance?: Uint256;
|
|
71
|
-
/**
|
|
72
|
-
* Balance from in-flight transfers not yet settled.
|
|
73
|
-
*
|
|
74
|
-
* @generated from field: inco.shield.v2.Uint256 pending_balance = 2;
|
|
75
|
-
*/
|
|
76
|
-
pendingBalance?: Uint256;
|
|
77
|
-
/**
|
|
78
|
-
* Total available balance (confirmed + pending).
|
|
79
|
-
*
|
|
80
|
-
* @generated from field: inco.shield.v2.Uint256 available_balance = 3;
|
|
81
|
-
*/
|
|
82
|
-
availableBalance?: Uint256;
|
|
83
|
-
/**
|
|
84
|
-
* The handle at which this balance was computed.
|
|
85
|
-
*
|
|
86
|
-
* @generated from field: inco.shield.v2.Handle handle = 4;
|
|
87
|
-
*/
|
|
88
|
-
handle?: Handle;
|
|
89
|
-
/**
|
|
90
|
-
* The block hash at which this balance was computed.
|
|
91
|
-
*
|
|
92
|
-
* @generated from field: inco.shield.v2.Bytes32 block_hash = 5;
|
|
93
|
-
*/
|
|
94
|
-
blockHash?: Bytes32;
|
|
95
|
-
constructor(data?: PartialMessage<GetBalanceResponse>);
|
|
96
|
-
static readonly runtime: typeof proto3;
|
|
97
|
-
static readonly typeName = "inco.shield.v2.GetBalanceResponse";
|
|
98
|
-
static readonly fields: FieldList;
|
|
99
|
-
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetBalanceResponse;
|
|
100
|
-
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetBalanceResponse;
|
|
101
|
-
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetBalanceResponse;
|
|
102
|
-
static equals(a: GetBalanceResponse | PlainMessage<GetBalanceResponse> | undefined, b: GetBalanceResponse | PlainMessage<GetBalanceResponse> | undefined): boolean;
|
|
103
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// @generated by protoc-gen-es v1.10.1 with parameter "target=ts,import_extension=.js"
|
|
2
|
-
// @generated from file inco/shield/v2/query.proto (package inco.shield.v2, syntax proto3)
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
// @ts-nocheck
|
|
5
|
-
import { Message, proto3, protoInt64 } from "@bufbuild/protobuf";
|
|
6
|
-
import { Address, AssetId, Bytes32, Handle, Uint256 } from "./types_pb.js";
|
|
7
|
-
/**
|
|
8
|
-
* GetBalanceRequest is the envelope payload for GetBalance.
|
|
9
|
-
* Account ownership is proven by eip712_signature.
|
|
10
|
-
* Response is AEAD-encrypted with response_key.
|
|
11
|
-
*
|
|
12
|
-
* @generated from message inco.shield.v2.GetBalanceRequest
|
|
13
|
-
*/
|
|
14
|
-
export class GetBalanceRequest extends Message {
|
|
15
|
-
/**
|
|
16
|
-
* The account to query.
|
|
17
|
-
*
|
|
18
|
-
* @generated from field: inco.shield.v2.Address address = 1;
|
|
19
|
-
*/
|
|
20
|
-
address;
|
|
21
|
-
/**
|
|
22
|
-
* The asset to query.
|
|
23
|
-
*
|
|
24
|
-
* @generated from field: inco.shield.v2.AssetId asset_id = 2;
|
|
25
|
-
*/
|
|
26
|
-
assetId;
|
|
27
|
-
/**
|
|
28
|
-
* Optional: query balance at a specific block (0 = latest).
|
|
29
|
-
*
|
|
30
|
-
* @generated from field: uint64 at_block = 3;
|
|
31
|
-
*/
|
|
32
|
-
atBlock = protoInt64.zero;
|
|
33
|
-
/**
|
|
34
|
-
* Symmetric key for AEAD-encrypting the response.
|
|
35
|
-
*
|
|
36
|
-
* @generated from field: bytes response_key = 4;
|
|
37
|
-
*/
|
|
38
|
-
responseKey = new Uint8Array(0);
|
|
39
|
-
/**
|
|
40
|
-
* EIP-712 signature proving ownership of the queried address.
|
|
41
|
-
*
|
|
42
|
-
* @generated from field: bytes eip712_signature = 5;
|
|
43
|
-
*/
|
|
44
|
-
eip712Signature = new Uint8Array(0);
|
|
45
|
-
/**
|
|
46
|
-
* Unix timestamp (seconds) the client signed into the BalanceQuery digest;
|
|
47
|
-
* the enclave verifies against this exact value.
|
|
48
|
-
*
|
|
49
|
-
* @generated from field: uint64 query_timestamp = 6;
|
|
50
|
-
*/
|
|
51
|
-
queryTimestamp = protoInt64.zero;
|
|
52
|
-
constructor(data) {
|
|
53
|
-
super();
|
|
54
|
-
proto3.util.initPartial(data, this);
|
|
55
|
-
}
|
|
56
|
-
static runtime = proto3;
|
|
57
|
-
static typeName = "inco.shield.v2.GetBalanceRequest";
|
|
58
|
-
static fields = proto3.util.newFieldList(() => [
|
|
59
|
-
{ no: 1, name: "address", kind: "message", T: Address },
|
|
60
|
-
{ no: 2, name: "asset_id", kind: "message", T: AssetId },
|
|
61
|
-
{ no: 3, name: "at_block", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
|
|
62
|
-
{ no: 4, name: "response_key", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
|
|
63
|
-
{ no: 5, name: "eip712_signature", kind: "scalar", T: 12 /* ScalarType.BYTES */ },
|
|
64
|
-
{ no: 6, name: "query_timestamp", kind: "scalar", T: 4 /* ScalarType.UINT64 */ },
|
|
65
|
-
]);
|
|
66
|
-
static fromBinary(bytes, options) {
|
|
67
|
-
return new GetBalanceRequest().fromBinary(bytes, options);
|
|
68
|
-
}
|
|
69
|
-
static fromJson(jsonValue, options) {
|
|
70
|
-
return new GetBalanceRequest().fromJson(jsonValue, options);
|
|
71
|
-
}
|
|
72
|
-
static fromJsonString(jsonString, options) {
|
|
73
|
-
return new GetBalanceRequest().fromJsonString(jsonString, options);
|
|
74
|
-
}
|
|
75
|
-
static equals(a, b) {
|
|
76
|
-
return proto3.util.equals(GetBalanceRequest, a, b);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* GetBalanceResponse returns the account's balance breakdown.
|
|
81
|
-
* Serialized and AEAD-encrypted into an EncryptedResponse.
|
|
82
|
-
*
|
|
83
|
-
* @generated from message inco.shield.v2.GetBalanceResponse
|
|
84
|
-
*/
|
|
85
|
-
export class GetBalanceResponse extends Message {
|
|
86
|
-
/**
|
|
87
|
-
* Balance from settled transfers.
|
|
88
|
-
*
|
|
89
|
-
* @generated from field: inco.shield.v2.Uint256 confirmed_balance = 1;
|
|
90
|
-
*/
|
|
91
|
-
confirmedBalance;
|
|
92
|
-
/**
|
|
93
|
-
* Balance from in-flight transfers not yet settled.
|
|
94
|
-
*
|
|
95
|
-
* @generated from field: inco.shield.v2.Uint256 pending_balance = 2;
|
|
96
|
-
*/
|
|
97
|
-
pendingBalance;
|
|
98
|
-
/**
|
|
99
|
-
* Total available balance (confirmed + pending).
|
|
100
|
-
*
|
|
101
|
-
* @generated from field: inco.shield.v2.Uint256 available_balance = 3;
|
|
102
|
-
*/
|
|
103
|
-
availableBalance;
|
|
104
|
-
/**
|
|
105
|
-
* The handle at which this balance was computed.
|
|
106
|
-
*
|
|
107
|
-
* @generated from field: inco.shield.v2.Handle handle = 4;
|
|
108
|
-
*/
|
|
109
|
-
handle;
|
|
110
|
-
/**
|
|
111
|
-
* The block hash at which this balance was computed.
|
|
112
|
-
*
|
|
113
|
-
* @generated from field: inco.shield.v2.Bytes32 block_hash = 5;
|
|
114
|
-
*/
|
|
115
|
-
blockHash;
|
|
116
|
-
constructor(data) {
|
|
117
|
-
super();
|
|
118
|
-
proto3.util.initPartial(data, this);
|
|
119
|
-
}
|
|
120
|
-
static runtime = proto3;
|
|
121
|
-
static typeName = "inco.shield.v2.GetBalanceResponse";
|
|
122
|
-
static fields = proto3.util.newFieldList(() => [
|
|
123
|
-
{ no: 1, name: "confirmed_balance", kind: "message", T: Uint256 },
|
|
124
|
-
{ no: 2, name: "pending_balance", kind: "message", T: Uint256 },
|
|
125
|
-
{ no: 3, name: "available_balance", kind: "message", T: Uint256 },
|
|
126
|
-
{ no: 4, name: "handle", kind: "message", T: Handle },
|
|
127
|
-
{ no: 5, name: "block_hash", kind: "message", T: Bytes32 },
|
|
128
|
-
]);
|
|
129
|
-
static fromBinary(bytes, options) {
|
|
130
|
-
return new GetBalanceResponse().fromBinary(bytes, options);
|
|
131
|
-
}
|
|
132
|
-
static fromJson(jsonValue, options) {
|
|
133
|
-
return new GetBalanceResponse().fromJson(jsonValue, options);
|
|
134
|
-
}
|
|
135
|
-
static fromJsonString(jsonString, options) {
|
|
136
|
-
return new GetBalanceResponse().fromJsonString(jsonString, options);
|
|
137
|
-
}
|
|
138
|
-
static equals(a, b) {
|
|
139
|
-
return proto3.util.equals(GetBalanceResponse, a, b);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ENTRYPOINT_VERSION } from './types.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ENTRYPOINT_VERSION } from './types.js';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sepolia testnet configuration for UniswapV4Adapter testing
|
|
3
|
-
*/
|
|
4
|
-
import type { Address } from 'viem';
|
|
5
|
-
export declare const SEPOLIA_CHAIN_ID = 11155111;
|
|
6
|
-
interface UniswapSepoliaContracts {
|
|
7
|
-
UNIVERSAL_ROUTER: Address;
|
|
8
|
-
PERMIT2: Address;
|
|
9
|
-
POOL_MANAGER: Address;
|
|
10
|
-
V4_QUOTER: Address;
|
|
11
|
-
STATE_VIEW: Address;
|
|
12
|
-
}
|
|
13
|
-
interface SepoliaTokens {
|
|
14
|
-
NATIVE_ETH: Address;
|
|
15
|
-
WETH: Address;
|
|
16
|
-
USDC: Address;
|
|
17
|
-
}
|
|
18
|
-
interface PoolConstants {
|
|
19
|
-
FEE: number;
|
|
20
|
-
TICK_SPACING: number;
|
|
21
|
-
HOOKS: Address;
|
|
22
|
-
}
|
|
23
|
-
export declare const UNISWAP_V4_SEPOLIA: UniswapSepoliaContracts;
|
|
24
|
-
export declare const SEPOLIA_TOKENS: SepoliaTokens;
|
|
25
|
-
export declare const POOL_CONFIG: PoolConstants;
|
|
26
|
-
export declare const WETH_USDC_POOL_CONFIG: PoolConstants;
|
|
27
|
-
export interface DeployedContracts {
|
|
28
|
-
incoShield: Address;
|
|
29
|
-
teeSmartAccount: Address;
|
|
30
|
-
erc20Adapter: Address;
|
|
31
|
-
uniswapV4Adapter: Address;
|
|
32
|
-
}
|
|
33
|
-
export declare const DEPLOYED_CONTRACTS: DeployedContracts;
|
|
34
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sepolia testnet configuration for UniswapV4Adapter testing
|
|
3
|
-
*/
|
|
4
|
-
// Chain configuration
|
|
5
|
-
export const SEPOLIA_CHAIN_ID = 11155111;
|
|
6
|
-
// Uniswap V4 contracts on Sepolia
|
|
7
|
-
export const UNISWAP_V4_SEPOLIA = {
|
|
8
|
-
UNIVERSAL_ROUTER: '0x3A9D48AB9751398BbFa63ad67599Bb04e4BdF98b',
|
|
9
|
-
PERMIT2: '0x000000000022D473030F116dDEE9F6B43aC78BA3',
|
|
10
|
-
POOL_MANAGER: '0xE03A1074c86CFeDd5C142C4F04F1a1536e203543',
|
|
11
|
-
V4_QUOTER: '0x61b3f2011a92d183c7dbadbda940a7555ccf9227',
|
|
12
|
-
STATE_VIEW: '0xe1dd9c3fa50edb962e442f60dfbc432e24537e4c',
|
|
13
|
-
};
|
|
14
|
-
// Common test tokens on Sepolia
|
|
15
|
-
export const SEPOLIA_TOKENS = {
|
|
16
|
-
// Native ETH (address(0) in V4)
|
|
17
|
-
NATIVE_ETH: '0x0000000000000000000000000000000000000000',
|
|
18
|
-
WETH: '0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9',
|
|
19
|
-
USDC: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // Circle's testnet USDC
|
|
20
|
-
};
|
|
21
|
-
// Pool configuration for ETH/USDC (best liquidity pool on Sepolia V4)
|
|
22
|
-
// Pool ID: 0x3390c733d8252e864d4ce769398dd3fb8680d1f626719e8d7736d062665f0987
|
|
23
|
-
// Currency0: Native ETH (0x0...0)
|
|
24
|
-
// Currency1: USDC
|
|
25
|
-
// Liquidity: 2805238952407756
|
|
26
|
-
export const POOL_CONFIG = {
|
|
27
|
-
FEE: 3000, // 0.3%
|
|
28
|
-
TICK_SPACING: 60,
|
|
29
|
-
HOOKS: '0x0000000000000000000000000000000000000000',
|
|
30
|
-
};
|
|
31
|
-
// Alternative: WETH/USDC pool with some liquidity
|
|
32
|
-
// Pool ID: 0xda4df63a89fcfed42a03810ab15dd5df417167b9ecef407de884465f23181d4e
|
|
33
|
-
// Fee: 10000 (1%), TickSpacing: 200, Liquidity: 39867548
|
|
34
|
-
export const WETH_USDC_POOL_CONFIG = {
|
|
35
|
-
FEE: 10000, // 1%
|
|
36
|
-
TICK_SPACING: 200,
|
|
37
|
-
HOOKS: '0x0000000000000000000000000000000000000000',
|
|
38
|
-
};
|
|
39
|
-
// Deployed contracts on Sepolia
|
|
40
|
-
export const DEPLOYED_CONTRACTS = {
|
|
41
|
-
incoShield: '0xf203cf28b03c8c3c47678c243c49E34A654e1bfb',
|
|
42
|
-
teeSmartAccount: '0xF468DCD280d345e1a2429Ae569Ebbf23c3D43795',
|
|
43
|
-
erc20Adapter: '0xF1CD72CFE89c6FF352bdDe4c126Bfec218D7EF95',
|
|
44
|
-
uniswapV4Adapter: '0xe634f32b0add29b975a58412eff6dfbd8cf946b6',
|
|
45
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find Uniswap V4 pools with liquidity
|
|
3
|
-
*
|
|
4
|
-
* Uses the StateView contract to query pool state and liquidity.
|
|
5
|
-
*/
|
|
6
|
-
import type { Address, Hex } from 'viem';
|
|
7
|
-
declare const STATE_VIEW_ABI: readonly [{
|
|
8
|
-
readonly name: "getSlot0";
|
|
9
|
-
readonly type: "function";
|
|
10
|
-
readonly stateMutability: "view";
|
|
11
|
-
readonly inputs: readonly [{
|
|
12
|
-
readonly type: "bytes32";
|
|
13
|
-
readonly name: "poolId";
|
|
14
|
-
}];
|
|
15
|
-
readonly outputs: readonly [{
|
|
16
|
-
readonly type: "uint160";
|
|
17
|
-
readonly name: "sqrtPriceX96";
|
|
18
|
-
}, {
|
|
19
|
-
readonly type: "int24";
|
|
20
|
-
readonly name: "tick";
|
|
21
|
-
}, {
|
|
22
|
-
readonly type: "uint24";
|
|
23
|
-
readonly name: "protocolFee";
|
|
24
|
-
}, {
|
|
25
|
-
readonly type: "uint24";
|
|
26
|
-
readonly name: "lpFee";
|
|
27
|
-
}];
|
|
28
|
-
}, {
|
|
29
|
-
readonly name: "getLiquidity";
|
|
30
|
-
readonly type: "function";
|
|
31
|
-
readonly stateMutability: "view";
|
|
32
|
-
readonly inputs: readonly [{
|
|
33
|
-
readonly type: "bytes32";
|
|
34
|
-
readonly name: "poolId";
|
|
35
|
-
}];
|
|
36
|
-
readonly outputs: readonly [{
|
|
37
|
-
readonly type: "uint128";
|
|
38
|
-
}];
|
|
39
|
-
}];
|
|
40
|
-
/** Pool key configuration */
|
|
41
|
-
export interface PoolKey {
|
|
42
|
-
currency0: Address;
|
|
43
|
-
currency1: Address;
|
|
44
|
-
fee: number;
|
|
45
|
-
tickSpacing: number;
|
|
46
|
-
hooks: Address;
|
|
47
|
-
}
|
|
48
|
-
/** Pool configuration with name for display */
|
|
49
|
-
export interface PoolConfig extends PoolKey {
|
|
50
|
-
name: string;
|
|
51
|
-
}
|
|
52
|
-
/** Pool state from on-chain query */
|
|
53
|
-
export interface PoolState {
|
|
54
|
-
pool: PoolConfig;
|
|
55
|
-
poolId: Hex;
|
|
56
|
-
liquidity: bigint;
|
|
57
|
-
tick: number;
|
|
58
|
-
sqrtPriceX96: bigint;
|
|
59
|
-
isInitialized: boolean;
|
|
60
|
-
hasLiquidity: boolean;
|
|
61
|
-
}
|
|
62
|
-
/** Client capable of reading contracts */
|
|
63
|
-
export interface ReadClient {
|
|
64
|
-
readContract: (params: {
|
|
65
|
-
address: Address;
|
|
66
|
-
abi: typeof STATE_VIEW_ABI;
|
|
67
|
-
functionName: string;
|
|
68
|
-
args: readonly unknown[];
|
|
69
|
-
}) => Promise<unknown>;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Compute pool ID from pool key
|
|
73
|
-
*
|
|
74
|
-
* Pool ID is keccak256(abi.encode(poolKey))
|
|
75
|
-
*/
|
|
76
|
-
export declare function computePoolId(pool: PoolKey): Hex;
|
|
77
|
-
/**
|
|
78
|
-
* Get pool state from StateView contract
|
|
79
|
-
*/
|
|
80
|
-
export declare function getPoolState(publicClient: ReadClient, stateViewAddress: Address, pool: PoolConfig): Promise<PoolState>;
|
|
81
|
-
/**
|
|
82
|
-
* Find pools with liquidity from a list of pool configurations
|
|
83
|
-
*
|
|
84
|
-
* @returns Array of pool states sorted by liquidity (descending)
|
|
85
|
-
*/
|
|
86
|
-
export declare function findPoolsWithLiquidity(publicClient: ReadClient, stateViewAddress: Address, pools: PoolConfig[]): Promise<PoolState[]>;
|
|
87
|
-
/**
|
|
88
|
-
* Get the best pool (highest liquidity) from a list
|
|
89
|
-
*/
|
|
90
|
-
export declare function findBestPool(publicClient: ReadClient, stateViewAddress: Address, pools: PoolConfig[]): Promise<PoolState | null>;
|
|
91
|
-
export {};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find Uniswap V4 pools with liquidity
|
|
3
|
-
*
|
|
4
|
-
* Uses the StateView contract to query pool state and liquidity.
|
|
5
|
-
*/
|
|
6
|
-
import { encodeAbiParameters, keccak256, parseAbi } from 'viem';
|
|
7
|
-
import { InvalidContractReturnType } from '../errors.js';
|
|
8
|
-
// StateView ABI for reading pool state
|
|
9
|
-
const STATE_VIEW_ABI = parseAbi([
|
|
10
|
-
'function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)',
|
|
11
|
-
'function getLiquidity(bytes32 poolId) view returns (uint128)',
|
|
12
|
-
]);
|
|
13
|
-
/**
|
|
14
|
-
* Compute pool ID from pool key
|
|
15
|
-
*
|
|
16
|
-
* Pool ID is keccak256(abi.encode(poolKey))
|
|
17
|
-
*/
|
|
18
|
-
export function computePoolId(pool) {
|
|
19
|
-
return keccak256(encodeAbiParameters([
|
|
20
|
-
{ type: 'address', name: 'currency0' },
|
|
21
|
-
{ type: 'address', name: 'currency1' },
|
|
22
|
-
{ type: 'uint24', name: 'fee' },
|
|
23
|
-
{ type: 'int24', name: 'tickSpacing' },
|
|
24
|
-
{ type: 'address', name: 'hooks' },
|
|
25
|
-
], [pool.currency0, pool.currency1, pool.fee, pool.tickSpacing, pool.hooks]));
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get pool state from StateView contract
|
|
29
|
-
*/
|
|
30
|
-
export async function getPoolState(publicClient, stateViewAddress, pool) {
|
|
31
|
-
const poolId = computePoolId(pool);
|
|
32
|
-
const [slot0, liquidity] = await Promise.all([
|
|
33
|
-
publicClient.readContract({
|
|
34
|
-
address: stateViewAddress,
|
|
35
|
-
abi: STATE_VIEW_ABI,
|
|
36
|
-
functionName: 'getSlot0',
|
|
37
|
-
args: [poolId],
|
|
38
|
-
}),
|
|
39
|
-
publicClient.readContract({
|
|
40
|
-
address: stateViewAddress,
|
|
41
|
-
abi: STATE_VIEW_ABI,
|
|
42
|
-
functionName: 'getLiquidity',
|
|
43
|
-
args: [poolId],
|
|
44
|
-
}),
|
|
45
|
-
]);
|
|
46
|
-
if (!Array.isArray(slot0) ||
|
|
47
|
-
typeof slot0[0] !== 'bigint' ||
|
|
48
|
-
typeof slot0[1] !== 'number') {
|
|
49
|
-
throw new InvalidContractReturnType({
|
|
50
|
-
message: 'Expected slot0 tuple from getSlot0',
|
|
51
|
-
functionName: 'getSlot0',
|
|
52
|
-
expectedType: '[bigint sqrtPriceX96, number tick, ...]',
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const sqrtPriceX96 = slot0[0];
|
|
56
|
-
const tick = slot0[1];
|
|
57
|
-
if (typeof liquidity !== 'bigint') {
|
|
58
|
-
throw new InvalidContractReturnType({
|
|
59
|
-
message: 'Expected bigint liquidity from getLiquidity',
|
|
60
|
-
functionName: 'getLiquidity',
|
|
61
|
-
expectedType: 'bigint',
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
const liquidityValue = liquidity;
|
|
65
|
-
return {
|
|
66
|
-
pool,
|
|
67
|
-
poolId,
|
|
68
|
-
liquidity: liquidityValue,
|
|
69
|
-
tick,
|
|
70
|
-
sqrtPriceX96,
|
|
71
|
-
isInitialized: sqrtPriceX96 > 0n,
|
|
72
|
-
hasLiquidity: liquidityValue > 0n,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Find pools with liquidity from a list of pool configurations
|
|
77
|
-
*
|
|
78
|
-
* @returns Array of pool states sorted by liquidity (descending)
|
|
79
|
-
*/
|
|
80
|
-
export async function findPoolsWithLiquidity(publicClient, stateViewAddress, pools) {
|
|
81
|
-
const results = [];
|
|
82
|
-
for (const pool of pools) {
|
|
83
|
-
try {
|
|
84
|
-
const state = await getPoolState(publicClient, stateViewAddress, pool);
|
|
85
|
-
results.push(state);
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
// Only skip if pool doesn't exist (sqrtPriceX96 is 0)
|
|
89
|
-
// Re-throw unexpected errors (network failures, etc.)
|
|
90
|
-
if (error instanceof Error &&
|
|
91
|
-
error.message.includes('returned no data')) {
|
|
92
|
-
continue; // Pool not initialized, expected
|
|
93
|
-
}
|
|
94
|
-
console.warn(`Failed to query pool ${pool.name}:`, error);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// Filter to pools with liquidity and sort by liquidity descending
|
|
98
|
-
return results
|
|
99
|
-
.filter((r) => r.hasLiquidity)
|
|
100
|
-
.sort((a, b) => (b.liquidity > a.liquidity ? 1 : -1));
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Get the best pool (highest liquidity) from a list
|
|
104
|
-
*/
|
|
105
|
-
export async function findBestPool(publicClient, stateViewAddress, pools) {
|
|
106
|
-
const poolsWithLiquidity = await findPoolsWithLiquidity(publicClient, stateViewAddress, pools);
|
|
107
|
-
return poolsWithLiquidity[0] ?? null;
|
|
108
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UniswapV4 Adapter SDK for IncoShield
|
|
3
|
-
*
|
|
4
|
-
* Provides functions for:
|
|
5
|
-
* - Finding Uniswap V4 pools with liquidity
|
|
6
|
-
* - Building and executing swaps through IncoShield
|
|
7
|
-
*/
|
|
8
|
-
export { DEPLOYED_CONTRACTS, type DeployedContracts, POOL_CONFIG, SEPOLIA_CHAIN_ID, SEPOLIA_TOKENS, UNISWAP_V4_SEPOLIA, WETH_USDC_POOL_CONFIG, } from './config.js';
|
|
9
|
-
export { computePoolId, findBestPool, findPoolsWithLiquidity, getPoolState, type PoolConfig, type PoolKey, type PoolState, } from './find-pools.js';
|
|
10
|
-
export { approveToken, type BuildV4ActionsParams, buildDefiInteraction, buildDeposit, buildEncodedV4Actions, type DefiInteractionParams, type DepositParams, depositToShield, encodeSwapArgs, executeDefiInteraction, generateNullifier, getDefiInteractionDigest, getTokenBalance, signDefiInteraction, type UniswapV4SwapArgs, } from './swap.js';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* UniswapV4 Adapter SDK for IncoShield
|
|
3
|
-
*
|
|
4
|
-
* Provides functions for:
|
|
5
|
-
* - Finding Uniswap V4 pools with liquidity
|
|
6
|
-
* - Building and executing swaps through IncoShield
|
|
7
|
-
*/
|
|
8
|
-
// Configuration
|
|
9
|
-
export { DEPLOYED_CONTRACTS, POOL_CONFIG, SEPOLIA_CHAIN_ID, SEPOLIA_TOKENS, UNISWAP_V4_SEPOLIA, WETH_USDC_POOL_CONFIG, } from './config.js';
|
|
10
|
-
// Pool discovery
|
|
11
|
-
export { computePoolId, findBestPool, findPoolsWithLiquidity, getPoolState, } from './find-pools.js';
|
|
12
|
-
// Swap functionality
|
|
13
|
-
export { approveToken, buildDefiInteraction, buildDeposit, buildEncodedV4Actions, depositToShield, encodeSwapArgs, executeDefiInteraction, generateNullifier, getDefiInteractionDigest, getTokenBalance, signDefiInteraction, } from './swap.js';
|