Skip to content

feat: enable dynamic Mainnet support for Soroban liquidity and staking tools#53

Merged
daiwikmh merged 1 commit into
Stellar-Tools:mainfrom
lohit-40:feat/mainnet-dynamic-network-support
Apr 16, 2026
Merged

feat: enable dynamic Mainnet support for Soroban liquidity and staking tools#53
daiwikmh merged 1 commit into
Stellar-Tools:mainfrom
lohit-40:feat/mainnet-dynamic-network-support

Conversation

@lohit-40

@lohit-40 lohit-40 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

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.ts

  • Added optional SorobanContractConfig param to all functions (deposit, swap, withdraw, getReserves, stake, unstake, claimRewards, getStake)
  • Allows overriding network, RPC URL, and contract address at runtime

tools/contract.ts & tools/stake.ts

  • Read STELLAR_NETWORK and SOROBAN_RPC_URL from environment variables
  • Added optional contractAddress to tool schemas for mainnet overrides

agent.ts

  • Forwards STELLAR_NETWORK and SOROBAN_RPC_URL env vars to the agent

Backward Compatibility

  • Defaults to testnet if STELLAR_NETWORK is not set — existing users unaffected
  • Mainnet usage: set STELLAR_NETWORK=mainnet + SOROBAN_RPC_URL=https://soroban-mainnet.stellar.org

Summary 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: Added SorobanContractConfig to all functions to override network, rpcUrl, and contractAddress; added optional simulate mode; enforces explicit contractAddress on Mainnet.
    • lib/stakeF.ts: Same config support for initialize, stake, unstake, claimRewards, getStake; requires contractAddress on Mainnet.
    • tools/contract.ts and tools/stake.ts: Read STELLAR_NETWORK and SOROBAN_RPC_URL; added optional contractAddress to tool schemas; pass config to all actions.
    • agent.ts: Forwards STELLAR_NETWORK/SOROBAN_RPC_URL; liquidity methods accept optional contractAddress; getReserves/getShareId now allow contract overrides.
  • Migration

    • Testnet: no changes needed.
    • Mainnet: set STELLAR_NETWORK=mainnet and SOROBAN_RPC_URL=https://soroban-mainnet.stellar.org; provide the target contractAddress via tools or agent params.

Written for commit c149507. Summary will update on new commits.

…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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

@daiwikmh daiwikmh merged commit 52d2cf9 into Stellar-Tools:main Apr 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants