@owney/sdk 0.7.22-beta.1 → 0.7.22-beta.2
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 +63 -1
- 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-E54CPWXF.js} +24 -4
- 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
|
@@ -803,6 +803,17 @@ async function permitIfShort(input) {
|
|
|
803
803
|
s
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
|
+
async function readStuckBalance(input) {
|
|
807
|
+
return input.chain.usdcBalanceOf(input.wallet.smartAccountAddress);
|
|
808
|
+
}
|
|
809
|
+
async function sweepStuckBalance(input) {
|
|
810
|
+
const stranded = await readStuckBalance(input);
|
|
811
|
+
if (stranded === 0n) return { amount: 0n };
|
|
812
|
+
const txHash = await input.wallet.sendCalls(
|
|
813
|
+
buildSweepCalls({ owner: input.wallet.ownerAddress, amount: stranded })
|
|
814
|
+
);
|
|
815
|
+
return { txHash, amount: stranded };
|
|
816
|
+
}
|
|
806
817
|
async function depositSponsored(input) {
|
|
807
818
|
const { api, chain, wallet, amount } = input;
|
|
808
819
|
const { vault, deploySalt, registerAfterDeposit } = await resolveVault(input);
|
|
@@ -849,7 +860,15 @@ async function withdrawSponsored(input) {
|
|
|
849
860
|
if (owner.toLowerCase() !== wallet.smartAccountAddress.toLowerCase()) {
|
|
850
861
|
throw new VaultNotSponsorableError(`SurfLiquid vault ${vault} is not owned by the smart account`);
|
|
851
862
|
}
|
|
852
|
-
|
|
863
|
+
let withdrawHash;
|
|
864
|
+
try {
|
|
865
|
+
withdrawHash = await wallet.sendCalls(buildWithdrawCalls({ vault, amount }));
|
|
866
|
+
} catch (redeemError) {
|
|
867
|
+
const stranded = await chain.usdcBalanceOf(wallet.smartAccountAddress);
|
|
868
|
+
if (stranded === 0n) throw redeemError;
|
|
869
|
+
const sweepHash = await wallet.sendCalls(buildSweepCalls({ owner: wallet.ownerAddress, amount: stranded }));
|
|
870
|
+
return { txHash: sweepHash, amount: stranded.toString() };
|
|
871
|
+
}
|
|
853
872
|
try {
|
|
854
873
|
const proceeds = await chain.usdcBalanceOf(wallet.smartAccountAddress);
|
|
855
874
|
if (proceeds === 0n) return { txHash: withdrawHash, amount: "0" };
|
|
@@ -1266,6 +1285,24 @@ var init_surfliquid_agent = __esm({
|
|
|
1266
1285
|
throw toOwneyError(error);
|
|
1267
1286
|
}
|
|
1268
1287
|
}
|
|
1288
|
+
/** Funds a prior withdrawal's sweep left in the smart account (never reached the EOA). No session needed — pure read. */
|
|
1289
|
+
async getStuckBalance(state) {
|
|
1290
|
+
const wallet = await this.sponsoredWallet(state);
|
|
1291
|
+
const { createSponsoredChain: createSponsoredChain2 } = await Promise.resolve().then(() => (init_surfliquid_smart_account(), surfliquid_smart_account_exports));
|
|
1292
|
+
const amount = await readStuckBalance({ chain: createSponsoredChain2(this.config.rpcUrl), wallet });
|
|
1293
|
+
return { amount: amount.toString(), smartAccountAddress: wallet.smartAccountAddress };
|
|
1294
|
+
}
|
|
1295
|
+
/** Sweep the stranded balance to the owner's EOA — one sponsored userOp, one signature. */
|
|
1296
|
+
async recoverStuckBalance(state) {
|
|
1297
|
+
const wallet = await this.sponsoredWallet(state);
|
|
1298
|
+
const { createSponsoredChain: createSponsoredChain2 } = await Promise.resolve().then(() => (init_surfliquid_smart_account(), surfliquid_smart_account_exports));
|
|
1299
|
+
try {
|
|
1300
|
+
const { txHash, amount } = await sweepStuckBalance({ chain: createSponsoredChain2(this.config.rpcUrl), wallet });
|
|
1301
|
+
return { txHash, type: "full", amount: amount.toString() };
|
|
1302
|
+
} catch (error) {
|
|
1303
|
+
throw toOwneyError(error);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1269
1306
|
// --- IAgent: portfolio reads ---
|
|
1270
1307
|
async vault(state) {
|
|
1271
1308
|
const broker = await this.connect(state);
|
|
@@ -5027,6 +5064,31 @@ var OwneySDK = class {
|
|
|
5027
5064
|
}
|
|
5028
5065
|
return { agentResult: results, totalWithdrawn: withdrawn.toString() };
|
|
5029
5066
|
}
|
|
5067
|
+
/**
|
|
5068
|
+
* Funds a prior withdrawal left stranded in the agent's smart account (the
|
|
5069
|
+
* payout leg never reached the owner's EOA). Read-only — check once after
|
|
5070
|
+
* connect. Agents without a smart account model report "0".
|
|
5071
|
+
*/
|
|
5072
|
+
async getStuckBalance(agentId) {
|
|
5073
|
+
const state = this.requireState();
|
|
5074
|
+
const chainId = this.requireChainId();
|
|
5075
|
+
const agent = this.getAgent(agentId);
|
|
5076
|
+
if (!agent.getStuckBalance) return { amount: "0", smartAccountAddress: "" };
|
|
5077
|
+
return agent.getStuckBalance(state, chainId);
|
|
5078
|
+
}
|
|
5079
|
+
/** Sweep that stranded balance to the owner's EOA — one signature. No-op ("0") when nothing is stuck. */
|
|
5080
|
+
async recoverStuckBalance(agentId) {
|
|
5081
|
+
const state = this.requireState();
|
|
5082
|
+
const chainId = this.requireChainId();
|
|
5083
|
+
const agent = this.getAgent(agentId);
|
|
5084
|
+
if (!agent.recoverStuckBalance) return { type: "full", amount: "0" };
|
|
5085
|
+
return withFailureReporting(
|
|
5086
|
+
this.apiKey,
|
|
5087
|
+
agent.id,
|
|
5088
|
+
() => agent.recoverStuckBalance(state, chainId),
|
|
5089
|
+
this.routingApiBaseUrl
|
|
5090
|
+
);
|
|
5091
|
+
}
|
|
5030
5092
|
// --- Portfolio reads ---
|
|
5031
5093
|
/**
|
|
5032
5094
|
* 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-E54CPWXF.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
|
|
@@ -533,7 +535,7 @@ var SurfLiquidAgent = class {
|
|
|
533
535
|
}
|
|
534
536
|
}
|
|
535
537
|
async sponsoredWallet(state) {
|
|
536
|
-
const { createSponsoredWallet } = await import("./surfliquid.smart-account-
|
|
538
|
+
const { createSponsoredWallet } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
537
539
|
return createSponsoredWallet({
|
|
538
540
|
provider: state.provider,
|
|
539
541
|
ownerAddress: state.walletAddress,
|
|
@@ -555,7 +557,7 @@ var SurfLiquidAgent = class {
|
|
|
555
557
|
async deposit(state, _chainId, amount, _asset, _depositCallback) {
|
|
556
558
|
const broker = await this.connect(state);
|
|
557
559
|
const wallet = await this.sponsoredWallet(state);
|
|
558
|
-
const { createSponsoredChain } = await import("./surfliquid.smart-account-
|
|
560
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
559
561
|
try {
|
|
560
562
|
const { txHash, vault } = await this.withSession(
|
|
561
563
|
state,
|
|
@@ -570,7 +572,7 @@ var SurfLiquidAgent = class {
|
|
|
570
572
|
async withdraw(state, _chainId, _token, amount) {
|
|
571
573
|
const broker = await this.connect(state);
|
|
572
574
|
const wallet = await this.sponsoredWallet(state);
|
|
573
|
-
const { createSponsoredChain } = await import("./surfliquid.smart-account-
|
|
575
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
574
576
|
try {
|
|
575
577
|
const result = await this.withSession(
|
|
576
578
|
state,
|
|
@@ -587,6 +589,24 @@ var SurfLiquidAgent = class {
|
|
|
587
589
|
throw toOwneyError(error);
|
|
588
590
|
}
|
|
589
591
|
}
|
|
592
|
+
/** Funds a prior withdrawal's sweep left in the smart account (never reached the EOA). No session needed — pure read. */
|
|
593
|
+
async getStuckBalance(state) {
|
|
594
|
+
const wallet = await this.sponsoredWallet(state);
|
|
595
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
596
|
+
const amount = await readStuckBalance({ chain: createSponsoredChain(this.config.rpcUrl), wallet });
|
|
597
|
+
return { amount: amount.toString(), smartAccountAddress: wallet.smartAccountAddress };
|
|
598
|
+
}
|
|
599
|
+
/** Sweep the stranded balance to the owner's EOA — one sponsored userOp, one signature. */
|
|
600
|
+
async recoverStuckBalance(state) {
|
|
601
|
+
const wallet = await this.sponsoredWallet(state);
|
|
602
|
+
const { createSponsoredChain } = await import("./surfliquid.smart-account-O6YPCQT3.js");
|
|
603
|
+
try {
|
|
604
|
+
const { txHash, amount } = await sweepStuckBalance({ chain: createSponsoredChain(this.config.rpcUrl), wallet });
|
|
605
|
+
return { txHash, type: "full", amount: amount.toString() };
|
|
606
|
+
} catch (error) {
|
|
607
|
+
throw toOwneyError(error);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
590
610
|
// --- IAgent: portfolio reads ---
|
|
591
611
|
async vault(state) {
|
|
592
612
|
const broker = await this.connect(state);
|