@zircuit/ovault-evm 0.0.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 +141 -0
- package/dist/addresses.d.ts +41 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +48 -0
- package/dist/contracts/EIP2612.d.ts +14 -0
- package/dist/contracts/EIP2612.d.ts.map +1 -0
- package/dist/contracts/EIP2612.js +38 -0
- package/dist/contracts/ERC20.d.ts +169 -0
- package/dist/contracts/ERC20.d.ts.map +1 -0
- package/dist/contracts/ERC20.js +222 -0
- package/dist/contracts/ERC4626.d.ts +2020 -0
- package/dist/contracts/ERC4626.d.ts.map +1 -0
- package/dist/contracts/ERC4626.js +2638 -0
- package/dist/contracts/OFT.d.ts +1736 -0
- package/dist/contracts/OFT.d.ts.map +1 -0
- package/dist/contracts/OFT.js +2251 -0
- package/dist/contracts/OVaultComposer.d.ts +94 -0
- package/dist/contracts/OVaultComposer.d.ts.map +1 -0
- package/dist/contracts/OVaultComposer.js +1629 -0
- package/dist/contracts/OVaultComposerSync.d.ts +528 -0
- package/dist/contracts/OVaultComposerSync.d.ts.map +1 -0
- package/dist/contracts/OVaultComposerSync.js +682 -0
- package/dist/contracts/OVaultComposerSyncNative.d.ts +560 -0
- package/dist/contracts/OVaultComposerSyncNative.d.ts.map +1 -0
- package/dist/contracts/OVaultComposerSyncNative.js +723 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/oVaultSync/index.d.ts +3 -0
- package/dist/oVaultSync/index.d.ts.map +1 -0
- package/dist/oVaultSync/index.js +2 -0
- package/dist/oVaultSync/tracking.d.ts +46 -0
- package/dist/oVaultSync/tracking.d.ts.map +1 -0
- package/dist/oVaultSync/tracking.js +458 -0
- package/dist/oVaultSync/transfer.d.ts +116 -0
- package/dist/oVaultSync/transfer.d.ts.map +1 -0
- package/dist/oVaultSync/transfer.js +515 -0
- package/dist/types.d.ts +202 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/package.json +51 -0
- package/src/addresses.ts +100 -0
- package/src/contracts/EIP2612.ts +38 -0
- package/src/contracts/ERC20.ts +222 -0
- package/src/contracts/ERC4626.ts +2638 -0
- package/src/contracts/OFT.ts +2251 -0
- package/src/contracts/OVaultComposer.ts +1629 -0
- package/src/contracts/OVaultComposerSync.ts +682 -0
- package/src/index.ts +3 -0
- package/src/oVaultSync/index.ts +2 -0
- package/src/oVaultSync/tracking.ts +614 -0
- package/src/oVaultSync/transfer.ts +742 -0
- package/src/types.ts +260 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { Chain as ViemChain } from "viem";
|
|
2
|
+
import { OFTAbi } from "./contracts/OFT";
|
|
3
|
+
import { OVaultComposerSyncAbi } from "./contracts/OVaultComposerSync";
|
|
4
|
+
import { ERC4626_ABI } from "./contracts/ERC4626";
|
|
5
|
+
import type { SupportedChainName, SupportedToken } from "./addresses";
|
|
6
|
+
export declare enum OVaultSyncOperations {
|
|
7
|
+
DEPOSIT = "deposit",
|
|
8
|
+
REDEEM = "redeem"
|
|
9
|
+
}
|
|
10
|
+
export type OVaultWithdrawalInfo = {
|
|
11
|
+
index: bigint | number | string;
|
|
12
|
+
initiator: `0x${string}`;
|
|
13
|
+
};
|
|
14
|
+
export type OVaultMessageWithTxHash = {
|
|
15
|
+
source?: {
|
|
16
|
+
tx?: {
|
|
17
|
+
txHash?: `0x${string}`;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export interface SendParamsInput {
|
|
22
|
+
srcEid: number;
|
|
23
|
+
hubEid: number;
|
|
24
|
+
dstEid: number;
|
|
25
|
+
dstAddress: `0x${string}`;
|
|
26
|
+
walletAddress: `0x${string}`;
|
|
27
|
+
referralCode?: string;
|
|
28
|
+
vaultAddress: `0x${string}`;
|
|
29
|
+
oftHubAddress: `0x${string}`;
|
|
30
|
+
composerAddress: `0x${string}`;
|
|
31
|
+
vaultTokenAddress: `0x${string}`;
|
|
32
|
+
hubChain: ViemChain;
|
|
33
|
+
sourceChain: ViemChain;
|
|
34
|
+
operation: OVaultSyncOperations;
|
|
35
|
+
amount: bigint;
|
|
36
|
+
tokenHubDecimals?: number;
|
|
37
|
+
dstAmount: bigint;
|
|
38
|
+
minDstAmount: bigint;
|
|
39
|
+
slippage: number;
|
|
40
|
+
oftAddress: `0x${string}`;
|
|
41
|
+
tokenAddress: `0x${string}`;
|
|
42
|
+
supportsEip2612?: boolean;
|
|
43
|
+
requiresZeroApprovalReset?: boolean;
|
|
44
|
+
hubLzComposeGasLimit?: bigint;
|
|
45
|
+
buffer?: number;
|
|
46
|
+
hubRpcUrl?: string;
|
|
47
|
+
sourceRpcUrl?: string;
|
|
48
|
+
}
|
|
49
|
+
export type GenerateOVaultSyncInputsProps = Omit<SendParamsInput, "dstAmount" | "minDstAmount" | "dstAddress" | "hubChainSourceAmount" | "amount"> & {
|
|
50
|
+
amount: string;
|
|
51
|
+
tokenLocalDecimals: number;
|
|
52
|
+
dstAddress?: `0x${string}`;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Simplified input for `generateOVaultInputs`. The SDK resolves all contract
|
|
56
|
+
* addresses, EIDs, chain objects, and decimals from the built-in registry.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const result = await OVaultSyncMessageBuilder.generateOVaultInputs({
|
|
61
|
+
* sourceChain: "ethereum",
|
|
62
|
+
* destinationChain: "base",
|
|
63
|
+
* token: "USDC",
|
|
64
|
+
* operation: OVaultSyncOperations.DEPOSIT,
|
|
65
|
+
* amount: "100",
|
|
66
|
+
* walletAddress: "0x...",
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export interface OVaultCoreInputs {
|
|
71
|
+
/** Chain where the user submits the transaction */
|
|
72
|
+
sourceChain: SupportedChainName;
|
|
73
|
+
/** Chain where tokens/shares are delivered */
|
|
74
|
+
destinationChain: SupportedChainName;
|
|
75
|
+
/** Token to deposit or redeem */
|
|
76
|
+
token: SupportedToken;
|
|
77
|
+
/** Deposit or redeem */
|
|
78
|
+
operation: OVaultSyncOperations;
|
|
79
|
+
/** Human-readable amount (e.g. "100" or "1.5") */
|
|
80
|
+
amount: string;
|
|
81
|
+
/** User's wallet address */
|
|
82
|
+
walletAddress: `0x${string}`;
|
|
83
|
+
/** Destination address (defaults to walletAddress) */
|
|
84
|
+
dstAddress?: `0x${string}`;
|
|
85
|
+
/** Slippage tolerance as a decimal (0.01 = 1%). Defaults to 0.01. */
|
|
86
|
+
slippage?: number;
|
|
87
|
+
/** Extra percentage buffer on the message fee. Defaults to 0.3 (30%). */
|
|
88
|
+
buffer?: number;
|
|
89
|
+
/** Whether the token supports EIP-2612 permit. Defaults to false. */
|
|
90
|
+
supportsEip2612?: boolean;
|
|
91
|
+
/** Override the LZ compose gas limit for cross-chain operations. */
|
|
92
|
+
hubLzComposeGasLimit?: bigint;
|
|
93
|
+
/** Referral code */
|
|
94
|
+
referralCode?: string;
|
|
95
|
+
/** Custom RPC URLs keyed by chain name. Avoids public RPC rate limits. */
|
|
96
|
+
rpcUrls?: Partial<Record<SupportedChainName, string>>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The send parameters for the OVault. Pass this to the OFT or OVaultComposer to send the tokens.
|
|
100
|
+
*
|
|
101
|
+
* @typedef {Object} SendParams
|
|
102
|
+
* @property {number} dstEid - The destination chain ID.
|
|
103
|
+
* @property {`0x${string}`} to - The address of the destination contract.
|
|
104
|
+
* @property {bigint} amountLD - The amount of tokens to send.
|
|
105
|
+
* @property {bigint} minAmountLD - The minimum amount of tokens to receive.
|
|
106
|
+
* @property {`0x${string}`} extraOptions - The extra options for the OVault.
|
|
107
|
+
* @property {`0x${string}`} composeMsg - The compose message for the OVault.
|
|
108
|
+
* @property {`0x${string}`} oftCmd - The OFT command for the OVault.
|
|
109
|
+
*/
|
|
110
|
+
export interface SendParams {
|
|
111
|
+
dstEid: number;
|
|
112
|
+
to: `0x${string}`;
|
|
113
|
+
amountLD: bigint;
|
|
114
|
+
minAmountLD: bigint;
|
|
115
|
+
extraOptions: `0x${string}`;
|
|
116
|
+
composeMsg: `0x${string}`;
|
|
117
|
+
oftCmd: `0x${string}`;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The message fee for the OVault.
|
|
121
|
+
*
|
|
122
|
+
* @typedef {Object} MessageFee
|
|
123
|
+
* @property {bigint} nativeFee - The native fee for the OVault.
|
|
124
|
+
* @property {bigint} lzTokenFee - The LZ token fee for the OVault.
|
|
125
|
+
*/
|
|
126
|
+
export interface MessageFee {
|
|
127
|
+
nativeFee: bigint;
|
|
128
|
+
lzTokenFee: bigint;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The inputs for the OVault.
|
|
132
|
+
*
|
|
133
|
+
* @typedef {Object} OVaultInputs
|
|
134
|
+
* @property {MessageFee} messageFee - The message fee for the OVault.
|
|
135
|
+
* @property {`0x${string}`} contractAddress - The address of the contract to call.
|
|
136
|
+
* @property {Object} dstAmount - The amount of tokens to send.
|
|
137
|
+
* @property {Object} approval - The approval parameters for the OVault. If undefined, then no approval is needed.
|
|
138
|
+
* @property {Object} txArgs - The transaction arguments for the OVault.
|
|
139
|
+
*/
|
|
140
|
+
export type OVaultSyncInputs = {
|
|
141
|
+
messageFee: MessageFee;
|
|
142
|
+
contractAddress: `0x${string}`;
|
|
143
|
+
dstAmount: {
|
|
144
|
+
amount: bigint;
|
|
145
|
+
minAmount: bigint;
|
|
146
|
+
};
|
|
147
|
+
approval?: {
|
|
148
|
+
tokenAddress: `0x${string}`;
|
|
149
|
+
amount: bigint;
|
|
150
|
+
spender: `0x${string}`;
|
|
151
|
+
usePermit?: boolean;
|
|
152
|
+
nonce?: bigint;
|
|
153
|
+
tokenName?: string;
|
|
154
|
+
tokenVersion?: string;
|
|
155
|
+
needsResetApproval?: boolean;
|
|
156
|
+
};
|
|
157
|
+
} & ({
|
|
158
|
+
txArgs: {
|
|
159
|
+
base: [SendParams, MessageFee, `0x${string}`];
|
|
160
|
+
permitParams: ["deadline", "v", "r", "s"] | null;
|
|
161
|
+
};
|
|
162
|
+
contractFunctionName: "send" | "sendWithPermit";
|
|
163
|
+
abi: typeof OFTAbi;
|
|
164
|
+
} | {
|
|
165
|
+
txArgs: {
|
|
166
|
+
base: [bigint, SendParams, `0x${string}`];
|
|
167
|
+
permitParams: ["deadline", "v", "r", "s"] | null;
|
|
168
|
+
};
|
|
169
|
+
contractFunctionName: "depositAndSendWithPermit" | "depositAndSend" | "redeemAndSend";
|
|
170
|
+
abi: typeof OVaultComposerSyncAbi;
|
|
171
|
+
} | {
|
|
172
|
+
txArgs: {
|
|
173
|
+
base: [bigint, `0x${string}`];
|
|
174
|
+
permitParams: null;
|
|
175
|
+
};
|
|
176
|
+
contractFunctionName: "deposit";
|
|
177
|
+
abi: typeof ERC4626_ABI;
|
|
178
|
+
} | {
|
|
179
|
+
txArgs: {
|
|
180
|
+
base: [bigint, `0x${string}`, `0x${string}`];
|
|
181
|
+
permitParams: null;
|
|
182
|
+
};
|
|
183
|
+
contractFunctionName: "redeem";
|
|
184
|
+
abi: typeof ERC4626_ABI;
|
|
185
|
+
});
|
|
186
|
+
export declare enum OVaultTransactionStep {
|
|
187
|
+
SOURCE_CHAIN_TRANSACTION = "sourceChainTransaction",
|
|
188
|
+
SOURCE_TO_HUB_LZ_TRANSACTION = "sourceToHubLzTransaction",
|
|
189
|
+
HUB_CHAIN_TRANSACTION = "hubChainTransaction",
|
|
190
|
+
HUB_TO_DST_LZ_TRANSACTION = "hubToDstLzTransaction",
|
|
191
|
+
DST_CHAIN_TRANSACTION = "dstChainTransaction",
|
|
192
|
+
COMPLETED = "completed"
|
|
193
|
+
}
|
|
194
|
+
export declare enum OVaultFailureReason {
|
|
195
|
+
UNKNOWN = "unknown"
|
|
196
|
+
}
|
|
197
|
+
export interface OVaultTransactionStatus {
|
|
198
|
+
step: OVaultTransactionStep;
|
|
199
|
+
failureReason?: OVaultFailureReason;
|
|
200
|
+
refunded?: boolean;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEtE,oBAAY,oBAAoB;IAC9B,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAGD,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAChC,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE;YAAE,MAAM,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;CAC9C,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,KAAK,MAAM,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;IAC5B,aAAa,EAAE,KAAK,M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O,WAAW,CAAC;CACzB,CACJ,CAAC;AAEF,oBAAY,qBAAqB;IAC/B,wBAAwB,2BAA2B;IACnD,4BAA4B,6BAA6B;IACzD,qBAAqB,wBAAwB;IAC7C,yBAAyB,0BAA0B;IACnD,qBAAqB,wBAAwB;IAC7C,SAAS,cAAc;CACxB;AAED,oBAAY,mBAAmB;IAC7B,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,qBAAqB,CAAC;IAG5B,aAAa,CAAC,EAAE,mBAAmB,CAAC;IAGpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export var OVaultSyncOperations;
|
|
2
|
+
(function (OVaultSyncOperations) {
|
|
3
|
+
OVaultSyncOperations["DEPOSIT"] = "deposit";
|
|
4
|
+
OVaultSyncOperations["REDEEM"] = "redeem";
|
|
5
|
+
})(OVaultSyncOperations || (OVaultSyncOperations = {}));
|
|
6
|
+
export var OVaultTransactionStep;
|
|
7
|
+
(function (OVaultTransactionStep) {
|
|
8
|
+
OVaultTransactionStep["SOURCE_CHAIN_TRANSACTION"] = "sourceChainTransaction";
|
|
9
|
+
OVaultTransactionStep["SOURCE_TO_HUB_LZ_TRANSACTION"] = "sourceToHubLzTransaction";
|
|
10
|
+
OVaultTransactionStep["HUB_CHAIN_TRANSACTION"] = "hubChainTransaction";
|
|
11
|
+
OVaultTransactionStep["HUB_TO_DST_LZ_TRANSACTION"] = "hubToDstLzTransaction";
|
|
12
|
+
OVaultTransactionStep["DST_CHAIN_TRANSACTION"] = "dstChainTransaction";
|
|
13
|
+
OVaultTransactionStep["COMPLETED"] = "completed";
|
|
14
|
+
})(OVaultTransactionStep || (OVaultTransactionStep = {}));
|
|
15
|
+
export var OVaultFailureReason;
|
|
16
|
+
(function (OVaultFailureReason) {
|
|
17
|
+
OVaultFailureReason["UNKNOWN"] = "unknown";
|
|
18
|
+
})(OVaultFailureReason || (OVaultFailureReason = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zircuit/ovault-evm",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Zircuit OVault Implementation SDK",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"LayerZero",
|
|
7
|
+
"Zircuit",
|
|
8
|
+
"OVault",
|
|
9
|
+
"ERC4626",
|
|
10
|
+
"Composer",
|
|
11
|
+
"OmniChain",
|
|
12
|
+
"EndpointV2",
|
|
13
|
+
"EVM"
|
|
14
|
+
],
|
|
15
|
+
"repository": "zircuit-labs/ovault-evm",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"require": "./dist/*.js",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"src/**/*",
|
|
28
|
+
"dist/**/*"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"prepublishOnly": "npm run build",
|
|
33
|
+
"test": "tsx node_modules/mocha/bin/_mocha test/**/*.test.ts"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@layerzerolabs/lz-v2-utilities": "^3.0.148",
|
|
37
|
+
"@layerzerolabs/scan-client-v2": "^0.0.1",
|
|
38
|
+
"viem": "^2.33.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/mocha": "^10.0.10",
|
|
42
|
+
"@types/node": "^24.1.0",
|
|
43
|
+
"dotenv": "^17.2.3",
|
|
44
|
+
"mocha": "^11.7.1",
|
|
45
|
+
"tsx": "^4.20.3",
|
|
46
|
+
"typescript": "^5.4.4"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/addresses.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Chain as ViemChain } from "viem";
|
|
2
|
+
import { mainnet, base } from "viem/chains";
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Supported chains
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
export type SupportedChainName = "ethereum" | "base";
|
|
9
|
+
|
|
10
|
+
export interface ChainMeta {
|
|
11
|
+
/** LayerZero Endpoint ID */
|
|
12
|
+
eid: number;
|
|
13
|
+
/** viem Chain object */
|
|
14
|
+
viemChain: ViemChain;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const CHAINS: Record<SupportedChainName, ChainMeta> = {
|
|
18
|
+
ethereum: { eid: 30101, viemChain: mainnet },
|
|
19
|
+
base: { eid: 30184, viemChain: base },
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Supported tokens
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
export type SupportedToken = "usdc" | "usdt";
|
|
27
|
+
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Per-token cluster config — hub chain is always Base
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
interface ClusterChainDeployment {
|
|
33
|
+
/** UnderlyingOFT (hub) or UnderlyingOFTAdapter (spoke) */
|
|
34
|
+
oft: `0x${string}`;
|
|
35
|
+
/** Vault (hub) or VaultToken (spoke) */
|
|
36
|
+
vault: `0x${string}`;
|
|
37
|
+
/** Underlying ERC-20 token address on this chain */
|
|
38
|
+
token: `0x${string}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface HubChainDeployment extends ClusterChainDeployment {
|
|
42
|
+
composer: `0x${string}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface ClusterConfig {
|
|
46
|
+
hubChain: "base";
|
|
47
|
+
/** Token decimals on the hub chain */
|
|
48
|
+
hubDecimals: number;
|
|
49
|
+
/** Whether the token requires resetting approval to 0 before setting a new value (e.g. USDT) */
|
|
50
|
+
requiresZeroApprovalReset: boolean;
|
|
51
|
+
/** Per-chain deployments keyed by chain name */
|
|
52
|
+
chains: Partial<Record<SupportedChainName, ClusterChainDeployment>> & {
|
|
53
|
+
/** Hub chain always present and includes composer */
|
|
54
|
+
base: HubChainDeployment;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Built-in address registry
|
|
60
|
+
*
|
|
61
|
+
* Hub chain is always **Base** for all clusters.
|
|
62
|
+
*/
|
|
63
|
+
export const CLUSTERS: Record<SupportedToken, ClusterConfig> = {
|
|
64
|
+
usdc: {
|
|
65
|
+
hubChain: "base",
|
|
66
|
+
hubDecimals: 6,
|
|
67
|
+
requiresZeroApprovalReset: false,
|
|
68
|
+
chains: {
|
|
69
|
+
base: {
|
|
70
|
+
oft: "0xd7aBC360dfcF1B6dD0a03138235e12A2bc1c1C8B",
|
|
71
|
+
vault: "0x03067bbD0d41E3Fe4A0bb6ca67c99e7352Da4CAE",
|
|
72
|
+
composer: "0xBb801ED781dF31F660cC743bEf7Bb9D04B030923",
|
|
73
|
+
token: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
74
|
+
},
|
|
75
|
+
ethereum: {
|
|
76
|
+
oft: "0xd58E8c1c83d598aD76B5f0E26B4a25cdB885d190",
|
|
77
|
+
vault: "0x07C898e77310870770f88d18a01009cB65A1c1a9",
|
|
78
|
+
token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
usdt: {
|
|
83
|
+
hubChain: "base",
|
|
84
|
+
hubDecimals: 6,
|
|
85
|
+
requiresZeroApprovalReset: true,
|
|
86
|
+
chains: {
|
|
87
|
+
base: {
|
|
88
|
+
oft: "0x264D6474802Ef8bc1bc05F89F7d640D1E93c5330",
|
|
89
|
+
vault: "0x25d90ABd6c1E8DCCD40932D2fdD2Cd381bfc832D",
|
|
90
|
+
composer: "0x16cE6D9576A411911e62b6073F1cc9d1347ad96B",
|
|
91
|
+
token: "0x820266ecC2D268B0fBbD2aA3a1bdf28d12582Bbc",
|
|
92
|
+
},
|
|
93
|
+
ethereum: {
|
|
94
|
+
oft: "0x2D342De4c58a871b3525740C58a1C112D5835865",
|
|
95
|
+
vault: "0x8ADbeA709B31A564f9750A280EC2690aD1cf470A",
|
|
96
|
+
token: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const EIP2612_ABI = [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{ name: "owner", type: "address" },
|
|
5
|
+
{ name: "spender", type: "address" },
|
|
6
|
+
{ name: "value", type: "uint256" },
|
|
7
|
+
{ name: "deadline", type: "uint256" },
|
|
8
|
+
{ name: "v", type: "uint8" },
|
|
9
|
+
{ name: "r", type: "bytes32" },
|
|
10
|
+
{ name: "s", type: "bytes32" },
|
|
11
|
+
],
|
|
12
|
+
name: "permit",
|
|
13
|
+
outputs: [],
|
|
14
|
+
stateMutability: "nonpayable",
|
|
15
|
+
type: "function",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
inputs: [{ name: "owner", type: "address" }],
|
|
19
|
+
name: "nonces",
|
|
20
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
21
|
+
stateMutability: "view",
|
|
22
|
+
type: "function",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
inputs: [],
|
|
26
|
+
name: "DOMAIN_SEPARATOR",
|
|
27
|
+
outputs: [{ name: "", type: "bytes32" }],
|
|
28
|
+
stateMutability: "view",
|
|
29
|
+
type: "function",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
inputs: [],
|
|
33
|
+
name: "version",
|
|
34
|
+
outputs: [{ name: "", type: "string" }],
|
|
35
|
+
stateMutability: "view",
|
|
36
|
+
type: "function",
|
|
37
|
+
},
|
|
38
|
+
];
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
export const ERC20Abi = [
|
|
2
|
+
{
|
|
3
|
+
constant: true,
|
|
4
|
+
inputs: [],
|
|
5
|
+
name: "name",
|
|
6
|
+
outputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "",
|
|
9
|
+
type: "string",
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
payable: false,
|
|
13
|
+
stateMutability: "view",
|
|
14
|
+
type: "function",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
constant: false,
|
|
18
|
+
inputs: [
|
|
19
|
+
{
|
|
20
|
+
name: "_spender",
|
|
21
|
+
type: "address",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "_value",
|
|
25
|
+
type: "uint256",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
name: "approve",
|
|
29
|
+
outputs: [
|
|
30
|
+
{
|
|
31
|
+
name: "",
|
|
32
|
+
type: "bool",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
payable: false,
|
|
36
|
+
stateMutability: "nonpayable",
|
|
37
|
+
type: "function",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
constant: true,
|
|
41
|
+
inputs: [],
|
|
42
|
+
name: "totalSupply",
|
|
43
|
+
outputs: [
|
|
44
|
+
{
|
|
45
|
+
name: "",
|
|
46
|
+
type: "uint256",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
payable: false,
|
|
50
|
+
stateMutability: "view",
|
|
51
|
+
type: "function",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
constant: false,
|
|
55
|
+
inputs: [
|
|
56
|
+
{
|
|
57
|
+
name: "_from",
|
|
58
|
+
type: "address",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "_to",
|
|
62
|
+
type: "address",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "_value",
|
|
66
|
+
type: "uint256",
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
name: "transferFrom",
|
|
70
|
+
outputs: [
|
|
71
|
+
{
|
|
72
|
+
name: "",
|
|
73
|
+
type: "bool",
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
payable: false,
|
|
77
|
+
stateMutability: "nonpayable",
|
|
78
|
+
type: "function",
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
constant: true,
|
|
82
|
+
inputs: [],
|
|
83
|
+
name: "decimals",
|
|
84
|
+
outputs: [
|
|
85
|
+
{
|
|
86
|
+
name: "",
|
|
87
|
+
type: "uint8",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
payable: false,
|
|
91
|
+
stateMutability: "view",
|
|
92
|
+
type: "function",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
constant: true,
|
|
96
|
+
inputs: [
|
|
97
|
+
{
|
|
98
|
+
name: "_owner",
|
|
99
|
+
type: "address",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
name: "balanceOf",
|
|
103
|
+
outputs: [
|
|
104
|
+
{
|
|
105
|
+
name: "balance",
|
|
106
|
+
type: "uint256",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
payable: false,
|
|
110
|
+
stateMutability: "view",
|
|
111
|
+
type: "function",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
constant: true,
|
|
115
|
+
inputs: [],
|
|
116
|
+
name: "symbol",
|
|
117
|
+
outputs: [
|
|
118
|
+
{
|
|
119
|
+
name: "",
|
|
120
|
+
type: "string",
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
payable: false,
|
|
124
|
+
stateMutability: "view",
|
|
125
|
+
type: "function",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
constant: false,
|
|
129
|
+
inputs: [
|
|
130
|
+
{
|
|
131
|
+
name: "_to",
|
|
132
|
+
type: "address",
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "_value",
|
|
136
|
+
type: "uint256",
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
name: "transfer",
|
|
140
|
+
outputs: [
|
|
141
|
+
{
|
|
142
|
+
name: "",
|
|
143
|
+
type: "bool",
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
payable: false,
|
|
147
|
+
stateMutability: "nonpayable",
|
|
148
|
+
type: "function",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
constant: true,
|
|
152
|
+
inputs: [
|
|
153
|
+
{
|
|
154
|
+
name: "_owner",
|
|
155
|
+
type: "address",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: "_spender",
|
|
159
|
+
type: "address",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
name: "allowance",
|
|
163
|
+
outputs: [
|
|
164
|
+
{
|
|
165
|
+
name: "",
|
|
166
|
+
type: "uint256",
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
payable: false,
|
|
170
|
+
stateMutability: "view",
|
|
171
|
+
type: "function",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
payable: true,
|
|
175
|
+
stateMutability: "payable",
|
|
176
|
+
type: "fallback",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
anonymous: false,
|
|
180
|
+
inputs: [
|
|
181
|
+
{
|
|
182
|
+
indexed: true,
|
|
183
|
+
name: "owner",
|
|
184
|
+
type: "address",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
indexed: true,
|
|
188
|
+
name: "spender",
|
|
189
|
+
type: "address",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
indexed: false,
|
|
193
|
+
name: "value",
|
|
194
|
+
type: "uint256",
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
name: "Approval",
|
|
198
|
+
type: "event",
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
anonymous: false,
|
|
202
|
+
inputs: [
|
|
203
|
+
{
|
|
204
|
+
indexed: true,
|
|
205
|
+
name: "from",
|
|
206
|
+
type: "address",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
indexed: true,
|
|
210
|
+
name: "to",
|
|
211
|
+
type: "address",
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
indexed: false,
|
|
215
|
+
name: "value",
|
|
216
|
+
type: "uint256",
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
name: "Transfer",
|
|
220
|
+
type: "event",
|
|
221
|
+
},
|
|
222
|
+
] as const;
|