@agether/sdk 1.6.2 → 1.6.4
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 +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli.d.ts +0 -25
- package/dist/cli.d.ts.map +0 -1
- package/dist/clients/AgentIdentityClient.d.ts +0 -188
- package/dist/clients/AgentIdentityClient.d.ts.map +0 -1
- package/dist/clients/AgentIdentityClient.js +0 -333
- package/dist/clients/AgetherClient.d.ts +0 -63
- package/dist/clients/AgetherClient.d.ts.map +0 -1
- package/dist/clients/AgetherClient.js +0 -171
- package/dist/clients/MorphoClient.d.ts +0 -287
- package/dist/clients/MorphoClient.d.ts.map +0 -1
- package/dist/clients/MorphoClient.js +0 -951
- package/dist/clients/ScoringClient.d.ts +0 -89
- package/dist/clients/ScoringClient.d.ts.map +0 -1
- package/dist/clients/ScoringClient.js +0 -93
- package/dist/clients/X402Client.d.ts +0 -130
- package/dist/clients/X402Client.d.ts.map +0 -1
- package/dist/clients/X402Client.js +0 -301
- package/dist/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -121
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -43
- package/dist/utils/abis.d.ts +0 -18
- package/dist/utils/abis.d.ts.map +0 -1
- package/dist/utils/abis.js +0 -93
- package/dist/utils/config.d.ts +0 -34
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -115
- package/dist/utils/format.d.ts +0 -44
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js +0 -75
package/dist/types/index.d.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agether SDK Types
|
|
3
|
-
*
|
|
4
|
-
* Architecture:
|
|
5
|
-
* - Agent registers via ERC-8004 → gets agentId
|
|
6
|
-
* - AccountFactory creates AgentAccount (KYA-gated smart wallet) per agent
|
|
7
|
-
* - AgentReputation: oracle-based credit scoring
|
|
8
|
-
* - Morpho Blue: direct overcollateralized lending (agents interact directly)
|
|
9
|
-
* - x402: HTTP payment protocol for scoring API
|
|
10
|
-
*/
|
|
11
|
-
export declare enum ChainId {
|
|
12
|
-
Ethereum = 1,
|
|
13
|
-
Base = 8453,
|
|
14
|
-
BaseSepolia = 84532,
|
|
15
|
-
Sepolia = 11155111,
|
|
16
|
-
Hardhat = 31337
|
|
17
|
-
}
|
|
18
|
-
/** Morpho Blue MarketParams struct */
|
|
19
|
-
export interface MorphoMarketParams {
|
|
20
|
-
loanToken: string;
|
|
21
|
-
collateralToken: string;
|
|
22
|
-
oracle: string;
|
|
23
|
-
irm: string;
|
|
24
|
-
lltv: bigint;
|
|
25
|
-
}
|
|
26
|
-
/** Morpho Blue on-chain position for an account */
|
|
27
|
-
export interface MorphoPosition {
|
|
28
|
-
supplyShares: bigint;
|
|
29
|
-
borrowShares: bigint;
|
|
30
|
-
collateral: bigint;
|
|
31
|
-
}
|
|
32
|
-
/** Morpho market info (from GraphQL API or on-chain) */
|
|
33
|
-
export interface MorphoMarketInfo {
|
|
34
|
-
uniqueKey: string;
|
|
35
|
-
loanAsset: {
|
|
36
|
-
address: string;
|
|
37
|
-
symbol: string;
|
|
38
|
-
decimals: number;
|
|
39
|
-
};
|
|
40
|
-
collateralAsset: {
|
|
41
|
-
address: string;
|
|
42
|
-
symbol: string;
|
|
43
|
-
decimals: number;
|
|
44
|
-
};
|
|
45
|
-
oracle: string;
|
|
46
|
-
irm: string;
|
|
47
|
-
lltv: bigint;
|
|
48
|
-
totalSupplyAssets: bigint;
|
|
49
|
-
totalBorrowAssets: bigint;
|
|
50
|
-
utilization: number;
|
|
51
|
-
}
|
|
52
|
-
/** On-chain score attestation from AgentReputation contract */
|
|
53
|
-
export interface ScoreAttestation {
|
|
54
|
-
score: bigint;
|
|
55
|
-
timestamp: bigint;
|
|
56
|
-
signer: string;
|
|
57
|
-
}
|
|
58
|
-
/** Score result from backend scoring API */
|
|
59
|
-
export interface ScoreResult {
|
|
60
|
-
agentId: string;
|
|
61
|
-
score: number;
|
|
62
|
-
timestamp: number;
|
|
63
|
-
breakdown: {
|
|
64
|
-
kyaBonus: number;
|
|
65
|
-
accountBonus: number;
|
|
66
|
-
balanceBonus: number;
|
|
67
|
-
historyBonus: number;
|
|
68
|
-
baseScore: number;
|
|
69
|
-
};
|
|
70
|
-
txHash?: string;
|
|
71
|
-
}
|
|
72
|
-
export interface TransactionResult {
|
|
73
|
-
txHash: string;
|
|
74
|
-
blockNumber: number;
|
|
75
|
-
status: 'success' | 'failed';
|
|
76
|
-
gasUsed: bigint;
|
|
77
|
-
}
|
|
78
|
-
export interface X402PaymentRequest {
|
|
79
|
-
service: string;
|
|
80
|
-
amount: bigint;
|
|
81
|
-
asset: string;
|
|
82
|
-
chain: ChainId;
|
|
83
|
-
recipient: string;
|
|
84
|
-
}
|
|
85
|
-
export interface X402PaymentResult {
|
|
86
|
-
paymentId: string;
|
|
87
|
-
txHash: string;
|
|
88
|
-
amount: bigint;
|
|
89
|
-
chain: ChainId;
|
|
90
|
-
status: 'pending' | 'confirmed' | 'failed';
|
|
91
|
-
}
|
|
92
|
-
export interface AgetherConfig {
|
|
93
|
-
chainId: ChainId;
|
|
94
|
-
rpcUrl: string;
|
|
95
|
-
contracts: ContractAddresses;
|
|
96
|
-
scoringEndpoint?: string;
|
|
97
|
-
kyaEndpoint?: string;
|
|
98
|
-
}
|
|
99
|
-
export interface ContractAddresses {
|
|
100
|
-
accountFactory: string;
|
|
101
|
-
validationRegistry: string;
|
|
102
|
-
agentReputation: string;
|
|
103
|
-
usdc: string;
|
|
104
|
-
identityRegistry: string;
|
|
105
|
-
morphoBlue: string;
|
|
106
|
-
}
|
|
107
|
-
export declare class AgetherError extends Error {
|
|
108
|
-
code: string;
|
|
109
|
-
details?: Record<string, unknown> | undefined;
|
|
110
|
-
constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
|
|
111
|
-
}
|
|
112
|
-
export declare class InsufficientBalanceError extends AgetherError {
|
|
113
|
-
constructor(available: bigint, required: bigint);
|
|
114
|
-
}
|
|
115
|
-
export declare class ScoringRejectedError extends AgetherError {
|
|
116
|
-
constructor(riskScore: number, reason?: string);
|
|
117
|
-
}
|
|
118
|
-
export declare class AgentNotApprovedError extends AgetherError {
|
|
119
|
-
constructor(agentId: bigint);
|
|
120
|
-
}
|
|
121
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"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"}
|
package/dist/types/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agether SDK Types
|
|
3
|
-
*
|
|
4
|
-
* Architecture:
|
|
5
|
-
* - Agent registers via ERC-8004 → gets agentId
|
|
6
|
-
* - AccountFactory creates AgentAccount (KYA-gated smart wallet) per agent
|
|
7
|
-
* - AgentReputation: oracle-based credit scoring
|
|
8
|
-
* - Morpho Blue: direct overcollateralized lending (agents interact directly)
|
|
9
|
-
* - x402: HTTP payment protocol for scoring API
|
|
10
|
-
*/
|
|
11
|
-
// ============ Enums ============
|
|
12
|
-
export var ChainId;
|
|
13
|
-
(function (ChainId) {
|
|
14
|
-
ChainId[ChainId["Ethereum"] = 1] = "Ethereum";
|
|
15
|
-
ChainId[ChainId["Base"] = 8453] = "Base";
|
|
16
|
-
ChainId[ChainId["BaseSepolia"] = 84532] = "BaseSepolia";
|
|
17
|
-
ChainId[ChainId["Sepolia"] = 11155111] = "Sepolia";
|
|
18
|
-
ChainId[ChainId["Hardhat"] = 31337] = "Hardhat";
|
|
19
|
-
})(ChainId || (ChainId = {}));
|
|
20
|
-
// ============ Error Types ============
|
|
21
|
-
export class AgetherError extends Error {
|
|
22
|
-
constructor(message, code, details) {
|
|
23
|
-
super(message);
|
|
24
|
-
this.code = code;
|
|
25
|
-
this.details = details;
|
|
26
|
-
this.name = 'AgetherError';
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export class InsufficientBalanceError extends AgetherError {
|
|
30
|
-
constructor(available, required) {
|
|
31
|
-
super(`Insufficient balance: available ${available}, required ${required}`, 'INSUFFICIENT_BALANCE', { available: available.toString(), required: required.toString() });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
export class ScoringRejectedError extends AgetherError {
|
|
35
|
-
constructor(riskScore, reason) {
|
|
36
|
-
super(`Scoring rejected: risk score ${riskScore}${reason ? `, ${reason}` : ''}`, 'SCORING_REJECTED', { riskScore, reason });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export class AgentNotApprovedError extends AgetherError {
|
|
40
|
-
constructor(agentId) {
|
|
41
|
-
super(`Agent ${agentId} is not KYA-approved. Submit code for validation first.`, 'AGENT_NOT_APPROVED', { agentId: agentId.toString() });
|
|
42
|
-
}
|
|
43
|
-
}
|
package/dist/utils/abis.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contract ABIs (minimal for SDK)
|
|
3
|
-
*
|
|
4
|
-
* Architecture:
|
|
5
|
-
* - AccountFactory + AgentAccount (KYA-gated smart wallets)
|
|
6
|
-
* - AgentReputation (oracle-based credit scores)
|
|
7
|
-
* - ValidationRegistry (KYA code validation)
|
|
8
|
-
* - ERC-8004 IdentityRegistry
|
|
9
|
-
* - Morpho Blue (direct overcollateralized lending)
|
|
10
|
-
*/
|
|
11
|
-
export declare const IDENTITY_REGISTRY_ABI: string[];
|
|
12
|
-
export declare const ACCOUNT_FACTORY_ABI: string[];
|
|
13
|
-
export declare const AGENT_ACCOUNT_ABI: string[];
|
|
14
|
-
export declare const AGENT_REPUTATION_ABI: string[];
|
|
15
|
-
export declare const VALIDATION_REGISTRY_ABI: string[];
|
|
16
|
-
export declare const MORPHO_BLUE_ABI: string[];
|
|
17
|
-
export declare const ERC20_ABI: string[];
|
|
18
|
-
//# sourceMappingURL=abis.d.ts.map
|
package/dist/utils/abis.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../../src/utils/abis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,eAAO,MAAM,qBAAqB,UAOjC,CAAC;AAIF,eAAO,MAAM,mBAAmB,UAQ/B,CAAC;AAIF,eAAO,MAAM,iBAAiB,UAc7B,CAAC;AAIF,eAAO,MAAM,oBAAoB,UAShC,CAAC;AAIF,eAAO,MAAM,uBAAuB,UAKnC,CAAC;AAIF,eAAO,MAAM,eAAe,UAiB3B,CAAC;AAIF,eAAO,MAAM,SAAS,UASrB,CAAC"}
|
package/dist/utils/abis.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contract ABIs (minimal for SDK)
|
|
3
|
-
*
|
|
4
|
-
* Architecture:
|
|
5
|
-
* - AccountFactory + AgentAccount (KYA-gated smart wallets)
|
|
6
|
-
* - AgentReputation (oracle-based credit scores)
|
|
7
|
-
* - ValidationRegistry (KYA code validation)
|
|
8
|
-
* - ERC-8004 IdentityRegistry
|
|
9
|
-
* - Morpho Blue (direct overcollateralized lending)
|
|
10
|
-
*/
|
|
11
|
-
// ── ERC-8004 Identity Registry ──
|
|
12
|
-
export const IDENTITY_REGISTRY_ABI = [
|
|
13
|
-
'function ownerOf(uint256 agentId) view returns (address)',
|
|
14
|
-
'function balanceOf(address owner) view returns (uint256)',
|
|
15
|
-
'function totalSupply() view returns (uint256)',
|
|
16
|
-
'function exists(uint256 agentId) view returns (bool)',
|
|
17
|
-
'function register() returns (uint256 agentId)',
|
|
18
|
-
'event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)',
|
|
19
|
-
];
|
|
20
|
-
// ── Account Factory ──
|
|
21
|
-
export const ACCOUNT_FACTORY_ABI = [
|
|
22
|
-
'function getAccount(uint256 agentId) view returns (address)',
|
|
23
|
-
'function accountExists(uint256 agentId) view returns (bool)',
|
|
24
|
-
'function predictAddress(uint256 agentId) view returns (address)',
|
|
25
|
-
'function totalAccounts() view returns (uint256)',
|
|
26
|
-
'function getAgentId(address account) view returns (uint256)',
|
|
27
|
-
'function createAccount(uint256 agentId) returns (address account)',
|
|
28
|
-
'event AccountCreated(uint256 indexed agentId, address indexed account, address indexed owner)',
|
|
29
|
-
];
|
|
30
|
-
// ── Agent Account (KYA-gated smart wallet) ──
|
|
31
|
-
export const AGENT_ACCOUNT_ABI = [
|
|
32
|
-
'function agentId() view returns (uint256)',
|
|
33
|
-
'function owner() view returns (address)',
|
|
34
|
-
'function factory() view returns (address)',
|
|
35
|
-
'function validationRegistry() view returns (address)',
|
|
36
|
-
'function identityRegistry() view returns (address)',
|
|
37
|
-
'function balanceOf(address token) view returns (uint256)',
|
|
38
|
-
'function ethBalance() view returns (uint256)',
|
|
39
|
-
'function execute(address target, uint256 value, bytes data) payable returns (bytes)',
|
|
40
|
-
'function executeBatch(address[] targets, uint256[] values, bytes[] datas) payable returns (bytes[])',
|
|
41
|
-
'function fund(address token, uint256 amount)',
|
|
42
|
-
'function withdraw(address token, uint256 amount, address to)',
|
|
43
|
-
'function withdrawETH(uint256 amount, address to)',
|
|
44
|
-
'function isValidSignature(bytes32 hash, bytes signature) view returns (bytes4)',
|
|
45
|
-
];
|
|
46
|
-
// ── Agent Reputation (oracle-based scoring) ──
|
|
47
|
-
export const AGENT_REPUTATION_ABI = [
|
|
48
|
-
'function getCreditScore(uint256 agentId) view returns (uint256)',
|
|
49
|
-
'function getAttestation(uint256 agentId) view returns (tuple(uint256 score, uint256 timestamp, address signer))',
|
|
50
|
-
'function isScoreFresh(uint256 agentId) view returns (bool fresh, uint256 age)',
|
|
51
|
-
'function isEligible(uint256 agentId, uint256 minScore) view returns (bool eligible, uint256 currentScore)',
|
|
52
|
-
'function oracleSigner() view returns (address)',
|
|
53
|
-
'function submitScore(uint256 agentId, uint256 score_, uint256 timestamp_, bytes signature)',
|
|
54
|
-
'function setOracleSigner(address signer_)',
|
|
55
|
-
'event ScoreUpdated(uint256 indexed agentId, uint256 score, uint256 timestamp, address signer)',
|
|
56
|
-
];
|
|
57
|
-
// ── Validation Registry (KYA) ──
|
|
58
|
-
export const VALIDATION_REGISTRY_ABI = [
|
|
59
|
-
'function isAgentCodeApproved(uint256 agentId) view returns (bool)',
|
|
60
|
-
'function isAgentCodeApprovedForTag(uint256 agentId, string tag) view returns (bool)',
|
|
61
|
-
'function getAgentValidations(uint256 agentId) view returns (bytes32[])',
|
|
62
|
-
'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))',
|
|
63
|
-
];
|
|
64
|
-
// ── Morpho Blue (direct lending protocol) ──
|
|
65
|
-
export const MORPHO_BLUE_ABI = [
|
|
66
|
-
// Supply & Withdraw (lending side)
|
|
67
|
-
'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)',
|
|
68
|
-
'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)',
|
|
69
|
-
// Collateral
|
|
70
|
-
'function supplyCollateral(tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, bytes data)',
|
|
71
|
-
'function withdrawCollateral(tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, address receiver)',
|
|
72
|
-
// Borrow & Repay
|
|
73
|
-
'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)',
|
|
74
|
-
'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)',
|
|
75
|
-
// Authorization
|
|
76
|
-
'function setAuthorization(address authorized, bool newIsAuthorized)',
|
|
77
|
-
'function isAuthorized(address authorizer, address authorized) view returns (bool)',
|
|
78
|
-
// Views
|
|
79
|
-
'function position(bytes32 id, address user) view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral)',
|
|
80
|
-
'function market(bytes32 id) view returns (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee)',
|
|
81
|
-
'function idToMarketParams(bytes32 id) view returns (tuple(address loanToken, address collateralToken, address oracle, address irm, uint256 lltv))',
|
|
82
|
-
];
|
|
83
|
-
// ── ERC-20 ──
|
|
84
|
-
export const ERC20_ABI = [
|
|
85
|
-
'function balanceOf(address account) view returns (uint256)',
|
|
86
|
-
'function allowance(address owner, address spender) view returns (uint256)',
|
|
87
|
-
'function approve(address spender, uint256 amount) returns (bool)',
|
|
88
|
-
'function transfer(address to, uint256 amount) returns (bool)',
|
|
89
|
-
'function transferFrom(address from, address to, uint256 amount) returns (bool)',
|
|
90
|
-
'function decimals() view returns (uint8)',
|
|
91
|
-
'function symbol() view returns (string)',
|
|
92
|
-
'function name() view returns (string)',
|
|
93
|
-
];
|
package/dist/utils/config.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Network configurations
|
|
3
|
-
*
|
|
4
|
-
* Contract architecture:
|
|
5
|
-
* - AccountFactory + AgentAccount (KYA-gated smart wallets)
|
|
6
|
-
* - AgentReputation (oracle-based scoring)
|
|
7
|
-
* - ValidationRegistry (KYA code validation)
|
|
8
|
-
* - ERC-8004 IdentityRegistry
|
|
9
|
-
* - Morpho Blue (direct overcollateralized lending)
|
|
10
|
-
*
|
|
11
|
-
* All contract addresses are baked in — agents only need to specify chainId.
|
|
12
|
-
*/
|
|
13
|
-
import { AgetherConfig, ChainId, ContractAddresses } from '../types';
|
|
14
|
-
/**
|
|
15
|
-
* Get default config for a chain — includes all addresses, RPC, and scoring endpoint.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getDefaultConfig(chainId: ChainId): AgetherConfig;
|
|
18
|
-
/**
|
|
19
|
-
* Create custom config (override any defaults)
|
|
20
|
-
*/
|
|
21
|
-
export declare function createConfig(chainId: ChainId, options?: Partial<AgetherConfig>): AgetherConfig;
|
|
22
|
-
/**
|
|
23
|
-
* Get USDC address for chain
|
|
24
|
-
*/
|
|
25
|
-
export declare function getUSDCAddress(chainId: ChainId): string;
|
|
26
|
-
/**
|
|
27
|
-
* Get Morpho Blue address for chain
|
|
28
|
-
*/
|
|
29
|
-
export declare function getMorphoBlueAddress(chainId: ChainId): string;
|
|
30
|
-
/**
|
|
31
|
-
* Get all contract addresses for a chain
|
|
32
|
-
*/
|
|
33
|
-
export declare function getContractAddresses(chainId: ChainId): ContractAddresses;
|
|
34
|
-
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAgErE;;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"}
|
package/dist/utils/config.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Network configurations
|
|
3
|
-
*
|
|
4
|
-
* Contract architecture:
|
|
5
|
-
* - AccountFactory + AgentAccount (KYA-gated smart wallets)
|
|
6
|
-
* - AgentReputation (oracle-based scoring)
|
|
7
|
-
* - ValidationRegistry (KYA code validation)
|
|
8
|
-
* - ERC-8004 IdentityRegistry
|
|
9
|
-
* - Morpho Blue (direct overcollateralized lending)
|
|
10
|
-
*
|
|
11
|
-
* All contract addresses are baked in — agents only need to specify chainId.
|
|
12
|
-
*/
|
|
13
|
-
import { ChainId } from '../types';
|
|
14
|
-
// Contract addresses per network
|
|
15
|
-
const CONTRACT_ADDRESSES = {
|
|
16
|
-
[ChainId.Ethereum]: {
|
|
17
|
-
accountFactory: '0x0000000000000000000000000000000000000000',
|
|
18
|
-
validationRegistry: '0x0000000000000000000000000000000000000000',
|
|
19
|
-
agentReputation: '0x0000000000000000000000000000000000000000',
|
|
20
|
-
usdc: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
21
|
-
identityRegistry: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
|
|
22
|
-
morphoBlue: '0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb',
|
|
23
|
-
},
|
|
24
|
-
[ChainId.Base]: {
|
|
25
|
-
accountFactory: '0x7D5D56416bAEA06a9DCBe3092eF335724C6320a0',
|
|
26
|
-
validationRegistry: '0xd196C32D2149270F56E209ba7aEE67CE9ceD2001',
|
|
27
|
-
agentReputation: '0x65c9cA1211809D3CF3A2707558198eb2b2bE623c',
|
|
28
|
-
usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
29
|
-
identityRegistry: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
|
|
30
|
-
morphoBlue: '0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb',
|
|
31
|
-
},
|
|
32
|
-
[ChainId.BaseSepolia]: {
|
|
33
|
-
accountFactory: '0x0000000000000000000000000000000000000000',
|
|
34
|
-
validationRegistry: '0x0000000000000000000000000000000000000000',
|
|
35
|
-
agentReputation: '0x0000000000000000000000000000000000000000',
|
|
36
|
-
usdc: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
|
|
37
|
-
identityRegistry: '0x8004A818BFB912233c491871b3d84c89A494BD9e',
|
|
38
|
-
morphoBlue: '0x0000000000000000000000000000000000000000',
|
|
39
|
-
},
|
|
40
|
-
[ChainId.Sepolia]: {
|
|
41
|
-
accountFactory: '0x0000000000000000000000000000000000000000',
|
|
42
|
-
validationRegistry: '0x0000000000000000000000000000000000000000',
|
|
43
|
-
agentReputation: '0x0000000000000000000000000000000000000000',
|
|
44
|
-
usdc: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
|
|
45
|
-
identityRegistry: '0x8004A818BFB912233c491871b3d84c89A494BD9e',
|
|
46
|
-
morphoBlue: '0x0000000000000000000000000000000000000000',
|
|
47
|
-
},
|
|
48
|
-
[ChainId.Hardhat]: {
|
|
49
|
-
accountFactory: '0x0000000000000000000000000000000000000000',
|
|
50
|
-
validationRegistry: '0x0000000000000000000000000000000000000000',
|
|
51
|
-
agentReputation: '0x0000000000000000000000000000000000000000',
|
|
52
|
-
usdc: '0x56d4d6aEe0278c5Df2FA23Ecb32eC146C9446FDf',
|
|
53
|
-
identityRegistry: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
|
|
54
|
-
morphoBlue: '0x0000000000000000000000000000000000000000',
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
// Default RPC URLs
|
|
58
|
-
const RPC_URLS = {
|
|
59
|
-
[ChainId.Ethereum]: 'https://ethereum-rpc.publicnode.com',
|
|
60
|
-
[ChainId.Base]: 'https://base-rpc.publicnode.com',
|
|
61
|
-
[ChainId.BaseSepolia]: 'https://sepolia.base.org',
|
|
62
|
-
[ChainId.Sepolia]: 'https://rpc.sepolia.org',
|
|
63
|
-
[ChainId.Hardhat]: 'http://127.0.0.1:8545',
|
|
64
|
-
};
|
|
65
|
-
// Scoring service endpoints
|
|
66
|
-
const SCORING_ENDPOINTS = {
|
|
67
|
-
[ChainId.Ethereum]: 'https://scoring.agether.ai/v1',
|
|
68
|
-
[ChainId.Base]: 'http://95.179.189.214:3001',
|
|
69
|
-
[ChainId.BaseSepolia]: 'http://95.179.189.214:3001',
|
|
70
|
-
[ChainId.Sepolia]: 'https://scoring-testnet.agether.ai/v1',
|
|
71
|
-
[ChainId.Hardhat]: 'http://127.0.0.1:3001',
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Get default config for a chain — includes all addresses, RPC, and scoring endpoint.
|
|
75
|
-
*/
|
|
76
|
-
export function getDefaultConfig(chainId) {
|
|
77
|
-
return {
|
|
78
|
-
chainId,
|
|
79
|
-
rpcUrl: RPC_URLS[chainId],
|
|
80
|
-
contracts: CONTRACT_ADDRESSES[chainId],
|
|
81
|
-
scoringEndpoint: SCORING_ENDPOINTS[chainId],
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Create custom config (override any defaults)
|
|
86
|
-
*/
|
|
87
|
-
export function createConfig(chainId, options) {
|
|
88
|
-
const defaultConfig = getDefaultConfig(chainId);
|
|
89
|
-
return {
|
|
90
|
-
...defaultConfig,
|
|
91
|
-
...options,
|
|
92
|
-
contracts: {
|
|
93
|
-
...defaultConfig.contracts,
|
|
94
|
-
...options?.contracts,
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get USDC address for chain
|
|
100
|
-
*/
|
|
101
|
-
export function getUSDCAddress(chainId) {
|
|
102
|
-
return CONTRACT_ADDRESSES[chainId].usdc;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Get Morpho Blue address for chain
|
|
106
|
-
*/
|
|
107
|
-
export function getMorphoBlueAddress(chainId) {
|
|
108
|
-
return CONTRACT_ADDRESSES[chainId].morphoBlue;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Get all contract addresses for a chain
|
|
112
|
-
*/
|
|
113
|
-
export function getContractAddresses(chainId) {
|
|
114
|
-
return CONTRACT_ADDRESSES[chainId];
|
|
115
|
-
}
|
package/dist/utils/format.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/utils/format.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Formatting utilities
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Parse units (e.g., "100" USDC -> 100000000n)
|
|
6
|
-
*/
|
|
7
|
-
export function parseUnits(value, decimals = 6) {
|
|
8
|
-
const [integer, fraction = ''] = value.split('.');
|
|
9
|
-
const paddedFraction = fraction.padEnd(decimals, '0').slice(0, decimals);
|
|
10
|
-
return BigInt(integer + paddedFraction);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Format units (e.g., 100000000n -> "100.00" USDC)
|
|
14
|
-
*/
|
|
15
|
-
export function formatUnits(value, decimals = 6) {
|
|
16
|
-
const str = value.toString().padStart(decimals + 1, '0');
|
|
17
|
-
const integer = str.slice(0, -decimals) || '0';
|
|
18
|
-
const fraction = str.slice(-decimals);
|
|
19
|
-
return `${integer}.${fraction}`;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Format USD value
|
|
23
|
-
*/
|
|
24
|
-
export function formatUSD(value, decimals = 6) {
|
|
25
|
-
const num = Number(formatUnits(value, decimals));
|
|
26
|
-
return new Intl.NumberFormat('en-US', {
|
|
27
|
-
style: 'currency',
|
|
28
|
-
currency: 'USD',
|
|
29
|
-
}).format(num);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Format percentage
|
|
33
|
-
*/
|
|
34
|
-
export function formatPercent(bps) {
|
|
35
|
-
return `${(bps / 100).toFixed(2)}%`;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Format APR from basis points
|
|
39
|
-
*/
|
|
40
|
-
export function formatAPR(bps) {
|
|
41
|
-
return formatPercent(Number(bps));
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Calculate health factor display
|
|
45
|
-
*/
|
|
46
|
-
export function formatHealthFactor(factor) {
|
|
47
|
-
const num = Number(factor) / 1e18;
|
|
48
|
-
if (num >= 100)
|
|
49
|
-
return '∞';
|
|
50
|
-
return num.toFixed(2);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Format address (truncate)
|
|
54
|
-
*/
|
|
55
|
-
export function formatAddress(address) {
|
|
56
|
-
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Format timestamp to date
|
|
60
|
-
*/
|
|
61
|
-
export function formatTimestamp(timestamp) {
|
|
62
|
-
return new Date(Number(timestamp) * 1000).toISOString();
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Convert basis points to decimal rate
|
|
66
|
-
*/
|
|
67
|
-
export function bpsToRate(bps) {
|
|
68
|
-
return Number(bps) / 10000;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Convert decimal rate to basis points
|
|
72
|
-
*/
|
|
73
|
-
export function rateToBps(rate) {
|
|
74
|
-
return BigInt(Math.round(rate * 10000));
|
|
75
|
-
}
|