Skip to content

Conversation

@parthg1901
Copy link
Contributor

@parthg1901 parthg1901 commented Feb 22, 2025

This PR adds support for DeBridge to ZerePy

Approach
The main idea was to integrate DeBridge while keeping the other connection intact.

Changes made

  1. Fixes some errors in the EVM Connection and also some typos in the code.
  2. Adds DeBridge Connection allowing access to most of the API Endpoints.
  3. Adds a send-transaction action to Ethereum, Sonic, EVM & Solana Connection.
  4. Adds a TransactionHelper to recreate Submitting An Order In Solana for our workflow.
  5. Adds a get_address method to Sonic and Solana connection class

Tests performed

  1. Tested manually on Ethereum, Sonic and Base using an Anvil Fork. And it executed successfully.
  2. Could not test on Solana since I couldn’t fork it. I’m not very familiar with Solana, but it should work as most of the implementation reuses existing code.

Note: This is not a real transaction. It was sent on the anvil fork of ethereum.
image

Some changes that might be needed
I've added token approval checks for evm-based chains but I'm not sure what's the equivalent in Solana.

Usage in CLI

  1. agent-action debridge create-bridge-tx {connection} ...other params - Creates a transaction and saves the latest pending-tx into the DeBridgeConnection (similar to what the previous PR does).
  2. agent-action debridge execute-bridge-tx {connection} - Executes the transaction on the passed connection. Make sure its the same as your source chain.

Example -

agent-action debridge create-bridge-tx sonic 1000000
14 0x29219dd400f2bf60e5a23d13be72b486d4038894 10000000000000000000 1 0x000000000
0000000000000000000000000000000 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

{connection} can be "ethereum", "sonic", "solana" or "evm".

Thanks! Let me know if any fixes are required. Any suggestions for the solana integration would be helpful.

@parthg1901
Copy link
Contributor Author

@bussyjd I've made the suggested changes, and also added some code for handling transactions which have "allowanceTarget" and "allowanceValue".

Please have a look at it.
Thanks!

@parthg1901 parthg1901 requested a review from bussyjd February 23, 2025 05:59
@ayoubed ayoubed requested review from ef95023 and removed request for bussyjd February 24, 2025 16:12
@ef95023
Copy link
Collaborator

ef95023 commented Feb 25, 2025

howdy partner @parthg1901. this is tremendous work and we really appreciate it!

however, i do have some difficulties to comment upon. all of my attempts to create a bridge tx so far have failed, do you see any errors in the way that i am using it? here is one of the commands ive tried

action debridge create-bridge-tx evm 8453 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 10 137 0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619 0xFF6CBf6830C47
F683aC3227baD83c0BE5397A08F

i have tried different chain and token combinations, all with either unsupported token/chain errors or this other error

{
"errorCode": 12,
"errorId": "ERROR_LOW_GIVE_AMOUNT",
"errorMessage": "Given amount of input asset is too small to cover operational costs of Takers, cannot estimate reasonable outcome of an order",
"reqId": "4709ae65-8af4-48b7-b981-456f7700b7ab"
}

the wallet has 45 usdc in it, and i have tried values from 10 to 40. also tried starting with weth but it wouldnt accept decimal token amounts

i have only tried stablecoins and weth. let me know if im doing things wrong friend. thanks again

@parthg1901
Copy link
Contributor Author

parthg1901 commented Feb 25, 2025

hey @ef95023 , thanks for trying it out!

{ "errorCode": 12, "errorId": "ERROR_LOW_GIVE_AMOUNT", "errorMessage": "Given amount of input asset is too small to cover operational costs of Takers, cannot estimate reasonable outcome of an order", "reqId": "4709ae65-8af4-48b7-b981-456f7700b7ab" }

You're getting this error because you need to add the required zeros to srcChainTokenInAmount. Instead of using 10, you should use 10000000 for USDC. That should work.

and for the unexpected chain error, please check if you're using the internal chain ID which DeBridge requires.

Check this out.

So, for example - for sonic you need to use 100000014 instead of 146 (Should I just make a Dict for it?)

We could abstract "adding zeros" into our code, but I haven’t found a clean way to do it without making a mess.
If you have any suggestions, please let me know!

Note - Since you're using USDC, keep in mind that the first transaction you create and execute will be an approval transaction. You’ll need to create and execute another transaction afterward.

Also make sure your wallet has some native tokens for the DeBridge Flat Fees.

Please let me know if you run into any more issues.
Happy to contribute :D

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.

3 participants