feat: add StellarClaimBalanceTool for automated fund recovery#33
Open
efekrbas wants to merge 9 commits intoStellar-Tools:mainfrom
Open
feat: add StellarClaimBalanceTool for automated fund recovery#33efekrbas wants to merge 9 commits intoStellar-Tools:mainfrom
efekrbas wants to merge 9 commits intoStellar-Tools:mainfrom
Conversation
There was a problem hiding this comment.
3 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/claimF.ts">
<violation number="1" location="lib/claimF.ts:4">
P1: Horizon endpoint default (Testnet) can conflict with PUBLIC network passphrase selection, causing network-mismatched transaction construction.</violation>
<violation number="2" location="lib/claimF.ts:7">
P2: `claim all` uses only the first fetched page of claimable balances, so additional balances may remain unclaimed.</violation>
</file>
<file name="tools/claim_balance_tool.ts">
<violation number="1" location="tools/claim_balance_tool.ts:15">
P2: The `claim` action is described as collecting funds, but it only builds and returns unsigned XDR without submitting on-chain, creating a misleading tool contract.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Contributor
|
resolve conflict errors |
b01dd65 to
cdd7371
Compare
Author
Hi, I've just resolved the conflicts. It should be ready for review now. |
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/claimF.ts">
<violation number="1" location="lib/claimF.ts:51">
P1: `claim all` builds a single transaction with unbounded operations, which can exceed Stellar transaction limits and fail for accounts with many claimable balances.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I have successfully implemented the
StellarClaimBalanceTooland its corresponding library helperclaimF.ts. This tool allows the AI agent to discover and claim pending assets (Claimable Balances) on the Stellar network for the user account.Technical Depth
DynamicStructuredToolwith a strictly defined Zod schema to ensure reliable agent interaction.@stellar/stellar-sdkto interact with Horizon'sclaimableBalancesendpoint and construct claim operations.stellarToolsarray.Impact
This contribution enhances the SDK's DeFi capabilities by automating the recovery of "stuck" or pending funds. Users no longer need to manually monitor for claimable balances; the agent can now proactively manage and collect these assets.
Summary by cubic
Adds
StellarClaimBalanceToolto list and claim Stellar claimable balances with safe batching, returning an unsigned XDR for claims. Also tightens the bridge with stricter mainnet gating, dynamic target-chain mapping, clearer params, unified XDR building, auto trustline setup with correct signing, and reorganized exports.New Features
StellarClaimBalanceToolusingDynamicStructuredTool+zod; supportslistandclaim; added tostellarToolsand exported from root.lib/claimF.tsadds Horizon pagination, caps batch claims to 50 ops per tx, fixes fee handling (baseFee.toString()), and builds single/batch claim txs with@stellar/stellar-sdk.fromNetwork(stellar-testnet/stellar-mainnet) with env safeguard, dynamictargetChainmapping, unified XDR builder, automatic trustline setup, corrected trustline signing, and clearertoAddressparam.tools/claim_balance_tool, export agent types (StellarAssetInput,QuoteSwapParams,RouteQuote,SwapBestRouteParams,SwapBestRouteResult), and includeStellarClaimBalanceToolinstellarTools.Migration
STELLAR_PUBLIC_KEY(required). Optional:HORIZON_URLandSTELLAR_NETWORK(PUBLICor defaults toTESTNET).allowMainnet: trueinAgentClientandALLOW_MAINNET_BRIDGE=truein.env.targetChain(defaults toethereum). Responses no longer includetargetChain.claimreturns an unsigned XDR; submit it via your signing/broadcast flow.Written for commit 1a1aa33. Summary will update on new commits.