@agether/sdk 2.0.0 → 2.1.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 +1 -1
- package/dist/cli.js +56 -55
- package/dist/index.d.mts +40 -36
- package/dist/index.d.ts +40 -36
- package/dist/index.js +83 -72
- package/dist/index.mjs +79 -72
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -528,7 +528,7 @@ $ agether apply --limit 5000
|
|
|
528
528
|
⚠️ You will need to deposit collateral before drawing funds.
|
|
529
529
|
After approval, run: agether collateral --amount 4000
|
|
530
530
|
|
|
531
|
-
[2/2] Submitting application
|
|
531
|
+
[2/2] Submitting application onchain...
|
|
532
532
|
✓ TX: 0x...
|
|
533
533
|
|
|
534
534
|
✅ Credit Line #1 created (Pending)
|
package/dist/cli.js
CHANGED
|
@@ -47,7 +47,7 @@ var init_types = __esm({
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
// src/utils/abis.ts
|
|
50
|
-
var IDENTITY_REGISTRY_ABI,
|
|
50
|
+
var IDENTITY_REGISTRY_ABI, AGETHER_4337_FACTORY_ABI, ACCOUNT_FACTORY_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, ERC8004_VALIDATION_MODULE_ABI, AGETHER_8004_SCORER_ABI, AGENT_REPUTATION_ABI, MORPHO_BLUE_ABI, ERC20_ABI, ENTRYPOINT_V07_ABI, SAFE7579_ACCOUNT_ABI;
|
|
51
51
|
var init_abis = __esm({
|
|
52
52
|
"src/utils/abis.ts"() {
|
|
53
53
|
"use strict";
|
|
@@ -59,7 +59,7 @@ var init_abis = __esm({
|
|
|
59
59
|
"function register() returns (uint256 agentId)",
|
|
60
60
|
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
|
|
61
61
|
];
|
|
62
|
-
|
|
62
|
+
AGETHER_4337_FACTORY_ABI = [
|
|
63
63
|
"function getAccount(uint256 agentId) view returns (address)",
|
|
64
64
|
"function accountExists(uint256 agentId) view returns (bool)",
|
|
65
65
|
"function totalAccounts() view returns (uint256)",
|
|
@@ -73,11 +73,10 @@ var init_abis = __esm({
|
|
|
73
73
|
"function safeSingleton() view returns (address)",
|
|
74
74
|
"function safe7579() view returns (address)",
|
|
75
75
|
"function bootstrap() view returns (address)",
|
|
76
|
-
"function SENTINEL_OWNER() view returns (address)",
|
|
77
76
|
"event AccountCreated(uint256 indexed agentId, address indexed safeAccount, address indexed owner)"
|
|
78
77
|
];
|
|
79
|
-
ACCOUNT_FACTORY_ABI =
|
|
80
|
-
|
|
78
|
+
ACCOUNT_FACTORY_ABI = AGETHER_4337_FACTORY_ABI;
|
|
79
|
+
AGETHER_8004_VALIDATION_MODULE_ABI = [
|
|
81
80
|
// View
|
|
82
81
|
"function getConfig(address account) view returns (address registry, uint256 agentId)",
|
|
83
82
|
"function getOwner(address account) view returns (address)",
|
|
@@ -88,7 +87,8 @@ var init_abis = __esm({
|
|
|
88
87
|
// Admin (via TimelockController)
|
|
89
88
|
"function setValidationRegistry(address registry_)"
|
|
90
89
|
];
|
|
91
|
-
|
|
90
|
+
ERC8004_VALIDATION_MODULE_ABI = AGETHER_8004_VALIDATION_MODULE_ABI;
|
|
91
|
+
AGETHER_8004_SCORER_ABI = [
|
|
92
92
|
"function getCreditScore(uint256 agentId) view returns (uint256)",
|
|
93
93
|
"function getAttestation(uint256 agentId) view returns (tuple(uint256 score, uint256 timestamp, address signer))",
|
|
94
94
|
"function isScoreFresh(uint256 agentId) view returns (bool fresh, uint256 age)",
|
|
@@ -98,6 +98,7 @@ var init_abis = __esm({
|
|
|
98
98
|
"function setOracleSigner(address signer_)",
|
|
99
99
|
"event ScoreUpdated(uint256 indexed agentId, uint256 score, uint256 timestamp, address signer)"
|
|
100
100
|
];
|
|
101
|
+
AGENT_REPUTATION_ABI = AGETHER_8004_SCORER_ABI;
|
|
101
102
|
MORPHO_BLUE_ABI = [
|
|
102
103
|
// Supply & Withdraw (lending side)
|
|
103
104
|
"function supply(tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsSupplied, uint256 sharesSupplied)",
|
|
@@ -174,12 +175,12 @@ var init_config = __esm({
|
|
|
174
175
|
safeProxyFactory: SAFE_PROXY_FACTORY,
|
|
175
176
|
safe7579: SAFE7579,
|
|
176
177
|
entryPoint: ENTRYPOINT_V07,
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
agether4337Factory: ZERO,
|
|
179
|
+
agether7579Bootstrap: ZERO,
|
|
179
180
|
erc8004ValidationModule: ZERO,
|
|
180
|
-
|
|
181
|
+
agetherHookMultiplexer: ZERO,
|
|
181
182
|
validationRegistry: ZERO,
|
|
182
|
-
|
|
183
|
+
agether8004Scorer: ZERO,
|
|
183
184
|
timelockController: ZERO,
|
|
184
185
|
usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
185
186
|
identityRegistry: ERC8004_IDENTITY_REGISTRY,
|
|
@@ -190,13 +191,13 @@ var init_config = __esm({
|
|
|
190
191
|
safeProxyFactory: SAFE_PROXY_FACTORY,
|
|
191
192
|
safe7579: SAFE7579,
|
|
192
193
|
entryPoint: ENTRYPOINT_V07,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
erc8004ValidationModule: "
|
|
196
|
-
|
|
197
|
-
validationRegistry:
|
|
198
|
-
|
|
199
|
-
timelockController: "
|
|
194
|
+
agether4337Factory: "0x7B23470dCD65b8fEA3Bf49466860b3A55D56268C",
|
|
195
|
+
agether7579Bootstrap: "0x62d34D22D379367EEDcb7D1E4dE899A654E982D0",
|
|
196
|
+
erc8004ValidationModule: "0xfC6ccFd12e163460C7Ef92d38DC0be6C6cA10f6C",
|
|
197
|
+
agetherHookMultiplexer: "0x094FE93a8b733a97a6945530cA83058CaCbf5278",
|
|
198
|
+
validationRegistry: ZERO,
|
|
199
|
+
agether8004Scorer: "0x9f0084E5c941365149c8953133cF062E33a19b8d",
|
|
200
|
+
timelockController: "0x2807912DA2a7278AF883a376bE15bBBf3ab99f52",
|
|
200
201
|
usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
201
202
|
identityRegistry: ERC8004_IDENTITY_REGISTRY,
|
|
202
203
|
morphoBlue: MORPHO_BLUE
|
|
@@ -206,12 +207,12 @@ var init_config = __esm({
|
|
|
206
207
|
safeProxyFactory: SAFE_PROXY_FACTORY,
|
|
207
208
|
safe7579: SAFE7579,
|
|
208
209
|
entryPoint: ENTRYPOINT_V07,
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
agether4337Factory: ZERO,
|
|
211
|
+
agether7579Bootstrap: ZERO,
|
|
211
212
|
erc8004ValidationModule: ZERO,
|
|
212
|
-
|
|
213
|
+
agetherHookMultiplexer: ZERO,
|
|
213
214
|
validationRegistry: ZERO,
|
|
214
|
-
|
|
215
|
+
agether8004Scorer: ZERO,
|
|
215
216
|
timelockController: ZERO,
|
|
216
217
|
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
217
218
|
identityRegistry: ERC8004_IDENTITY_REGISTRY_TESTNET,
|
|
@@ -222,12 +223,12 @@ var init_config = __esm({
|
|
|
222
223
|
safeProxyFactory: SAFE_PROXY_FACTORY,
|
|
223
224
|
safe7579: SAFE7579,
|
|
224
225
|
entryPoint: ENTRYPOINT_V07,
|
|
225
|
-
|
|
226
|
-
|
|
226
|
+
agether4337Factory: ZERO,
|
|
227
|
+
agether7579Bootstrap: ZERO,
|
|
227
228
|
erc8004ValidationModule: ZERO,
|
|
228
|
-
|
|
229
|
+
agetherHookMultiplexer: ZERO,
|
|
229
230
|
validationRegistry: ZERO,
|
|
230
|
-
|
|
231
|
+
agether8004Scorer: ZERO,
|
|
231
232
|
timelockController: ZERO,
|
|
232
233
|
usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
233
234
|
identityRegistry: ERC8004_IDENTITY_REGISTRY_TESTNET,
|
|
@@ -238,12 +239,12 @@ var init_config = __esm({
|
|
|
238
239
|
safeProxyFactory: SAFE_PROXY_FACTORY,
|
|
239
240
|
safe7579: SAFE7579,
|
|
240
241
|
entryPoint: ENTRYPOINT_V07,
|
|
241
|
-
|
|
242
|
-
|
|
242
|
+
agether4337Factory: ZERO,
|
|
243
|
+
agether7579Bootstrap: ZERO,
|
|
243
244
|
erc8004ValidationModule: ZERO,
|
|
244
|
-
|
|
245
|
+
agetherHookMultiplexer: ZERO,
|
|
245
246
|
validationRegistry: ZERO,
|
|
246
|
-
|
|
247
|
+
agether8004Scorer: ZERO,
|
|
247
248
|
timelockController: ZERO,
|
|
248
249
|
usdc: "0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf",
|
|
249
250
|
identityRegistry: ERC8004_IDENTITY_REGISTRY,
|
|
@@ -322,9 +323,9 @@ var init_MorphoClient = __esm({
|
|
|
322
323
|
this._eoaAddress = wallet.address;
|
|
323
324
|
}
|
|
324
325
|
const addrs = { ...defaultCfg.contracts, ...config.contracts };
|
|
325
|
-
this.
|
|
326
|
+
this.agether4337Factory = new import_ethers.Contract(addrs.agether4337Factory, ACCOUNT_FACTORY_ABI, this._signer);
|
|
326
327
|
this.morphoBlue = new import_ethers.Contract(addrs.morphoBlue, MORPHO_BLUE_ABI, this.provider);
|
|
327
|
-
this.
|
|
328
|
+
this.agether8004Scorer = new import_ethers.Contract(addrs.agether8004Scorer, AGENT_REPUTATION_ABI, this._signer);
|
|
328
329
|
this.identityRegistry = new import_ethers.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this._signer);
|
|
329
330
|
this.entryPoint = new import_ethers.Contract(addrs.entryPoint, ENTRYPOINT_V07_ABI, this._signer);
|
|
330
331
|
this.validationModule = new import_ethers.Contract(addrs.erc8004ValidationModule, ERC8004_VALIDATION_MODULE_ABI, this.provider);
|
|
@@ -356,7 +357,7 @@ var init_MorphoClient = __esm({
|
|
|
356
357
|
let lastErr;
|
|
357
358
|
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
|
|
358
359
|
try {
|
|
359
|
-
const addr = await this.
|
|
360
|
+
const addr = await this.agether4337Factory.getAccount(BigInt(this.agentId));
|
|
360
361
|
if (addr === import_ethers.ethers.ZeroAddress) {
|
|
361
362
|
throw new AgetherError("No AgentAccount found. Call register() first.", "NO_ACCOUNT");
|
|
362
363
|
}
|
|
@@ -434,9 +435,9 @@ var init_MorphoClient = __esm({
|
|
|
434
435
|
async register(_name) {
|
|
435
436
|
const eoaAddr = await this.getSignerAddress();
|
|
436
437
|
if (this.agentId) {
|
|
437
|
-
const exists = await this.
|
|
438
|
+
const exists = await this.agether4337Factory.accountExists(BigInt(this.agentId));
|
|
438
439
|
if (exists) {
|
|
439
|
-
const acct = await this.
|
|
440
|
+
const acct = await this.agether4337Factory.getAccount(BigInt(this.agentId));
|
|
440
441
|
this._accountAddress = acct;
|
|
441
442
|
const kyaRequired2 = await this.isKyaRequired();
|
|
442
443
|
return { agentId: this.agentId, address: eoaAddr, agentAccount: acct, alreadyRegistered: true, kyaRequired: kyaRequired2 };
|
|
@@ -454,15 +455,15 @@ var init_MorphoClient = __esm({
|
|
|
454
455
|
agentId = await this._mintNewIdentity();
|
|
455
456
|
}
|
|
456
457
|
this.agentId = agentId.toString();
|
|
457
|
-
const acctExists = await this.
|
|
458
|
+
const acctExists = await this.agether4337Factory.accountExists(agentId);
|
|
458
459
|
let txHash;
|
|
459
460
|
if (!acctExists) {
|
|
460
|
-
const tx = await this.
|
|
461
|
+
const tx = await this.agether4337Factory.createAccount(agentId);
|
|
461
462
|
const receipt = await tx.wait();
|
|
462
463
|
this._refreshSigner();
|
|
463
464
|
txHash = receipt.hash;
|
|
464
465
|
}
|
|
465
|
-
const acctAddr = await this.
|
|
466
|
+
const acctAddr = await this.agether4337Factory.getAccount(agentId);
|
|
466
467
|
this._accountAddress = acctAddr;
|
|
467
468
|
const kyaRequired = await this.isKyaRequired();
|
|
468
469
|
return {
|
|
@@ -606,7 +607,7 @@ var init_MorphoClient = __esm({
|
|
|
606
607
|
}
|
|
607
608
|
/**
|
|
608
609
|
* Get MarketParams for a collateral token.
|
|
609
|
-
* Tries cache → API →
|
|
610
|
+
* Tries cache → API → onchain idToMarketParams.
|
|
610
611
|
*/
|
|
611
612
|
async findMarketForCollateral(collateralSymbolOrAddress) {
|
|
612
613
|
const colInfo = BASE_COLLATERALS[collateralSymbolOrAddress];
|
|
@@ -621,7 +622,7 @@ var init_MorphoClient = __esm({
|
|
|
621
622
|
"MARKET_NOT_FOUND"
|
|
622
623
|
);
|
|
623
624
|
}
|
|
624
|
-
/** Read MarketParams
|
|
625
|
+
/** Read MarketParams onchain by market ID (bytes32). */
|
|
625
626
|
async getMarketParams(marketId) {
|
|
626
627
|
const result = await this.morphoBlue.idToMarketParams(marketId);
|
|
627
628
|
return {
|
|
@@ -635,7 +636,7 @@ var init_MorphoClient = __esm({
|
|
|
635
636
|
// ════════════════════════════════════════════════════════
|
|
636
637
|
// Position Reads
|
|
637
638
|
// ════════════════════════════════════════════════════════
|
|
638
|
-
/** Read
|
|
639
|
+
/** Read onchain position for a specific market. */
|
|
639
640
|
async getPosition(marketId) {
|
|
640
641
|
const acctAddr = await this.getAccountAddress();
|
|
641
642
|
const pos = await this.morphoBlue.position(marketId, acctAddr);
|
|
@@ -1189,7 +1190,7 @@ var init_MorphoClient = __esm({
|
|
|
1189
1190
|
if (target.address) {
|
|
1190
1191
|
targetAddr = target.address;
|
|
1191
1192
|
} else if (target.agentId) {
|
|
1192
|
-
targetAddr = await this.
|
|
1193
|
+
targetAddr = await this.agether4337Factory.getAccount(BigInt(target.agentId));
|
|
1193
1194
|
if (targetAddr === import_ethers.ethers.ZeroAddress) throw new AgetherError("Target agent has no account", "NO_ACCOUNT");
|
|
1194
1195
|
} else {
|
|
1195
1196
|
throw new AgetherError("Provide agentId or address", "INVALID_TARGET");
|
|
@@ -1202,25 +1203,25 @@ var init_MorphoClient = __esm({
|
|
|
1202
1203
|
return { tx: receipt.hash, targetAccount: targetAddr, targetAgentId: target.agentId };
|
|
1203
1204
|
}
|
|
1204
1205
|
// ════════════════════════════════════════════════════════
|
|
1205
|
-
// Reputation (
|
|
1206
|
+
// Reputation (Agether8004Scorer contract)
|
|
1206
1207
|
// ════════════════════════════════════════════════════════
|
|
1207
1208
|
async getCreditScore() {
|
|
1208
1209
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
1209
|
-
return this.
|
|
1210
|
+
return this.agether8004Scorer.getCreditScore(BigInt(this.agentId));
|
|
1210
1211
|
}
|
|
1211
1212
|
async getAttestation() {
|
|
1212
1213
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
1213
|
-
const att = await this.
|
|
1214
|
+
const att = await this.agether8004Scorer.getAttestation(BigInt(this.agentId));
|
|
1214
1215
|
return { score: att.score, timestamp: att.timestamp, signer: att.signer };
|
|
1215
1216
|
}
|
|
1216
1217
|
async isEligible(minScore = 500n) {
|
|
1217
1218
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
1218
|
-
const [eligible, currentScore] = await this.
|
|
1219
|
+
const [eligible, currentScore] = await this.agether8004Scorer.isEligible(BigInt(this.agentId), minScore);
|
|
1219
1220
|
return { eligible, currentScore };
|
|
1220
1221
|
}
|
|
1221
1222
|
async isScoreFresh() {
|
|
1222
1223
|
if (!this.agentId) throw new AgetherError("agentId not set", "NO_AGENT_ID");
|
|
1223
|
-
const [fresh, age] = await this.
|
|
1224
|
+
const [fresh, age] = await this.agether8004Scorer.isScoreFresh(BigInt(this.agentId));
|
|
1224
1225
|
return { fresh, age };
|
|
1225
1226
|
}
|
|
1226
1227
|
// ════════════════════════════════════════════════════════
|
|
@@ -1242,10 +1243,10 @@ var init_MorphoClient = __esm({
|
|
|
1242
1243
|
_refreshSigner() {
|
|
1243
1244
|
if (this._useExternalSigner) {
|
|
1244
1245
|
const addrs = this.config.contracts;
|
|
1245
|
-
this.
|
|
1246
|
+
this.agether4337Factory = new import_ethers.Contract(addrs.agether4337Factory, ACCOUNT_FACTORY_ABI, this._signer);
|
|
1246
1247
|
this.entryPoint = new import_ethers.Contract(addrs.entryPoint, ENTRYPOINT_V07_ABI, this._signer);
|
|
1247
1248
|
this.validationModule = new import_ethers.Contract(addrs.erc8004ValidationModule, ERC8004_VALIDATION_MODULE_ABI, this.provider);
|
|
1248
|
-
this.
|
|
1249
|
+
this.agether8004Scorer = new import_ethers.Contract(addrs.agether8004Scorer, AGENT_REPUTATION_ABI, this._signer);
|
|
1249
1250
|
this.identityRegistry = new import_ethers.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this._signer);
|
|
1250
1251
|
} else {
|
|
1251
1252
|
this.provider = new import_ethers.ethers.JsonRpcProvider(this._rpcUrl);
|
|
@@ -1253,10 +1254,10 @@ var init_MorphoClient = __esm({
|
|
|
1253
1254
|
this._signer = wallet;
|
|
1254
1255
|
this._eoaAddress = wallet.address;
|
|
1255
1256
|
const addrs = this.config.contracts;
|
|
1256
|
-
this.
|
|
1257
|
+
this.agether4337Factory = new import_ethers.Contract(addrs.agether4337Factory, ACCOUNT_FACTORY_ABI, this._signer);
|
|
1257
1258
|
this.entryPoint = new import_ethers.Contract(addrs.entryPoint, ENTRYPOINT_V07_ABI, this._signer);
|
|
1258
1259
|
this.validationModule = new import_ethers.Contract(addrs.erc8004ValidationModule, ERC8004_VALIDATION_MODULE_ABI, this.provider);
|
|
1259
|
-
this.
|
|
1260
|
+
this.agether8004Scorer = new import_ethers.Contract(addrs.agether8004Scorer, AGENT_REPUTATION_ABI, this._signer);
|
|
1260
1261
|
this.identityRegistry = new import_ethers.Contract(addrs.identityRegistry, IDENTITY_REGISTRY_ABI, this._signer);
|
|
1261
1262
|
}
|
|
1262
1263
|
}
|
|
@@ -1834,10 +1835,10 @@ async function cmdRegister(name) {
|
|
|
1834
1835
|
process.exit(1);
|
|
1835
1836
|
}
|
|
1836
1837
|
const registryAddr = contracts.agentRegistry || contracts.identityRegistry;
|
|
1837
|
-
const factoryAddr = contracts.safeAgentFactory || contracts.accountFactory;
|
|
1838
|
+
const factoryAddr = contracts.agether4337Factory || contracts.safeAgentFactory || contracts.accountFactory;
|
|
1838
1839
|
const validationAddr = contracts.validationRegistry;
|
|
1839
1840
|
if (!registryAddr || !factoryAddr) {
|
|
1840
|
-
console.error(" \u274C Backend missing agentRegistry or
|
|
1841
|
+
console.error(" \u274C Backend missing agentRegistry or agether4337Factory");
|
|
1841
1842
|
process.exit(1);
|
|
1842
1843
|
}
|
|
1843
1844
|
console.log(" [2/4] Registering on ERC-8004 IdentityRegistry...");
|
|
@@ -1854,7 +1855,7 @@ async function cmdRegister(name) {
|
|
|
1854
1855
|
process.exit(1);
|
|
1855
1856
|
}
|
|
1856
1857
|
} catch {
|
|
1857
|
-
console.error(` \u274C agentId ${agentId} does not exist
|
|
1858
|
+
console.error(` \u274C agentId ${agentId} does not exist onchain`);
|
|
1858
1859
|
process.exit(1);
|
|
1859
1860
|
}
|
|
1860
1861
|
} else {
|
|
@@ -2015,12 +2016,12 @@ async function cmdScore() {
|
|
|
2015
2016
|
try {
|
|
2016
2017
|
const data = await apiGet(config.backendUrl, `/score/${config.agentId}/current`);
|
|
2017
2018
|
if (data.score !== void 0) {
|
|
2018
|
-
console.log(`
|
|
2019
|
+
console.log(` Onchain Score: ${data.score}`);
|
|
2019
2020
|
console.log(` Timestamp: ${data.timestamp ? new Date(Number(data.timestamp) * 1e3).toISOString() : "N/A"}`);
|
|
2020
2021
|
console.log(` Signer: ${data.signer || "N/A"}`);
|
|
2021
2022
|
console.log(` Fresh: ${data.fresh ? "\u2705" : "\u26A0\uFE0F stale"}`);
|
|
2022
2023
|
} else {
|
|
2023
|
-
console.log(" No score
|
|
2024
|
+
console.log(" No score onchain yet.");
|
|
2024
2025
|
}
|
|
2025
2026
|
} catch {
|
|
2026
2027
|
console.log(" Could not fetch current score.");
|
package/dist/index.d.mts
CHANGED
|
@@ -6,11 +6,11 @@ import { WalletClient } from 'viem';
|
|
|
6
6
|
*
|
|
7
7
|
* Architecture (v2 — Safe + Safe7579):
|
|
8
8
|
* - Agent registers via ERC-8004 → gets agentId
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
9
|
+
* - Agether4337Factory creates Safe proxy with Safe7579 adapter per agent
|
|
10
|
+
* - Agether8004ValidationModule: ownership + KYA gate + module lock (single 7579 validator)
|
|
11
|
+
* - AgetherHookMultiplexer: admin-managed hook chain
|
|
12
12
|
* - All execution via ERC-4337 UserOps through EntryPoint v0.7
|
|
13
|
-
* -
|
|
13
|
+
* - Agether8004Scorer: oracle-based credit scoring
|
|
14
14
|
* - Morpho Blue: direct overcollateralized lending (agents interact via UserOps)
|
|
15
15
|
* - x402: HTTP payment protocol for scoring API
|
|
16
16
|
*/
|
|
@@ -29,13 +29,13 @@ interface MorphoMarketParams {
|
|
|
29
29
|
irm: string;
|
|
30
30
|
lltv: bigint;
|
|
31
31
|
}
|
|
32
|
-
/** Morpho Blue
|
|
32
|
+
/** Morpho Blue onchain position for an account */
|
|
33
33
|
interface MorphoPosition {
|
|
34
34
|
supplyShares: bigint;
|
|
35
35
|
borrowShares: bigint;
|
|
36
36
|
collateral: bigint;
|
|
37
37
|
}
|
|
38
|
-
/** Morpho market info (from GraphQL API or
|
|
38
|
+
/** Morpho market info (from GraphQL API or onchain) */
|
|
39
39
|
interface MorphoMarketInfo {
|
|
40
40
|
uniqueKey: string;
|
|
41
41
|
loanAsset: {
|
|
@@ -55,7 +55,7 @@ interface MorphoMarketInfo {
|
|
|
55
55
|
totalBorrowAssets: bigint;
|
|
56
56
|
utilization: number;
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
58
|
+
/** Onchain score attestation from Agether8004Scorer contract */
|
|
59
59
|
interface ScoreAttestation {
|
|
60
60
|
score: bigint;
|
|
61
61
|
timestamp: bigint;
|
|
@@ -107,12 +107,12 @@ interface ContractAddresses {
|
|
|
107
107
|
safeProxyFactory: string;
|
|
108
108
|
safe7579: string;
|
|
109
109
|
entryPoint: string;
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
agether4337Factory: string;
|
|
111
|
+
agether7579Bootstrap: string;
|
|
112
112
|
erc8004ValidationModule: string;
|
|
113
|
-
|
|
113
|
+
agetherHookMultiplexer: string;
|
|
114
114
|
validationRegistry: string;
|
|
115
|
-
|
|
115
|
+
agether8004Scorer: string;
|
|
116
116
|
timelockController: string;
|
|
117
117
|
identityRegistry: string;
|
|
118
118
|
usdc: string;
|
|
@@ -142,9 +142,9 @@ declare class AgetherClient {
|
|
|
142
142
|
private config;
|
|
143
143
|
private signer;
|
|
144
144
|
private agentId;
|
|
145
|
-
private
|
|
145
|
+
private agether4337Factory;
|
|
146
146
|
private identityRegistry;
|
|
147
|
-
private
|
|
147
|
+
private agether8004Scorer;
|
|
148
148
|
private validationModule;
|
|
149
149
|
private accountAddress?;
|
|
150
150
|
constructor(options: AgetherClientOptions);
|
|
@@ -228,10 +228,10 @@ interface MorphoClientBaseConfig {
|
|
|
228
228
|
agentId?: string;
|
|
229
229
|
chainId?: ChainId;
|
|
230
230
|
contracts?: Partial<{
|
|
231
|
-
|
|
231
|
+
agether4337Factory: string;
|
|
232
232
|
morphoBlue: string;
|
|
233
233
|
usdc: string;
|
|
234
|
-
|
|
234
|
+
agether8004Scorer: string;
|
|
235
235
|
identityRegistry: string;
|
|
236
236
|
erc8004ValidationModule: string;
|
|
237
237
|
entryPoint: string;
|
|
@@ -356,9 +356,9 @@ declare class MorphoClient {
|
|
|
356
356
|
private _privateKey?;
|
|
357
357
|
private _useExternalSigner;
|
|
358
358
|
private _eoaAddress?;
|
|
359
|
-
private
|
|
359
|
+
private agether4337Factory;
|
|
360
360
|
private morphoBlue;
|
|
361
|
-
private
|
|
361
|
+
private agether8004Scorer;
|
|
362
362
|
private identityRegistry;
|
|
363
363
|
private entryPoint;
|
|
364
364
|
private validationModule;
|
|
@@ -407,12 +407,12 @@ declare class MorphoClient {
|
|
|
407
407
|
getMarkets(forceRefresh?: boolean): Promise<MorphoMarketInfo[]>;
|
|
408
408
|
/**
|
|
409
409
|
* Get MarketParams for a collateral token.
|
|
410
|
-
* Tries cache → API →
|
|
410
|
+
* Tries cache → API → onchain idToMarketParams.
|
|
411
411
|
*/
|
|
412
412
|
findMarketForCollateral(collateralSymbolOrAddress: string): Promise<MorphoMarketParams>;
|
|
413
|
-
/** Read MarketParams
|
|
413
|
+
/** Read MarketParams onchain by market ID (bytes32). */
|
|
414
414
|
getMarketParams(marketId: string): Promise<MorphoMarketParams>;
|
|
415
|
-
/** Read
|
|
415
|
+
/** Read onchain position for a specific market. */
|
|
416
416
|
getPosition(marketId: string): Promise<MorphoPosition>;
|
|
417
417
|
/**
|
|
418
418
|
* Full status: positions across all discovered markets.
|
|
@@ -754,8 +754,8 @@ declare class X402Client {
|
|
|
754
754
|
* ScoringClient — Client for the Agether backend scoring API
|
|
755
755
|
*
|
|
756
756
|
* Endpoints:
|
|
757
|
-
* GET /score/:agentId — x402-gated, compute + submit score
|
|
758
|
-
* GET /score/:agentId/current — free, read current
|
|
757
|
+
* GET /score/:agentId — x402-gated, compute + submit score onchain
|
|
758
|
+
* GET /score/:agentId/current — free, read current onchain score
|
|
759
759
|
* GET /health — service health
|
|
760
760
|
* GET /status — detailed status
|
|
761
761
|
* GET /agents/:agentId/details — agent details
|
|
@@ -777,13 +777,13 @@ declare class ScoringClient {
|
|
|
777
777
|
*
|
|
778
778
|
* This is x402-gated: the backend returns 402, the X402Client
|
|
779
779
|
* signs an EIP-3009 payment, and the backend computes + submits
|
|
780
|
-
* the score
|
|
780
|
+
* the score onchain via AgentReputation.submitScore().
|
|
781
781
|
*
|
|
782
782
|
* Returns the ScoreResult with breakdown and txHash.
|
|
783
783
|
*/
|
|
784
784
|
requestScore(agentId: string | bigint): Promise<ScoreResult>;
|
|
785
785
|
/**
|
|
786
|
-
* Get the current
|
|
786
|
+
* Get the current onchain score (free, no payment required).
|
|
787
787
|
*/
|
|
788
788
|
getCurrentScore(agentId: string | bigint): Promise<{
|
|
789
789
|
agentId: string;
|
|
@@ -932,7 +932,7 @@ declare class AgentIdentityClient {
|
|
|
932
932
|
existing: boolean;
|
|
933
933
|
}>;
|
|
934
934
|
/**
|
|
935
|
-
* Register agent with URI and
|
|
935
|
+
* Register agent with URI and onchain metadata
|
|
936
936
|
*/
|
|
937
937
|
registerWithMetadata(agentURI: string, metadata: {
|
|
938
938
|
key: string;
|
|
@@ -954,11 +954,11 @@ declare class AgentIdentityClient {
|
|
|
954
954
|
*/
|
|
955
955
|
setAgentURI(agentId: bigint, newURI: string): Promise<string>;
|
|
956
956
|
/**
|
|
957
|
-
* Set
|
|
957
|
+
* Set onchain metadata (key-value)
|
|
958
958
|
*/
|
|
959
959
|
setMetadata(agentId: bigint, key: string, value: string): Promise<string>;
|
|
960
960
|
/**
|
|
961
|
-
* Get
|
|
961
|
+
* Get onchain metadata
|
|
962
962
|
*/
|
|
963
963
|
getMetadata(agentId: bigint, key: string): Promise<string>;
|
|
964
964
|
/**
|
|
@@ -1069,20 +1069,24 @@ declare function rateToBps(rate: number): bigint;
|
|
|
1069
1069
|
* Contract ABIs (minimal for SDK)
|
|
1070
1070
|
*
|
|
1071
1071
|
* Architecture (v2 — Safe + Safe7579):
|
|
1072
|
-
* -
|
|
1073
|
-
* -
|
|
1074
|
-
* -
|
|
1075
|
-
* -
|
|
1072
|
+
* - Agether4337Factory (deploys Safe proxies with modules)
|
|
1073
|
+
* - Agether8004ValidationModule (ownership + KYA + module lock)
|
|
1074
|
+
* - AgetherHookMultiplexer (admin-managed hooks)
|
|
1075
|
+
* - Agether8004Scorer (oracle-based credit scores)
|
|
1076
1076
|
* - ValidationRegistry (KYA code validation)
|
|
1077
1077
|
* - ERC-8004 IdentityRegistry
|
|
1078
1078
|
* - Morpho Blue (direct overcollateralized lending)
|
|
1079
1079
|
* - EntryPoint v0.7 (ERC-4337 UserOp submission)
|
|
1080
1080
|
*/
|
|
1081
1081
|
declare const IDENTITY_REGISTRY_ABI: string[];
|
|
1082
|
+
declare const AGETHER_4337_FACTORY_ABI: string[];
|
|
1082
1083
|
declare const SAFE_AGENT_FACTORY_ABI: string[];
|
|
1083
1084
|
declare const ACCOUNT_FACTORY_ABI: string[];
|
|
1085
|
+
declare const AGETHER_8004_VALIDATION_MODULE_ABI: string[];
|
|
1084
1086
|
declare const ERC8004_VALIDATION_MODULE_ABI: string[];
|
|
1087
|
+
declare const AGETHER_HOOK_MULTIPLEXER_ABI: string[];
|
|
1085
1088
|
declare const HOOK_MULTIPLEXER_ABI: string[];
|
|
1089
|
+
declare const AGETHER_8004_SCORER_ABI: string[];
|
|
1086
1090
|
declare const AGENT_REPUTATION_ABI: string[];
|
|
1087
1091
|
declare const VALIDATION_REGISTRY_ABI: string[];
|
|
1088
1092
|
declare const MORPHO_BLUE_ABI: string[];
|
|
@@ -1094,10 +1098,10 @@ declare const SAFE7579_ACCOUNT_ABI: string[];
|
|
|
1094
1098
|
* Network configurations
|
|
1095
1099
|
*
|
|
1096
1100
|
* Contract architecture (v2 — Safe + Safe7579):
|
|
1097
|
-
* -
|
|
1098
|
-
* -
|
|
1099
|
-
* -
|
|
1100
|
-
* -
|
|
1101
|
+
* - Agether4337Factory + Safe proxy (4337-only smart wallets)
|
|
1102
|
+
* - Agether8004ValidationModule (ownership + KYA + module lock)
|
|
1103
|
+
* - AgetherHookMultiplexer (admin-managed hooks)
|
|
1104
|
+
* - Agether8004Scorer (oracle-based scoring)
|
|
1101
1105
|
* - ValidationRegistry (KYA code validation)
|
|
1102
1106
|
* - ERC-8004 IdentityRegistry
|
|
1103
1107
|
* - Morpho Blue (direct overcollateralized lending)
|
|
@@ -1114,4 +1118,4 @@ declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
|
|
|
1114
1118
|
*/
|
|
1115
1119
|
declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
|
|
1116
1120
|
|
|
1117
|
-
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, type FundResult, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, parseUnits, rateToBps };
|
|
1121
|
+
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, type FundResult, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getDefaultConfig, parseUnits, rateToBps };
|