@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
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AgetherClient — Account management & identity for AI agents
|
|
3
|
-
*
|
|
4
|
-
* Flow:
|
|
5
|
-
* 1. Agent registers via ERC-8004 → gets agentId
|
|
6
|
-
* 2. AccountFactory.createAccount(agentId) → AgentAccount (KYA-gated smart wallet)
|
|
7
|
-
* 3. Use MorphoClient for lending, ScoringClient for scores, X402Client for payments
|
|
8
|
-
*/
|
|
9
|
-
import { ethers, Contract } from 'ethers';
|
|
10
|
-
import { AgetherError, } from '../types';
|
|
11
|
-
import { ACCOUNT_FACTORY_ABI, AGENT_ACCOUNT_ABI, IDENTITY_REGISTRY_ABI, VALIDATION_REGISTRY_ABI, AGENT_REPUTATION_ABI, ERC20_ABI, } from '../utils/abis';
|
|
12
|
-
import { getDefaultConfig } from '../utils/config';
|
|
13
|
-
export class AgetherClient {
|
|
14
|
-
constructor(options) {
|
|
15
|
-
this.config = options.config;
|
|
16
|
-
this.signer = options.signer;
|
|
17
|
-
this.agentId = options.agentId;
|
|
18
|
-
const provider = options.signer.provider;
|
|
19
|
-
if (!provider)
|
|
20
|
-
throw new AgetherError('Signer must have a provider', 'NO_PROVIDER');
|
|
21
|
-
this.accountFactory = new Contract(options.config.contracts.accountFactory, ACCOUNT_FACTORY_ABI, options.signer);
|
|
22
|
-
this.identityRegistry = new Contract(options.config.contracts.identityRegistry, IDENTITY_REGISTRY_ABI, provider);
|
|
23
|
-
this.validationRegistry = new Contract(options.config.contracts.validationRegistry, VALIDATION_REGISTRY_ABI, provider);
|
|
24
|
-
this.agentReputation = new Contract(options.config.contracts.agentReputation, AGENT_REPUTATION_ABI, provider);
|
|
25
|
-
}
|
|
26
|
-
// Static Factory
|
|
27
|
-
static fromPrivateKey(privateKey, agentId, chainIdOrConfig) {
|
|
28
|
-
const config = typeof chainIdOrConfig === 'number'
|
|
29
|
-
? getDefaultConfig(chainIdOrConfig)
|
|
30
|
-
: chainIdOrConfig;
|
|
31
|
-
const provider = new ethers.JsonRpcProvider(config.rpcUrl);
|
|
32
|
-
const signer = new ethers.Wallet(privateKey, provider);
|
|
33
|
-
return new AgetherClient({ config, signer, agentId });
|
|
34
|
-
}
|
|
35
|
-
// Account Management
|
|
36
|
-
async createAccount() {
|
|
37
|
-
const tx = await this.accountFactory.createAccount(this.agentId);
|
|
38
|
-
const receipt = await tx.wait();
|
|
39
|
-
const event = receipt.logs
|
|
40
|
-
.map((log) => {
|
|
41
|
-
try {
|
|
42
|
-
return this.accountFactory.interface.parseLog(log);
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
.find((e) => e?.name === 'AccountCreated');
|
|
49
|
-
if (event) {
|
|
50
|
-
this.accountAddress = event.args.account;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
this.accountAddress = await this.accountFactory.getAccount(this.agentId);
|
|
54
|
-
}
|
|
55
|
-
return this.accountAddress;
|
|
56
|
-
}
|
|
57
|
-
async getAccountAddress() {
|
|
58
|
-
if (this.accountAddress)
|
|
59
|
-
return this.accountAddress;
|
|
60
|
-
const addr = await this.accountFactory.getAccount(this.agentId);
|
|
61
|
-
if (addr === ethers.ZeroAddress) {
|
|
62
|
-
throw new AgetherError('No account found. Create one with createAccount().', 'NO_ACCOUNT');
|
|
63
|
-
}
|
|
64
|
-
this.accountAddress = addr;
|
|
65
|
-
return addr;
|
|
66
|
-
}
|
|
67
|
-
async accountExists() {
|
|
68
|
-
return this.accountFactory.accountExists(this.agentId);
|
|
69
|
-
}
|
|
70
|
-
async predictAddress() {
|
|
71
|
-
return this.accountFactory.predictAddress(this.agentId);
|
|
72
|
-
}
|
|
73
|
-
// Balances
|
|
74
|
-
async getBalances() {
|
|
75
|
-
const provider = this.signer.provider;
|
|
76
|
-
const eoaAddr = await this.signer.getAddress();
|
|
77
|
-
const usdc = new Contract(this.config.contracts.usdc, ERC20_ABI, provider);
|
|
78
|
-
const ethBal = await provider.getBalance(eoaAddr);
|
|
79
|
-
const usdcBal = await usdc.balanceOf(eoaAddr);
|
|
80
|
-
const result = {
|
|
81
|
-
eoa: { eth: ethers.formatEther(ethBal), usdc: ethers.formatUnits(usdcBal, 6) },
|
|
82
|
-
};
|
|
83
|
-
try {
|
|
84
|
-
const acctAddr = await this.getAccountAddress();
|
|
85
|
-
const acctEth = await provider.getBalance(acctAddr);
|
|
86
|
-
const acctUsdc = await usdc.balanceOf(acctAddr);
|
|
87
|
-
result.account = {
|
|
88
|
-
address: acctAddr,
|
|
89
|
-
eth: ethers.formatEther(acctEth),
|
|
90
|
-
usdc: ethers.formatUnits(acctUsdc, 6),
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
catch { /* no account */ }
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
async fundAccount(usdcAmount) {
|
|
97
|
-
const acctAddr = await this.getAccountAddress();
|
|
98
|
-
const usdc = new Contract(this.config.contracts.usdc, ERC20_ABI, this.signer);
|
|
99
|
-
const amount = ethers.parseUnits(usdcAmount, 6);
|
|
100
|
-
const tx = await usdc.transfer(acctAddr, amount);
|
|
101
|
-
const receipt = await tx.wait();
|
|
102
|
-
return {
|
|
103
|
-
txHash: receipt.hash,
|
|
104
|
-
blockNumber: receipt.blockNumber,
|
|
105
|
-
status: receipt.status === 1 ? 'success' : 'failed',
|
|
106
|
-
gasUsed: receipt.gasUsed,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
async withdrawUsdc(usdcAmount) {
|
|
110
|
-
const acctAddr = await this.getAccountAddress();
|
|
111
|
-
const account = new Contract(acctAddr, AGENT_ACCOUNT_ABI, this.signer);
|
|
112
|
-
const amount = ethers.parseUnits(usdcAmount, 6);
|
|
113
|
-
const eoaAddr = await this.signer.getAddress();
|
|
114
|
-
const tx = await account.withdraw(this.config.contracts.usdc, amount, eoaAddr);
|
|
115
|
-
const receipt = await tx.wait();
|
|
116
|
-
return {
|
|
117
|
-
txHash: receipt.hash,
|
|
118
|
-
blockNumber: receipt.blockNumber,
|
|
119
|
-
status: receipt.status === 1 ? 'success' : 'failed',
|
|
120
|
-
gasUsed: receipt.gasUsed,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
async withdrawEth(ethAmount) {
|
|
124
|
-
const acctAddr = await this.getAccountAddress();
|
|
125
|
-
const account = new Contract(acctAddr, AGENT_ACCOUNT_ABI, this.signer);
|
|
126
|
-
const amount = ethers.parseEther(ethAmount);
|
|
127
|
-
const eoaAddr = await this.signer.getAddress();
|
|
128
|
-
const tx = await account.withdrawETH(amount, eoaAddr);
|
|
129
|
-
const receipt = await tx.wait();
|
|
130
|
-
return {
|
|
131
|
-
txHash: receipt.hash,
|
|
132
|
-
blockNumber: receipt.blockNumber,
|
|
133
|
-
status: receipt.status === 1 ? 'success' : 'failed',
|
|
134
|
-
gasUsed: receipt.gasUsed,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
// Identity & Validation
|
|
138
|
-
async isKyaApproved() {
|
|
139
|
-
return this.validationRegistry.isAgentCodeApproved(this.agentId);
|
|
140
|
-
}
|
|
141
|
-
async identityExists() {
|
|
142
|
-
try {
|
|
143
|
-
await this.identityRegistry.ownerOf(this.agentId);
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async getIdentityOwner() {
|
|
151
|
-
return this.identityRegistry.ownerOf(this.agentId);
|
|
152
|
-
}
|
|
153
|
-
// Reputation
|
|
154
|
-
async getCreditScore() {
|
|
155
|
-
return this.agentReputation.getCreditScore(this.agentId);
|
|
156
|
-
}
|
|
157
|
-
async isScoreFresh() {
|
|
158
|
-
const [fresh, age] = await this.agentReputation.isScoreFresh(this.agentId);
|
|
159
|
-
return { fresh, age };
|
|
160
|
-
}
|
|
161
|
-
async isEligible(minScore = 500n) {
|
|
162
|
-
const [eligible, currentScore] = await this.agentReputation.isEligible(this.agentId, minScore);
|
|
163
|
-
return { eligible, currentScore };
|
|
164
|
-
}
|
|
165
|
-
// Getters
|
|
166
|
-
get chainId() { return this.config.chainId; }
|
|
167
|
-
get contracts() { return this.config.contracts; }
|
|
168
|
-
get currentAccountAddress() { return this.accountAddress; }
|
|
169
|
-
getSigner() { return this.signer; }
|
|
170
|
-
getAgentId() { return this.agentId; }
|
|
171
|
-
}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MorphoClient — Direct Morpho Blue lending via AgentAccount.executeBatch
|
|
3
|
-
*
|
|
4
|
-
* Architecture (no intermediary contract):
|
|
5
|
-
* EOA → AgentAccount.executeBatch → Morpho Blue (direct)
|
|
6
|
-
*
|
|
7
|
-
* Batched operations:
|
|
8
|
-
* - depositAndBorrow: [ERC20.approve, Morpho.supplyCollateral, Morpho.borrow]
|
|
9
|
-
* - repay: [ERC20.approve, Morpho.repay]
|
|
10
|
-
* - supplyCollateral: [ERC20.approve, Morpho.supplyCollateral]
|
|
11
|
-
*
|
|
12
|
-
* Market discovery via Morpho GraphQL API (https://api.morpho.org/graphql)
|
|
13
|
-
*/
|
|
14
|
-
import { MorphoMarketParams, MorphoMarketInfo, MorphoPosition, ScoreAttestation, ChainId } from '../types';
|
|
15
|
-
export interface MorphoClientConfig {
|
|
16
|
-
privateKey: string;
|
|
17
|
-
rpcUrl: string;
|
|
18
|
-
agentId?: string;
|
|
19
|
-
chainId?: ChainId;
|
|
20
|
-
contracts?: Partial<{
|
|
21
|
-
accountFactory: string;
|
|
22
|
-
morphoBlue: string;
|
|
23
|
-
usdc: string;
|
|
24
|
-
agentReputation: string;
|
|
25
|
-
identityRegistry: string;
|
|
26
|
-
}>;
|
|
27
|
-
}
|
|
28
|
-
export interface BalancesResult {
|
|
29
|
-
agentId: string;
|
|
30
|
-
address: string;
|
|
31
|
-
eth: string;
|
|
32
|
-
usdc: string;
|
|
33
|
-
collateral: Record<string, string>;
|
|
34
|
-
agentAccount?: {
|
|
35
|
-
address: string;
|
|
36
|
-
eth: string;
|
|
37
|
-
usdc: string;
|
|
38
|
-
collateral: Record<string, string>;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export interface RegisterResult {
|
|
42
|
-
agentId: string;
|
|
43
|
-
address: string;
|
|
44
|
-
agentAccount: string;
|
|
45
|
-
alreadyRegistered: boolean;
|
|
46
|
-
tx?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface PositionResult {
|
|
49
|
-
marketId: string;
|
|
50
|
-
collateralToken: string;
|
|
51
|
-
collateral: string;
|
|
52
|
-
borrowShares: string;
|
|
53
|
-
supplyShares: string;
|
|
54
|
-
debt: string;
|
|
55
|
-
}
|
|
56
|
-
export interface StatusResult {
|
|
57
|
-
agentId: string;
|
|
58
|
-
agentAccount: string;
|
|
59
|
-
totalDebt: string;
|
|
60
|
-
positions: PositionResult[];
|
|
61
|
-
}
|
|
62
|
-
export interface DepositResult {
|
|
63
|
-
tx: string;
|
|
64
|
-
collateralToken: string;
|
|
65
|
-
amount: string;
|
|
66
|
-
agentAccount: string;
|
|
67
|
-
}
|
|
68
|
-
export interface BorrowResult {
|
|
69
|
-
tx: string;
|
|
70
|
-
amount: string;
|
|
71
|
-
collateralToken: string;
|
|
72
|
-
agentAccount: string;
|
|
73
|
-
}
|
|
74
|
-
export interface DepositAndBorrowResult {
|
|
75
|
-
tx: string;
|
|
76
|
-
collateralToken: string;
|
|
77
|
-
collateralAmount: string;
|
|
78
|
-
borrowAmount: string;
|
|
79
|
-
agentAccount: string;
|
|
80
|
-
}
|
|
81
|
-
export interface RepayResult {
|
|
82
|
-
tx: string;
|
|
83
|
-
amount: string;
|
|
84
|
-
remainingDebt: string;
|
|
85
|
-
}
|
|
86
|
-
export interface WithdrawResult {
|
|
87
|
-
tx: string;
|
|
88
|
-
token: string;
|
|
89
|
-
amount: string;
|
|
90
|
-
remainingCollateral: string;
|
|
91
|
-
destination: string;
|
|
92
|
-
}
|
|
93
|
-
export interface FundResult {
|
|
94
|
-
tx: string;
|
|
95
|
-
amount: string;
|
|
96
|
-
agentAccount: string;
|
|
97
|
-
}
|
|
98
|
-
export declare class MorphoClient {
|
|
99
|
-
private wallet;
|
|
100
|
-
private provider;
|
|
101
|
-
private config;
|
|
102
|
-
private agentId;
|
|
103
|
-
private accountFactory;
|
|
104
|
-
private morphoBlue;
|
|
105
|
-
private agentReputation;
|
|
106
|
-
private identityRegistry;
|
|
107
|
-
private _accountAddress?;
|
|
108
|
-
private _marketCache;
|
|
109
|
-
private _discoveredMarkets?;
|
|
110
|
-
private _discoveredAt;
|
|
111
|
-
constructor(config: MorphoClientConfig);
|
|
112
|
-
/** Resolve the AgentAccount address (cached). */
|
|
113
|
-
getAccountAddress(): Promise<string>;
|
|
114
|
-
getAgentId(): string;
|
|
115
|
-
getWalletAddress(): string;
|
|
116
|
-
/** Mint a new ERC-8004 identity and return the agentId. */
|
|
117
|
-
private _mintNewIdentity;
|
|
118
|
-
/**
|
|
119
|
-
* Register: create ERC-8004 identity + AgentAccount in one flow.
|
|
120
|
-
* If already registered, returns existing state.
|
|
121
|
-
*/
|
|
122
|
-
register(_name?: string): Promise<RegisterResult>;
|
|
123
|
-
/** Get ETH / USDC / collateral balances for EOA and AgentAccount. */
|
|
124
|
-
getBalances(): Promise<BalancesResult>;
|
|
125
|
-
/** Transfer USDC from EOA to AgentAccount. */
|
|
126
|
-
fundAccount(usdcAmount: string): Promise<FundResult>;
|
|
127
|
-
/**
|
|
128
|
-
* Fetch USDC borrow markets on Base from Morpho API.
|
|
129
|
-
* Caches results for 5 minutes.
|
|
130
|
-
*/
|
|
131
|
-
getMarkets(forceRefresh?: boolean): Promise<MorphoMarketInfo[]>;
|
|
132
|
-
/**
|
|
133
|
-
* Get MarketParams for a collateral token.
|
|
134
|
-
* Tries cache → API → on-chain idToMarketParams.
|
|
135
|
-
*/
|
|
136
|
-
findMarketForCollateral(collateralSymbolOrAddress: string): Promise<MorphoMarketParams>;
|
|
137
|
-
/** Read MarketParams on-chain by market ID (bytes32). */
|
|
138
|
-
getMarketParams(marketId: string): Promise<MorphoMarketParams>;
|
|
139
|
-
/** Read on-chain position for a specific market. */
|
|
140
|
-
getPosition(marketId: string): Promise<MorphoPosition>;
|
|
141
|
-
/**
|
|
142
|
-
* Full status: positions across all discovered markets.
|
|
143
|
-
*/
|
|
144
|
-
getStatus(): Promise<StatusResult>;
|
|
145
|
-
/**
|
|
146
|
-
* Get the USDC balance of the AgentAccount.
|
|
147
|
-
* @returns USDC balance in raw units (6 decimals)
|
|
148
|
-
*/
|
|
149
|
-
getUsdcBalance(): Promise<bigint>;
|
|
150
|
-
/**
|
|
151
|
-
* Calculate the maximum additional USDC that can be borrowed
|
|
152
|
-
* given the agent's current collateral and debt across all markets.
|
|
153
|
-
*
|
|
154
|
-
* For each market with collateral deposited:
|
|
155
|
-
* maxBorrow = (collateralValue * LLTV) - currentDebt
|
|
156
|
-
*
|
|
157
|
-
* Uses the Morpho oracle to price collateral → loan token.
|
|
158
|
-
*
|
|
159
|
-
* @returns Maximum additional USDC borrowable (6 decimals)
|
|
160
|
-
*/
|
|
161
|
-
getMaxBorrowable(): Promise<{
|
|
162
|
-
total: bigint;
|
|
163
|
-
byMarket: Array<{
|
|
164
|
-
collateralToken: string;
|
|
165
|
-
maxAdditional: bigint;
|
|
166
|
-
currentDebt: bigint;
|
|
167
|
-
collateralValue: bigint;
|
|
168
|
-
}>;
|
|
169
|
-
}>;
|
|
170
|
-
/**
|
|
171
|
-
* Fetch current supply/borrow APY for a collateral market from Morpho GraphQL API.
|
|
172
|
-
*
|
|
173
|
-
* Note: On Morpho Blue, collateral does NOT earn yield directly. Supply APY
|
|
174
|
-
* is what lenders earn; borrow APY is what borrowers pay.
|
|
175
|
-
*/
|
|
176
|
-
getMarketRates(collateralSymbolOrAddress?: string): Promise<Array<{
|
|
177
|
-
collateralToken: string;
|
|
178
|
-
loanToken: string;
|
|
179
|
-
supplyApy: number;
|
|
180
|
-
borrowApy: number;
|
|
181
|
-
utilization: number;
|
|
182
|
-
totalSupplyUsd: number;
|
|
183
|
-
totalBorrowUsd: number;
|
|
184
|
-
lltv: string;
|
|
185
|
-
marketId: string;
|
|
186
|
-
}>>;
|
|
187
|
-
/**
|
|
188
|
-
* Estimate theoretical yield for a given collateral amount over a period.
|
|
189
|
-
*
|
|
190
|
-
* ⚠️ IMPORTANT: On Morpho Blue, collateral does NOT earn yield directly.
|
|
191
|
-
* This estimates what the collateral WOULD earn if it were instead supplied
|
|
192
|
-
* as a lender (not used as collateral). This is a theoretical upper bound
|
|
193
|
-
* useful for setting spending caps.
|
|
194
|
-
*
|
|
195
|
-
* @param collateralSymbol - e.g. 'WETH'
|
|
196
|
-
* @param amount - collateral amount in human-readable (e.g. '1.5')
|
|
197
|
-
* @param periodDays - estimation period in days (default: 1)
|
|
198
|
-
* @param ethPriceUsd - ETH price in USD for value conversion (if not provided, uses oracle)
|
|
199
|
-
* @returns Estimated yield in USD for the period
|
|
200
|
-
*/
|
|
201
|
-
getYieldEstimate(collateralSymbol: string, amount: string, periodDays?: number, ethPriceUsd?: number): Promise<{
|
|
202
|
-
collateralToken: string;
|
|
203
|
-
amount: string;
|
|
204
|
-
periodDays: number;
|
|
205
|
-
theoreticalSupplyApy: number;
|
|
206
|
-
estimatedYieldUsd: number;
|
|
207
|
-
collateralValueUsd: number;
|
|
208
|
-
disclaimer: string;
|
|
209
|
-
}>;
|
|
210
|
-
/**
|
|
211
|
-
* Deposit collateral into Morpho Blue.
|
|
212
|
-
*
|
|
213
|
-
* Flow:
|
|
214
|
-
* 1. EOA transfers collateral to AgentAccount
|
|
215
|
-
* 2. AgentAccount.executeBatch:
|
|
216
|
-
* [collateral.approve(MorphoBlue), Morpho.supplyCollateral(params)]
|
|
217
|
-
*/
|
|
218
|
-
supplyCollateral(tokenSymbol: string, amount: string, marketParams?: MorphoMarketParams): Promise<DepositResult>;
|
|
219
|
-
/**
|
|
220
|
-
* Borrow USDC against existing collateral.
|
|
221
|
-
*
|
|
222
|
-
* AgentAccount.execute: Morpho.borrow(params, amount, 0, account, account)
|
|
223
|
-
*
|
|
224
|
-
* @param usdcAmount - USDC amount (e.g. '100')
|
|
225
|
-
* @param tokenSymbol - collateral symbol to identify which market (default: first with collateral)
|
|
226
|
-
*/
|
|
227
|
-
borrow(usdcAmount: string, tokenSymbol?: string, marketParams?: MorphoMarketParams): Promise<BorrowResult>;
|
|
228
|
-
/**
|
|
229
|
-
* Deposit collateral AND borrow USDC in one batched transaction.
|
|
230
|
-
*
|
|
231
|
-
* AgentAccount.executeBatch:
|
|
232
|
-
* [collateral.approve, Morpho.supplyCollateral, Morpho.borrow]
|
|
233
|
-
*
|
|
234
|
-
* The collateral must be transferred to AgentAccount first.
|
|
235
|
-
*/
|
|
236
|
-
depositAndBorrow(tokenSymbol: string, collateralAmount: string, borrowUsdcAmount: string, marketParams?: MorphoMarketParams): Promise<DepositAndBorrowResult>;
|
|
237
|
-
/**
|
|
238
|
-
* Repay borrowed USDC from AgentAccount.
|
|
239
|
-
*
|
|
240
|
-
* AgentAccount.executeBatch:
|
|
241
|
-
* [USDC.approve(MorphoBlue), Morpho.repay(params)]
|
|
242
|
-
*/
|
|
243
|
-
repay(usdcAmount: string, tokenSymbol?: string, marketParams?: MorphoMarketParams): Promise<RepayResult>;
|
|
244
|
-
/**
|
|
245
|
-
* Withdraw collateral from Morpho Blue.
|
|
246
|
-
*
|
|
247
|
-
* AgentAccount.execute: Morpho.withdrawCollateral(params, amount, account, receiver)
|
|
248
|
-
*
|
|
249
|
-
* @param receiver - defaults to EOA wallet
|
|
250
|
-
*/
|
|
251
|
-
withdrawCollateral(tokenSymbol: string, amount: string, marketParams?: MorphoMarketParams, receiver?: string): Promise<WithdrawResult>;
|
|
252
|
-
/**
|
|
253
|
-
* Sponsor: transfer collateral to another agent's AgentAccount.
|
|
254
|
-
* (The agent must then supplyCollateral themselves via their own account.)
|
|
255
|
-
*/
|
|
256
|
-
sponsor(target: {
|
|
257
|
-
agentId?: string;
|
|
258
|
-
address?: string;
|
|
259
|
-
}, tokenSymbol: string, amount: string): Promise<{
|
|
260
|
-
tx: string;
|
|
261
|
-
targetAccount: string;
|
|
262
|
-
targetAgentId?: string;
|
|
263
|
-
}>;
|
|
264
|
-
getCreditScore(): Promise<bigint>;
|
|
265
|
-
getAttestation(): Promise<ScoreAttestation>;
|
|
266
|
-
isEligible(minScore?: bigint): Promise<{
|
|
267
|
-
eligible: boolean;
|
|
268
|
-
currentScore: bigint;
|
|
269
|
-
}>;
|
|
270
|
-
isScoreFresh(): Promise<{
|
|
271
|
-
fresh: boolean;
|
|
272
|
-
age: bigint;
|
|
273
|
-
}>;
|
|
274
|
-
/**
|
|
275
|
-
* Execute a single call via AgentAccount.execute.
|
|
276
|
-
*/
|
|
277
|
-
private exec;
|
|
278
|
-
/**
|
|
279
|
-
* Execute multiple calls via AgentAccount.executeBatch.
|
|
280
|
-
*/
|
|
281
|
-
private batch;
|
|
282
|
-
/** Convert MorphoMarketParams to Solidity tuple. */
|
|
283
|
-
private _toTuple;
|
|
284
|
-
/** Find the first market where the agent has collateral deposited. */
|
|
285
|
-
private _findActiveMarket;
|
|
286
|
-
}
|
|
287
|
-
//# sourceMappingURL=MorphoClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MorphoClient.d.ts","sourceRoot":"","sources":["../../src/clients/MorphoClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAEL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAEhB,OAAO,EACR,MAAM,UAAU,CAAC;AAuBlB,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAA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