@agether/sdk 1.6.1 → 1.6.3
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.d.ts +25 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +351 -3
- package/dist/clients/AgentIdentityClient.d.ts +188 -0
- package/dist/clients/AgentIdentityClient.d.ts.map +1 -0
- package/dist/clients/AgentIdentityClient.js +333 -0
- package/dist/clients/AgetherClient.d.ts +63 -0
- package/dist/clients/AgetherClient.d.ts.map +1 -0
- package/dist/clients/AgetherClient.js +171 -0
- package/dist/clients/MorphoClient.d.ts +287 -0
- package/dist/clients/MorphoClient.d.ts.map +1 -0
- package/dist/clients/MorphoClient.js +951 -0
- package/dist/clients/ScoringClient.d.ts +89 -0
- package/dist/clients/ScoringClient.d.ts.map +1 -0
- package/dist/clients/ScoringClient.js +93 -0
- package/dist/clients/X402Client.d.ts +130 -0
- package/dist/clients/X402Client.d.ts.map +1 -0
- package/dist/clients/X402Client.js +301 -0
- package/dist/index.d.mts +142 -1
- package/dist/index.d.ts +142 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +351 -3
- package/dist/index.mjs +351 -3
- package/dist/types/index.d.ts +121 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +43 -0
- package/dist/utils/abis.d.ts +18 -0
- package/dist/utils/abis.d.ts.map +1 -0
- package/dist/utils/abis.js +93 -0
- package/dist/utils/config.d.ts +34 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +115 -0
- package/dist/utils/format.d.ts +44 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +75 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
}
|
|
@@ -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"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
}
|