Skip to content

Conversation

@hitarthkhurana
Copy link

Summary

Implements 6 ecosystem connectors for the Flare AI Kit, enabling AI agents to interact with major DeFi protocols on Flare Network.

Closes #28

Connectors Added

1. SparkDEX (Uniswap V3 Fork DEX)

  • Swap any ERC20 token to any other (exactInputSingle, exactOutputSingle)
  • Supports multiple fee tiers (0.05%, 0.3%, 1%)
  • ✅ Tested: Swapped 0.05 FLR → WFLR on mainnet

2. Sceptre (Liquid Staking)

  • Stake FLR → sFLR, request/claim withdrawals
  • Query balances, rates, total pooled FLR
  • ✅ Tested: Staked 0.05 FLR on mainnet

3. Kinetic (Lending Protocol)

  • Supply/redeem sFLR ↔ ksFLR
  • Query balances, exchange rates
  • ✅ Tested: Supplied 0.03 sFLR on mainnet

4. Cyclo (Liquidation-Free Leverage)

  • Deposit/redeem sFLR ↔ cysFLR (ERC1155 vault)
  • Query balances, total assets
  • ✅ Tested: Deposited 0.2 sFLR on mainnet

5. Firelight (XRP Staking + DeFi Cover) ⭐ Bonus

  • Stake FXRP → stXRP with period-based vesting
  • Request/claim withdrawals, query balances
  • Code complete (vault at capacity during testing)

6. Stargate (Cross-Chain Bridge)

  • Info-only connector for AI agents
  • Get OFT addresses (ETH, USDC, USDT) and LayerZero endpoints
  • Supports 10+ destination chains

Critical Bug Fixes

Fixed several issues in base Flare class discovered during testing:

  1. SecretStr unwrapping - Fixed transaction signing TypeError
  2. Missing await - Added to all .call() query methods
  3. Transaction refactoring - All connectors use base class methods
  4. Payable functions - Added value parameter support
  5. Cyclo parameters - Fixed min_share_ratio default

All connectors tested with real mainnet transactions.

Files Changed

New: 6 connector files + 5 ABI files + 5 examples
Modified: flare.py, __init__.py, api.py, README.md

All connectors follow consistent patterns: async init, transaction methods, query methods, comprehensive error handling.

- Add SparkDEX connector for token swaps on Flare
- Implement swap_exact_input_single and swap_exact_output_single
- Update SparkDEXRouter ABI to V3 (Uniswap V3 compatible)
- Add comprehensive unit tests (11 tests, all passing)
- Add example script and documentation
- Export SparkDEX from ecosystem.api

Closes flare-foundation#28 (partial - SparkDEX connector)
Cyclo (Non-liquidating leverage):
- Add Cyclo connector for sFLR vault (cysFLR)
- Implement deposit_sflr() and redeem_sflr() operations
- Add balance query functions for cysFLR and receipt NFTs
- Include ABIs for CycloVaultSFLR and CycloReceiptSFLR contracts
- Add unit tests for core functionality
- Add example (09_cyclo_leverage.py) and documentation
- Export Cyclo from ecosystem.api

SparkDEX:
- Rename sparkdex_swap.py to 08_sparkdex_swap.py (follow numbering convention)

Cyclo allows users to lock collateral without liquidation risk.
Related to flare-foundation#28 (partial - Cyclo connector)
- Add Sceptre connector for FLR liquid staking (stake FLR → sFLR)
- Implement stake_flr(), request_withdrawal(), claim_withdrawal()
- Add balance and conversion rate queries (5 query functions)
- Include ABI for Sceptre sFLR contract
- Add 5 unit tests (initialization, balance, conversions)
- Add example (10_sceptre_staking.py) and documentation
- Export Sceptre from ecosystem.api

Sceptre allows users to stake FLR and receive liquid sFLR tokens
that can be used in DeFi while earning staking rewards.
Cooldown period: ~14.5 days for withdrawals.

Related to flare-foundation#28 (partial - Sceptre connector)
- Add Kinetic class for ksFLR market operations
- Implement supply(), redeem(), and balance query methods
- Add get_exchange_rate() and get_supply_rate() for market info
- Include comprehensive unit tests (5 tests, all passing)
- Add example script (11_kinetic_lending.py) demonstrating usage
- Add detailed documentation (kinetic_readme.md)
- Export Kinetic from ecosystem.applications and ecosystem.api
- Add Firelight class for stXRP vault operations
- Implement stake_xrp(), request_withdrawal(), and claim_withdrawal()
- Add balance and period query methods
- Include comprehensive unit tests (5 tests, all passing)
- Add example script (12_firelight_xrp_staking.py) with XRP staking demo
- Add detailed documentation (firelight_readme.md)
- Export Firelight from ecosystem.applications and ecosystem.api

XRP to the moon! 🚀
- Add Stargate class for bridge information and chain endpoints
- Implement OFT token address lookup (ETH, USDC, USDT)
- Add destination chain endpoint ID mapping (10 chains)
- Include comprehensive unit tests (6 tests, all passing)
- Add example script (13_stargate_bridge.py) with bridge info demo
- Add detailed documentation (stargate_readme.md)
- Export Stargate from ecosystem.applications and ecosystem.api

Bridge all the things! 🌉
…tors

- Fix base Flare class to properly unwrap SecretStr for private keys
- Add value parameter to build_transaction for payable functions
- Fix missing await on all .call() query methods across all connectors
- Refactor transaction methods to use base class build_transaction/sign_and_send_transaction
- Fix Cyclo min_share_ratio default (0 -> 1) for successful deposits
- Add Firelight implementation ABI for complete vault interface
- Update ecosystem __init__ to export all connector classes

Tested with real transactions on Flare mainnet:
- SparkDEX: token swaps working
- Sceptre: FLR staking working
- Kinetic: sFLR supply working
- Cyclo: sFLR deposits working
- Firelight: code complete (vault at capacity for testing)
- Stargate: info-only connector as designed
@hitarthkhurana
Copy link
Author

Closing to reopen with proper feature branch

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.

[Ecosystem Engine] Develop Connectors for Sceptre, OpenOcean, SparkDEX, Kinetic, Stargate and Cyclo

1 participant