@agether/sdk 2.17.2 → 2.18.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.
- package/dist/cli.js +433 -363
- package/dist/index.d.mts +164 -49
- package/dist/index.d.ts +164 -49
- package/dist/index.js +672 -295
- package/dist/index.mjs +670 -295
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer, ethers } from 'ethers';
|
|
1
|
+
import { Signer, ethers, Contract } from 'ethers';
|
|
2
2
|
import { WalletClient } from 'viem';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -407,6 +407,72 @@ declare class AgetherClient {
|
|
|
407
407
|
private _exec;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
+
/**
|
|
411
|
+
* AgentAccountClient — Base class for protocol integrations that operate
|
|
412
|
+
* through an Agent's Safe account via ERC-4337 UserOperations.
|
|
413
|
+
*
|
|
414
|
+
* Provides:
|
|
415
|
+
* - Signer/provider setup (privateKey or external signer)
|
|
416
|
+
* - Safe account address resolution
|
|
417
|
+
* - UserOp submission through EntryPoint
|
|
418
|
+
* - executeSingle() / executeBatch() for Safe7579 execution
|
|
419
|
+
* - Auto-funding Safe with ETH for gas
|
|
420
|
+
*
|
|
421
|
+
* Subclass this for each protocol (Morpho, Aave, etc.)
|
|
422
|
+
*/
|
|
423
|
+
|
|
424
|
+
interface AgentAccountBaseConfig {
|
|
425
|
+
rpcUrl: string;
|
|
426
|
+
agentId: string;
|
|
427
|
+
chainId?: ChainId;
|
|
428
|
+
contracts?: Partial<{
|
|
429
|
+
agether4337Factory: string;
|
|
430
|
+
entryPoint: string;
|
|
431
|
+
}>;
|
|
432
|
+
}
|
|
433
|
+
type AgentAccountConfig = AgentAccountBaseConfig & ({
|
|
434
|
+
privateKey: string;
|
|
435
|
+
signer?: never;
|
|
436
|
+
} | {
|
|
437
|
+
signer: ethers.AbstractSigner;
|
|
438
|
+
privateKey?: never;
|
|
439
|
+
});
|
|
440
|
+
declare class AgentAccountClient {
|
|
441
|
+
protected _signer: ethers.AbstractSigner;
|
|
442
|
+
protected provider: ethers.JsonRpcProvider;
|
|
443
|
+
protected config: AgetherConfig;
|
|
444
|
+
protected agentId: string;
|
|
445
|
+
protected _rpcUrl: string;
|
|
446
|
+
protected _privateKey?: string;
|
|
447
|
+
protected _useExternalSigner: boolean;
|
|
448
|
+
protected _eoaAddress?: string;
|
|
449
|
+
protected agether4337Factory: Contract;
|
|
450
|
+
protected entryPoint: Contract;
|
|
451
|
+
protected _accountAddress?: string;
|
|
452
|
+
constructor(config: AgentAccountConfig);
|
|
453
|
+
/** Resolve the AgentAccount (Safe) address. Cached after first call. */
|
|
454
|
+
getAccountAddress(): Promise<string>;
|
|
455
|
+
getAgentId(): string;
|
|
456
|
+
/** Get the EOA wallet address (synchronous). */
|
|
457
|
+
getWalletAddress(): string;
|
|
458
|
+
/** Get EOA wallet address (async, works for all signer types). */
|
|
459
|
+
getSignerAddress(): Promise<string>;
|
|
460
|
+
/** Pack two uint128 values into a single bytes32. */
|
|
461
|
+
private _packUint128;
|
|
462
|
+
/**
|
|
463
|
+
* Build, sign and submit a PackedUserOperation through EntryPoint.handleOps.
|
|
464
|
+
*/
|
|
465
|
+
private _submitUserOp;
|
|
466
|
+
/**
|
|
467
|
+
* Execute a single call via Safe7579 account through ERC-4337 UserOp.
|
|
468
|
+
*/
|
|
469
|
+
executeSingle(target: string, data: string, value?: bigint): Promise<ethers.TransactionReceipt>;
|
|
470
|
+
/**
|
|
471
|
+
* Execute multiple calls via Safe7579 account in one atomic batch.
|
|
472
|
+
*/
|
|
473
|
+
executeBatch(targets: string[], values: bigint[], datas: string[]): Promise<ethers.TransactionReceipt>;
|
|
474
|
+
}
|
|
475
|
+
|
|
410
476
|
/**
|
|
411
477
|
* MorphoClient — Morpho Blue lending only (supply, borrow, repay, withdraw collateral)
|
|
412
478
|
*
|
|
@@ -429,6 +495,7 @@ declare class AgetherClient {
|
|
|
429
495
|
* - `signer`: external signer (Bankr, Privy, Turnkey, MetaMask, etc.)
|
|
430
496
|
*/
|
|
431
497
|
|
|
498
|
+
/** Single call: callType=0x00, execType=0x00, rest zero-padded to 32 bytes */
|
|
432
499
|
/**
|
|
433
500
|
* Convenience type alias for any ethers-compatible signer.
|
|
434
501
|
* Use this when declaring variables or parameters that accept
|
|
@@ -581,21 +648,12 @@ interface YieldSpreadResult {
|
|
|
581
648
|
maxSafeLeverage: number;
|
|
582
649
|
leveragedNetApy: number;
|
|
583
650
|
liquidity: number;
|
|
651
|
+
totalSupply: number;
|
|
652
|
+
utilization: number;
|
|
584
653
|
marketId: string;
|
|
585
654
|
}
|
|
586
|
-
declare class MorphoClient {
|
|
587
|
-
private _signer;
|
|
588
|
-
private provider;
|
|
589
|
-
private config;
|
|
590
|
-
private agentId;
|
|
591
|
-
private _rpcUrl;
|
|
592
|
-
private _privateKey?;
|
|
593
|
-
private _useExternalSigner;
|
|
594
|
-
private _eoaAddress?;
|
|
595
|
-
private agether4337Factory;
|
|
655
|
+
declare class MorphoClient extends AgentAccountClient {
|
|
596
656
|
private morphoBlue;
|
|
597
|
-
private entryPoint;
|
|
598
|
-
private _accountAddress?;
|
|
599
657
|
/** Market params cache: keyed by market uniqueKey (bytes32 hash) */
|
|
600
658
|
private _marketCache;
|
|
601
659
|
/** Dynamic token registry: symbol (uppercase) or address (lowercase) → { address, symbol, decimals } */
|
|
@@ -603,17 +661,6 @@ declare class MorphoClient {
|
|
|
603
661
|
private _discoveredMarkets?;
|
|
604
662
|
private _discoveredAt;
|
|
605
663
|
constructor(config: MorphoClientConfig);
|
|
606
|
-
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
607
|
-
getAccountAddress(): Promise<string>;
|
|
608
|
-
getAgentId(): string;
|
|
609
|
-
/**
|
|
610
|
-
* Get the EOA wallet address (synchronous, best-effort).
|
|
611
|
-
*
|
|
612
|
-
* For the `privateKey` path this always works. For the `signer` path
|
|
613
|
-
* it works if the signer exposes `.address` synchronously (e.g. ethers.Wallet).
|
|
614
|
-
* If the address has not been resolved yet, throws — call `getSignerAddress()` first.
|
|
615
|
-
*/
|
|
616
|
-
getWalletAddress(): string;
|
|
617
664
|
/**
|
|
618
665
|
* Resolve the EOA signer address (async, works with all signer types).
|
|
619
666
|
* Result is cached after the first call.
|
|
@@ -932,7 +979,7 @@ declare class MorphoClient {
|
|
|
932
979
|
*
|
|
933
980
|
* @returns Array of markets with yield analysis, sorted by net spread descending.
|
|
934
981
|
*/
|
|
935
|
-
getYieldSpread(): Promise<YieldSpreadResult[]>;
|
|
982
|
+
getYieldSpread(minLiquidity?: number): Promise<YieldSpreadResult[]>;
|
|
936
983
|
/**
|
|
937
984
|
* Withdraw collateral from Morpho Blue.
|
|
938
985
|
*
|
|
@@ -955,29 +1002,6 @@ declare class MorphoClient {
|
|
|
955
1002
|
* responsibility.
|
|
956
1003
|
*/
|
|
957
1004
|
private _refreshSigner;
|
|
958
|
-
/**
|
|
959
|
-
* Pack two uint128 values into a single bytes32:
|
|
960
|
-
* bytes32 = (hi << 128) | lo
|
|
961
|
-
*/
|
|
962
|
-
private _packUint128;
|
|
963
|
-
/**
|
|
964
|
-
* Build, sign and submit a PackedUserOperation through EntryPoint.handleOps.
|
|
965
|
-
*
|
|
966
|
-
* @param callData – the ABI-encoded calldata for the Safe7579 account
|
|
967
|
-
* (e.g. `execute(mode, executionCalldata)`)
|
|
968
|
-
* @returns the transaction receipt of the handleOps call
|
|
969
|
-
*/
|
|
970
|
-
private _submitUserOp;
|
|
971
|
-
/**
|
|
972
|
-
* Execute a single call via Safe7579 account (ERC-7579 single mode)
|
|
973
|
-
* through an ERC-4337 UserOperation.
|
|
974
|
-
*/
|
|
975
|
-
private exec;
|
|
976
|
-
/**
|
|
977
|
-
* Execute multiple calls via Safe7579 account (ERC-7579 batch mode)
|
|
978
|
-
* through an ERC-4337 UserOperation.
|
|
979
|
-
*/
|
|
980
|
-
private batch;
|
|
981
1005
|
/** Convert MorphoMarketParams to Solidity tuple. */
|
|
982
1006
|
private _toTuple;
|
|
983
1007
|
/** Find the first market where the agent has collateral deposited. */
|
|
@@ -1016,6 +1040,97 @@ declare class MorphoClient {
|
|
|
1016
1040
|
private _computeNetDepositedAll;
|
|
1017
1041
|
}
|
|
1018
1042
|
|
|
1043
|
+
interface AaveReserveInfo {
|
|
1044
|
+
symbol: string;
|
|
1045
|
+
address: string;
|
|
1046
|
+
decimals: number;
|
|
1047
|
+
supplyApy: number;
|
|
1048
|
+
borrowApy: number;
|
|
1049
|
+
totalSupply: number;
|
|
1050
|
+
totalBorrow: number;
|
|
1051
|
+
ltv: number;
|
|
1052
|
+
liquidationThreshold: number;
|
|
1053
|
+
borrowingEnabled: boolean;
|
|
1054
|
+
isActive: boolean;
|
|
1055
|
+
priceUsd: number;
|
|
1056
|
+
}
|
|
1057
|
+
interface AavePosition {
|
|
1058
|
+
asset: string;
|
|
1059
|
+
address: string;
|
|
1060
|
+
supplied: number;
|
|
1061
|
+
suppliedUsd: number;
|
|
1062
|
+
borrowed: number;
|
|
1063
|
+
borrowedUsd: number;
|
|
1064
|
+
usedAsCollateral: boolean;
|
|
1065
|
+
supplyApy: number;
|
|
1066
|
+
borrowApy: number;
|
|
1067
|
+
}
|
|
1068
|
+
interface AaveAccountData {
|
|
1069
|
+
totalCollateralUsd: number;
|
|
1070
|
+
totalDebtUsd: number;
|
|
1071
|
+
availableBorrowUsd: number;
|
|
1072
|
+
currentLtv: number;
|
|
1073
|
+
liquidationThreshold: number;
|
|
1074
|
+
healthFactor: number;
|
|
1075
|
+
positions: AavePosition[];
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* AaveClient — Aave V3 lending operations through the Agent's Safe account.
|
|
1079
|
+
*
|
|
1080
|
+
* All write operations (supply, borrow, repay, withdraw) are executed through
|
|
1081
|
+
* the Safe7579 account via ERC-4337 UserOperations, just like MorphoClient.
|
|
1082
|
+
* This reuses MorphoClient's exec/batch infrastructure for Safe account execution.
|
|
1083
|
+
*/
|
|
1084
|
+
declare class AaveClient extends AgentAccountClient {
|
|
1085
|
+
private _aaveChainId;
|
|
1086
|
+
private _pool;
|
|
1087
|
+
private _oracle;
|
|
1088
|
+
private _dataProvider;
|
|
1089
|
+
private _poolIface;
|
|
1090
|
+
private _erc20Iface;
|
|
1091
|
+
private _reserveCache;
|
|
1092
|
+
private _reserveCacheTs;
|
|
1093
|
+
private static readonly CACHE_TTL;
|
|
1094
|
+
/**
|
|
1095
|
+
* Create an AaveClient. Takes the same config as MorphoClient — the agent's
|
|
1096
|
+
* Safe account is used for all Aave operations.
|
|
1097
|
+
*/
|
|
1098
|
+
constructor(config: AgentAccountConfig);
|
|
1099
|
+
/** Get the Agent's Safe account address. */
|
|
1100
|
+
getAccountAddress(): Promise<string>;
|
|
1101
|
+
/** Get chainId. */
|
|
1102
|
+
get aaveChainId(): ChainId;
|
|
1103
|
+
getReserves(forceRefresh?: boolean): Promise<AaveReserveInfo[]>;
|
|
1104
|
+
getAccountData(): Promise<AaveAccountData>;
|
|
1105
|
+
/**
|
|
1106
|
+
* Supply an asset to Aave V3 from the Agent's Safe account.
|
|
1107
|
+
* Batch: approve + supply in one UserOp.
|
|
1108
|
+
*/
|
|
1109
|
+
supply(asset: string, amount: string): Promise<ethers.TransactionReceipt>;
|
|
1110
|
+
/**
|
|
1111
|
+
* Withdraw a supplied asset from Aave V3 to the Safe account.
|
|
1112
|
+
*/
|
|
1113
|
+
withdraw(asset: string, amount: string, to?: string): Promise<ethers.TransactionReceipt>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Borrow an asset from Aave V3 (variable rate) to the Safe account.
|
|
1116
|
+
*/
|
|
1117
|
+
borrow(asset: string, amount: string): Promise<ethers.TransactionReceipt>;
|
|
1118
|
+
/**
|
|
1119
|
+
* Repay borrowed asset on Aave V3 from the Safe account.
|
|
1120
|
+
* Batch: approve + repay in one UserOp.
|
|
1121
|
+
*/
|
|
1122
|
+
repay(asset: string, amount: string): Promise<ethers.TransactionReceipt>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Enable or disable a supplied asset as collateral.
|
|
1125
|
+
*/
|
|
1126
|
+
setCollateral(asset: string, useAsCollateral: boolean): Promise<ethers.TransactionReceipt>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Supply an asset and borrow in one atomic batch operation.
|
|
1129
|
+
*/
|
|
1130
|
+
supplyAndBorrow(supplyAsset: string, supplyAmount: string, borrowAsset: string, borrowAmount: string): Promise<ethers.TransactionReceipt>;
|
|
1131
|
+
private _resolveReserve;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1019
1134
|
/**
|
|
1020
1135
|
* x402 HTTP Client — Make paid API calls via the x402 protocol (v2)
|
|
1021
1136
|
*
|
|
@@ -1633,4 +1748,4 @@ interface RetryOptions {
|
|
|
1633
1748
|
*/
|
|
1634
1749
|
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
1635
1750
|
|
|
1636
|
-
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, type MarketFilter, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PayFromYieldResult, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, type RetryOptions, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type SupplyAssetResult, type SupplyPositionResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawFromAccountResult, type WithdrawResult, type WithdrawSupplyResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, type YieldSpreadResult, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getContractAddresses, getDefaultConfig, getMorphoBlueAddress, getUSDCAddress, parseUnits, rateToBps, withRetry };
|
|
1751
|
+
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, type AaveAccountData, AaveClient, type AavePosition, type AaveReserveInfo, AgentAccountClient, type AgentAccountConfig, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, type MarketFilter, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PayFromYieldResult, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, type RetryOptions, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type SupplyAssetResult, type SupplyPositionResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawFromAccountResult, type WithdrawResult, type WithdrawSupplyResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, type YieldSpreadResult, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getContractAddresses, getDefaultConfig, getMorphoBlueAddress, getUSDCAddress, parseUnits, rateToBps, withRetry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Signer, ethers } from 'ethers';
|
|
1
|
+
import { Signer, ethers, Contract } from 'ethers';
|
|
2
2
|
import { WalletClient } from 'viem';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -407,6 +407,72 @@ declare class AgetherClient {
|
|
|
407
407
|
private _exec;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
+
/**
|
|
411
|
+
* AgentAccountClient — Base class for protocol integrations that operate
|
|
412
|
+
* through an Agent's Safe account via ERC-4337 UserOperations.
|
|
413
|
+
*
|
|
414
|
+
* Provides:
|
|
415
|
+
* - Signer/provider setup (privateKey or external signer)
|
|
416
|
+
* - Safe account address resolution
|
|
417
|
+
* - UserOp submission through EntryPoint
|
|
418
|
+
* - executeSingle() / executeBatch() for Safe7579 execution
|
|
419
|
+
* - Auto-funding Safe with ETH for gas
|
|
420
|
+
*
|
|
421
|
+
* Subclass this for each protocol (Morpho, Aave, etc.)
|
|
422
|
+
*/
|
|
423
|
+
|
|
424
|
+
interface AgentAccountBaseConfig {
|
|
425
|
+
rpcUrl: string;
|
|
426
|
+
agentId: string;
|
|
427
|
+
chainId?: ChainId;
|
|
428
|
+
contracts?: Partial<{
|
|
429
|
+
agether4337Factory: string;
|
|
430
|
+
entryPoint: string;
|
|
431
|
+
}>;
|
|
432
|
+
}
|
|
433
|
+
type AgentAccountConfig = AgentAccountBaseConfig & ({
|
|
434
|
+
privateKey: string;
|
|
435
|
+
signer?: never;
|
|
436
|
+
} | {
|
|
437
|
+
signer: ethers.AbstractSigner;
|
|
438
|
+
privateKey?: never;
|
|
439
|
+
});
|
|
440
|
+
declare class AgentAccountClient {
|
|
441
|
+
protected _signer: ethers.AbstractSigner;
|
|
442
|
+
protected provider: ethers.JsonRpcProvider;
|
|
443
|
+
protected config: AgetherConfig;
|
|
444
|
+
protected agentId: string;
|
|
445
|
+
protected _rpcUrl: string;
|
|
446
|
+
protected _privateKey?: string;
|
|
447
|
+
protected _useExternalSigner: boolean;
|
|
448
|
+
protected _eoaAddress?: string;
|
|
449
|
+
protected agether4337Factory: Contract;
|
|
450
|
+
protected entryPoint: Contract;
|
|
451
|
+
protected _accountAddress?: string;
|
|
452
|
+
constructor(config: AgentAccountConfig);
|
|
453
|
+
/** Resolve the AgentAccount (Safe) address. Cached after first call. */
|
|
454
|
+
getAccountAddress(): Promise<string>;
|
|
455
|
+
getAgentId(): string;
|
|
456
|
+
/** Get the EOA wallet address (synchronous). */
|
|
457
|
+
getWalletAddress(): string;
|
|
458
|
+
/** Get EOA wallet address (async, works for all signer types). */
|
|
459
|
+
getSignerAddress(): Promise<string>;
|
|
460
|
+
/** Pack two uint128 values into a single bytes32. */
|
|
461
|
+
private _packUint128;
|
|
462
|
+
/**
|
|
463
|
+
* Build, sign and submit a PackedUserOperation through EntryPoint.handleOps.
|
|
464
|
+
*/
|
|
465
|
+
private _submitUserOp;
|
|
466
|
+
/**
|
|
467
|
+
* Execute a single call via Safe7579 account through ERC-4337 UserOp.
|
|
468
|
+
*/
|
|
469
|
+
executeSingle(target: string, data: string, value?: bigint): Promise<ethers.TransactionReceipt>;
|
|
470
|
+
/**
|
|
471
|
+
* Execute multiple calls via Safe7579 account in one atomic batch.
|
|
472
|
+
*/
|
|
473
|
+
executeBatch(targets: string[], values: bigint[], datas: string[]): Promise<ethers.TransactionReceipt>;
|
|
474
|
+
}
|
|
475
|
+
|
|
410
476
|
/**
|
|
411
477
|
* MorphoClient — Morpho Blue lending only (supply, borrow, repay, withdraw collateral)
|
|
412
478
|
*
|
|
@@ -429,6 +495,7 @@ declare class AgetherClient {
|
|
|
429
495
|
* - `signer`: external signer (Bankr, Privy, Turnkey, MetaMask, etc.)
|
|
430
496
|
*/
|
|
431
497
|
|
|
498
|
+
/** Single call: callType=0x00, execType=0x00, rest zero-padded to 32 bytes */
|
|
432
499
|
/**
|
|
433
500
|
* Convenience type alias for any ethers-compatible signer.
|
|
434
501
|
* Use this when declaring variables or parameters that accept
|
|
@@ -581,21 +648,12 @@ interface YieldSpreadResult {
|
|
|
581
648
|
maxSafeLeverage: number;
|
|
582
649
|
leveragedNetApy: number;
|
|
583
650
|
liquidity: number;
|
|
651
|
+
totalSupply: number;
|
|
652
|
+
utilization: number;
|
|
584
653
|
marketId: string;
|
|
585
654
|
}
|
|
586
|
-
declare class MorphoClient {
|
|
587
|
-
private _signer;
|
|
588
|
-
private provider;
|
|
589
|
-
private config;
|
|
590
|
-
private agentId;
|
|
591
|
-
private _rpcUrl;
|
|
592
|
-
private _privateKey?;
|
|
593
|
-
private _useExternalSigner;
|
|
594
|
-
private _eoaAddress?;
|
|
595
|
-
private agether4337Factory;
|
|
655
|
+
declare class MorphoClient extends AgentAccountClient {
|
|
596
656
|
private morphoBlue;
|
|
597
|
-
private entryPoint;
|
|
598
|
-
private _accountAddress?;
|
|
599
657
|
/** Market params cache: keyed by market uniqueKey (bytes32 hash) */
|
|
600
658
|
private _marketCache;
|
|
601
659
|
/** Dynamic token registry: symbol (uppercase) or address (lowercase) → { address, symbol, decimals } */
|
|
@@ -603,17 +661,6 @@ declare class MorphoClient {
|
|
|
603
661
|
private _discoveredMarkets?;
|
|
604
662
|
private _discoveredAt;
|
|
605
663
|
constructor(config: MorphoClientConfig);
|
|
606
|
-
/** Resolve the AgentAccount address (cached, with retry for flaky RPCs). */
|
|
607
|
-
getAccountAddress(): Promise<string>;
|
|
608
|
-
getAgentId(): string;
|
|
609
|
-
/**
|
|
610
|
-
* Get the EOA wallet address (synchronous, best-effort).
|
|
611
|
-
*
|
|
612
|
-
* For the `privateKey` path this always works. For the `signer` path
|
|
613
|
-
* it works if the signer exposes `.address` synchronously (e.g. ethers.Wallet).
|
|
614
|
-
* If the address has not been resolved yet, throws — call `getSignerAddress()` first.
|
|
615
|
-
*/
|
|
616
|
-
getWalletAddress(): string;
|
|
617
664
|
/**
|
|
618
665
|
* Resolve the EOA signer address (async, works with all signer types).
|
|
619
666
|
* Result is cached after the first call.
|
|
@@ -932,7 +979,7 @@ declare class MorphoClient {
|
|
|
932
979
|
*
|
|
933
980
|
* @returns Array of markets with yield analysis, sorted by net spread descending.
|
|
934
981
|
*/
|
|
935
|
-
getYieldSpread(): Promise<YieldSpreadResult[]>;
|
|
982
|
+
getYieldSpread(minLiquidity?: number): Promise<YieldSpreadResult[]>;
|
|
936
983
|
/**
|
|
937
984
|
* Withdraw collateral from Morpho Blue.
|
|
938
985
|
*
|
|
@@ -955,29 +1002,6 @@ declare class MorphoClient {
|
|
|
955
1002
|
* responsibility.
|
|
956
1003
|
*/
|
|
957
1004
|
private _refreshSigner;
|
|
958
|
-
/**
|
|
959
|
-
* Pack two uint128 values into a single bytes32:
|
|
960
|
-
* bytes32 = (hi << 128) | lo
|
|
961
|
-
*/
|
|
962
|
-
private _packUint128;
|
|
963
|
-
/**
|
|
964
|
-
* Build, sign and submit a PackedUserOperation through EntryPoint.handleOps.
|
|
965
|
-
*
|
|
966
|
-
* @param callData – the ABI-encoded calldata for the Safe7579 account
|
|
967
|
-
* (e.g. `execute(mode, executionCalldata)`)
|
|
968
|
-
* @returns the transaction receipt of the handleOps call
|
|
969
|
-
*/
|
|
970
|
-
private _submitUserOp;
|
|
971
|
-
/**
|
|
972
|
-
* Execute a single call via Safe7579 account (ERC-7579 single mode)
|
|
973
|
-
* through an ERC-4337 UserOperation.
|
|
974
|
-
*/
|
|
975
|
-
private exec;
|
|
976
|
-
/**
|
|
977
|
-
* Execute multiple calls via Safe7579 account (ERC-7579 batch mode)
|
|
978
|
-
* through an ERC-4337 UserOperation.
|
|
979
|
-
*/
|
|
980
|
-
private batch;
|
|
981
1005
|
/** Convert MorphoMarketParams to Solidity tuple. */
|
|
982
1006
|
private _toTuple;
|
|
983
1007
|
/** Find the first market where the agent has collateral deposited. */
|
|
@@ -1016,6 +1040,97 @@ declare class MorphoClient {
|
|
|
1016
1040
|
private _computeNetDepositedAll;
|
|
1017
1041
|
}
|
|
1018
1042
|
|
|
1043
|
+
interface AaveReserveInfo {
|
|
1044
|
+
symbol: string;
|
|
1045
|
+
address: string;
|
|
1046
|
+
decimals: number;
|
|
1047
|
+
supplyApy: number;
|
|
1048
|
+
borrowApy: number;
|
|
1049
|
+
totalSupply: number;
|
|
1050
|
+
totalBorrow: number;
|
|
1051
|
+
ltv: number;
|
|
1052
|
+
liquidationThreshold: number;
|
|
1053
|
+
borrowingEnabled: boolean;
|
|
1054
|
+
isActive: boolean;
|
|
1055
|
+
priceUsd: number;
|
|
1056
|
+
}
|
|
1057
|
+
interface AavePosition {
|
|
1058
|
+
asset: string;
|
|
1059
|
+
address: string;
|
|
1060
|
+
supplied: number;
|
|
1061
|
+
suppliedUsd: number;
|
|
1062
|
+
borrowed: number;
|
|
1063
|
+
borrowedUsd: number;
|
|
1064
|
+
usedAsCollateral: boolean;
|
|
1065
|
+
supplyApy: number;
|
|
1066
|
+
borrowApy: number;
|
|
1067
|
+
}
|
|
1068
|
+
interface AaveAccountData {
|
|
1069
|
+
totalCollateralUsd: number;
|
|
1070
|
+
totalDebtUsd: number;
|
|
1071
|
+
availableBorrowUsd: number;
|
|
1072
|
+
currentLtv: number;
|
|
1073
|
+
liquidationThreshold: number;
|
|
1074
|
+
healthFactor: number;
|
|
1075
|
+
positions: AavePosition[];
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* AaveClient — Aave V3 lending operations through the Agent's Safe account.
|
|
1079
|
+
*
|
|
1080
|
+
* All write operations (supply, borrow, repay, withdraw) are executed through
|
|
1081
|
+
* the Safe7579 account via ERC-4337 UserOperations, just like MorphoClient.
|
|
1082
|
+
* This reuses MorphoClient's exec/batch infrastructure for Safe account execution.
|
|
1083
|
+
*/
|
|
1084
|
+
declare class AaveClient extends AgentAccountClient {
|
|
1085
|
+
private _aaveChainId;
|
|
1086
|
+
private _pool;
|
|
1087
|
+
private _oracle;
|
|
1088
|
+
private _dataProvider;
|
|
1089
|
+
private _poolIface;
|
|
1090
|
+
private _erc20Iface;
|
|
1091
|
+
private _reserveCache;
|
|
1092
|
+
private _reserveCacheTs;
|
|
1093
|
+
private static readonly CACHE_TTL;
|
|
1094
|
+
/**
|
|
1095
|
+
* Create an AaveClient. Takes the same config as MorphoClient — the agent's
|
|
1096
|
+
* Safe account is used for all Aave operations.
|
|
1097
|
+
*/
|
|
1098
|
+
constructor(config: AgentAccountConfig);
|
|
1099
|
+
/** Get the Agent's Safe account address. */
|
|
1100
|
+
getAccountAddress(): Promise<string>;
|
|
1101
|
+
/** Get chainId. */
|
|
1102
|
+
get aaveChainId(): ChainId;
|
|
1103
|
+
getReserves(forceRefresh?: boolean): Promise<AaveReserveInfo[]>;
|
|
1104
|
+
getAccountData(): Promise<AaveAccountData>;
|
|
1105
|
+
/**
|
|
1106
|
+
* Supply an asset to Aave V3 from the Agent's Safe account.
|
|
1107
|
+
* Batch: approve + supply in one UserOp.
|
|
1108
|
+
*/
|
|
1109
|
+
supply(asset: string, amount: string): Promise<ethers.TransactionReceipt>;
|
|
1110
|
+
/**
|
|
1111
|
+
* Withdraw a supplied asset from Aave V3 to the Safe account.
|
|
1112
|
+
*/
|
|
1113
|
+
withdraw(asset: string, amount: string, to?: string): Promise<ethers.TransactionReceipt>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Borrow an asset from Aave V3 (variable rate) to the Safe account.
|
|
1116
|
+
*/
|
|
1117
|
+
borrow(asset: string, amount: string): Promise<ethers.TransactionReceipt>;
|
|
1118
|
+
/**
|
|
1119
|
+
* Repay borrowed asset on Aave V3 from the Safe account.
|
|
1120
|
+
* Batch: approve + repay in one UserOp.
|
|
1121
|
+
*/
|
|
1122
|
+
repay(asset: string, amount: string): Promise<ethers.TransactionReceipt>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Enable or disable a supplied asset as collateral.
|
|
1125
|
+
*/
|
|
1126
|
+
setCollateral(asset: string, useAsCollateral: boolean): Promise<ethers.TransactionReceipt>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Supply an asset and borrow in one atomic batch operation.
|
|
1129
|
+
*/
|
|
1130
|
+
supplyAndBorrow(supplyAsset: string, supplyAmount: string, borrowAsset: string, borrowAmount: string): Promise<ethers.TransactionReceipt>;
|
|
1131
|
+
private _resolveReserve;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1019
1134
|
/**
|
|
1020
1135
|
* x402 HTTP Client — Make paid API calls via the x402 protocol (v2)
|
|
1021
1136
|
*
|
|
@@ -1633,4 +1748,4 @@ interface RetryOptions {
|
|
|
1633
1748
|
*/
|
|
1634
1749
|
declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
1635
1750
|
|
|
1636
|
-
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, type MarketFilter, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PayFromYieldResult, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, type RetryOptions, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type SupplyAssetResult, type SupplyPositionResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawFromAccountResult, type WithdrawResult, type WithdrawSupplyResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, type YieldSpreadResult, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getContractAddresses, getDefaultConfig, getMorphoBlueAddress, getUSDCAddress, parseUnits, rateToBps, withRetry };
|
|
1751
|
+
export { ACCOUNT_FACTORY_ABI, AGENT_REPUTATION_ABI, AGETHER_4337_FACTORY_ABI, AGETHER_8004_SCORER_ABI, AGETHER_8004_VALIDATION_MODULE_ABI, AGETHER_HOOK_MULTIPLEXER_ABI, type AaveAccountData, AaveClient, type AavePosition, type AaveReserveInfo, AgentAccountClient, type AgentAccountConfig, AgentIdentityClient, type AgentIdentityClientOptions, AgentNotApprovedError, AgetherClient, type AgetherClientOptions, type AgetherConfig, AgetherError, type AgetherSigner, type AgetherViemWallet, type BalancesResult, type BorrowResult, ChainId, type ContractAddresses, type DepositAndBorrowResult, type DepositResult, ENTRYPOINT_V07_ABI, ERC20_ABI, ERC8004_VALIDATION_MODULE_ABI, HOOK_MULTIPLEXER_ABI, IDENTITY_REGISTRY_ABI, InsufficientBalanceError, MORPHO_BLUE_ABI, type MarketFilter, MorphoClient, type MorphoClientConfig, type MorphoMarketInfo, type MorphoMarketParams, type MorphoPosition, type PayFromYieldResult, type PaymentRequirements, type PositionResult, type RegisterResult, type RepayResult, type RetryOptions, SAFE7579_ACCOUNT_ABI, SAFE_AGENT_FACTORY_ABI, type ScoreAttestation, type ScoreResult, ScoringClient, type ScoringClientConfig, ScoringRejectedError, type SpendingTracker, type StatusResult, type SupplyAssetResult, type SupplyPositionResult, type TransactionResult, VALIDATION_REGISTRY_ABI, type WithdrawFromAccountResult, type WithdrawResult, type WithdrawSupplyResult, X402Client, type X402Config, type X402PaymentRequest, type X402PaymentResult, type X402Response, type YieldSpreadResult, bpsToRate, createConfig, formatAPR, formatAddress, formatHealthFactor, formatPercent, formatTimestamp, formatUSD, formatUnits, getContractAddresses, getDefaultConfig, getMorphoBlueAddress, getUSDCAddress, parseUnits, rateToBps, withRetry };
|