@agether/sdk 1.0.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.
Files changed (42) hide show
  1. package/README.md +480 -0
  2. package/dist/cli.d.mts +2 -0
  3. package/dist/cli.d.ts +19 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +2149 -0
  6. package/dist/cli.mjs +0 -0
  7. package/dist/clients/AgentIdentityClient.d.ts +163 -0
  8. package/dist/clients/AgentIdentityClient.d.ts.map +1 -0
  9. package/dist/clients/AgentIdentityClient.js +293 -0
  10. package/dist/clients/AgetherClient.d.ts +101 -0
  11. package/dist/clients/AgetherClient.d.ts.map +1 -0
  12. package/dist/clients/AgetherClient.js +272 -0
  13. package/dist/clients/ScoringClient.d.ts +138 -0
  14. package/dist/clients/ScoringClient.d.ts.map +1 -0
  15. package/dist/clients/ScoringClient.js +135 -0
  16. package/dist/clients/VaultClient.d.ts +62 -0
  17. package/dist/clients/VaultClient.d.ts.map +1 -0
  18. package/dist/clients/VaultClient.js +157 -0
  19. package/dist/clients/WalletClient.d.ts +73 -0
  20. package/dist/clients/WalletClient.d.ts.map +1 -0
  21. package/dist/clients/WalletClient.js +174 -0
  22. package/dist/clients/X402Client.d.ts +61 -0
  23. package/dist/clients/X402Client.d.ts.map +1 -0
  24. package/dist/clients/X402Client.js +303 -0
  25. package/dist/index.d.mts +932 -0
  26. package/dist/index.d.ts +932 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +1680 -0
  29. package/dist/index.mjs +1610 -0
  30. package/dist/types/index.d.ts +220 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/index.js +52 -0
  33. package/dist/utils/abis.d.ts +21 -0
  34. package/dist/utils/abis.d.ts.map +1 -0
  35. package/dist/utils/abis.js +134 -0
  36. package/dist/utils/config.d.ts +31 -0
  37. package/dist/utils/config.d.ts.map +1 -0
  38. package/dist/utils/config.js +117 -0
  39. package/dist/utils/format.d.ts +44 -0
  40. package/dist/utils/format.d.ts.map +1 -0
  41. package/dist/utils/format.js +75 -0
  42. package/package.json +57 -0
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Agether SDK Types v2
3
+ *
4
+ * Account-based credit model:
5
+ * - Agent registers via ERC-8004 → gets agentId
6
+ * - AccountFactory creates AgentAccount (smart wallet) per agent
7
+ * - ReputationCredit: undercollateralized credit (LP-funded, Bayesian scoring)
8
+ * - MorphoCredit: overcollateralized credit (Morpho Blue)
9
+ * - Apply/approve pipeline: agent applies → scoring evaluates → admin approves/rejects on-chain
10
+ */
11
+ export declare enum CreditStatus {
12
+ None = 0,
13
+ Pending = 1,
14
+ Active = 2,
15
+ Frozen = 3,
16
+ Closed = 4,
17
+ Defaulted = 5
18
+ }
19
+ export declare enum ChainId {
20
+ Ethereum = 1,
21
+ Base = 8453,
22
+ BaseSepolia = 84532,
23
+ Sepolia = 11155111,
24
+ Hardhat = 31337
25
+ }
26
+ /** ICreditProvider.CreditInfo view struct */
27
+ export interface CreditInfo {
28
+ limit: bigint;
29
+ used: bigint;
30
+ available: bigint;
31
+ accruedInterest: bigint;
32
+ aprBps: bigint;
33
+ isActive: boolean;
34
+ requiresCollateral: boolean;
35
+ }
36
+ /** ReputationCredit full credit line details */
37
+ export interface CreditLine {
38
+ agentId: bigint;
39
+ limit: bigint;
40
+ used: bigint;
41
+ aprBps: bigint;
42
+ accruedInterest: bigint;
43
+ requestedLimit: bigint;
44
+ createdAt: bigint;
45
+ lastActivityAt: bigint;
46
+ status: CreditStatus;
47
+ }
48
+ /** Credit application request */
49
+ export interface CreditApplication {
50
+ agentId: bigint;
51
+ requestedLimit: bigint;
52
+ }
53
+ /** Scored credit preview */
54
+ export interface ScoredLimitPreview {
55
+ limit: bigint;
56
+ score: bigint;
57
+ eligible: boolean;
58
+ }
59
+ /** AgentReputation data */
60
+ export interface AgentReputation {
61
+ totalBorrowed: bigint;
62
+ totalRepaid: bigint;
63
+ totalInterestPaid: bigint;
64
+ onTimePayments: bigint;
65
+ latePayments: bigint;
66
+ missedPayments: bigint;
67
+ peakUtilization: bigint;
68
+ avgUtilization: bigint;
69
+ utilizationSamples: bigint;
70
+ firstActivityAt: bigint;
71
+ lastActivityAt: bigint;
72
+ lastScoreUpdate: bigint;
73
+ creditScore: bigint;
74
+ creditLinesOpened: bigint;
75
+ lastCreditOpenedAt: bigint;
76
+ currentOutstanding: bigint;
77
+ currentLimit: bigint;
78
+ totalDeposits: bigint;
79
+ totalWithdrawals: bigint;
80
+ }
81
+ /** Loan position tracked by AgentReputation (OCCR model) */
82
+ export interface LoanPosition {
83
+ amount: bigint;
84
+ collateral: bigint;
85
+ ltvBps: bigint;
86
+ timestamp: bigint;
87
+ liquidated: boolean;
88
+ repaid: boolean;
89
+ active: boolean;
90
+ }
91
+ /** OCCR score explanation (5 subscores + raw/decayed) */
92
+ export interface ScoreExplanation {
93
+ historical: bigint;
94
+ currentRisk: bigint;
95
+ utilization: bigint;
96
+ onChainTx: bigint;
97
+ newCredit: bigint;
98
+ rawScore: bigint;
99
+ decayedScore: bigint;
100
+ }
101
+ /** Bayesian score result */
102
+ export interface BayesianScore {
103
+ combinedScore: bigint;
104
+ confidence: bigint;
105
+ }
106
+ export interface ScoringRequest {
107
+ agentId: bigint;
108
+ requestedLimit: bigint;
109
+ codeHash?: string;
110
+ }
111
+ export interface ScoringResult {
112
+ approved: boolean;
113
+ limit: bigint;
114
+ aprBps: number;
115
+ riskScore: number;
116
+ bayesianScore: number;
117
+ confidence: number;
118
+ reason?: string;
119
+ }
120
+ export interface DrawRequest {
121
+ account: string;
122
+ amount: bigint;
123
+ }
124
+ export interface RepayRequest {
125
+ account: string;
126
+ amount: bigint;
127
+ }
128
+ export interface TransactionResult {
129
+ txHash: string;
130
+ blockNumber: number;
131
+ status: 'success' | 'failed';
132
+ gasUsed: bigint;
133
+ }
134
+ export interface X402PaymentRequest {
135
+ service: string;
136
+ amount: bigint;
137
+ asset: string;
138
+ chain: ChainId;
139
+ recipient: string;
140
+ }
141
+ export interface X402PaymentResult {
142
+ paymentId: string;
143
+ txHash: string;
144
+ amount: bigint;
145
+ chain: ChainId;
146
+ status: 'pending' | 'confirmed' | 'failed';
147
+ }
148
+ export interface VaultStats {
149
+ totalAssets: bigint;
150
+ totalBorrowed: bigint;
151
+ availableLiquidity: bigint;
152
+ utilizationRate: number;
153
+ sharePrice: bigint;
154
+ }
155
+ export interface LPPosition {
156
+ shares: bigint;
157
+ assets: bigint;
158
+ pendingYield: bigint;
159
+ }
160
+ export interface AgetherConfig {
161
+ chainId: ChainId;
162
+ rpcUrl: string;
163
+ contracts: ContractAddresses;
164
+ scoringEndpoint?: string;
165
+ kyaEndpoint?: string;
166
+ }
167
+ export interface ContractAddresses {
168
+ accountFactory: string;
169
+ reputationCredit: string;
170
+ lpVault: string;
171
+ validationRegistry: string;
172
+ usdc: string;
173
+ identityRegistry: string;
174
+ morphoCredit?: string;
175
+ agentReputation?: string;
176
+ }
177
+ export interface CreditAppliedEvent {
178
+ agentId: bigint;
179
+ account: string;
180
+ requestedLimit: bigint;
181
+ timestamp: number;
182
+ }
183
+ export interface CreditApprovedEvent {
184
+ account: string;
185
+ limit: bigint;
186
+ aprBps: bigint;
187
+ timestamp: number;
188
+ }
189
+ export interface CreditRejectedEvent {
190
+ account: string;
191
+ reason: string;
192
+ timestamp: number;
193
+ }
194
+ export interface CreditDrawnEvent {
195
+ account: string;
196
+ amount: bigint;
197
+ totalUsed: bigint;
198
+ timestamp: number;
199
+ }
200
+ export interface CreditRepaidEvent {
201
+ account: string;
202
+ amount: bigint;
203
+ totalUsed: bigint;
204
+ timestamp: number;
205
+ }
206
+ export declare class AgetherError extends Error {
207
+ code: string;
208
+ details?: Record<string, unknown> | undefined;
209
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
210
+ }
211
+ export declare class InsufficientCreditError extends AgetherError {
212
+ constructor(available: bigint, requested: bigint);
213
+ }
214
+ export declare class ScoringRejectedError extends AgetherError {
215
+ constructor(riskScore: number, reason?: string);
216
+ }
217
+ export declare class CreditNotActiveError extends AgetherError {
218
+ constructor(account: string, status: CreditStatus);
219
+ }
220
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,oBAAY,YAAY;IACtB,IAAI,IAAI;IACR,OAAO,IAAI;IACX,MAAM,IAAI;IACV,MAAM,IAAI;IACV,MAAM,IAAI;IACV,SAAS,IAAI;CACd;AAED,oBAAY,OAAO;IACjB,QAAQ,IAAI;IACZ,IAAI,OAAO;IACX,WAAW,QAAQ;IACnB,OAAO,WAAW;IAClB,OAAO,QAAQ;CAChB;AAID,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,gDAAgD;AAChD,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;CACtB;AAED,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,4BAA4B;AAC5B,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CA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IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;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,uBAAwB,SAAQ,YAAY;gBAC3C,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAOjD;AAED,qBAAa,oBAAqB,SAAQ,YAAY;gBACxC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAO/C;AAED,qBAAa,oBAAqB,SAAQ,YAAY;gBACxC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY;CAOlD"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Agether SDK Types v2
3
+ *
4
+ * Account-based credit model:
5
+ * - Agent registers via ERC-8004 → gets agentId
6
+ * - AccountFactory creates AgentAccount (smart wallet) per agent
7
+ * - ReputationCredit: undercollateralized credit (LP-funded, Bayesian scoring)
8
+ * - MorphoCredit: overcollateralized credit (Morpho Blue)
9
+ * - Apply/approve pipeline: agent applies → scoring evaluates → admin approves/rejects on-chain
10
+ */
11
+ // ============ Enums ============
12
+ export var CreditStatus;
13
+ (function (CreditStatus) {
14
+ CreditStatus[CreditStatus["None"] = 0] = "None";
15
+ CreditStatus[CreditStatus["Pending"] = 1] = "Pending";
16
+ CreditStatus[CreditStatus["Active"] = 2] = "Active";
17
+ CreditStatus[CreditStatus["Frozen"] = 3] = "Frozen";
18
+ CreditStatus[CreditStatus["Closed"] = 4] = "Closed";
19
+ CreditStatus[CreditStatus["Defaulted"] = 5] = "Defaulted";
20
+ })(CreditStatus || (CreditStatus = {}));
21
+ export var ChainId;
22
+ (function (ChainId) {
23
+ ChainId[ChainId["Ethereum"] = 1] = "Ethereum";
24
+ ChainId[ChainId["Base"] = 8453] = "Base";
25
+ ChainId[ChainId["BaseSepolia"] = 84532] = "BaseSepolia";
26
+ ChainId[ChainId["Sepolia"] = 11155111] = "Sepolia";
27
+ ChainId[ChainId["Hardhat"] = 31337] = "Hardhat";
28
+ })(ChainId || (ChainId = {}));
29
+ // ============ Error Types ============
30
+ export class AgetherError extends Error {
31
+ constructor(message, code, details) {
32
+ super(message);
33
+ this.code = code;
34
+ this.details = details;
35
+ this.name = 'AgetherError';
36
+ }
37
+ }
38
+ export class InsufficientCreditError extends AgetherError {
39
+ constructor(available, requested) {
40
+ super(`Insufficient credit: available ${available}, requested ${requested}`, 'INSUFFICIENT_CREDIT', { available: available.toString(), requested: requested.toString() });
41
+ }
42
+ }
43
+ export class ScoringRejectedError extends AgetherError {
44
+ constructor(riskScore, reason) {
45
+ super(`Scoring rejected: risk score ${riskScore}${reason ? `, ${reason}` : ''}`, 'SCORING_REJECTED', { riskScore, reason });
46
+ }
47
+ }
48
+ export class CreditNotActiveError extends AgetherError {
49
+ constructor(account, status) {
50
+ super(`Credit line for ${account} is not active (status: ${CreditStatus[status]})`, 'CREDIT_NOT_ACTIVE', { account, status: CreditStatus[status] });
51
+ }
52
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Contract ABIs v2 (minimal for SDK)
3
+ *
4
+ * v2 architecture:
5
+ * - AccountFactory + AgentAccount (smart wallets)
6
+ * - ReputationCredit (undercollateralized, ICreditProvider)
7
+ * - MorphoCredit (overcollateralized, ICreditProvider)
8
+ * - LPVault (ERC-4626)
9
+ * - ValidationRegistry (KYA)
10
+ * - AgentReputation (Bayesian scoring)
11
+ */
12
+ export declare const IDENTITY_REGISTRY_ABI: string[];
13
+ export declare const ACCOUNT_FACTORY_ABI: string[];
14
+ export declare const AGENT_ACCOUNT_ABI: string[];
15
+ export declare const CREDIT_PROVIDER_ABI: string[];
16
+ export declare const REPUTATION_CREDIT_ABI: string[];
17
+ export declare const LP_VAULT_ABI: string[];
18
+ export declare const AGENT_REPUTATION_ABI: string[];
19
+ export declare const VALIDATION_REGISTRY_ABI: string[];
20
+ export declare const ERC20_ABI: string[];
21
+ //# sourceMappingURL=abis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../../src/utils/abis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,eAAO,MAAM,qBAAqB,UAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,UAQ/B,CAAC;AAIF,eAAO,MAAM,iBAAiB,UAU7B,CAAC;AAIF,eAAO,MAAM,mBAAmB,UAY/B,CAAC;AAIF,eAAO,MAAM,qBAAqB,UA6BjC,CAAC;AAIF,eAAO,MAAM,YAAY,UAgBxB,CAAC;AAIF,eAAO,MAAM,oBAAoB,UAWhC,CAAC;AAIF,eAAO,MAAM,uBAAuB,UAInC,CAAC;AAIF,eAAO,MAAM,SAAS,UAQrB,CAAC"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Contract ABIs v2 (minimal for SDK)
3
+ *
4
+ * v2 architecture:
5
+ * - AccountFactory + AgentAccount (smart wallets)
6
+ * - ReputationCredit (undercollateralized, ICreditProvider)
7
+ * - MorphoCredit (overcollateralized, ICreditProvider)
8
+ * - LPVault (ERC-4626)
9
+ * - ValidationRegistry (KYA)
10
+ * - AgentReputation (Bayesian scoring)
11
+ */
12
+ // ── ERC-8004 Identity Registry ──
13
+ export const IDENTITY_REGISTRY_ABI = [
14
+ 'function ownerOf(uint256 agentId) view returns (address)',
15
+ 'function balanceOf(address owner) view returns (uint256)',
16
+ 'function totalSupply() view returns (uint256)',
17
+ 'function exists(uint256 agentId) view returns (bool)',
18
+ 'function register() returns (uint256 agentId)',
19
+ 'event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)',
20
+ ];
21
+ // ── Account Factory ──
22
+ export const ACCOUNT_FACTORY_ABI = [
23
+ 'function getAccount(uint256 agentId) view returns (address)',
24
+ 'function accountExists(uint256 agentId) view returns (bool)',
25
+ 'function predictAddress(uint256 agentId) view returns (address)',
26
+ 'function totalAccounts() view returns (uint256)',
27
+ 'function getAgentId(address account) view returns (uint256)',
28
+ 'function createAccount(uint256 agentId) returns (address account)',
29
+ 'event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)',
30
+ ];
31
+ // ── Agent Account (smart wallet) ──
32
+ export const AGENT_ACCOUNT_ABI = [
33
+ 'function agentId() view returns (uint256)',
34
+ 'function owner() view returns (address)',
35
+ 'function balanceOf(address token) view returns (uint256)',
36
+ 'function ethBalance() view returns (uint256)',
37
+ 'function execute(address target, uint256 value, bytes data) payable returns (bytes)',
38
+ 'function drawCredit(address creditProvider, uint256 amount)',
39
+ 'function repayCredit(address creditProvider, uint256 amount)',
40
+ 'function fund(address token, uint256 amount)',
41
+ 'function withdraw(address token, uint256 amount, address to)',
42
+ ];
43
+ // ── ICreditProvider (shared interface for ReputationCredit & MorphoCredit) ──
44
+ export const CREDIT_PROVIDER_ABI = [
45
+ 'function asset() view returns (address)',
46
+ 'function isEligible(address account) view returns (bool)',
47
+ 'function getCreditInfo(address account) view returns (tuple(uint256 limit, uint256 used, uint256 available, uint256 accruedInterest, uint256 aprBps, bool isActive, bool requiresCollateral))',
48
+ 'function getTotalDebt(address account) view returns (uint256)',
49
+ 'function maxDrawable(address account) view returns (uint256)',
50
+ 'function draw(address account, uint256 amount)',
51
+ 'function repay(address account, uint256 amount)',
52
+ 'event CreditDrawn(address indexed account, uint256 amount, uint256 totalUsed)',
53
+ 'event CreditRepaid(address indexed account, uint256 amount, uint256 totalUsed)',
54
+ 'event CreditLineOpened(address indexed account, uint256 limit, uint256 aprBps)',
55
+ 'event CreditLineClosed(address indexed account)',
56
+ ];
57
+ // ── ReputationCredit (undercollateralized) ──
58
+ export const REPUTATION_CREDIT_ABI = [
59
+ ...CREDIT_PROVIDER_ABI,
60
+ // Application / Approval flow
61
+ 'function applyForCredit(address account, uint256 requestedLimit)',
62
+ 'function approveCreditLine(address account, uint256 limit, uint256 aprBps)',
63
+ 'function rejectCreditLine(address account, string reason)',
64
+ 'function requestLimitIncrease(address account, uint256 newRequestedLimit)',
65
+ 'function approveLimitIncrease(address account, uint256 newLimit)',
66
+ 'function freezeCreditLine(address account)',
67
+ 'function unfreezeCreditLine(address account)',
68
+ // Admin
69
+ 'function setCreditLine(address account, uint256 limit, uint256 aprBps)',
70
+ 'function openScoredCreditLine(address account)',
71
+ 'function closeCreditLine(address account)',
72
+ 'function declareDefault(address account)',
73
+ // View
74
+ 'function getCreditLineStatus(address account) view returns (uint8)',
75
+ 'function getCreditLineDetails(address account) view returns (uint256 agentId, uint256 limit, uint256 used, uint256 aprBps, uint256 accruedInterest, uint256 requestedLimit, uint256 createdAt, uint256 lastActivityAt, uint8 status)',
76
+ 'function getAgentAccount(uint256 agentId) view returns (address)',
77
+ 'function previewScoredLimit(uint256 agentId) view returns (uint256 limit, uint256 score, bool eligible)',
78
+ 'function dailyDrawLimit() view returns (uint256)',
79
+ 'function totalBorrowed() view returns (uint256)',
80
+ // Events
81
+ 'event CreditApplied(uint256 indexed creditLineId, uint256 indexed agentId, uint256 requestedLimit)',
82
+ 'event CreditApproved(uint256 indexed creditLineId, uint256 limit, uint256 aprBps)',
83
+ 'event CreditRejected(uint256 indexed creditLineId, string reason)',
84
+ 'event CreditFrozen(uint256 indexed creditLineId)',
85
+ 'event CreditUnfrozen(uint256 indexed creditLineId)',
86
+ 'event DefaultDeclared(address indexed account, uint256 amount)',
87
+ ];
88
+ // ── LP Vault (ERC-4626) ──
89
+ export const LP_VAULT_ABI = [
90
+ 'function asset() view returns (address)',
91
+ 'function totalAssets() view returns (uint256)',
92
+ 'function totalSupply() view returns (uint256)',
93
+ 'function balanceOf(address account) view returns (uint256)',
94
+ 'function convertToShares(uint256 assets) view returns (uint256)',
95
+ 'function convertToAssets(uint256 shares) view returns (uint256)',
96
+ 'function previewDeposit(uint256 assets) view returns (uint256)',
97
+ 'function previewRedeem(uint256 shares) view returns (uint256)',
98
+ 'function deposit(uint256 assets, address receiver) returns (uint256)',
99
+ 'function withdraw(uint256 assets, address receiver, address owner) returns (uint256)',
100
+ 'function redeem(uint256 shares, address receiver, address owner) returns (uint256)',
101
+ 'function totalBorrowed() view returns (uint256)',
102
+ 'function availableLiquidity() view returns (uint256)',
103
+ 'event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares)',
104
+ 'event Withdraw(address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares)',
105
+ ];
106
+ // ── Agent Reputation ──
107
+ export const AGENT_REPUTATION_ABI = [
108
+ 'function getReputation(uint256 agentId) view returns (tuple(uint256 totalBorrowed, uint256 totalRepaid, uint256 totalInterestPaid, uint256 onTimePayments, uint256 latePayments, uint256 missedPayments, uint256 peakUtilization, uint256 avgUtilization, uint256 utilizationSamples, uint256 firstActivityAt, uint256 lastActivityAt, uint256 lastScoreUpdate, uint256 creditScore, uint256 creditLinesOpened, uint256 lastCreditOpenedAt, uint256 currentOutstanding, uint256 currentLimit, uint256 totalDeposits, uint256 totalWithdrawals))',
109
+ 'function getCreditScore(uint256 agentId) view returns (uint256)',
110
+ 'function getBayesianScore(uint256 agentId) view returns (uint256 combinedScore, uint256 confidence)',
111
+ 'function getRecommendedLimit(uint256 agentId, uint256 baseLimit) view returns (uint256)',
112
+ 'function isEligible(uint256 agentId, uint256 minScore) view returns (bool eligible, uint256 currentScore)',
113
+ 'function getDecayedScore(uint256 agentId) view returns (uint256)',
114
+ 'function getScoreExplanation(uint256 agentId) view returns (uint256 historical, uint256 currentRisk, uint256 utilization, uint256 onChainTx, uint256 newCredit, uint256 rawScore, uint256 decayedScore)',
115
+ 'function getLoanPositions(uint256 agentId) view returns (tuple(uint256 amount, uint256 collateral, uint256 ltvBps, uint256 timestamp, bool liquidated, bool repaid, bool active)[])',
116
+ 'function stressMultiplier() view returns (uint256)',
117
+ 'function decayPeriod() view returns (uint256)',
118
+ ];
119
+ // ── Validation Registry (KYA) ──
120
+ export const VALIDATION_REGISTRY_ABI = [
121
+ 'function isAgentCodeApproved(uint256 agentId) view returns (bool)',
122
+ 'function isAgentCodeApprovedForTag(uint256 agentId, string tag) view returns (bool)',
123
+ 'function getAgentValidations(uint256 agentId) view returns (bytes32[])',
124
+ ];
125
+ // ── ERC-20 ──
126
+ export const ERC20_ABI = [
127
+ 'function balanceOf(address account) view returns (uint256)',
128
+ 'function allowance(address owner, address spender) view returns (uint256)',
129
+ 'function approve(address spender, uint256 amount) returns (bool)',
130
+ 'function transfer(address to, uint256 amount) returns (bool)',
131
+ 'function transferFrom(address from, address to, uint256 amount) returns (bool)',
132
+ 'function decimals() view returns (uint8)',
133
+ 'function symbol() view returns (string)',
134
+ ];
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Network configurations (v2)
3
+ *
4
+ * v2 contract architecture:
5
+ * - AccountFactory + AgentAccount (smart wallets)
6
+ * - ReputationCredit (ICreditProvider, undercollateralized)
7
+ * - LPVault (ERC-4626)
8
+ * - ValidationRegistry (KYA)
9
+ * - AgentReputation (Bayesian scoring)
10
+ * - ERC-8004 IdentityRegistry
11
+ *
12
+ * All contract addresses are baked in — agents only need to specify chainId.
13
+ */
14
+ import { AgetherConfig, ChainId, ContractAddresses } from '../types';
15
+ /**
16
+ * Get default config for a chain — includes all addresses, RPC, and scoring endpoint.
17
+ */
18
+ export declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
19
+ /**
20
+ * Create custom config (override any defaults)
21
+ */
22
+ export declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
23
+ /**
24
+ * Get USDC address for chain
25
+ */
26
+ export declare function getUSDCAddress(chainId: ChainId): string;
27
+ /**
28
+ * Get all contract addresses for a chain
29
+ */
30
+ export declare function getContractAddresses(chainId: ChainId): ContractAddresses;
31
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAuErE;;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,iBAAiB,CAExE"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Network configurations (v2)
3
+ *
4
+ * v2 contract architecture:
5
+ * - AccountFactory + AgentAccount (smart wallets)
6
+ * - ReputationCredit (ICreditProvider, undercollateralized)
7
+ * - LPVault (ERC-4626)
8
+ * - ValidationRegistry (KYA)
9
+ * - AgentReputation (Bayesian scoring)
10
+ * - ERC-8004 IdentityRegistry
11
+ *
12
+ * All contract addresses are baked in — agents only need to specify chainId.
13
+ */
14
+ import { ChainId } from '../types';
15
+ // Contract addresses per network
16
+ const CONTRACT_ADDRESSES = {
17
+ [ChainId.Ethereum]: {
18
+ accountFactory: '0x0000000000000000000000000000000000000000',
19
+ reputationCredit: '0x0000000000000000000000000000000000000000',
20
+ lpVault: '0x0000000000000000000000000000000000000000',
21
+ validationRegistry: '0x0000000000000000000000000000000000000000',
22
+ usdc: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
23
+ identityRegistry: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
24
+ agentReputation: '0x0000000000000000000000000000000000000000',
25
+ },
26
+ [ChainId.Base]: {
27
+ accountFactory: '0xeB72f248Ad9F4bf4024e8D9da75cf7AAD37B58f5',
28
+ reputationCredit: '0x57B2B4ef3e7B8BE5FC86c6369602125d240F552A',
29
+ lpVault: '0x612A80D6c3175F8283e9C7EE71d5177fE9acc338',
30
+ validationRegistry: '0x8842f2383A86134Dd80c3Ecf6Bbae2e38396A5ec',
31
+ usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
32
+ identityRegistry: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
33
+ agentReputation: '0xF1bed094D4E33E47CC8C72E086FFFde09e2211b4',
34
+ morphoCredit: '0x7dFfa40E17471F7f26F5662D0F07a31977F47BeB',
35
+ },
36
+ [ChainId.BaseSepolia]: {
37
+ accountFactory: '0x0000000000000000000000000000000000000000',
38
+ reputationCredit: '0x0000000000000000000000000000000000000000',
39
+ lpVault: '0x0000000000000000000000000000000000000000',
40
+ validationRegistry: '0x0000000000000000000000000000000000000000',
41
+ usdc: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
42
+ identityRegistry: '0x8004A818BFB912233c491871b3d84c89A494BD9e',
43
+ agentReputation: '0x0000000000000000000000000000000000000000',
44
+ },
45
+ [ChainId.Sepolia]: {
46
+ accountFactory: '0x0000000000000000000000000000000000000000',
47
+ reputationCredit: '0x0000000000000000000000000000000000000000',
48
+ lpVault: '0x0000000000000000000000000000000000000000',
49
+ validationRegistry: '0x0000000000000000000000000000000000000000',
50
+ usdc: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
51
+ identityRegistry: '0x8004A818BFB912233c491871b3d84c89A494BD9e',
52
+ agentReputation: '0x0000000000000000000000000000000000000000',
53
+ },
54
+ [ChainId.Hardhat]: {
55
+ accountFactory: '0x0000000000000000000000000000000000000000',
56
+ reputationCredit: '0x0000000000000000000000000000000000000000',
57
+ lpVault: '0x0000000000000000000000000000000000000000',
58
+ validationRegistry: '0x0000000000000000000000000000000000000000',
59
+ usdc: '0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf',
60
+ identityRegistry: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
61
+ agentReputation: '0x0000000000000000000000000000000000000000',
62
+ morphoCredit: '0x0000000000000000000000000000000000000000',
63
+ },
64
+ };
65
+ // Default RPC URLs
66
+ const RPC_URLS = {
67
+ [ChainId.Ethereum]: 'https://ethereum-rpc.publicnode.com',
68
+ [ChainId.Base]: 'https://base-rpc.publicnode.com',
69
+ [ChainId.BaseSepolia]: 'https://sepolia.base.org',
70
+ [ChainId.Sepolia]: 'https://rpc.sepolia.org',
71
+ [ChainId.Hardhat]: 'http://127.0.0.1:8545',
72
+ };
73
+ // Scoring service endpoints
74
+ const SCORING_ENDPOINTS = {
75
+ [ChainId.Ethereum]: 'https://scoring.agether.ai/v1',
76
+ [ChainId.Base]: 'http://95.179.189.214:3001',
77
+ [ChainId.BaseSepolia]: 'http://95.179.189.214:3001',
78
+ [ChainId.Sepolia]: 'https://scoring-testnet.agether.ai/v1',
79
+ [ChainId.Hardhat]: 'http://127.0.0.1:3001',
80
+ };
81
+ /**
82
+ * Get default config for a chain — includes all addresses, RPC, and scoring endpoint.
83
+ */
84
+ export function getDefaultConfig(chainId) {
85
+ return {
86
+ chainId,
87
+ rpcUrl: RPC_URLS[chainId],
88
+ contracts: CONTRACT_ADDRESSES[chainId],
89
+ scoringEndpoint: SCORING_ENDPOINTS[chainId],
90
+ };
91
+ }
92
+ /**
93
+ * Create custom config (override any defaults)
94
+ */
95
+ export function createConfig(chainId, options) {
96
+ const defaultConfig = getDefaultConfig(chainId);
97
+ return {
98
+ ...defaultConfig,
99
+ ...options,
100
+ contracts: {
101
+ ...defaultConfig.contracts,
102
+ ...options?.contracts,
103
+ },
104
+ };
105
+ }
106
+ /**
107
+ * Get USDC address for chain
108
+ */
109
+ export function getUSDCAddress(chainId) {
110
+ return CONTRACT_ADDRESSES[chainId].usdc;
111
+ }
112
+ /**
113
+ * Get all contract addresses for a chain
114
+ */
115
+ export function getContractAddresses(chainId) {
116
+ return CONTRACT_ADDRESSES[chainId];
117
+ }
@@ -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"}