I am trying to perform a cryptocurrency swap, but I am facing challenges due to the nested Gnosis Safe wallet setup. Here's the situation:
Wallet Setup:
Main Wallet:
A Gnosis Safe smart contract wallet containing the cryptocurrencies to be swapped.
Owners:
- api wallet (another Gnosis Safe).
- admin wallet (an EOA). Requires both owners (api and admin) to sign transactions.
API Wallet:
A Gnosis Safe wallet programmatically used for signing transactions.
Owners: Two EOAs with known public/private keys (EOA1 and EOA2). Requires both EOA1 and EOA2 to sign transactions. 
Problem:
I want to execute a crypto swap (e.g., using Sushiswap or similar) from the Main Wallet, but the nested nature of the wallets creates complications:
The Main Wallet requires a valid signature from the API Wallet, which in turn requires valid signatures from both EOA1 and EOA2. The backend has access to the private keys of EOA1 and EOA2 but no funds to cover transaction fees for signing operations directly.
Existing Work / Research:
My understanding of the problem so far is:
- I need to create a transaction that is signed by both EOA1 and EOA2.
- This signed transaction must be packaged as an argument for another transaction submitted by the API Wallet.
- Finally, this nested transaction should be included within the swap transaction submitted by the Main Wallet to the network.
I am exploring how to implement this flow programmatically in Go while minimizing gas fees and ensuring the security of the wallet hierarchy.
Questions:
- How can I structure the signing process to handle this nested wallet hierarchy efficiently?
- Can the API Wallet sign and relay the transaction without involving gas fees for the individual EOAs?
- Are there any tools, libraries, or best practices for working with such nested Gnosis Safe setups in a backend system (e.g., in Go)?
Environment:
- Backend: Go
- Swapping service: 1inch, Sushiswap or other decentralized exchange
- Wallet setup: Gnosis Safe with multiple owners
Any guidance on how to resolve this would be greatly appreciated!