@owney/sdk 0.7.22-beta.1 → 0.7.22-beta.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/{chunk-3HL52KM7.js → chunk-5W56YOBO.js} +22 -1
- package/dist/index.cjs +91 -5
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +26 -1
- package/dist/{surfliquid.agent-AE7RZ66F.js → surfliquid.agent-BFBNEQQI.js} +51 -7
- package/dist/{surfliquid.smart-account-C535356J.js → surfliquid.smart-account-O6YPCQT3.js} +1 -1
- package/package.json +1 -1
|
@@ -205,6 +205,17 @@ async function permitIfShort(input) {
|
|
|
205
205
|
s
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
|
+
async function readStuckBalance(input) {
|
|
209
|
+
return input.chain.usdcBalanceOf(input.wallet.smartAccountAddress);
|
|
210
|
+
}
|
|
211
|
+
async function sweepStuckBalance(input) {
|
|
212
|
+
const stranded = await readStuckBalance(input);
|
|
213
|
+
if (stranded === 0n) return { amount: 0n };
|
|
214
|
+
const txHash = await input.wallet.sendCalls(
|
|
215
|
+
buildSweepCalls({ owner: input.wallet.ownerAddress, amount: stranded })
|
|
216
|
+
);
|
|
217
|
+
return { txHash, amount: stranded };
|
|
218
|
+
}
|
|
208
219
|
async function depositSponsored(input) {
|
|
209
220
|
const { api, chain, wallet, amount } = input;
|
|
210
221
|
const { vault, deploySalt, registerAfterDeposit } = await resolveVault(input);
|
|
@@ -251,7 +262,15 @@ async function withdrawSponsored(input) {
|
|
|
251
262
|
if (owner.toLowerCase() !== wallet.smartAccountAddress.toLowerCase()) {
|
|
252
263
|
throw new VaultNotSponsorableError(`SurfLiquid vault ${vault} is not owned by the smart account`);
|
|
253
264
|
}
|
|
254
|
-
|
|
265
|
+
let withdrawHash;
|
|
266
|
+
try {
|
|
267
|
+
withdrawHash = await wallet.sendCalls(buildWithdrawCalls({ vault, amount }));
|
|
268
|
+
} catch (redeemError) {
|
|
269
|
+
const stranded = await chain.usdcBalanceOf(wallet.smartAccountAddress);
|
|
270
|
+
if (stranded === 0n) throw redeemError;
|
|
271
|
+
const sweepHash = await wallet.sendCalls(buildSweepCalls({ owner: wallet.ownerAddress, amount: stranded }));
|
|
272
|
+
return { txHash: sweepHash, amount: stranded.toString() };
|
|
273
|
+
}
|
|
255
274
|
try {
|
|
256
275
|
const proceeds = await chain.usdcBalanceOf(wallet.smartAccountAddress);
|
|
257
276
|
if (proceeds === 0n) return { txHash: withdrawHash, amount: "0" };
|
|
@@ -278,6 +297,8 @@ export {
|
|
|
278
297
|
USDC_ABI,
|
|
279
298
|
SubmittedError,
|
|
280
299
|
VaultNotSponsorableError,
|
|
300
|
+
readStuckBalance,
|
|
301
|
+
sweepStuckBalance,
|
|
281
302
|
depositSponsored,
|
|
282
303
|
withdrawSponsored
|
|
283
304
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -526,8 +526,8 @@ var init_surfliquid_broker = __esm({
|
|
|
526
526
|
// src/agents/surfliquid/surfliquid.mapper.ts
|
|
527
527
|
function mapMessage(message) {
|
|
528
528
|
const action = SURFLIQUID_ACTION_MAP[message.transactionType];
|
|
529
|
-
if (!action) return
|
|
530
|
-
|
|
529
|
+
if (!action) return [];
|
|
530
|
+
const base5 = {
|
|
531
531
|
agent: "surfliquid",
|
|
532
532
|
action,
|
|
533
533
|
date: message.timestamp,
|
|
@@ -543,9 +543,27 @@ function mapMessage(message) {
|
|
|
543
543
|
],
|
|
544
544
|
rebalanceLog: []
|
|
545
545
|
};
|
|
546
|
+
if (DEPOSIT_TRANSACTION_TYPES.has(message.transactionType) && message.toVault?.name && message.amount != null) {
|
|
547
|
+
return [
|
|
548
|
+
base5,
|
|
549
|
+
{
|
|
550
|
+
...base5,
|
|
551
|
+
action: "Deposit",
|
|
552
|
+
positions: [
|
|
553
|
+
{
|
|
554
|
+
protocol: SURFLIQUID_PROTOCOL,
|
|
555
|
+
pool: message.toVault.name,
|
|
556
|
+
tokenSymbol: message.token ?? void 0,
|
|
557
|
+
amount: String(message.amount)
|
|
558
|
+
}
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
];
|
|
562
|
+
}
|
|
563
|
+
return [base5];
|
|
546
564
|
}
|
|
547
565
|
function mapHistory(result, _chainId) {
|
|
548
|
-
const data = result.messages.
|
|
566
|
+
const data = result.messages.flatMap(mapMessage);
|
|
549
567
|
const hasMore = result.page < result.pages;
|
|
550
568
|
return {
|
|
551
569
|
data,
|
|
@@ -620,11 +638,17 @@ function mapUserProfile2(vault, address) {
|
|
|
620
638
|
protocols: ["SurfLiquid"]
|
|
621
639
|
};
|
|
622
640
|
}
|
|
623
|
-
var APY_WINDOW_KEY;
|
|
641
|
+
var SURFLIQUID_PROTOCOL, DEPOSIT_TRANSACTION_TYPES, APY_WINDOW_KEY;
|
|
624
642
|
var init_surfliquid_mapper = __esm({
|
|
625
643
|
"src/agents/surfliquid/surfliquid.mapper.ts"() {
|
|
626
644
|
"use strict";
|
|
627
645
|
init_surfliquid_constants();
|
|
646
|
+
SURFLIQUID_PROTOCOL = "Morpho";
|
|
647
|
+
DEPOSIT_TRANSACTION_TYPES = /* @__PURE__ */ new Set([
|
|
648
|
+
"INITIAL_DEPOSIT",
|
|
649
|
+
"DEPOSIT",
|
|
650
|
+
"USER_DEPOSIT"
|
|
651
|
+
]);
|
|
628
652
|
APY_WINDOW_KEY = {
|
|
629
653
|
"7D": "apy7d",
|
|
630
654
|
"14D": "apy14d",
|
|
@@ -803,6 +827,17 @@ async function permitIfShort(input) {
|
|
|
803
827
|
s
|
|
804
828
|
};
|
|
805
829
|
}
|
|
830
|
+
async function readStuckBalance(input) {
|
|
831
|
+
return input.chain.usdcBalanceOf(input.wallet.smartAccountAddress);
|
|
832
|
+
}
|
|
833
|
+
async function sweepStuckBalance(input) {
|
|
834
|
+
const stranded = await readStuckBalance(input);
|
|
835
|
+
if (stranded === 0n) return { amount: 0n };
|
|
836
|
+
const txHash = await input.wallet.sendCalls(
|
|
837
|
+
buildSweepCalls({ owner: input.wallet.ownerAddress, amount: stranded })
|
|
838
|
+
);
|
|
839
|
+
return { txHash, amount: stranded };
|
|
840
|
+
}
|
|
806
841
|
async function depositSponsored(input) {
|
|
807
842
|
const { api, chain, wallet, amount } = input;
|
|
808
843
|
const { vault, deploySalt, registerAfterDeposit } = await resolveVault(input);
|
|
@@ -849,7 +884,15 @@ async function withdrawSponsored(input) {
|
|
|
849
884
|
if (owner.toLowerCase() !== wallet.smartAccountAddress.toLowerCase()) {
|
|
850
885
|
throw new VaultNotSponsorableError(`SurfLiquid vault ${vault} is not owned by the smart account`);
|
|
851
886
|
}
|
|
852
|
-
|
|
887
|
+
let withdrawHash;
|
|
888
|
+
try {
|
|
889
|
+
withdrawHash = await wallet.sendCalls(buildWithdrawCalls({ vault, amount }));
|
|
890
|
+
} catch (redeemError) {
|
|
891
|
+
const stranded = await chain.usdcBalanceOf(wallet.smartAccountAddress);
|
|
892
|
+
if (stranded === 0n) throw redeemError;
|
|
893
|
+
const sweepHash = await wallet.sendCalls(buildSweepCalls({ owner: wallet.ownerAddress, amount: stranded }));
|
|
894
|
+
return { txHash: sweepHash, amount: stranded.toString() };
|
|
895
|
+
}
|
|
853
896
|
try {
|
|
854
897
|
const proceeds = await chain.usdcBalanceOf(wallet.smartAccountAddress);
|
|
855
898
|
if (proceeds === 0n) return { txHash: withdrawHash, amount: "0" };
|
|
@@ -1266,6 +1309,24 @@ var init_surfliquid_agent = __esm({
|
|
|
1266
1309
|
throw toOwneyError(error);
|
|
1267
1310
|
}
|
|
1268
1311
|
}
|
|
1312
|
+
/** Funds a prior withdrawal's sweep left in the smart account (never reached the EOA). No session needed — pure read. */
|
|
1313
|
+
async getStuckBalance(state) {
|
|
1314
|
+
const wallet = await this.sponsoredWallet(state);
|
|
1315
|
+
const { createSponsoredChain: createSponsoredChain2 } = await Promise.resolve().then(() => (init_surfliquid_smart_account(), surfliquid_smart_account_exports));
|
|
1316
|
+
const amount = await readStuckBalance({ chain: createSponsoredChain2(this.config.rpcUrl), wallet });
|
|
1317
|
+
return { amount: amount.toString(), smartAccountAddress: wallet.smartAccountAddress };
|
|
1318
|
+
}
|
|
1319
|
+
/** Sweep the stranded balance to the owner's EOA — one sponsored userOp, one signature. */
|
|
1320
|
+
async recoverStuckBalance(state) {
|
|
1321
|
+
const wallet = await this.sponsoredWallet(state);
|
|
1322
|
+
const { createSponsoredChain: createSponsoredChain2 } = await Promise.resolve().then(() => (init_surfliquid_smart_account(), surfliquid_smart_account_exports));
|
|
1323
|
+
try {
|
|
1324
|
+
const { txHash, amount } = await sweepStuckBalance({ chain: createSponsoredChain2(this.config.rpcUrl), wallet });
|
|
1325
|
+
return { txHash, type: "full", amount: amount.toString() };
|
|
1326
|
+
} catch (error) {
|
|
1327
|
+
throw toOwneyError(error);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1269
1330
|
// --- IAgent: portfolio reads ---
|
|
1270
1331
|
async vault(state) {
|
|
1271
1332
|
const broker = await this.connect(state);
|
|
@@ -5027,6 +5088,31 @@ var OwneySDK = class {
|
|
|
5027
5088
|
}
|
|
5028
5089
|
return { agentResult: results, totalWithdrawn: withdrawn.toString() };
|
|
5029
5090
|
}
|
|
5091
|
+
/**
|
|
5092
|
+
* Funds a prior withdrawal left stranded in the agent's smart account (the
|
|
5093
|
+
* payout leg never reached the owner's EOA). Read-only — check once after
|
|
5094
|
+
* connect. Agents without a smart account model report "0".
|
|
5095
|
+
*/
|
|
5096
|
+
async getStuckBalance(agentId) {
|
|
5097
|
+
const state = this.requireState();
|
|
5098
|
+
const chainId = this.requireChainId();
|
|
5099
|
+
const agent = this.getAgent(agentId);
|
|
5100
|
+
if (!agent.getStuckBalance) return { amount: "0", smartAccountAddress: "" };
|
|
5101
|
+
return agent.getStuckBalance(state, chainId);
|
|
5102
|
+
}
|
|
5103
|
+
/** Sweep that stranded balance to the owner's EOA — one signature. No-op ("0") when nothing is stuck. */
|
|
5104
|
+
async recoverStuckBalance(agentId) {
|
|
5105
|
+
const state = this.requireState();
|
|
5106
|
+
const chainId = this.requireChainId();
|
|
5107
|
+
const agent = this.getAgent(agentId);
|
|
5108
|
+
if (!agent.recoverStuckBalance) return { type: "full", amount: "0" };
|
|
5109
|
+
return withFailureReporting(
|
|
5110
|
+
this.apiKey,
|
|
5111
|
+
agent.id,
|
|
5112
|
+
() => agent.recoverStuckBalance(state, chainId),
|
|
5113
|
+
this.routingApiBaseUrl
|
|
5114
|
+
);
|
|
5115
|
+
}
|
|
5030
5116
|
// --- Portfolio reads ---
|
|
5031
5117
|
/**
|
|
5032
5118
|
* Get the user's balances for a specific agent, or aggregated across all agents.
|
package/dist/index.d.cts
CHANGED
|
@@ -195,6 +195,13 @@ interface AgentWithdrawResult {
|
|
|
195
195
|
/** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
|
|
196
196
|
amount: string;
|
|
197
197
|
}
|
|
198
|
+
/** Funds a prior withdrawal left in the agent's smart account, awaiting recovery to the owner's EOA. */
|
|
199
|
+
interface AgentStuckBalance {
|
|
200
|
+
/** Smallest-unit amount stuck in the smart account; "0" when nothing is stuck. */
|
|
201
|
+
amount: string;
|
|
202
|
+
/** The smart account holding the funds (for display / on-chain verification). */
|
|
203
|
+
smartAccountAddress: string;
|
|
204
|
+
}
|
|
198
205
|
interface OwneyWithdrawResult {
|
|
199
206
|
agentResult: Record<AgentId, AgentWithdrawResult>;
|
|
200
207
|
/**
|
|
@@ -446,6 +453,14 @@ interface IAgent {
|
|
|
446
453
|
* a write occurred (`false` = already enabled / not supported).
|
|
447
454
|
*/
|
|
448
455
|
ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
|
|
456
|
+
/**
|
|
457
|
+
* Read funds a prior withdrawal left stranded in the agent's smart account
|
|
458
|
+
* (the payout leg never reached the owner's EOA). Optional capability — only
|
|
459
|
+
* agents with a per-user smart account model this. Checked once after connect.
|
|
460
|
+
*/
|
|
461
|
+
getStuckBalance?(state: ConnectionState, chainId: number): Promise<AgentStuckBalance>;
|
|
462
|
+
/** Sweep that stranded balance to the owner's EOA. No-op (amount "0") when nothing is stuck. */
|
|
463
|
+
recoverStuckBalance?(state: ConnectionState, chainId: number): Promise<AgentWithdrawResult>;
|
|
449
464
|
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
450
465
|
}
|
|
451
466
|
/**
|
|
@@ -656,6 +671,14 @@ declare class OwneySDK {
|
|
|
656
671
|
* @returns {AgentWithdrawResult} for a single agent, or {OwneyWithdrawResult} with per-agent results
|
|
657
672
|
*/
|
|
658
673
|
withdraw(options: WithdrawOptions): Promise<OwneyWithdrawResult | AgentWithdrawResult>;
|
|
674
|
+
/**
|
|
675
|
+
* Funds a prior withdrawal left stranded in the agent's smart account (the
|
|
676
|
+
* payout leg never reached the owner's EOA). Read-only — check once after
|
|
677
|
+
* connect. Agents without a smart account model report "0".
|
|
678
|
+
*/
|
|
679
|
+
getStuckBalance(agentId: AgentId): Promise<AgentStuckBalance>;
|
|
680
|
+
/** Sweep that stranded balance to the owner's EOA — one signature. No-op ("0") when nothing is stuck. */
|
|
681
|
+
recoverStuckBalance(agentId: AgentId): Promise<AgentWithdrawResult>;
|
|
659
682
|
/**
|
|
660
683
|
* Get the user's balances for a specific agent, or aggregated across all agents.
|
|
661
684
|
* @param agentId - Optional. Agent to query. Omit for aggregated balances.
|
|
@@ -812,4 +835,4 @@ type OwneySIWXConfig = {
|
|
|
812
835
|
*/
|
|
813
836
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
814
837
|
|
|
815
|
-
export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
|
|
838
|
+
export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentStuckBalance, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
|
package/dist/index.d.ts
CHANGED
|
@@ -195,6 +195,13 @@ interface AgentWithdrawResult {
|
|
|
195
195
|
/** Smallest-unit amount, or a provider sentinel such as "all" for a full request. */
|
|
196
196
|
amount: string;
|
|
197
197
|
}
|
|
198
|
+
/** Funds a prior withdrawal left in the agent's smart account, awaiting recovery to the owner's EOA. */
|
|
199
|
+
interface AgentStuckBalance {
|
|
200
|
+
/** Smallest-unit amount stuck in the smart account; "0" when nothing is stuck. */
|
|
201
|
+
amount: string;
|
|
202
|
+
/** The smart account holding the funds (for display / on-chain verification). */
|
|
203
|
+
smartAccountAddress: string;
|
|
204
|
+
}
|
|
198
205
|
interface OwneyWithdrawResult {
|
|
199
206
|
agentResult: Record<AgentId, AgentWithdrawResult>;
|
|
200
207
|
/**
|
|
@@ -446,6 +453,14 @@ interface IAgent {
|
|
|
446
453
|
* a write occurred (`false` = already enabled / not supported).
|
|
447
454
|
*/
|
|
448
455
|
ensureAutoSelectProtocols?(state: ConnectionState, chainId: number, asset: "USDC" | "WETH"): Promise<boolean>;
|
|
456
|
+
/**
|
|
457
|
+
* Read funds a prior withdrawal left stranded in the agent's smart account
|
|
458
|
+
* (the payout leg never reached the owner's EOA). Optional capability — only
|
|
459
|
+
* agents with a per-user smart account model this. Checked once after connect.
|
|
460
|
+
*/
|
|
461
|
+
getStuckBalance?(state: ConnectionState, chainId: number): Promise<AgentStuckBalance>;
|
|
462
|
+
/** Sweep that stranded balance to the owner's EOA. No-op (amount "0") when nothing is stuck. */
|
|
463
|
+
recoverStuckBalance?(state: ConnectionState, chainId: number): Promise<AgentWithdrawResult>;
|
|
449
464
|
getAgentApy(days: DailyApyDays, options?: AgentApyOptions): Promise<AgentApy>;
|
|
450
465
|
}
|
|
451
466
|
/**
|
|
@@ -656,6 +671,14 @@ declare class OwneySDK {
|
|
|
656
671
|
* @returns {AgentWithdrawResult} for a single agent, or {OwneyWithdrawResult} with per-agent results
|
|
657
672
|
*/
|
|
658
673
|
withdraw(options: WithdrawOptions): Promise<OwneyWithdrawResult | AgentWithdrawResult>;
|
|
674
|
+
/**
|
|
675
|
+
* Funds a prior withdrawal left stranded in the agent's smart account (the
|
|
676
|
+
* payout leg never reached the owner's EOA). Read-only — check once after
|
|
677
|
+
* connect. Agents without a smart account model report "0".
|
|
678
|
+
*/
|
|
679
|
+
getStuckBalance(agentId: AgentId): Promise<AgentStuckBalance>;
|
|
680
|
+
/** Sweep that stranded balance to the owner's EOA — one signature. No-op ("0") when nothing is stuck. */
|
|
681
|
+
recoverStuckBalance(agentId: AgentId): Promise<AgentWithdrawResult>;
|
|
659
682
|
/**
|
|
660
683
|
* Get the user's balances for a specific agent, or aggregated across all agents.
|
|
661
684
|
* @param agentId - Optional. Agent to query. Omit for aggregated balances.
|
|
@@ -812,4 +835,4 @@ type OwneySIWXConfig = {
|
|
|
812
835
|
*/
|
|
813
836
|
declare function createOwneySIWX(config: OwneySIWXConfig): SIWXConfig;
|
|
814
837
|
|
|
815
|
-
export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
|
|
838
|
+
export { type AccountAgentApy, type AccountApyOptions, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentStuckBalance, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type WithdrawOptions, createOwneySIWX, setOwneyDebug };
|
package/dist/index.js
CHANGED
|
@@ -3036,7 +3036,7 @@ var OwneySDK = class {
|
|
|
3036
3036
|
}
|
|
3037
3037
|
if (agentId === "surfliquid") {
|
|
3038
3038
|
if (!key2) return null;
|
|
3039
|
-
const { SurfLiquidAgent } = await import("./surfliquid.agent-
|
|
3039
|
+
const { SurfLiquidAgent } = await import("./surfliquid.agent-BFBNEQQI.js");
|
|
3040
3040
|
return new SurfLiquidAgent({
|
|
3041
3041
|
apiKey: this.apiKey,
|
|
3042
3042
|
routingApiBaseUrl: this.routingApiBaseUrl
|
|
@@ -3691,6 +3691,31 @@ var OwneySDK = class {
|
|
|
3691
3691
|
}
|
|
3692
3692
|
return { agentResult: results, totalWithdrawn: withdrawn.toString() };
|
|
3693
3693
|
}
|
|
3694
|
+
/**
|
|
3695
|
+
* Funds a prior withdrawal left stranded in the agent's smart account (the
|
|
3696
|
+
* payout leg never reached the owner's EOA). Read-only — check once after
|
|
3697
|
+
* connect. Agents without a smart account model report "0".
|
|
3698
|
+
*/
|
|
3699
|
+
async getStuckBalance(agentId) {
|
|
3700
|
+
const state = this.requireState();
|
|
3701
|
+
const chainId = this.requireChainId();
|
|
3702
|
+
const agent = this.getAgent(agentId);
|
|
3703
|
+
if (!agent.getStuckBalance) return { amount: "0", smartAccountAddress: "" };
|
|
3704
|
+
return agent.getStuckBalance(state, chainId);
|
|
3705
|
+
}
|
|
3706
|
+
/** Sweep that stranded balance to the owner's EOA — one signature. No-op ("0") when nothing is stuck. */
|
|
3707
|
+
async recoverStuckBalance(agentId) {
|
|
3708
|
+
const state = this.requireState();
|
|
3709
|
+
const chainId = this.requireChainId();
|
|
3710
|
+
const agent = this.getAgent(agentId);
|
|
3711
|
+
if (!agent.recoverStuckBalance) return { type: "full", amount: "0" };
|
|
3712
|
+
return withFailureReporting(
|
|
3713
|
+
this.apiKey,
|
|
3714
|
+
agent.id,
|
|
3715
|
+
() => agent.recoverStuckBalance(state, chainId),
|
|
3716
|
+
this.routingApiBaseUrl
|
|
3717
|
+
);
|
|
3718
|
+
}
|
|
3694
3719
|
// --- Portfolio reads ---
|
|
3695
3720
|
/**
|
|
3696
3721
|
* Get the user's balances for a specific agent, or aggregated across all agents.
|
|
@@ -10,8 +10,10 @@ import {
|
|
|
10
10
|
SubmittedError,
|
|
11
11
|
VaultNotSponsorableError,
|
|
12
12
|
depositSponsored,
|
|
13
|
+
readStuckBalance,
|
|
14
|
+
sweepStuckBalance,
|
|
13
15
|
withdrawSponsored
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-5W56YOBO.js";
|
|
15
17
|
import "./chunk-AURO3C3R.js";
|
|
16
18
|
|
|
17
19
|
// src/agents/surfliquid/surfliquid.agent.ts
|
|
@@ -259,10 +261,16 @@ function createSurfBroker(options) {
|
|
|
259
261
|
}
|
|
260
262
|
|
|
261
263
|
// src/agents/surfliquid/surfliquid.mapper.ts
|
|
264
|
+
var SURFLIQUID_PROTOCOL = "Morpho";
|
|
265
|
+
var DEPOSIT_TRANSACTION_TYPES = /* @__PURE__ */ new Set([
|
|
266
|
+
"INITIAL_DEPOSIT",
|
|
267
|
+
"DEPOSIT",
|
|
268
|
+
"USER_DEPOSIT"
|
|
269
|
+
]);
|
|
262
270
|
function mapMessage(message) {
|
|
263
271
|
const action = SURFLIQUID_ACTION_MAP[message.transactionType];
|
|
264
|
-
if (!action) return
|
|
265
|
-
|
|
272
|
+
if (!action) return [];
|
|
273
|
+
const base2 = {
|
|
266
274
|
agent: "surfliquid",
|
|
267
275
|
action,
|
|
268
276
|
date: message.timestamp,
|
|
@@ -278,9 +286,27 @@ function mapMessage(message) {
|
|
|
278
286
|
],
|
|
279
287
|
rebalanceLog: []
|
|
280
288
|
};
|
|
289
|
+
if (DEPOSIT_TRANSACTION_TYPES.has(message.transactionType) && message.toVault?.name && message.amount != null) {
|
|
290
|
+
return [
|
|
291
|
+
base2,
|
|
292
|
+
{
|
|
293
|
+
...base2,
|
|
294
|
+
action: "Deposit",
|
|
295
|
+
positions: [
|
|
296
|
+
{
|
|
297
|
+
protocol: SURFLIQUID_PROTOCOL,
|
|
298
|
+
pool: message.toVault.name,
|
|
299
|
+
tokenSymbol: message.token ?? void 0,
|
|
300
|
+
amount: String(message.amount)
|
|
301
|
+
}
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
];
|
|
305
|
+
}
|
|
306
|
+
return [base2];
|
|
281
307
|
}
|
|
282
308
|
function mapHistory(result, _chainId) {
|
|
283
|
-
const data = result.messages.
|
|
309
|
+
const data = result.messages.flatMap(mapMessage);
|
|
284
310
|
const hasMore = result.page < result.pages;
|
|
285
311
|
return {
|
|
286
312
|
data,
|
|
@@ -533,7 +559,7 @@ var SurfLiquidAgent = class {
|
|
|
533
559
|
}
|
|
534
560
|
}
|
|
535
561
|
async sponsoredWallet(state) {
|
|
536
|
-
const { createSponsoredWallet } = await import("./surfliquid.smart-account-
|
|
562
|
+
const { createSponsoredWallet } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
537
563
|
return createSponsoredWallet({
|
|
538
564
|
provider: state.provider,
|
|
539
565
|
ownerAddress: state.walletAddress,
|
|
@@ -555,7 +581,7 @@ var SurfLiquidAgent = class {
|
|
|
555
581
|
async deposit(state, _chainId, amount, _asset, _depositCallback) {
|
|
556
582
|
const broker = await this.connect(state);
|
|
557
583
|
const wallet = await this.sponsoredWallet(state);
|
|
558
|
-
const { createSponsoredChain } = await import("./surfliquid.smart-account-
|
|
584
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
559
585
|
try {
|
|
560
586
|
const { txHash, vault } = await this.withSession(
|
|
561
587
|
state,
|
|
@@ -570,7 +596,7 @@ var SurfLiquidAgent = class {
|
|
|
570
596
|
async withdraw(state, _chainId, _token, amount) {
|
|
571
597
|
const broker = await this.connect(state);
|
|
572
598
|
const wallet = await this.sponsoredWallet(state);
|
|
573
|
-
const { createSponsoredChain } = await import("./surfliquid.smart-account-
|
|
599
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
574
600
|
try {
|
|
575
601
|
const result = await this.withSession(
|
|
576
602
|
state,
|
|
@@ -587,6 +613,24 @@ var SurfLiquidAgent = class {
|
|
|
587
613
|
throw toOwneyError(error);
|
|
588
614
|
}
|
|
589
615
|
}
|
|
616
|
+
/** Funds a prior withdrawal's sweep left in the smart account (never reached the EOA). No session needed — pure read. */
|
|
617
|
+
async getStuckBalance(state) {
|
|
618
|
+
const wallet = await this.sponsoredWallet(state);
|
|
619
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
620
|
+
const amount = await readStuckBalance({ chain: createSponsoredChain(this.config.rpcUrl), wallet });
|
|
621
|
+
return { amount: amount.toString(), smartAccountAddress: wallet.smartAccountAddress };
|
|
622
|
+
}
|
|
623
|
+
/** Sweep the stranded balance to the owner's EOA — one sponsored userOp, one signature. */
|
|
624
|
+
async recoverStuckBalance(state) {
|
|
625
|
+
const wallet = await this.sponsoredWallet(state);
|
|
626
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
627
|
+
try {
|
|
628
|
+
const { txHash, amount } = await sweepStuckBalance({ chain: createSponsoredChain(this.config.rpcUrl), wallet });
|
|
629
|
+
return { txHash, type: "full", amount: amount.toString() };
|
|
630
|
+
} catch (error) {
|
|
631
|
+
throw toOwneyError(error);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
590
634
|
// --- IAgent: portfolio reads ---
|
|
591
635
|
async vault(state) {
|
|
592
636
|
const broker = await this.connect(state);
|