@agether/sdk 2.13.0 → 2.14.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.
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Agether SDK Types
3
+ *
4
+ * Architecture (v2 — Safe + Safe7579):
5
+ * - Agent registers via ERC-8004 → gets agentId
6
+ * - Agether4337Factory creates Safe proxy with Safe7579 adapter per agent
7
+ * - Agether8004ValidationModule: ownership + KYA gate + module lock (single 7579 validator)
8
+ * - AgetherHookMultiplexer: admin-managed hook chain
9
+ * - All execution via ERC-4337 UserOps through EntryPoint v0.7
10
+ * - Agether8004Scorer: oracle-based credit scoring
11
+ * - Morpho Blue: direct overcollateralized lending (agents interact via UserOps)
12
+ * - x402: HTTP payment protocol for scoring API
13
+ */
14
+ export declare enum ChainId {
15
+ Ethereum = 1,
16
+ Base = 8453,
17
+ BaseSepolia = 84532,
18
+ Sepolia = 11155111,
19
+ Hardhat = 31337
20
+ }
21
+ /** Morpho Blue MarketParams struct */
22
+ export interface MorphoMarketParams {
23
+ loanToken: string;
24
+ collateralToken: string;
25
+ oracle: string;
26
+ irm: string;
27
+ lltv: bigint;
28
+ }
29
+ /** Morpho Blue onchain position for an account */
30
+ export interface MorphoPosition {
31
+ supplyShares: bigint;
32
+ borrowShares: bigint;
33
+ collateral: bigint;
34
+ }
35
+ /** Morpho market info (from GraphQL API or onchain) */
36
+ export interface MorphoMarketInfo {
37
+ uniqueKey: string;
38
+ loanAsset: {
39
+ address: string;
40
+ symbol: string;
41
+ decimals: number;
42
+ };
43
+ collateralAsset: {
44
+ address: string;
45
+ symbol: string;
46
+ decimals: number;
47
+ };
48
+ oracle: string;
49
+ irm: string;
50
+ lltv: bigint;
51
+ totalSupplyAssets: bigint;
52
+ totalBorrowAssets: bigint;
53
+ utilization: number;
54
+ }
55
+ /** Onchain score attestation from Agether8004Scorer contract */
56
+ export interface ScoreAttestation {
57
+ score: bigint;
58
+ timestamp: bigint;
59
+ signer: string;
60
+ }
61
+ /** Score result from backend scoring API */
62
+ export interface ScoreResult {
63
+ agentId: string;
64
+ score: number;
65
+ timestamp: number;
66
+ breakdown: {
67
+ kyaBonus: number;
68
+ accountBonus: number;
69
+ balanceBonus: number;
70
+ historyBonus: number;
71
+ baseScore: number;
72
+ };
73
+ txHash?: string;
74
+ }
75
+ export interface TransactionResult {
76
+ txHash: string;
77
+ blockNumber: number;
78
+ status: 'success' | 'failed';
79
+ gasUsed: bigint;
80
+ }
81
+ export interface X402PaymentRequest {
82
+ service: string;
83
+ amount: bigint;
84
+ asset: string;
85
+ chain: ChainId;
86
+ recipient: string;
87
+ }
88
+ export interface X402PaymentResult {
89
+ paymentId: string;
90
+ txHash: string;
91
+ amount: bigint;
92
+ chain: ChainId;
93
+ status: 'pending' | 'confirmed' | 'failed';
94
+ }
95
+ export interface AgetherConfig {
96
+ chainId: ChainId;
97
+ rpcUrl: string;
98
+ contracts: ContractAddresses;
99
+ scoringEndpoint?: string;
100
+ kyaEndpoint?: string;
101
+ }
102
+ export interface ContractAddresses {
103
+ safeSingleton: string;
104
+ safeProxyFactory: string;
105
+ safe7579: string;
106
+ entryPoint: string;
107
+ agether4337Factory: string;
108
+ agether7579Bootstrap: string;
109
+ erc8004ValidationModule: string;
110
+ agetherHookMultiplexer: string;
111
+ validationRegistry: string;
112
+ agether8004Scorer: string;
113
+ timelockController: string;
114
+ identityRegistry: string;
115
+ usdc: string;
116
+ morphoBlue: string;
117
+ }
118
+ export declare class AgetherError extends Error {
119
+ code: string;
120
+ details?: Record<string, unknown> | undefined;
121
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
122
+ }
123
+ export declare class InsufficientBalanceError extends AgetherError {
124
+ constructor(available: bigint, required: bigint);
125
+ }
126
+ export declare class ScoringRejectedError extends AgetherError {
127
+ constructor(riskScore: number, reason?: string);
128
+ }
129
+ export declare class AgentNotApprovedError extends AgetherError {
130
+ constructor(agentId: bigint);
131
+ }
132
+ //# sourceMappingURL=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kB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;IAChC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAG1B,kBAAkB,EAAE,MAAM,CAAC;IAG3B,gBAAgB,EAAE,MAAM,CAAC;IAGzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAID,qBAAa,YAAa,SAAQ,KAAK;IAG5B,IAAI,EAAE,MAAM;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFxC,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAK3C;AAED,qBAAa,wBAAyB,SAAQ,YAAY;gBAC5C,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAOhD;AAED,qBAAa,oBAAqB,SAAQ,YAAY;gBACxC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAO/C;AAED,qBAAa,qBAAsB,SAAQ,YAAY;gBACzC,OAAO,EAAE,MAAM;CAO5B"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Agether SDK Types
3
+ *
4
+ * Architecture (v2 — Safe + Safe7579):
5
+ * - Agent registers via ERC-8004 → gets agentId
6
+ * - Agether4337Factory creates Safe proxy with Safe7579 adapter per agent
7
+ * - Agether8004ValidationModule: ownership + KYA gate + module lock (single 7579 validator)
8
+ * - AgetherHookMultiplexer: admin-managed hook chain
9
+ * - All execution via ERC-4337 UserOps through EntryPoint v0.7
10
+ * - Agether8004Scorer: oracle-based credit scoring
11
+ * - Morpho Blue: direct overcollateralized lending (agents interact via UserOps)
12
+ * - x402: HTTP payment protocol for scoring API
13
+ */
14
+ // ============ Enums ============
15
+ export var ChainId;
16
+ (function (ChainId) {
17
+ ChainId[ChainId["Ethereum"] = 1] = "Ethereum";
18
+ ChainId[ChainId["Base"] = 8453] = "Base";
19
+ ChainId[ChainId["BaseSepolia"] = 84532] = "BaseSepolia";
20
+ ChainId[ChainId["Sepolia"] = 11155111] = "Sepolia";
21
+ ChainId[ChainId["Hardhat"] = 31337] = "Hardhat";
22
+ })(ChainId || (ChainId = {}));
23
+ // ============ Error Types ============
24
+ export class AgetherError extends Error {
25
+ constructor(message, code, details) {
26
+ super(message);
27
+ this.code = code;
28
+ this.details = details;
29
+ this.name = 'AgetherError';
30
+ }
31
+ }
32
+ export class InsufficientBalanceError extends AgetherError {
33
+ constructor(available, required) {
34
+ super(`Insufficient balance: available ${available}, required ${required}`, 'INSUFFICIENT_BALANCE', { available: available.toString(), required: required.toString() });
35
+ }
36
+ }
37
+ export class ScoringRejectedError extends AgetherError {
38
+ constructor(riskScore, reason) {
39
+ super(`Scoring rejected: risk score ${riskScore}${reason ? `, ${reason}` : ''}`, 'SCORING_REJECTED', { riskScore, reason });
40
+ }
41
+ }
42
+ export class AgentNotApprovedError extends AgetherError {
43
+ constructor(agentId) {
44
+ super(`Agent ${agentId} is not KYA-approved. Submit code for validation first.`, 'AGENT_NOT_APPROVED', { agentId: agentId.toString() });
45
+ }
46
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Contract ABIs (minimal for SDK)
3
+ *
4
+ * Architecture (v2 — Safe + Safe7579):
5
+ * - Agether4337Factory (deploys Safe proxies with modules)
6
+ * - Agether8004ValidationModule (ownership + KYA + module lock)
7
+ * - AgetherHookMultiplexer (admin-managed hooks)
8
+ * - Agether8004Scorer (oracle-based credit scores)
9
+ * - ValidationRegistry (KYA code validation)
10
+ * - ERC-8004 IdentityRegistry
11
+ * - Morpho Blue (direct overcollateralized lending)
12
+ * - EntryPoint v0.7 (ERC-4337 UserOp submission)
13
+ */
14
+ export declare const IDENTITY_REGISTRY_ABI: string[];
15
+ export declare const AGETHER_4337_FACTORY_ABI: string[];
16
+ export declare const SAFE_AGENT_FACTORY_ABI: string[];
17
+ export declare const ACCOUNT_FACTORY_ABI: string[];
18
+ export declare const AGETHER_8004_VALIDATION_MODULE_ABI: string[];
19
+ export declare const ERC8004_VALIDATION_MODULE_ABI: string[];
20
+ export declare const AGETHER_HOOK_MULTIPLEXER_ABI: string[];
21
+ export declare const HOOK_MULTIPLEXER_ABI: string[];
22
+ export declare const AGETHER_8004_SCORER_ABI: string[];
23
+ export declare const AGENT_REPUTATION_ABI: string[];
24
+ export declare const VALIDATION_REGISTRY_ABI: string[];
25
+ export declare const MORPHO_BLUE_ABI: string[];
26
+ export declare const ERC20_ABI: string[];
27
+ export declare const ENTRYPOINT_V07_ABI: string[];
28
+ export declare const SAFE7579_ACCOUNT_ABI: string[];
29
+ //# sourceMappingURL=abis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../../src/utils/abis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,eAAO,MAAM,qBAAqB,UASjC,CAAC;AAIF,eAAO,MAAM,wBAAwB,UAepC,CAAC;AAGF,eAAO,MAAM,sBAAsB,UAA2B,CAAC;AAC/D,eAAO,MAAM,mBAAmB,UAA2B,CAAC;AAI5D,eAAO,MAAM,kCAAkC,UAU9C,CAAC;AAGF,eAAO,MAAM,6BAA6B,UAAqC,CAAC;AAIhF,eAAO,MAAM,4BAA4B,UAMxC,CAAC;AAGF,eAAO,MAAM,oBAAoB,UAA+B,CAAC;AAIjE,eAAO,MAAM,uBAAuB,UASnC,CAAC;AAGF,eAAO,MAAM,oBAAoB,UAA0B,CAAC;AAI5D,eAAO,MAAM,uBAAuB,UAKnC,CAAC;AAIF,eAAO,MAAM,eAAe,UAiB3B,CAAC;AAIF,eAAO,MAAM,SAAS,UASrB,CAAC;AAIF,eAAO,MAAM,kBAAkB,UAQ9B,CAAC;AAIF,eAAO,MAAM,oBAAoB,UAQhC,CAAC"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Contract ABIs (minimal for SDK)
3
+ *
4
+ * Architecture (v2 — Safe + Safe7579):
5
+ * - Agether4337Factory (deploys Safe proxies with modules)
6
+ * - Agether8004ValidationModule (ownership + KYA + module lock)
7
+ * - AgetherHookMultiplexer (admin-managed hooks)
8
+ * - Agether8004Scorer (oracle-based credit scores)
9
+ * - ValidationRegistry (KYA code validation)
10
+ * - ERC-8004 IdentityRegistry
11
+ * - Morpho Blue (direct overcollateralized lending)
12
+ * - EntryPoint v0.7 (ERC-4337 UserOp submission)
13
+ */
14
+ // ── ERC-8004 Identity Registry ──
15
+ export const IDENTITY_REGISTRY_ABI = [
16
+ 'function ownerOf(uint256 agentId) view returns (address)',
17
+ 'function balanceOf(address owner) view returns (uint256)',
18
+ 'function totalSupply() view returns (uint256)',
19
+ 'function exists(uint256 agentId) view returns (bool)',
20
+ 'function register() returns (uint256 agentId)',
21
+ 'function register(string agentURI) returns (uint256 agentId)',
22
+ 'function setAgentURI(uint256 agentId, string newURI)',
23
+ 'event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)',
24
+ ];
25
+ // ── Agether4337Factory (v2 — replaces old AccountFactory) ──
26
+ export const AGETHER_4337_FACTORY_ABI = [
27
+ 'function getAccount(uint256 agentId) view returns (address)',
28
+ 'function accountExists(uint256 agentId) view returns (bool)',
29
+ 'function totalAccounts() view returns (uint256)',
30
+ 'function getAgentId(address account) view returns (uint256)',
31
+ 'function getAgentIdByIndex(uint256 index) view returns (uint256)',
32
+ 'function getAllAgentIds() view returns (uint256[])',
33
+ 'function createAccount(uint256 agentId) returns (address safeAccount)',
34
+ 'function identityRegistry() view returns (address)',
35
+ 'function validationModule() view returns (address)',
36
+ 'function hookMultiplexer() view returns (address)',
37
+ 'function safeSingleton() view returns (address)',
38
+ 'function safe7579() view returns (address)',
39
+ 'function bootstrap() view returns (address)',
40
+ 'event AccountCreated(uint256 indexed agentId, address indexed safeAccount, address indexed owner)',
41
+ ];
42
+ // ── Backward compat aliases ──
43
+ export const SAFE_AGENT_FACTORY_ABI = AGETHER_4337_FACTORY_ABI;
44
+ export const ACCOUNT_FACTORY_ABI = AGETHER_4337_FACTORY_ABI;
45
+ // ── Agether8004ValidationModule (v2 — replaces AgentAccount + KYA Hook) ──
46
+ export const AGETHER_8004_VALIDATION_MODULE_ABI = [
47
+ // View
48
+ 'function getConfig(address account) view returns (address registry, uint256 agentId)',
49
+ 'function getOwner(address account) view returns (address)',
50
+ 'function isInstalled(address account) view returns (bool)',
51
+ 'function isKYAApproved(address account) view returns (bool)',
52
+ 'function validationRegistry() view returns (address)',
53
+ 'function owner() view returns (address)',
54
+ // Admin (via TimelockController)
55
+ 'function setValidationRegistry(address registry_)',
56
+ ];
57
+ // ── Backward compat alias ──
58
+ export const ERC8004_VALIDATION_MODULE_ABI = AGETHER_8004_VALIDATION_MODULE_ABI;
59
+ // ── AgetherHookMultiplexer (v2) ──
60
+ export const AGETHER_HOOK_MULTIPLEXER_ABI = [
61
+ 'function getHooks() view returns (address[])',
62
+ 'function hookCount() view returns (uint256)',
63
+ 'function owner() view returns (address)',
64
+ 'function addHook(address hook)',
65
+ 'function removeHook(address hook)',
66
+ ];
67
+ // ── Backward compat alias ──
68
+ export const HOOK_MULTIPLEXER_ABI = AGETHER_HOOK_MULTIPLEXER_ABI;
69
+ // ── Agether8004Scorer (oracle-based scoring) ──
70
+ export const AGETHER_8004_SCORER_ABI = [
71
+ 'function getCreditScore(uint256 agentId) view returns (uint256)',
72
+ 'function getAttestation(uint256 agentId) view returns (tuple(uint256 score, uint256 timestamp, address signer))',
73
+ 'function isScoreFresh(uint256 agentId) view returns (bool fresh, uint256 age)',
74
+ 'function isEligible(uint256 agentId, uint256 minScore) view returns (bool eligible, uint256 currentScore)',
75
+ 'function oracleSigner() view returns (address)',
76
+ 'function submitScore(uint256 agentId, uint256 score_, uint256 timestamp_, bytes signature)',
77
+ 'function setOracleSigner(address signer_)',
78
+ 'event ScoreUpdated(uint256 indexed agentId, uint256 score, uint256 timestamp, address signer)',
79
+ ];
80
+ // ── Backward compat alias ──
81
+ export const AGENT_REPUTATION_ABI = AGETHER_8004_SCORER_ABI;
82
+ // ── Validation Registry (KYA) ──
83
+ export const VALIDATION_REGISTRY_ABI = [
84
+ 'function isAgentCodeApproved(uint256 agentId) view returns (bool)',
85
+ 'function isAgentCodeApprovedForTag(uint256 agentId, string tag) view returns (bool)',
86
+ 'function getAgentValidations(uint256 agentId) view returns (bytes32[])',
87
+ 'function getValidation(bytes32 requestHash) view returns (tuple(address validatorAddress, uint256 agentId, string requestURI, uint8 response, string responseURI, bytes32 responseHash, string tag, uint256 requestedAt, uint256 respondedAt, bool hasResponse))',
88
+ ];
89
+ // ── Morpho Blue (direct lending protocol) ──
90
+ export const MORPHO_BLUE_ABI = [
91
+ // Supply & Withdraw (lending side)
92
+ '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)',
93
+ 'function withdraw(tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn)',
94
+ // Collateral
95
+ 'function supplyCollateral(tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, bytes data)',
96
+ 'function withdrawCollateral(tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, address receiver)',
97
+ // Borrow & Repay
98
+ 'function borrow(tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsBorrowed, uint256 sharesBorrowed)',
99
+ 'function repay(tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsRepaid, uint256 sharesRepaid)',
100
+ // Authorization
101
+ 'function setAuthorization(address authorized, bool newIsAuthorized)',
102
+ 'function isAuthorized(address authorizer, address authorized) view returns (bool)',
103
+ // Views
104
+ 'function position(bytes32 id, address user) view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral)',
105
+ 'function market(bytes32 id) view returns (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee)',
106
+ 'function idToMarketParams(bytes32 id) view returns (tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv))',
107
+ ];
108
+ // ── ERC-20 ──
109
+ export const ERC20_ABI = [
110
+ 'function balanceOf(address account) view returns (uint256)',
111
+ 'function allowance(address owner, address spender) view returns (uint256)',
112
+ 'function approve(address spender, uint256 amount) returns (bool)',
113
+ 'function transfer(address to, uint256 amount) returns (bool)',
114
+ 'function transferFrom(address from, address to, uint256 amount) returns (bool)',
115
+ 'function decimals() view returns (uint8)',
116
+ 'function symbol() view returns (string)',
117
+ 'function name() view returns (string)',
118
+ ];
119
+ // ── EntryPoint v0.7 (ERC-4337) ──
120
+ export const ENTRYPOINT_V07_ABI = [
121
+ 'function handleOps(tuple(address sender, uint256 nonce, bytes initCode, bytes callData, bytes32 accountGasLimits, uint256 preVerificationGas, bytes32 gasFees, bytes paymasterAndData, bytes signature)[] ops, address payable beneficiary)',
122
+ 'function getUserOpHash(tuple(address sender, uint256 nonce, bytes initCode, bytes callData, bytes32 accountGasLimits, uint256 preVerificationGas, bytes32 gasFees, bytes paymasterAndData, bytes signature) userOp) view returns (bytes32)',
123
+ 'function getNonce(address sender, uint192 key) view returns (uint256 nonce)',
124
+ 'function balanceOf(address account) view returns (uint256)',
125
+ 'function depositTo(address account) payable',
126
+ 'event UserOperationEvent(bytes32 indexed userOpHash, address indexed sender, address indexed paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed)',
127
+ 'event UserOperationRevertReason(bytes32 indexed userOpHash, address indexed sender, uint256 nonce, bytes revertReason)',
128
+ ];
129
+ // ── Safe7579 Account Interface (execute via fallback handler) ──
130
+ export const SAFE7579_ACCOUNT_ABI = [
131
+ // ERC-7579 execution (called via UserOp through Safe7579 fallback)
132
+ 'function execute(bytes32 mode, bytes executionCalldata) payable',
133
+ 'function executeFromExecutor(bytes32 mode, bytes executionCalldata) payable returns (bytes[])',
134
+ // ERC-7579 module queries
135
+ 'function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)',
136
+ // EIP-1271
137
+ 'function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4)',
138
+ ];
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Network configurations
3
+ *
4
+ * Contract architecture (v2 — Safe + Safe7579):
5
+ * - Agether4337Factory + Safe proxy (4337-only smart wallets)
6
+ * - Agether8004ValidationModule (ownership + KYA + module lock)
7
+ * - AgetherHookMultiplexer (admin-managed hooks)
8
+ * - Agether8004Scorer (oracle-based scoring)
9
+ * - ValidationRegistry (KYA code validation)
10
+ * - ERC-8004 IdentityRegistry
11
+ * - Morpho Blue (direct overcollateralized lending)
12
+ *
13
+ * All contract addresses are baked in — agents only need to specify chainId.
14
+ */
15
+ import { AgetherConfig, ChainId, ContractAddresses } from '../types';
16
+ /**
17
+ * Get default config for a chain — includes all addresses, RPC, and scoring endpoint.
18
+ */
19
+ export declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
20
+ /**
21
+ * Create custom config (override any defaults)
22
+ */
23
+ export declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
24
+ /**
25
+ * Get USDC address for chain
26
+ */
27
+ export declare function getUSDCAddress(chainId: ChainId): string;
28
+ /**
29
+ * Get Morpho Blue address for chain
30
+ */
31
+ export declare function getMorphoBlueAddress(chainId: ChainId): string;
32
+ /**
33
+ * Get all contract addresses for a chain
34
+ */
35
+ export declare function getContractAddresses(chainId: ChainId): ContractAddresses;
36
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAsHrE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAOhE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC/B,aAAa,CAUf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAEvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAExE"}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Network configurations
3
+ *
4
+ * Contract architecture (v2 — Safe + Safe7579):
5
+ * - Agether4337Factory + Safe proxy (4337-only smart wallets)
6
+ * - Agether8004ValidationModule (ownership + KYA + module lock)
7
+ * - AgetherHookMultiplexer (admin-managed hooks)
8
+ * - Agether8004Scorer (oracle-based scoring)
9
+ * - ValidationRegistry (KYA code validation)
10
+ * - ERC-8004 IdentityRegistry
11
+ * - Morpho Blue (direct overcollateralized lending)
12
+ *
13
+ * All contract addresses are baked in — agents only need to specify chainId.
14
+ */
15
+ import { ChainId } from '../types';
16
+ // Zero address placeholder for networks without deployments
17
+ const ZERO = '0x0000000000000000000000000000000000000000';
18
+ // Well-known cross-chain addresses
19
+ const ENTRYPOINT_V07 = '0x0000000071727De22E5E9d8BAf0edAc6f37da032';
20
+ const ERC8004_IDENTITY_REGISTRY = '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432';
21
+ const ERC8004_IDENTITY_REGISTRY_TESTNET = '0x8004A818BFB912233c491871b3d84c89A494BD9e';
22
+ const MORPHO_BLUE = '0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb';
23
+ // Safe infrastructure (same addresses across chains)
24
+ const SAFE_SINGLETON = '0x41675C099F32341bf84BFc5382aF534df5C7461a';
25
+ const SAFE_PROXY_FACTORY = '0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67';
26
+ const SAFE7579 = '0x7579EE8307284F293B1927136486880611F20002';
27
+ // Contract addresses per network
28
+ const CONTRACT_ADDRESSES = {
29
+ [ChainId.Ethereum]: {
30
+ safeSingleton: SAFE_SINGLETON,
31
+ safeProxyFactory: SAFE_PROXY_FACTORY,
32
+ safe7579: SAFE7579,
33
+ entryPoint: ENTRYPOINT_V07,
34
+ agether4337Factory: '0xb6363c2B5C72C14D3fC4261e3dd836D8966bE072',
35
+ agether7579Bootstrap: '0x055C2e70dd011C4ADEEfB795Ab77D74437be6D33',
36
+ erc8004ValidationModule: '0xE282fB8615abb8bA53F07b8BAB2937C78fE3867D',
37
+ agetherHookMultiplexer: '0xeD62ac874F58CEc9F065aB8e6872752Eb0F6eA14',
38
+ validationRegistry: ZERO,
39
+ agether8004Scorer: '0x960853769d52B14aA0daeab7E1E59f5c9299cb65',
40
+ timelockController: '0x78e0227f9DE577e583B8149C73F0bA1E7200AD01',
41
+ usdc: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
42
+ identityRegistry: ERC8004_IDENTITY_REGISTRY,
43
+ morphoBlue: MORPHO_BLUE,
44
+ },
45
+ [ChainId.Base]: {
46
+ safeSingleton: SAFE_SINGLETON,
47
+ safeProxyFactory: SAFE_PROXY_FACTORY,
48
+ safe7579: SAFE7579,
49
+ entryPoint: ENTRYPOINT_V07,
50
+ agether4337Factory: '0x73f4153bf1d46dB203Db27fc8FC942f6279D8d38',
51
+ agether7579Bootstrap: '0xbD0BDFE70fDB88fc03F2Ea22B81A2dfc99298E42',
52
+ erc8004ValidationModule: '0x85C8C97cE5AE540a4408D6A77a6D3aFcA9BCdB71',
53
+ agetherHookMultiplexer: '0x688cab46ce5A7450D706e9E3C8e0F31BaEa6c8BE',
54
+ validationRegistry: ZERO,
55
+ agether8004Scorer: '0x33eB904fe9975e2D8c577aD7e5B14CefBD4A65E1',
56
+ timelockController: '0xB3FD04f0B7c9DeC7f7B52d5c2CdfdCB3Fc9eE111',
57
+ usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
58
+ identityRegistry: ERC8004_IDENTITY_REGISTRY,
59
+ morphoBlue: MORPHO_BLUE,
60
+ },
61
+ [ChainId.BaseSepolia]: {
62
+ safeSingleton: SAFE_SINGLETON,
63
+ safeProxyFactory: SAFE_PROXY_FACTORY,
64
+ safe7579: SAFE7579,
65
+ entryPoint: ENTRYPOINT_V07,
66
+ agether4337Factory: ZERO,
67
+ agether7579Bootstrap: ZERO,
68
+ erc8004ValidationModule: ZERO,
69
+ agetherHookMultiplexer: ZERO,
70
+ validationRegistry: ZERO,
71
+ agether8004Scorer: ZERO,
72
+ timelockController: ZERO,
73
+ usdc: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
74
+ identityRegistry: ERC8004_IDENTITY_REGISTRY_TESTNET,
75
+ morphoBlue: ZERO,
76
+ },
77
+ [ChainId.Sepolia]: {
78
+ safeSingleton: SAFE_SINGLETON,
79
+ safeProxyFactory: SAFE_PROXY_FACTORY,
80
+ safe7579: SAFE7579,
81
+ entryPoint: ENTRYPOINT_V07,
82
+ agether4337Factory: ZERO,
83
+ agether7579Bootstrap: ZERO,
84
+ erc8004ValidationModule: ZERO,
85
+ agetherHookMultiplexer: ZERO,
86
+ validationRegistry: ZERO,
87
+ agether8004Scorer: ZERO,
88
+ timelockController: ZERO,
89
+ usdc: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
90
+ identityRegistry: ERC8004_IDENTITY_REGISTRY_TESTNET,
91
+ morphoBlue: ZERO,
92
+ },
93
+ [ChainId.Hardhat]: {
94
+ safeSingleton: SAFE_SINGLETON,
95
+ safeProxyFactory: SAFE_PROXY_FACTORY,
96
+ safe7579: SAFE7579,
97
+ entryPoint: ENTRYPOINT_V07,
98
+ agether4337Factory: ZERO,
99
+ agether7579Bootstrap: ZERO,
100
+ erc8004ValidationModule: ZERO,
101
+ agetherHookMultiplexer: ZERO,
102
+ validationRegistry: ZERO,
103
+ agether8004Scorer: ZERO,
104
+ timelockController: ZERO,
105
+ usdc: '0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf',
106
+ identityRegistry: ERC8004_IDENTITY_REGISTRY,
107
+ morphoBlue: ZERO,
108
+ },
109
+ };
110
+ // Default RPC URLs
111
+ const RPC_URLS = {
112
+ [ChainId.Ethereum]: 'https://ethereum-rpc.publicnode.com',
113
+ [ChainId.Base]: 'https://base-rpc.publicnode.com',
114
+ [ChainId.BaseSepolia]: 'https://sepolia.base.org',
115
+ [ChainId.Sepolia]: 'https://rpc.sepolia.org',
116
+ [ChainId.Hardhat]: 'http://127.0.0.1:8545',
117
+ };
118
+ // Scoring service endpoints
119
+ const SCORING_ENDPOINTS = {
120
+ [ChainId.Ethereum]: 'https://api.agether.ai',
121
+ [ChainId.Base]: 'https://api.agether.ai',
122
+ [ChainId.BaseSepolia]: 'https://api.agether.ai',
123
+ [ChainId.Sepolia]: 'https://scoring-testnet.agether.ai/v1',
124
+ [ChainId.Hardhat]: 'http://127.0.0.1:3001',
125
+ };
126
+ /**
127
+ * Get default config for a chain — includes all addresses, RPC, and scoring endpoint.
128
+ */
129
+ export function getDefaultConfig(chainId) {
130
+ return {
131
+ chainId,
132
+ rpcUrl: RPC_URLS[chainId],
133
+ contracts: CONTRACT_ADDRESSES[chainId],
134
+ scoringEndpoint: SCORING_ENDPOINTS[chainId],
135
+ };
136
+ }
137
+ /**
138
+ * Create custom config (override any defaults)
139
+ */
140
+ export function createConfig(chainId, options) {
141
+ const defaultConfig = getDefaultConfig(chainId);
142
+ return {
143
+ ...defaultConfig,
144
+ ...options,
145
+ contracts: {
146
+ ...defaultConfig.contracts,
147
+ ...options?.contracts,
148
+ },
149
+ };
150
+ }
151
+ /**
152
+ * Get USDC address for chain
153
+ */
154
+ export function getUSDCAddress(chainId) {
155
+ return CONTRACT_ADDRESSES[chainId].usdc;
156
+ }
157
+ /**
158
+ * Get Morpho Blue address for chain
159
+ */
160
+ export function getMorphoBlueAddress(chainId) {
161
+ return CONTRACT_ADDRESSES[chainId].morphoBlue;
162
+ }
163
+ /**
164
+ * Get all contract addresses for a chain
165
+ */
166
+ export function getContractAddresses(chainId) {
167
+ return CONTRACT_ADDRESSES[chainId];
168
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Formatting utilities
3
+ */
4
+ /**
5
+ * Parse units (e.g., "100" USDC -> 100000000n)
6
+ */
7
+ export declare function parseUnits(value: string, decimals?: number): bigint;
8
+ /**
9
+ * Format units (e.g., 100000000n -> "100.00" USDC)
10
+ */
11
+ export declare function formatUnits(value: bigint, decimals?: number): string;
12
+ /**
13
+ * Format USD value
14
+ */
15
+ export declare function formatUSD(value: bigint, decimals?: number): string;
16
+ /**
17
+ * Format percentage
18
+ */
19
+ export declare function formatPercent(bps: number): string;
20
+ /**
21
+ * Format APR from basis points
22
+ */
23
+ export declare function formatAPR(bps: bigint): string;
24
+ /**
25
+ * Calculate health factor display
26
+ */
27
+ export declare function formatHealthFactor(factor: bigint): string;
28
+ /**
29
+ * Format address (truncate)
30
+ */
31
+ export declare function formatAddress(address: string): string;
32
+ /**
33
+ * Format timestamp to date
34
+ */
35
+ export declare function formatTimestamp(timestamp: bigint): string;
36
+ /**
37
+ * Convert basis points to decimal rate
38
+ */
39
+ export declare function bpsToRate(bps: bigint): number;
40
+ /**
41
+ * Convert decimal rate to basis points
42
+ */
43
+ export declare function rateToBps(rate: number): bigint;
44
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/utils/format.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAItE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAKvE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,MAAM,CAMrE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C"}