Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batcher contract - revisit Notification and Activity #139

Open
ashachaf opened this issue Jan 22, 2025 · 1 comment
Open

Batcher contract - revisit Notification and Activity #139

ashachaf opened this issue Jan 22, 2025 · 1 comment
Labels
prioritized Belongs to the top 5 issues to solve next

Comments

@ashachaf
Copy link
Collaborator

ashachaf commented Jan 22, 2025

Goal

when a caller is using the batcher contract to create multiple strategies in a single transaction, the create event will indicate the strategy owner/creator as the batcher contract.
we would like to identify these cases and change the owner to be the transaction caller instead.

Notification

in the notification service, we would need to update the owner information we use in the message (deep link in the URL)

Activity

in the activity, we would need to update the owner information on the create event in order to allocate the create action to the correct wallet.

Conditions

The event we track:

StrategyCreated (uint256 id, index_topic_1 address owner, index_topic_2 address token0, index_topic_3 address token1, tuple order0, tuple order1)

This is the condition we would like to apply:
IF StrategyCreated.owner = batcherContract, use transaction caller (not part of the event).

Batcher address

TBA - contract not live yet.

Tenderly example

https://dashboard.tenderly.co/bancor/ivan-test-forks/testnet/1671fd5d-50b5-4f51-ac16-e47cc165e460/tx/mainnet/0xeab5deda923beeb7ee85e7e93abc0d7029440c173cc85554ce0bad37894a7c92/logs

This transaction created 3 strategies using the batcher contract.
The flow of events include StrategyCreated which is followed by a Transfer of the new strategy from the batcher contract to the caller.

StrategyCreated event:

{
"id":"3402823669209384634633746074317682116040"
"owner":"0x03ede52e1174be0956f3d3e0e86e05626974bee2"
"token0":"0x6982508145454ce325ddbe47a25d4ec3d2311933"
"token1":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
"order0":{
"y":"2222222222000000000000000000"
"z":"4478653084740035463915094378"
"A":6352358218145472
"B":8143043674990641
}
"order1":{
"y":"35702458847"
"z":"71197811364"
"A":10657
"B":1116398
}
}

as we can see, the owner is the batcher contract address.

Transfer event:

{
"from":"0x03ede52e1174be0956f3d3e0e86e05626974bee2"
"to":"0xf977814e90da44bfa03b6295a0616a897441acec"
"tokenId":"3402823669209384634633746074317682116040"
}

The recipient of this event is the actual creator of the strategy.

Expected results

Current indication:
StrategyCreated.owner is the creator.

updated indication:
IF StrategyCreated.owner = batcher contract, use Transfer.to address as the creator.

@ashachaf ashachaf changed the title Notification - handle batcher contract Batcher contract - revisit Notification and Activity Jan 22, 2025
@NIXBNT
Copy link
Collaborator

NIXBNT commented Jan 23, 2025

My suggestion is that we track the "StrategiesCreated" Event that is emitted from the Batcher and then replace the owner by joining on the txhash.
This would be more consistent with the logic we use in the backend.
It would match the implementation on Dune.
And it requires no knowledge of the Batcher address allowing it to be future-proof for new contract deployments.

The implementation would look similar to this:

WITH batcher_events AS (
    SELECT 
        "transactionHash",
        owner as real_owner,
        UNNEST("strategyIds") AS id -- Expand the array into individual stratid values
    FROM "strategies-created-events" -- New backend table from Batcher
)
SELECT sc."blockNumber", sc.token0, sc.token1, sc.id, -- list relevant strategy-created-event columns here
    CASE WHEN real_owner is NULL THEN sc.owner else b.real_owner END as owner,
    sc."transactionHash"
FROM "strategy-created-events" sc
LEFT JOIN batcher_events b on b.id = sc.id AND b."transactionHash" = sc."transactionHash"

@ashachaf ashachaf added the prioritized Belongs to the top 5 issues to solve next label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prioritized Belongs to the top 5 issues to solve next
Projects
None yet
Development

No branches or pull requests

2 participants