@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.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
ERC20_ABI: () => ERC20_ABI,
|
|
42
42
|
IDENTITY_REGISTRY_ABI: () => IDENTITY_REGISTRY_ABI,
|
|
43
43
|
InsufficientBalanceError: () => InsufficientBalanceError,
|
|
44
|
+
KYA_HOOK_ABI: () => KYA_HOOK_ABI,
|
|
44
45
|
MORPHO_BLUE_ABI: () => MORPHO_BLUE_ABI,
|
|
45
46
|
MorphoClient: () => MorphoClient,
|
|
46
47
|
ScoringClient: () => ScoringClient,
|
|
@@ -126,24 +127,30 @@ var ACCOUNT_FACTORY_ABI = [
|
|
|
126
127
|
"function totalAccounts() view returns (uint256)",
|
|
127
128
|
"function getAgentId(address account) view returns (uint256)",
|
|
128
129
|
"function createAccount(uint256 agentId) returns (address account)",
|
|
129
|
-
"function
|
|
130
|
-
"function
|
|
131
|
-
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
132
|
-
"event ValidationRegistryUpdated(address indexed oldRegistry, address indexed newRegistry)"
|
|
130
|
+
"function protocolHook() view returns (address)",
|
|
131
|
+
"function identityRegistry() view returns (address)",
|
|
132
|
+
"event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)"
|
|
133
133
|
];
|
|
134
134
|
var AGENT_ACCOUNT_ABI = [
|
|
135
135
|
"function agentId() view returns (uint256)",
|
|
136
136
|
"function owner() view returns (address)",
|
|
137
137
|
"function factory() view returns (address)",
|
|
138
|
-
"function validationRegistry() view returns (address)",
|
|
139
138
|
"function identityRegistry() view returns (address)",
|
|
140
139
|
"function balanceOf(address token) view returns (uint256)",
|
|
141
140
|
"function ethBalance() view returns (uint256)",
|
|
142
|
-
|
|
143
|
-
"function
|
|
141
|
+
// ERC-7579 execution
|
|
142
|
+
"function execute(bytes32 mode, bytes executionCalldata) payable",
|
|
143
|
+
"function executeFromExecutor(bytes32 mode, bytes executionCalldata) payable returns (bytes[])",
|
|
144
|
+
// ERC-7579 module management
|
|
145
|
+
"function installModule(uint256 moduleTypeId, address module, bytes initData) payable",
|
|
146
|
+
"function uninstallModule(uint256 moduleTypeId, address module, bytes deInitData) payable",
|
|
147
|
+
"function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)",
|
|
148
|
+
"function hook() view returns (address)",
|
|
149
|
+
// Funding (direct, no execution needed)
|
|
144
150
|
"function fund(address token, uint256 amount)",
|
|
145
151
|
"function withdraw(address token, uint256 amount, address to)",
|
|
146
152
|
"function withdrawETH(uint256 amount, address to)",
|
|
153
|
+
// EIP-1271
|
|
147
154
|
"function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4)"
|
|
148
155
|
];
|
|
149
156
|
var AGENT_REPUTATION_ABI = [
|
|
@@ -190,6 +197,10 @@ var ERC20_ABI = [
|
|
|
190
197
|
"function symbol() view returns (string)",
|
|
191
198
|
"function name() view returns (string)"
|
|
192
199
|
];
|
|
200
|
+
var KYA_HOOK_ABI = [
|
|
201
|
+
"function validationRegistry() view returns (address)",
|
|
202
|
+
"function setValidationRegistry(address newRegistry)"
|
|
203
|
+
];
|
|
193
204
|
|
|
194
205
|
// src/utils/config.ts
|
|
195
206
|
var CONTRACT_ADDRESSES = {
|
|
@@ -197,14 +208,16 @@ var CONTRACT_ADDRESSES = {
|
|
|
197
208
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
198
209
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
199
210
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
211
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
200
212
|
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
201
213
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
202
214
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
203
215
|
},
|
|
204
216
|
[8453 /* Base */]: {
|
|
205
|
-
accountFactory: "
|
|
206
|
-
validationRegistry: "
|
|
207
|
-
agentReputation: "
|
|
217
|
+
accountFactory: "0x89a8758E60A56EcB47247D92E05447eFd450d6Bf",
|
|
218
|
+
validationRegistry: "0x6f76cF69B71Dc5F9A414BCEe4583b12738E47985",
|
|
219
|
+
agentReputation: "0xe88f3419a2dbac70e3aF6E487b0C63e8301C6A87",
|
|
220
|
+
kyaHook: "0x28e50Aa9eD517E369b2806928709B44062aD9821",
|
|
208
221
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
209
222
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
210
223
|
morphoBlue: "0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb"
|
|
@@ -213,6 +226,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
213
226
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
214
227
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
215
228
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
229
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
216
230
|
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
217
231
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
218
232
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -221,6 +235,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
221
235
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
222
236
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
223
237
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
238
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
224
239
|
usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
225
240
|
identityRegistry: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
|
|
226
241
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -229,6 +244,7 @@ var CONTRACT_ADDRESSES = {
|
|
|
229
244
|
accountFactory: "0x0000000000000000000000000000000000000000",
|
|
230
245
|
validationRegistry: "0x0000000000000000000000000000000000000000",
|
|
231
246
|
agentReputation: "0x0000000000000000000000000000000000000000",
|
|
247
|
+
kyaHook: "0x0000000000000000000000000000000000000000",
|
|
232
248
|
usdc: "0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf",
|
|
233
249
|
identityRegistry: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432",
|
|
234
250
|
morphoBlue: "0x0000000000000000000000000000000000000000"
|
|
@@ -311,7 +327,8 @@ var AgetherClient = class _AgetherClient {
|
|
|
311
327
|
const event = receipt.logs.map((log) => {
|
|
312
328
|
try {
|
|
313
329
|
return this.accountFactory.interface.parseLog(log);
|
|
314
|
-
} catch {
|
|
330
|
+
} catch (e) {
|
|
331
|
+
console.warn("[agether] createAccount parseLog skip:", e instanceof Error ? e.message : e);
|
|
315
332
|
return null;
|
|
316
333
|
}
|
|
317
334
|
}).find((e) => e?.name === "AccountCreated");
|
|
@@ -356,7 +373,8 @@ var AgetherClient = class _AgetherClient {
|
|
|
356
373
|
eth: import_ethers.ethers.formatEther(acctEth),
|
|
357
374
|
usdc: import_ethers.ethers.formatUnits(acctUsdc, 6)
|
|
358
375
|
};
|
|
359
|
-
} catch {
|
|
376
|
+
} catch (e) {
|
|
377
|
+
console.warn("[agether] getBalances: no AgentAccount or fetch failed:", e instanceof Error ? e.message : e);
|
|
360
378
|
}
|
|
361
379
|
return result;
|
|
362
380
|
}
|
|
@@ -409,7 +427,8 @@ var AgetherClient = class _AgetherClient {
|
|
|
409
427
|
try {
|
|
410
428
|
await this.identityRegistry.ownerOf(this.agentId);
|
|
411
429
|
return true;
|
|
412
|
-
} catch {
|
|
430
|
+
} catch (e) {
|
|
431
|
+
console.warn("[agether] identityExists check failed:", e instanceof Error ? e.message : e);
|
|
413
432
|
return false;
|
|
414
433
|
}
|
|
415
434
|
}
|
|
@@ -455,6 +474,8 @@ var BASE_COLLATERALS = {
|
|
|
455
474
|
cbETH: { address: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22", symbol: "cbETH", decimals: 18 }
|
|
456
475
|
};
|
|
457
476
|
var MORPHO_API_URL = "https://api.morpho.org/graphql";
|
|
477
|
+
var MODE_SINGLE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
478
|
+
var MODE_BATCH = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
458
479
|
var morphoIface = new import_ethers2.ethers.Interface(MORPHO_BLUE_ABI);
|
|
459
480
|
var erc20Iface = new import_ethers2.ethers.Interface(ERC20_ABI);
|
|
460
481
|
var MorphoClient = class {
|
|
@@ -498,12 +519,21 @@ var MorphoClient = class {
|
|
|
498
519
|
// ════════════════════════════════════════════════════════
|
|
499
520
|
/**
|
|
500
521
|
* Check whether the KYA (Know Your Agent) code verification gate is active.
|
|
501
|
-
*
|
|
502
|
-
*
|
|
522
|
+
* Reads the account's installed hook and checks if it has a non-zero
|
|
523
|
+
* validationRegistry — when set, the hook enforces KYA code approval.
|
|
503
524
|
*/
|
|
504
525
|
async isKyaRequired() {
|
|
505
|
-
|
|
506
|
-
|
|
526
|
+
try {
|
|
527
|
+
const acctAddr = await this.getAccountAddress();
|
|
528
|
+
const account = new import_ethers2.Contract(acctAddr, AGENT_ACCOUNT_ABI, this.provider);
|
|
529
|
+
const hookAddr = await account.hook();
|
|
530
|
+
if (hookAddr === import_ethers2.ethers.ZeroAddress) return false;
|
|
531
|
+
const hook = new import_ethers2.Contract(hookAddr, KYA_HOOK_ABI, this.provider);
|
|
532
|
+
const registryAddr = await hook.validationRegistry();
|
|
533
|
+
return registryAddr !== import_ethers2.ethers.ZeroAddress;
|
|
534
|
+
} catch {
|
|
535
|
+
return false;
|
|
536
|
+
}
|
|
507
537
|
}
|
|
508
538
|
// ════════════════════════════════════════════════════════
|
|
509
539
|
// Account Management
|
|
@@ -579,7 +609,8 @@ var MorphoClient = class {
|
|
|
579
609
|
agentId = parsed.args[2];
|
|
580
610
|
break;
|
|
581
611
|
}
|
|
582
|
-
} catch {
|
|
612
|
+
} catch (e) {
|
|
613
|
+
console.warn("[agether] parseLog skip:", e instanceof Error ? e.message : e);
|
|
583
614
|
continue;
|
|
584
615
|
}
|
|
585
616
|
}
|
|
@@ -645,7 +676,8 @@ var MorphoClient = class {
|
|
|
645
676
|
const token = new import_ethers2.Contract(info.address, ERC20_ABI, this.provider);
|
|
646
677
|
const bal = await token.balanceOf(eoaAddr);
|
|
647
678
|
eoaCollateral[symbol] = import_ethers2.ethers.formatUnits(bal, info.decimals);
|
|
648
|
-
} catch {
|
|
679
|
+
} catch (e) {
|
|
680
|
+
console.warn(`[agether] EOA collateral fetch failed for ${symbol}:`, e instanceof Error ? e.message : e);
|
|
649
681
|
eoaCollateral[symbol] = "0";
|
|
650
682
|
}
|
|
651
683
|
}
|
|
@@ -666,7 +698,8 @@ var MorphoClient = class {
|
|
|
666
698
|
const token = new import_ethers2.Contract(info.address, ERC20_ABI, this.provider);
|
|
667
699
|
const bal = await token.balanceOf(acctAddr);
|
|
668
700
|
acctCollateral[symbol] = import_ethers2.ethers.formatUnits(bal, info.decimals);
|
|
669
|
-
} catch {
|
|
701
|
+
} catch (e) {
|
|
702
|
+
console.warn(`[agether] AgentAccount collateral fetch failed for ${symbol}:`, e instanceof Error ? e.message : e);
|
|
670
703
|
acctCollateral[symbol] = "0";
|
|
671
704
|
}
|
|
672
705
|
}
|
|
@@ -756,7 +789,8 @@ var MorphoClient = class {
|
|
|
756
789
|
}
|
|
757
790
|
}
|
|
758
791
|
return this._discoveredMarkets;
|
|
759
|
-
} catch {
|
|
792
|
+
} catch (e) {
|
|
793
|
+
console.warn("[agether] getMarkets failed, using cache:", e instanceof Error ? e.message : e);
|
|
760
794
|
return this._discoveredMarkets ?? [];
|
|
761
795
|
}
|
|
762
796
|
}
|
|
@@ -822,7 +856,8 @@ var MorphoClient = class {
|
|
|
822
856
|
const totalBorrowAssets = BigInt(mkt.totalBorrowAssets);
|
|
823
857
|
debt = totalBorrowShares > 0n ? BigInt(pos.borrowShares) * totalBorrowAssets / totalBorrowShares : 0n;
|
|
824
858
|
totalDebt += debt;
|
|
825
|
-
} catch {
|
|
859
|
+
} catch (e) {
|
|
860
|
+
console.warn(`[agether] debt calc failed for market ${m.uniqueKey}:`, e instanceof Error ? e.message : e);
|
|
826
861
|
}
|
|
827
862
|
}
|
|
828
863
|
positions.push({
|
|
@@ -833,7 +868,8 @@ var MorphoClient = class {
|
|
|
833
868
|
supplyShares: pos.supplyShares.toString(),
|
|
834
869
|
debt: import_ethers2.ethers.formatUnits(debt, 6)
|
|
835
870
|
});
|
|
836
|
-
} catch {
|
|
871
|
+
} catch (e) {
|
|
872
|
+
console.warn(`[agether] position read failed for market:`, e instanceof Error ? e.message : e);
|
|
837
873
|
continue;
|
|
838
874
|
}
|
|
839
875
|
}
|
|
@@ -889,7 +925,8 @@ var MorphoClient = class {
|
|
|
889
925
|
const oraclePrice = await oracleContract.price();
|
|
890
926
|
const ORACLE_PRICE_SCALE = 10n ** 36n;
|
|
891
927
|
collateralValueInLoan = BigInt(pos.collateral) * oraclePrice / ORACLE_PRICE_SCALE;
|
|
892
|
-
} catch {
|
|
928
|
+
} catch (e) {
|
|
929
|
+
console.warn(`[agether] oracle price fetch failed:`, e instanceof Error ? e.message : e);
|
|
893
930
|
continue;
|
|
894
931
|
}
|
|
895
932
|
const maxBorrowTotal = collateralValueInLoan * m.lltv / 10n ** 18n;
|
|
@@ -901,7 +938,8 @@ var MorphoClient = class {
|
|
|
901
938
|
currentDebt,
|
|
902
939
|
collateralValue: collateralValueInLoan
|
|
903
940
|
});
|
|
904
|
-
} catch {
|
|
941
|
+
} catch (e) {
|
|
942
|
+
console.warn(`[agether] maxBorrow calc failed:`, e instanceof Error ? e.message : e);
|
|
905
943
|
continue;
|
|
906
944
|
}
|
|
907
945
|
}
|
|
@@ -961,7 +999,8 @@ var MorphoClient = class {
|
|
|
961
999
|
lltv: `${(Number(m.lltv) / 1e16).toFixed(0)}%`,
|
|
962
1000
|
marketId: m.uniqueKey
|
|
963
1001
|
}));
|
|
964
|
-
} catch {
|
|
1002
|
+
} catch (e) {
|
|
1003
|
+
console.warn("[agether] getMarketRates failed:", e instanceof Error ? e.message : e);
|
|
965
1004
|
return [];
|
|
966
1005
|
}
|
|
967
1006
|
}
|
|
@@ -1002,7 +1041,8 @@ var MorphoClient = class {
|
|
|
1002
1041
|
const amountWei = import_ethers2.ethers.parseUnits(amount, colInfo.decimals);
|
|
1003
1042
|
const valueInUsdc = amountWei * oraclePrice / ORACLE_PRICE_SCALE;
|
|
1004
1043
|
collateralValueUsd = Number(valueInUsdc) / 1e6;
|
|
1005
|
-
} catch {
|
|
1044
|
+
} catch (e) {
|
|
1045
|
+
console.warn("[agether] oracle price fetch for yield estimation failed:", e instanceof Error ? e.message : e);
|
|
1006
1046
|
throw new AgetherError("Cannot determine collateral value. Provide ethPriceUsd.", "PRICE_UNAVAILABLE");
|
|
1007
1047
|
}
|
|
1008
1048
|
}
|
|
@@ -1205,7 +1245,8 @@ var MorphoClient = class {
|
|
|
1205
1245
|
approveAmount = currentDebt + 10n;
|
|
1206
1246
|
}
|
|
1207
1247
|
}
|
|
1208
|
-
} catch {
|
|
1248
|
+
} catch (e) {
|
|
1249
|
+
console.warn("[agether] share-based repay detection failed, falling through to asset-based:", e instanceof Error ? e.message : e);
|
|
1209
1250
|
}
|
|
1210
1251
|
}
|
|
1211
1252
|
const targets = [usdcAddr, morphoAddr];
|
|
@@ -1225,7 +1266,8 @@ var MorphoClient = class {
|
|
|
1225
1266
|
try {
|
|
1226
1267
|
const status = await this.getStatus();
|
|
1227
1268
|
remainingDebt = status.totalDebt;
|
|
1228
|
-
} catch {
|
|
1269
|
+
} catch (e) {
|
|
1270
|
+
console.warn("[agether] failed to read remaining debt after repay:", e instanceof Error ? e.message : e);
|
|
1229
1271
|
}
|
|
1230
1272
|
return { tx: receipt.hash, amount: usdcAmount, remainingDebt };
|
|
1231
1273
|
}
|
|
@@ -1273,7 +1315,8 @@ var MorphoClient = class {
|
|
|
1273
1315
|
const pos = await this.morphoBlue.position(market.uniqueKey, acctAddr);
|
|
1274
1316
|
remainingCollateral = import_ethers2.ethers.formatUnits(pos.collateral, colInfo.decimals);
|
|
1275
1317
|
}
|
|
1276
|
-
} catch {
|
|
1318
|
+
} catch (e) {
|
|
1319
|
+
console.warn("[agether] failed to read remaining collateral after withdraw:", e instanceof Error ? e.message : e);
|
|
1277
1320
|
}
|
|
1278
1321
|
return {
|
|
1279
1322
|
tx: receipt.hash,
|
|
@@ -1362,37 +1405,48 @@ var MorphoClient = class {
|
|
|
1362
1405
|
}
|
|
1363
1406
|
}
|
|
1364
1407
|
/**
|
|
1365
|
-
* Execute a single call via AgentAccount.execute.
|
|
1408
|
+
* Execute a single call via AgentAccount.execute (ERC-7579 single mode).
|
|
1366
1409
|
*/
|
|
1367
1410
|
async exec(target, data, value = 0n) {
|
|
1368
1411
|
const acctAddr = await this.getAccountAddress();
|
|
1369
1412
|
const account = new import_ethers2.Contract(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1413
|
+
const executionCalldata = import_ethers2.ethers.AbiCoder.defaultAbiCoder().encode(
|
|
1414
|
+
["address", "uint256", "bytes"],
|
|
1415
|
+
[target, value, data]
|
|
1416
|
+
);
|
|
1370
1417
|
let gasLimit;
|
|
1371
1418
|
try {
|
|
1372
|
-
const estimate = await account.execute.estimateGas(
|
|
1419
|
+
const estimate = await account.execute.estimateGas(MODE_SINGLE, executionCalldata);
|
|
1373
1420
|
gasLimit = estimate * 130n / 100n;
|
|
1374
|
-
} catch {
|
|
1421
|
+
} catch (e) {
|
|
1422
|
+
console.warn("[agether] exec gas estimation failed, using default 500k:", e instanceof Error ? e.message : e);
|
|
1375
1423
|
gasLimit = 500000n;
|
|
1376
1424
|
}
|
|
1377
|
-
const tx = await account.execute(
|
|
1425
|
+
const tx = await account.execute(MODE_SINGLE, executionCalldata, { gasLimit });
|
|
1378
1426
|
const receipt = await tx.wait();
|
|
1379
1427
|
this._refreshSigner();
|
|
1380
1428
|
return receipt;
|
|
1381
1429
|
}
|
|
1382
1430
|
/**
|
|
1383
|
-
* Execute multiple calls via AgentAccount.
|
|
1431
|
+
* Execute multiple calls via AgentAccount.execute (ERC-7579 batch mode).
|
|
1384
1432
|
*/
|
|
1385
1433
|
async batch(targets, values, datas) {
|
|
1386
1434
|
const acctAddr = await this.getAccountAddress();
|
|
1387
1435
|
const account = new import_ethers2.Contract(acctAddr, AGENT_ACCOUNT_ABI, this._signer);
|
|
1436
|
+
const executions = targets.map((t, i) => [t, values[i], datas[i]]);
|
|
1437
|
+
const executionCalldata = import_ethers2.ethers.AbiCoder.defaultAbiCoder().encode(
|
|
1438
|
+
["(address,uint256,bytes)[]"],
|
|
1439
|
+
[executions]
|
|
1440
|
+
);
|
|
1388
1441
|
let gasLimit;
|
|
1389
1442
|
try {
|
|
1390
|
-
const estimate = await account.
|
|
1443
|
+
const estimate = await account.execute.estimateGas(MODE_BATCH, executionCalldata);
|
|
1391
1444
|
gasLimit = estimate * 130n / 100n;
|
|
1392
|
-
} catch {
|
|
1445
|
+
} catch (e) {
|
|
1446
|
+
console.warn("[agether] batch gas estimation failed, using default 800k:", e instanceof Error ? e.message : e);
|
|
1393
1447
|
gasLimit = 800000n;
|
|
1394
1448
|
}
|
|
1395
|
-
const tx = await account.
|
|
1449
|
+
const tx = await account.execute(MODE_BATCH, executionCalldata, { gasLimit });
|
|
1396
1450
|
const receipt = await tx.wait();
|
|
1397
1451
|
this._refreshSigner();
|
|
1398
1452
|
return receipt;
|
|
@@ -1421,7 +1475,8 @@ var MorphoClient = class {
|
|
|
1421
1475
|
symbol: m.collateralAsset.symbol
|
|
1422
1476
|
};
|
|
1423
1477
|
}
|
|
1424
|
-
} catch {
|
|
1478
|
+
} catch (e) {
|
|
1479
|
+
console.warn("[agether] _findActiveMarket position check failed:", e instanceof Error ? e.message : e);
|
|
1425
1480
|
continue;
|
|
1426
1481
|
}
|
|
1427
1482
|
}
|
|
@@ -1616,7 +1671,8 @@ var X402Client = class {
|
|
|
1616
1671
|
Buffer.from(paymentResponse, "base64").toString("utf-8")
|
|
1617
1672
|
);
|
|
1618
1673
|
txHash = settlement.transaction;
|
|
1619
|
-
} catch {
|
|
1674
|
+
} catch (e) {
|
|
1675
|
+
console.warn("[agether] x402 payment response parse failed:", e instanceof Error ? e.message : e);
|
|
1620
1676
|
}
|
|
1621
1677
|
}
|
|
1622
1678
|
return {
|
|
@@ -1671,10 +1727,12 @@ var X402Client = class {
|
|
|
1671
1727
|
return BigInt(amount);
|
|
1672
1728
|
}
|
|
1673
1729
|
}
|
|
1674
|
-
} catch {
|
|
1730
|
+
} catch (e) {
|
|
1731
|
+
console.warn("[agether] x402 payment header parse failed:", e instanceof Error ? e.message : e);
|
|
1675
1732
|
}
|
|
1676
1733
|
return null;
|
|
1677
|
-
} catch {
|
|
1734
|
+
} catch (e) {
|
|
1735
|
+
console.warn("[agether] x402 getPaymentRequired failed:", e instanceof Error ? e.message : e);
|
|
1678
1736
|
return null;
|
|
1679
1737
|
}
|
|
1680
1738
|
}
|
|
@@ -1714,7 +1772,8 @@ var X402Client = class {
|
|
|
1714
1772
|
// 1 day
|
|
1715
1773
|
);
|
|
1716
1774
|
totalDailyYieldUsdc += estimate.estimatedYieldUsd;
|
|
1717
|
-
} catch {
|
|
1775
|
+
} catch (e) {
|
|
1776
|
+
console.warn(`[agether] yield calc failed for ${pos.collateralToken}:`, e instanceof Error ? e.message : e);
|
|
1718
1777
|
}
|
|
1719
1778
|
}
|
|
1720
1779
|
}
|
|
@@ -1726,7 +1785,8 @@ var X402Client = class {
|
|
|
1726
1785
|
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)}`
|
|
1727
1786
|
};
|
|
1728
1787
|
}
|
|
1729
|
-
} catch {
|
|
1788
|
+
} catch (e) {
|
|
1789
|
+
console.warn("[agether] yield-limited spending check failed, falling through to fixed limit:", e instanceof Error ? e.message : e);
|
|
1730
1790
|
}
|
|
1731
1791
|
}
|
|
1732
1792
|
if (this._spendingTracker.dailyLimit > 0n) {
|
|
@@ -1909,7 +1969,8 @@ var AgentIdentityClient = class {
|
|
|
1909
1969
|
const address = await this.signer.getAddress();
|
|
1910
1970
|
const balance = await this.identityRegistry.balanceOf(address);
|
|
1911
1971
|
return balance > 0n;
|
|
1912
|
-
} catch {
|
|
1972
|
+
} catch (e) {
|
|
1973
|
+
console.warn("[agether] hasExistingIdentity check failed:", e instanceof Error ? e.message : e);
|
|
1913
1974
|
return false;
|
|
1914
1975
|
}
|
|
1915
1976
|
}
|
|
@@ -2015,7 +2076,8 @@ var AgentIdentityClient = class {
|
|
|
2015
2076
|
const response = await fetch(fetchUrl);
|
|
2016
2077
|
if (!response.ok) return null;
|
|
2017
2078
|
return await response.json();
|
|
2018
|
-
} catch {
|
|
2079
|
+
} catch (e) {
|
|
2080
|
+
console.warn("[agether] getMetadata fetch failed:", e instanceof Error ? e.message : e);
|
|
2019
2081
|
return null;
|
|
2020
2082
|
}
|
|
2021
2083
|
}
|
|
@@ -2121,7 +2183,8 @@ var AgentIdentityClient = class {
|
|
|
2121
2183
|
let owner;
|
|
2122
2184
|
try {
|
|
2123
2185
|
owner = await this.getOwner(agentId);
|
|
2124
|
-
} catch {
|
|
2186
|
+
} catch (e) {
|
|
2187
|
+
console.warn("[agether] checkCreditEligibility: agent not found:", e instanceof Error ? e.message : e);
|
|
2125
2188
|
return { eligible: false, reason: "Agent not found in ERC-8004 registry" };
|
|
2126
2189
|
}
|
|
2127
2190
|
const reputation = await this.getReputation(agentId, "credit", "");
|
|
@@ -2150,7 +2213,8 @@ var AgentIdentityClient = class {
|
|
|
2150
2213
|
if (parsed?.name === "Transfer") {
|
|
2151
2214
|
return parsed.args[2];
|
|
2152
2215
|
}
|
|
2153
|
-
} catch {
|
|
2216
|
+
} catch (e) {
|
|
2217
|
+
console.warn("[agether] parseAgentIdFromReceipt parseLog skip:", e instanceof Error ? e.message : e);
|
|
2154
2218
|
continue;
|
|
2155
2219
|
}
|
|
2156
2220
|
}
|
|
@@ -2222,6 +2286,7 @@ function rateToBps(rate) {
|
|
|
2222
2286
|
ERC20_ABI,
|
|
2223
2287
|
IDENTITY_REGISTRY_ABI,
|
|
2224
2288
|
InsufficientBalanceError,
|
|
2289
|
+
KYA_HOOK_ABI,
|
|
2225
2290
|
MORPHO_BLUE_ABI,
|
|
2226
2291
|
MorphoClient,
|
|
2227
2292
|
ScoringClient,
|