-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic tenderly action triggered by settlement events (#181)
- Loading branch information
Showing
7 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Internal Transfers | ||
|
||
|
||
## Motivation & Summary | ||
Internal Settlements have been a challenge to evaluate slippage since some information | ||
required for the computation never winds up on chain. | ||
Specifically, when the driver decides to internalize an interaction provided by a solver, | ||
the interaction is excluded from the settlement call data. | ||
In order to recover this data we must make token transfers (or imbalances) from | ||
internalized interactions transparently available for consumption. | ||
|
||
This project replaces the subquery | ||
[buffer_trades](https://github.com/cowprotocol/solver-rewards/blob/c7e9c85706decb1a1be28d639ee34e35646bca50/queries/dune_v2/period_slippage.sql#L239-L309) | ||
(an approximation for internal interactions implemented purely within Dune Analytics) with the actual internalized data. | ||
|
||
In brief, the project consists of a Data Pipeline implementing the following flow; | ||
|
||
1. WebHook/Event Listener for CoW Protocol Settlement Events emitted by [CoW Protocol: GPv2Settlement](https://etherscan.io/address/0x9008d19f58aabd9ed0d60971565aa8510560ab41) | ||
2. Settlement Events trigger an ETL Pipeline that | ||
- Fetches full/unoptimized call data provided by the solver for the winning settlement from the [Orderbook API](https://api.cow.fi/docs/#) | ||
- Simulates the full call data extracting and classifying transfers from event logs | ||
- Evaluates the `InternalizedLedger` as the difference `FullLedger - ActualLedger` | ||
3. Finally, the `InternalizedLedger` from step 2 is written to a [Database](./database/README.md) and later synced into Dune community sources. | ||
|
||
For more Details on each component outlined above please visit respective readmes: | ||
|
||
|
||
## [Webhook] Tenderly Actions | ||
|
||
Documentation: https://tenderly.co/web3-actions | ||
Requirements: [Tenderly CLI](https://github.com/Tenderly/tenderly-cli) | ||
|
||
actions directory was scaffolded and deployed as follows: | ||
|
||
```shell | ||
tenderly actions init --language typescript | ||
tenderly actions deploy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Dependency directories | ||
node_modules/ | ||
|
||
# Ignore tsc output | ||
out/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { | ||
ActionFn, | ||
Context, | ||
Event, | ||
TransactionEvent, | ||
} from '@tenderly/actions'; | ||
|
||
export const triggerInternalTransfersPipeline: ActionFn = async ( | ||
context: Context, | ||
event: Event | ||
) => { | ||
const transactionEvent = event as TransactionEvent; | ||
const txHash = transactionEvent.hash; | ||
console.log(`Received Settlement Event with txHash ${txHash}`); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "actions", | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^4.3.5" | ||
}, | ||
"dependencies": { | ||
"@tenderly/actions": "^0.1.0" | ||
}, | ||
"private": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"noImplicitReturns": true, | ||
"noUnusedLocals": true, | ||
"outDir": "out", | ||
"sourceMap": true, | ||
"strict": true, | ||
"target": "es2020" | ||
}, | ||
"exclude": [ | ||
"**/*.spec.ts" | ||
], | ||
"include": [ | ||
"**/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
actions: | ||
gp-v2/solver-slippage: | ||
runtime: v2 | ||
sources: actions | ||
specs: | ||
settlement-event-trigger: | ||
description: Trigger Data Pipeline for each Settlement event. | ||
function: index:triggerInternalTransfersPipeline | ||
trigger: | ||
type: transaction | ||
transaction: | ||
status: | ||
- mined | ||
filters: | ||
- network: 1 | ||
eventEmitted: | ||
contract: | ||
address: 0x9008D19f58AAbD9eD0D60971565AA8510560ab41 | ||
name: Settlement |