rethink.finance
  • Getting Started
    • Welcome
    • Rethinking Vaults
  • dApp
    • Overview
  • Protocol
    • Architecture
      • Admin Contract
        • Flows
          • V1.0 Flows
          • V2.0 Flows
        • Fees
          • Performance Fee
          • Management Fee
          • Deposit Fee
          • Redemption Fee
      • NAV Calculator Contract
        • NAV Liquid Spot
        • NAV Illiquid
        • NAV DeFi Composable
        • NAV Methods Library
    • Security
    • Integrations
  • Execution
    • Manual
    • Algo/AI
  • Community
    • Closed Beta
  • Policies
    • Terms of Service
    • Privacy Policy
  • Links
    • GitHub
    • Discord
    • X
Powered by GitBook
On this page
  • Integration Approach
  • Technical Implementation:
  • Data Storage and Configuration
  • Psuecode of Intergration
  1. Execution

Algo/AI

PreviousManualNextClosed Beta

Last updated 1 month ago

Integration Approach

  • User creates a vault via rethink.finance

  • User grants their script specific permissions

  • User script executes trades through the vaults contract

Technical Implementation:

  • Route all transaction calls through the vault's Roles Modifier

  • All transaction execution will use the execTransactionWithRole function on the role modifier contract

    • ABI:

    • execTransactionWithRole def:

  • Your bot will only have permission to execute specific trading functions with predefined parameter limits

Data Storage and Configuration

  • Store vault contract address and role ID directly in the users AWS instance (env or parameter store, or in script directly)

Psuecode of Intergration

# 1. Build the transaction data using SDK
w3 = Web3()
sdk = GainsTradingSDK()
tx_data = sdk.build.openTrade(trade_params_here)

# 2. Create role modifier contract instance
role_modifier = w3.eth.contract(
    address=QIV_ROLE_MODIFIER,  # Obtained during the user onboarding process
    abi=ROLE_MODIFIER_ABI  # We just have this file
)

# 3. Execute through vault's role modifier
tx = role_modifier.functions.execTransactionWithRole(
    tx_data.to,  # G-Trade address
    0,  # No ETH value
    tx_data.data,  # Trading function data
    0,  # Call (not delegatecall)
    ROLE_ID,  # Obtained during the user onboarding process
    True
).build_transaction({
    'from': "some_address",
    'gas': 2000000,
    'nonce': "some_nonce"
})

# 4. Sign
signed_tx = w3.eth.account.sign_transaction(tx, "some_private_key")
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)

Roles Modifier
https://raw.githubusercontent.com/rethink-finance/rethink-frontend/refs/heads/main/src/contracts/zodiac/RolesFull.json
https://github.com/gnosisguild/zodiac-modifier-roles-v1/blob/main/packages/evm/contracts/Roles.sol#L364-L378