Algo/AI
Integration Approach
User creates a vault via rethink.finance
User grants their script specific permissions
User script executes trades through the vaults Roles Modifier 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 contractexecTransactionWithRole
def: https://github.com/gnosisguild/zodiac-modifier-roles-v1/blob/main/packages/evm/contracts/Roles.sol#L364-L378
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)
Last updated