Skip to content

Commit e55c1ea

Browse files
committed
add scripts
1 parent 4997e77 commit e55c1ea

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@
253253
},
254254
"arb_sepolia": {
255255
"USDC": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
256+
"USDT": "0xEf54C221Fc94517877F0F40eCd71E0A3866D66C2",
256257
"endpoint": "0x6EDCE65403992e310A62460808c4b910D972f10f",
257258
"chainId": 421614,
258259
"eid": 40231,
@@ -397,6 +398,7 @@
397398
},
398399
"base_sepolia": {
399400
"USDC": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
401+
"USDT": "0x78398524Ab8500736B56eaAb1a590733c2B04144",
400402
"endpoint": "0x6EDCE65403992e310A62460808c4b910D972f10f",
401403
"chainId": 84532,
402404
"eid": 40245,

contracts/interfaces/IVaultAdapter.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ interface IVaultAdapter {
1111
event BrokerAllowedSet(bytes32 brokerHash, bool isAllowed);
1212
event TokenHashToTokenSet(bytes32 tokenHash, address token);
1313
event ProtocolVaultSet(address protocolVault);
14-
14+
//0x82b42900
1515
error Unauthorized();
16+
//0xd92e233d
1617
error ZeroAddress();
18+
//0x6eaf1c06
1719
error InvalidRoleType();
20+
//0x29a3ee79
1821
error InvalidTokenHash();
22+
//0x44e8bd2c
1923
error InvalidNativeAmount();
2024
error BrokerNotAllowed();
2125
error RecordAlreadyHandled(uint256 recordId);

tasks/check.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ async function checkVaultAdapter(env) {
189189
deployment[env].vaultAdapter
190190
)
191191

192-
console.log("Checking contract deployment...");
193192
// 检查合约代码是否存在
194193
const code = await ethers.provider.getCode(deployment[env].vaultAdapter);
195194
if (code === "0x") {
@@ -199,45 +198,47 @@ async function checkVaultAdapter(env) {
199198

200199
try {
201200
//check dex operator
202-
console.log("Checking operator...");
203201
const operator = await adapterContract.operator();
204202
assert.equal(operator.toLowerCase(), deployment[env].dex_operator.toLowerCase(), `${env} operator config error`);
205203
console.log("Operator verified ✓");
206204

207205
//check dexVault
208-
console.log("Checking dexVault...");
209206
const dexVault = await adapterContract.dexVault();
210207
assert.equal(dexVault.toLowerCase(), deployment[env].dex[currentNetwork].toLowerCase(), `${env} dex on ${currentNetwork} config error`);
211208
console.log("DexVault verified ✓");
212209

213210
//check engine
214-
console.log("Checking engine...");
215211
const engine = await adapterContract.engine();
216212
assert.equal(engine.toLowerCase(), deployment[env].adapter_engine.toLowerCase(), `${env} engine config error`);
217213
console.log("Engine verified ✓");
218214

219215
//check USDC token mapping
220-
console.log("Checking USDC token mapping...");
221216
const usdcHash = "0xd6aca1be9729c13d677335161321649cccae6a591554772516700f986f942eaa"; // USDC hash
222217
const mappedToken = await adapterContract.tokenHashToToken(usdcHash);
223218
assert.equal(mappedToken.toLowerCase(), config[currentNetwork].USDC.toLowerCase(), `${env} USDC token mapping error`);
224219
console.log("USDC token mapping verified ✓");
225220

221+
//check USDT token mapping
222+
console.log("Checking USDT token mapping...");
223+
const usdtHash = "0x8b1a1d9c2b109e527c9134b25b1a1833b16b6594f92daa9f6d9b7a6024bce9d0"; // USDT hash
224+
const mappedUsdtToken = await adapterContract.tokenHashToToken(usdtHash);
225+
assert.equal(mappedUsdtToken.toLowerCase(), config[currentNetwork].USDT.toLowerCase(), `${env} USDT token mapping error`);
226+
console.log("USDT token mapping verified ✓");
227+
226228
//check protocol vault
227-
console.log("Checking protocol vault...");
228229
const protocolVault = await adapterContract.protocolVault();
229230
assert.equal(protocolVault.toLowerCase(), deployment[env].protocolVault.toLowerCase(), `${env} protocol vault config error`);
230231
console.log("Protocol vault verified ✓");
231-
232+
233+
232234
//check brokers
233-
console.log("Checking allowed brokers...");
234235
const allowedBrokers = deployment.allowedBrokersForAdapter;
235-
236+
236237
if (!allowedBrokers || allowedBrokers.length === 0) {
237238
console.log("No allowed brokers found in deployment config");
238239
} else {
239240
console.log(`Found ${allowedBrokers.length} brokers to verify:`);
240-
241+
241242
for (const brokerHash of allowedBrokers) {
242243
console.log(`Checking broker: ${brokerHash}`);
243244
const isAllowed = await adapterContract.isAllowedBroker(brokerHash);
@@ -250,4 +251,4 @@ async function checkVaultAdapter(env) {
250251
console.error(`Failed to verify configuration: ${error.message}`);
251252
throw error;
252253
}
253-
}
254+
}

tasks/config.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ async function configProtocolVault(env) {
278278

279279
async function configVaultAdapter(env) {
280280
console.log(`Configuring VaultAdapter for ${env} environment...`);
281-
281+
const currentNetwork = hre.network.name;
282+
282283
// Get the contract instance
283284
const vaultAdapterContract = await ethers.getContractAt(
284285
"VaultAdapter",
@@ -287,23 +288,23 @@ async function configVaultAdapter(env) {
287288

288289
// Get allowed brokers from deployment config
289290
const allowedBrokers = deployment.allowedBrokersForAdapter;
290-
291+
291292
if (!allowedBrokers || allowedBrokers.length === 0) {
292293
console.log("No allowed brokers found in deployment config");
293294
return;
294295
}
295-
296+
296297
let configuredCount = 0;
297298
let skippedCount = 0;
298299

299300
//set allowed brokers
300301
for (const brokerHash of allowedBrokers) {
301302
console.log(`Checking broker: ${brokerHash}`);
302-
303+
303304
try {
304305
// Check if broker is already allowed
305306
const isAllowed = await vaultAdapterContract.isAllowedBroker(brokerHash);
306-
307+
307308
if (isAllowed) {
308309
console.log(`✓ Broker ${brokerHash} is already configured`);
309310
skippedCount++;
@@ -320,6 +321,19 @@ async function configVaultAdapter(env) {
320321
}
321322
}
322323

324+
//set usdt token hash
325+
const usdtHash = "0x8b1a1d9c2b109e527c9134b25b1a1833b16b6594f92daa9f6d9b7a6024bce9d0"; // USDT hash
326+
const usdtToken = config[currentNetwork].USDT;
327+
const mappedUsdtToken = await vaultAdapterContract.tokenHashToToken(usdtHash);
328+
329+
if (usdtToken != mappedUsdtToken) {
330+
tx = await vaultAdapterContract.setAllowedTokenHashToToken(usdtHash, usdtToken);
331+
await tx.wait();
332+
console.log(`USDT token hash ${usdtHash} set to ${usdtToken} successfully`);
333+
} else {
334+
console.log(`USDT token hash ${usdtHash} is already set to ${usdtToken}`);
335+
}
336+
323337
//set protocol vault
324338
const protocolVault = deployment[env].protocolVault;
325339
tx = await vaultAdapterContract.setProtocolVault(protocolVault);

0 commit comments

Comments
 (0)