@agether/sdk 1.10.1 → 1.11.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/dist/cli.js +99 -43
- package/dist/index.d.mts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +113 -48
- package/dist/index.mjs +112 -48
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -62,24 +62,30 @@ var ACCOUNT_FACTORY_ABI = [
|
|
|
62
62
|
"function totalAccounts() view returns (uint256)",
|
|
63
63
|
"function getAgentId(address account) view returns (uint256)",
|
|
64
64
|
"function createAccount(uint256 agentId) returns (address account)",
|
|
65
|
-
"function
|
|
66
|
-
"function
|
|
67
|
-
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
68
|
-
"event ValidationRegistryUpdated(address indexed oldRegistry, address indexed newRegistry)"
|
|
65
|
+
"function protocolHook() view returns (address)",
|
|
66
|
+
"function identityRegistry() view returns (address)",
|
|
67
|
+
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
69
68
|
];
|
|
70
69
|
var AGENT_ACCOUNT_ABI = [
|
|
71
70
|
"function agentId() view returns (uint256)",
|
|
72
71
|
"function owner() view returns (address)",
|
|
73
72
|
"function factory() view returns (address)",
|
|
74
|
-
"function validationRegistry() view returns (address)",
|
|
75
73
|
"function identityRegistry() view returns (address)",
|
|
76
74
|
"function balanceOf(address token) view returns (uint256)",
|
|
77
75
|
"function ethBalance() view returns (uint256)",
|
|
78
|
-
|
|
79
|
-
"function
|
|
76
|
+
// ERC-7579 execution
|
|
77
|
+
"function execute(bytes32 mode, bytes executionCalldata) payable",
|
|
78
|
+
"function executeFromExecutor(bytes32 mode, bytes executionCalldata) payable returns (bytes[])",
|
|
79
|
+
// ERC-7579 module management
|
|
80
|
+
"function installModule(uint256 moduleTypeId, address module, bytes initData) payable",
|
|
81
|
+
"function uninstallModule(uint256 moduleTypeId, address module, bytes deInitData) payable",
|
|
82
|
+
"function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)",
|
|
83
|
+
"function hook() view returns (address)",
|
|
84
|
+
// Funding (direct, no execution needed)
|
|
80
85
|
"function fund(address token, uint256 amount)",
|
|
81
86
|
"function withdraw(address token, uint256 amount, address to)",
|
|
82
87
|
"function withdrawETH(uint256 amount, address to)",
|
|
88
|
+
// EIP-1271
|
|
83
89
|
"function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4)"
|
|
84
90
|
];
|
|
85
91
|
var AGENT_REPUTATION_ABI = [
|
|
@@ -126,6 +132,10 @@ var ERC20_ABI = [
|
|
|
126
132
|
"function symbol() view returns (string)",
|
|
127
133
|
"function name() view returns (string)"
|
|
128
134
|
];
|
|
135
|
+
var KYA_HOOK_ABI = [
|
|
136
|
+
"function validationRegistry() view returns (address)",
|
|
137
|
+
"function setValidationRegistry(address newRegistry)"
|
|
138
|
+
];
|
|
129
139
|
|
|
130
140
|
// src/utils/config.ts
|
|
131
141
|
var CONTRACT_ADDRESSES = {
|
|
@@ -133,14 +143,16 @@ var CONTRACT_ADDRESSES = {
|
|
|
133
143
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
134
144
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
135
145
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
146
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
136
147
|
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
137
148
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
138
149
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
139
150
|
},
|
|
140
151
|
[8453 /* Base */]: {
|
|
141
|
-
accountFactory: "
|
|
142
|
-
validationRegistry: "
|
|
143
|
-
agentReputation: "
|
|
152
|
+
accountFactory: "0x89a8758E60A56EcB47247D92E05447eFd450d6Bf",
|
|
153
|
+
validationRegistry: "0x6f76cF69B71Dc5F9A414BCEe4583b12738E47985",
|
|
154
|
+
agentReputation: "0xe88f3419a2dbac70e3aF6E487b0C63e8301C6A87",
|
|
155
|
+
kyaHook: "0x28e50Aa9eD517E369b2806928709B44062aD9821",
|
|
144
156
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
145
157
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
146
158
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
@@ -149,6 +161,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
149
161
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
150
162
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
151
163
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
164
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
152
165
|
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
153
166
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
154
167
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -157,6 +170,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
157
170
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
158
171
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
159
172
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
173
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
160
174
|
usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
161
175
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
162
176
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -165,6 +179,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
165
179
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
166
180
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
167
181
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
182
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
168
183
|
usdc: "0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf",
|
|
169
184
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
170
185
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -247,7 +262,8 @@ var AgetherClient = class _AgetherClient {
|
|
|
247
262
|
const event = receipt.logs.map((log) => {
|
|
248
263
|
try {
|
|
249
264
|
return this.accountFactory.interface.parseLog(log);
|
|
250
|
-
} catch {
|
|
265
|
+
} catch (e) {
|
|
266
|
+
console.warn("[agether] createAccount parseLog skip:", e instanceof Error ? e.message : e);
|
|
251
267
|
return null;
|
|
252
268
|
}
|
|
253
269
|
}).find((e) => e?.name === "AccountCreated");
|
|
@@ -292,7 +308,8 @@ var AgetherClient = class _AgetherClient {
|
|
|
292
308
|
eth: ethers.formatEther(acctEth),
|
|
293
309
|
usdc: ethers.formatUnits(acctUsdc, 6)
|
|
294
310
|
};
|
|
295
|
-
} catch {
|
|
311
|
+
} catch (e) {
|
|
312
|
+
console.warn("[agether] getBalances: no AgentAccount or fetch failed:", e instanceof Error ? e.message : e);
|
|
296
313
|
}
|
|
297
314
|
return result;
|
|
298
315
|
}
|
|
@@ -345,7 +362,8 @@ var AgetherClient = class _AgetherClient {
|
|
|
345
362
|
try {
|
|
346
363
|
await this.identityRegistry.ownerOf(this.agentId);
|
|
347
364
|
return true;
|
|
348
|
-
} catch {
|
|
365
|
+
} catch (e) {
|
|
366
|
+
console.warn("[agether] identityExists check failed:", e instanceof Error ? e.message : e);
|
|
349
367
|
return false;
|
|
350
368
|
}
|
|
351
369
|
}
|
|
@@ -391,6 +409,8 @@ var BASE_COLLATERALS = {
|
|
|
391
409
|
cbETH: { address: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", symbol: "cbETH", decimals: 18 }
|
|
392
410
|
};
|
|
393
411
|
var MORPHO_API_URL = "https://api.morpho.org/graphql";
|
|
412
|
+
var MODE_SINGLE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
413
|
+
var MODE_BATCH = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
394
414
|
var morphoIface = new ethers2.Interface(MORPHO_BLUE_ABI);
|
|
395
415
|
var erc20Iface = new ethers2.Interface(ERC20_ABI);
|
|
396
416
|
var MorphoClient = class {
|
|
@@ -434,12 +454,21 @@ var MorphoClient = class {
|
|
|
434
454
|
// ════════════════════════════════════════════════════════
|
|
435
455
|
/**
|
|
436
456
|
* Check whether the KYA (Know Your Agent) code verification gate is active.
|
|
437
|
-
*
|
|
438
|
-
*
|
|
457
|
+
* Reads the account's installed hook and checks if it has a non-zero
|
|
458
|
+
* validationRegistry — when set, the hook enforces KYA code approval.
|
|
439
459
|
*/
|
|
440
460
|
async isKyaRequired() {
|
|
441
|
-
|
|
442
|
-
|
|
461
|
+
try {
|
|
462
|
+
const acctAddr = await this.getAccountAddress();
|
|
463
|
+
const account = new Contract2(acctAddr, AGENT_ACCOUNT_ABI, this.provider);
|
|
464
|
+
const hookAddr = await account.hook();
|
|
465
|
+
if (hookAddr === ethers2.ZeroAddress) return false;
|
|
466
|
+
const hook = new Contract2(hookAddr, KYA_HOOK_ABI, this.provider);
|
|
467
|
+
const registryAddr = await hook.validationRegistry();
|
|
468
|
+
return registryAddr !== ethers2.ZeroAddress;
|
|
469
|
+
} catch {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
443
472
|
}
|
|
444
473
|
// ════════════════════════════════════════════════════════
|
|
445
474
|
// Account Management
|
|
@@ -515,7 +544,8 @@ var MorphoClient = class {
|
|
|
515
544
|
agentId = parsed.args[2];
|
|
516
545
|
break;
|
|
517
546
|
}
|
|
518
|
-
} catch {
|
|
547
|
+
} catch (e) {
|
|
548
|
+
console.warn("[agether] parseLog skip:", e instanceof Error ? e.message : e);
|
|
519
549
|
continue;
|
|
520
550
|
}
|
|
521
551
|
}
|
|
@@ -581,7 +611,8 @@ var MorphoClient = class {
|
|
|
581
611
|
const token = new Contract2(info.address, ERC20_ABI, this.provider);
|
|
582
612
|
const bal = await token.balanceOf(eoaAddr);
|
|
583
613
|
eoaCollateral[symbol] = ethers2.formatUnits(bal, info.decimals);
|
|
584
|
-
} catch {
|
|
614
|
+
} catch (e) {
|
|
615
|
+
console.warn(`[agether] EOA collateral fetch failed for ${symbol}:`, e instanceof Error ? e.message : e);
|
|
585
616
|
eoaCollateral[symbol] = "0";
|
|
586
617
|
}
|
|
587
618
|
}
|
|
@@ -602,7 +633,8 @@ var MorphoClient = class {
|
|
|
602
633
|
const token = new Contract2(info.address, ERC20_ABI, this.provider);
|
|
603
634
|
const bal = await token.balanceOf(acctAddr);
|
|
604
635
|
acctCollateral[symbol] = ethers2.formatUnits(bal, info.decimals);
|
|
605
|
-
} catch {
|
|
636
|
+
} catch (e) {
|
|
637
|
+
console.warn(`[agether] AgentAccount collateral fetch failed for ${symbol}:`, e instanceof Error ? e.message : e);
|
|
606
638
|
acctCollateral[symbol] = "0";
|
|
607
639
|
}
|
|
608
640
|
}
|
|
@@ -692,7 +724,8 @@ var MorphoClient = class {
|
|
|
692
724
|
}
|
|
693
725
|
}
|
|
694
726
|
return this._discoveredMarkets;
|
|
695
|
-
} catch {
|
|
727
|
+
} catch (e) {
|
|
728
|
+
console.warn("[agether] getMarkets failed, using cache:", e instanceof Error ? e.message : e);
|
|
696
729
|
return this._discoveredMarkets ?? [];
|
|
697
730
|
}
|
|
698
731
|
}
|
|
@@ -758,7 +791,8 @@ var MorphoClient = class {
|
|
|
758
791
|
const totalBorrowAssets = BigInt(mkt.totalBorrowAssets);
|
|
759
792
|
debt = totalBorrowShares > 0n ? BigInt(pos.borrowShares) * totalBorrowAssets / totalBorrowShares : 0n;
|
|
760
793
|
totalDebt += debt;
|
|
761
|
-
} catch {
|
|
794
|
+
} catch (e) {
|
|
795
|
+
console.warn(`[agether] debt calc failed for market ${m.uniqueKey}:`, e instanceof Error ? e.message : e);
|
|
762
796
|
}
|
|
763
797
|
}
|
|
764
798
|
positions.push({
|
|
@@ -769,7 +803,8 @@ var MorphoClient = class {
|
|
|
769
803
|
supplyShares: pos.supplyShares.toString(),
|
|
770
804
|
debt: ethers2.formatUnits(debt, 6)
|
|
771
805
|
});
|
|
772
|
-
} catch {
|
|
806
|
+
} catch (e) {
|
|
807
|
+
console.warn(`[agether] position read failed for market:`, e instanceof Error ? e.message : e);
|
|
773
808
|
continue;
|
|
774
809
|
}
|
|
775
810
|
}
|
|
@@ -825,7 +860,8 @@ var MorphoClient = class {
|
|
|
825
860
|
const oraclePrice = await oracleContract.price();
|
|
826
861
|
const ORACLE_PRICE_SCALE = 10n ** 36n;
|
|
827
862
|
collateralValueInLoan = BigInt(pos.collateral) * oraclePrice / ORACLE_PRICE_SCALE;
|
|
828
|
-
} catch {
|
|
863
|
+
} catch (e) {
|
|
864
|
+
console.warn(`[agether] oracle price fetch failed:`, e instanceof Error ? e.message : e);
|
|
829
865
|
continue;
|
|
830
866
|
}
|
|
831
867
|
const maxBorrowTotal = collateralValueInLoan * m.lltv / 10n ** 18n;
|
|
@@ -837,7 +873,8 @@ var MorphoClient = class {
|
|
|
837
873
|
currentDebt,
|
|
838
874
|
collateralValue: collateralValueInLoan
|
|
839
875
|
});
|
|
840
|
-
} catch {
|
|
876
|
+
} catch (e) {
|
|
877
|
+
console.warn(`[agether] maxBorrow calc failed:`, e instanceof Error ? e.message : e);
|
|
841
878
|
continue;
|
|
842
879
|
}
|
|
843
880
|
}
|
|
@@ -897,7 +934,8 @@ var MorphoClient = class {
|
|
|
897
934
|
lltv: `${(Number(m.lltv) / 1e16).toFixed(0)}%`,
|
|
898
935
|
marketId: m.uniqueKey
|
|
899
936
|
}));
|
|
900
|
-
} catch {
|
|
937
|
+
} catch (e) {
|
|
938
|
+
console.warn("[agether] getMarketRates failed:", e instanceof Error ? e.message : e);
|
|
901
939
|
return [];
|
|
902
940
|
}
|
|
903
941
|
}
|
|
@@ -938,7 +976,8 @@ var MorphoClient = class {
|
|
|
938
976
|
const amountWei = ethers2.parseUnits(amount, colInfo.decimals);
|
|
939
977
|
const valueInUsdc = amountWei * oraclePrice / ORACLE_PRICE_SCALE;
|
|
940
978
|
collateralValueUsd = Number(valueInUsdc) / 1e6;
|
|
941
|
-
} catch {
|
|
979
|
+
} catch (e) {
|
|
980
|
+
console.warn("[agether] oracle price fetch for yield estimation failed:", e instanceof Error ? e.message : e);
|
|
942
981
|
throw new AgetherError("Cannot determine collateral value. Provide ethPriceUsd.", "PRICE_UNAVAILABLE");
|
|
943
982
|
}
|
|
944
983
|
}
|
|
@@ -1141,7 +1180,8 @@ var MorphoClient = class {
|
|
|
1141
1180
|
approveAmount = currentDebt + 10n;
|
|
1142
1181
|
}
|
|
1143
1182
|
}
|
|
1144
|
-
} catch {
|
|
1183
|
+
} catch (e) {
|
|
1184
|
+
console.warn("[agether] share-based repay detection failed, falling through to asset-based:", e instanceof Error ? e.message : e);
|
|
1145
1185
|
}
|
|
1146
1186
|
}
|
|
1147
1187
|
const targets = [usdcAddr, morphoAddr];
|
|
@@ -1161,7 +1201,8 @@ var MorphoClient = class {
|
|
|
1161
1201
|
try {
|
|
1162
1202
|
const status = await this.getStatus();
|
|
1163
1203
|
remainingDebt = status.totalDebt;
|
|
1164
|
-
} catch {
|
|
1204
|
+
} catch (e) {
|
|
1205
|
+
console.warn("[agether] failed to read remaining debt after repay:", e instanceof Error ? e.message : e);
|
|
1165
1206
|
}
|
|
1166
1207
|
return { tx: receipt.hash, amount: usdcAmount, remainingDebt };
|
|
1167
1208
|
}
|
|
@@ -1209,7 +1250,8 @@ var MorphoClient = class {
|
|
|
1209
1250
|
const pos = await this.morphoBlue.position(market.uniqueKey, acctAddr);
|
|
1210
1251
|
remainingCollateral = ethers2.formatUnits(pos.collateral, colInfo.decimals);
|
|
1211
1252
|
}
|
|
1212
|
-
} catch {
|
|
1253
|
+
} catch (e) {
|
|
1254
|
+
console.warn("[agether] failed to read remaining collateral after withdraw:", e instanceof Error ? e.message : e);
|
|
1213
1255
|
}
|
|
1214
1256
|
return {
|
|
1215
1257
|
tx: receipt.hash,
|
|
@@ -1298,37 +1340,48 @@ var MorphoClient = class {
|
|
|
1298
1340
|
}
|
|
1299
1341
|
}
|
|
1300
1342
|
/**
|
|
1301
|
-
* Execute a single call via AgentAccount.execute.
|
|
1343
|
+
* Execute a single call via AgentAccount.execute (ERC-7579 single mode).
|
|
1302
1344
|
*/
|
|
1303
1345
|
async exec(target, data, value = 0n) {
|
|
1304
1346
|
const acctAddr = await this.getAccountAddress();
|
|
1305
1347
|
const account = new Contract2(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1348
|
+
const executionCalldata = ethers2.AbiCoder.defaultAbiCoder().encode(
|
|
1349
|
+
["address", "uint256", "bytes"],
|
|
1350
|
+
[target, value, data]
|
|
1351
|
+
);
|
|
1306
1352
|
let gasLimit;
|
|
1307
1353
|
try {
|
|
1308
|
-
const estimate = await account.execute.estimateGas(
|
|
1354
|
+
const estimate = await account.execute.estimateGas(MODE_SINGLE, executionCalldata);
|
|
1309
1355
|
gasLimit = estimate * 130n / 100n;
|
|
1310
|
-
} catch {
|
|
1356
|
+
} catch (e) {
|
|
1357
|
+
console.warn("[agether] exec gas estimation failed, using default 500k:", e instanceof Error ? e.message : e);
|
|
1311
1358
|
gasLimit = 500000n;
|
|
1312
1359
|
}
|
|
1313
|
-
const tx = await account.execute(
|
|
1360
|
+
const tx = await account.execute(MODE_SINGLE, executionCalldata, { gasLimit });
|
|
1314
1361
|
const receipt = await tx.wait();
|
|
1315
1362
|
this._refreshSigner();
|
|
1316
1363
|
return receipt;
|
|
1317
1364
|
}
|
|
1318
1365
|
/**
|
|
1319
|
-
* Execute multiple calls via AgentAccount.
|
|
1366
|
+
* Execute multiple calls via AgentAccount.execute (ERC-7579 batch mode).
|
|
1320
1367
|
*/
|
|
1321
1368
|
async batch(targets, values, datas) {
|
|
1322
1369
|
const acctAddr = await this.getAccountAddress();
|
|
1323
1370
|
const account = new Contract2(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1371
|
+
const executions = targets.map((t, i) => [t, values[i], datas[i]]);
|
|
1372
|
+
const executionCalldata = ethers2.AbiCoder.defaultAbiCoder().encode(
|
|
1373
|
+
["(address,uint256,bytes)[]"],
|
|
1374
|
+
[executions]
|
|
1375
|
+
);
|
|
1324
1376
|
let gasLimit;
|
|
1325
1377
|
try {
|
|
1326
|
-
const estimate = await account.
|
|
1378
|
+
const estimate = await account.execute.estimateGas(MODE_BATCH, executionCalldata);
|
|
1327
1379
|
gasLimit = estimate * 130n / 100n;
|
|
1328
|
-
} catch {
|
|
1380
|
+
} catch (e) {
|
|
1381
|
+
console.warn("[agether] batch gas estimation failed, using default 800k:", e instanceof Error ? e.message : e);
|
|
1329
1382
|
gasLimit = 800000n;
|
|
1330
1383
|
}
|
|
1331
|
-
const tx = await account.
|
|
1384
|
+
const tx = await account.execute(MODE_BATCH, executionCalldata, { gasLimit });
|
|
1332
1385
|
const receipt = await tx.wait();
|
|
1333
1386
|
this._refreshSigner();
|
|
1334
1387
|
return receipt;
|
|
@@ -1357,7 +1410,8 @@ var MorphoClient = class {
|
|
|
1357
1410
|
symbol: m.collateralAsset.symbol
|
|
1358
1411
|
};
|
|
1359
1412
|
}
|
|
1360
|
-
} catch {
|
|
1413
|
+
} catch (e) {
|
|
1414
|
+
console.warn("[agether] _findActiveMarket position check failed:", e instanceof Error ? e.message : e);
|
|
1361
1415
|
continue;
|
|
1362
1416
|
}
|
|
1363
1417
|
}
|
|
@@ -1552,7 +1606,8 @@ var X402Client = class {
|
|
|
1552
1606
|
Buffer.from(paymentResponse, "base64").toString("utf-8")
|
|
1553
1607
|
);
|
|
1554
1608
|
txHash = settlement.transaction;
|
|
1555
|
-
} catch {
|
|
1609
|
+
} catch (e) {
|
|
1610
|
+
console.warn("[agether] x402 payment response parse failed:", e instanceof Error ? e.message : e);
|
|
1556
1611
|
}
|
|
1557
1612
|
}
|
|
1558
1613
|
return {
|
|
@@ -1607,10 +1662,12 @@ var X402Client = class {
|
|
|
1607
1662
|
return BigInt(amount);
|
|
1608
1663
|
}
|
|
1609
1664
|
}
|
|
1610
|
-
} catch {
|
|
1665
|
+
} catch (e) {
|
|
1666
|
+
console.warn("[agether] x402 payment header parse failed:", e instanceof Error ? e.message : e);
|
|
1611
1667
|
}
|
|
1612
1668
|
return null;
|
|
1613
|
-
} catch {
|
|
1669
|
+
} catch (e) {
|
|
1670
|
+
console.warn("[agether] x402 getPaymentRequired failed:", e instanceof Error ? e.message : e);
|
|
1614
1671
|
return null;
|
|
1615
1672
|
}
|
|
1616
1673
|
}
|
|
@@ -1650,7 +1707,8 @@ var X402Client = class {
|
|
|
1650
1707
|
// 1 day
|
|
1651
1708
|
);
|
|
1652
1709
|
totalDailyYieldUsdc += estimate.estimatedYieldUsd;
|
|
1653
|
-
} catch {
|
|
1710
|
+
} catch (e) {
|
|
1711
|
+
console.warn(`[agether] yield calc failed for ${pos.collateralToken}:`, e instanceof Error ? e.message : e);
|
|
1654
1712
|
}
|
|
1655
1713
|
}
|
|
1656
1714
|
}
|
|
@@ -1662,7 +1720,8 @@ var X402Client = class {
|
|
|
1662
1720
|
reason: `Yield-limited spending exceeded. Daily yield cap: $${(Number(yieldLimit) / 1e6).toFixed(2)}, already spent: $${(Number(this._spendingTracker.totalBorrowed) / 1e6).toFixed(2)}, requested: $${(Number(amount) / 1e6).toFixed(2)}`
|
|
1663
1721
|
};
|
|
1664
1722
|
}
|
|
1665
|
-
} catch {
|
|
1723
|
+
} catch (e) {
|
|
1724
|
+
console.warn("[agether] yield-limited spending check failed, falling through to fixed limit:", e instanceof Error ? e.message : e);
|
|
1666
1725
|
}
|
|
1667
1726
|
}
|
|
1668
1727
|
if (this._spendingTracker.dailyLimit > 0n) {
|
|
@@ -1845,7 +1904,8 @@ var AgentIdentityClient = class {
|
|
|
1845
1904
|
const address = await this.signer.getAddress();
|
|
1846
1905
|
const balance = await this.identityRegistry.balanceOf(address);
|
|
1847
1906
|
return balance > 0n;
|
|
1848
|
-
} catch {
|
|
1907
|
+
} catch (e) {
|
|
1908
|
+
console.warn("[agether] hasExistingIdentity check failed:", e instanceof Error ? e.message : e);
|
|
1849
1909
|
return false;
|
|
1850
1910
|
}
|
|
1851
1911
|
}
|
|
@@ -1951,7 +2011,8 @@ var AgentIdentityClient = class {
|
|
|
1951
2011
|
const response = await fetch(fetchUrl);
|
|
1952
2012
|
if (!response.ok) return null;
|
|
1953
2013
|
return await response.json();
|
|
1954
|
-
} catch {
|
|
2014
|
+
} catch (e) {
|
|
2015
|
+
console.warn("[agether] getMetadata fetch failed:", e instanceof Error ? e.message : e);
|
|
1955
2016
|
return null;
|
|
1956
2017
|
}
|
|
1957
2018
|
}
|
|
@@ -2057,7 +2118,8 @@ var AgentIdentityClient = class {
|
|
|
2057
2118
|
let owner;
|
|
2058
2119
|
try {
|
|
2059
2120
|
owner = await this.getOwner(agentId);
|
|
2060
|
-
} catch {
|
|
2121
|
+
} catch (e) {
|
|
2122
|
+
console.warn("[agether] checkCreditEligibility: agent not found:", e instanceof Error ? e.message : e);
|
|
2061
2123
|
return { eligible: false, reason: "Agent not found in ERC-8004 registry" };
|
|
2062
2124
|
}
|
|
2063
2125
|
const reputation = await this.getReputation(agentId, "credit", "");
|
|
@@ -2086,7 +2148,8 @@ var AgentIdentityClient = class {
|
|
|
2086
2148
|
if (parsed?.name === "Transfer") {
|
|
2087
2149
|
return parsed.args[2];
|
|
2088
2150
|
}
|
|
2089
|
-
} catch {
|
|
2151
|
+
} catch (e) {
|
|
2152
|
+
console.warn("[agether] parseAgentIdFromReceipt parseLog skip:", e instanceof Error ? e.message : e);
|
|
2090
2153
|
continue;
|
|
2091
2154
|
}
|
|
2092
2155
|
}
|
|
@@ -2157,6 +2220,7 @@ export {
|
|
|
2157
2220
|
ERC20_ABI,
|
|
2158
2221
|
IDENTITY_REGISTRY_ABI,
|
|
2159
2222
|
InsufficientBalanceError,
|
|
2223
|
+
KYA_HOOK_ABI,
|
|
2160
2224
|
MORPHO_BLUE_ABI,
|
|
2161
2225
|
MorphoClient,
|
|
2162
2226
|
ScoringClient,
|