feat: enable dynamic Mainnet support for Soroban liquidity and staking tools#53
Merged
daiwikmh merged 1 commit intoApr 16, 2026
Conversation
…g tools - Add optional SorobanContractConfig param to all lib/contract.ts functions (getShareId, deposit, swap, withdraw, getReserves) enabling dynamic network selection and contract address overrides at runtime - Add optional SorobanContractConfig param to all lib/stakeF.ts functions (initialize, stake, unstake, claimRewards, getStake) with same pattern - Update tools/contract.ts to read STELLAR_NETWORK and SOROBAN_RPC_URL from environment variables and propagate config through all tool actions. Add optional contractAddress field to tool schema for mainnet pool overrides. - Update tools/stake.ts with identical env-driven config propagation and optional contractAddress schema field for mainnet staking contracts. - Update agent.ts to read and forward STELLAR_NETWORK and SOROBAN_RPC_URL env vars ensuring the AI agent respects the configured network. Previously all Soroban operations were hardcoded to testnet RPC and contract addresses, making Mainnet usage impossible without code changes. This PR introduces a zero-breaking-change config layer that defaults to testnet behavior while enabling Mainnet via environment variables.
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.
Summary
This PR removes hardcoded testnet restrictions from the Soroban liquidity and staking tools, enabling Mainnet support via environment variables with zero breaking changes.
Changes
lib/contract.ts&lib/stakeF.tsSorobanContractConfigparam to all functions (deposit,swap,withdraw,getReserves,stake,unstake,claimRewards,getStake)tools/contract.ts&tools/stake.tsSTELLAR_NETWORKandSOROBAN_RPC_URLfrom environment variablescontractAddressto tool schemas for mainnet overridesagent.tsSTELLAR_NETWORKandSOROBAN_RPC_URLenv vars to the agentBackward Compatibility
testnetifSTELLAR_NETWORKis not set — existing users unaffectedSTELLAR_NETWORK=mainnet+SOROBAN_RPC_URL=https://soroban-mainnet.stellar.orgSummary by cubic
Enables dynamic Mainnet support for Soroban liquidity (LP/swap) and staking tools using environment-driven config. Testnet remains default; switch to Mainnet with env vars and optional contract overrides.
New Features
lib/contract.ts: AddedSorobanContractConfigto all functions to overridenetwork,rpcUrl, andcontractAddress; added optionalsimulatemode; enforces explicitcontractAddresson Mainnet.lib/stakeF.ts: Same config support forinitialize,stake,unstake,claimRewards,getStake; requirescontractAddresson Mainnet.tools/contract.tsandtools/stake.ts: ReadSTELLAR_NETWORKandSOROBAN_RPC_URL; added optionalcontractAddressto tool schemas; pass config to all actions.agent.ts: ForwardsSTELLAR_NETWORK/SOROBAN_RPC_URL; liquidity methods accept optionalcontractAddress;getReserves/getShareIdnow allow contract overrides.Migration
STELLAR_NETWORK=mainnetandSOROBAN_RPC_URL=https://soroban-mainnet.stellar.org; provide the targetcontractAddressvia tools or agent params.Written for commit c149507. Summary will update on new commits.