Skip to content

Commit 0c2cb5d

Browse files
committed
add dune queries and update tenderly action flow
1 parent 20c5824 commit 0c2cb5d

File tree

9 files changed

+144
-43
lines changed

9 files changed

+144
-43
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
with bids as (
2+
SELECT
3+
Bidder as bidder,
4+
sum(amount) as bid_size
5+
FROM
6+
ipnft_{{chain}}.CrowdSale_evt_Bid
7+
WHERE
8+
saleId = cast('{{saleId}}' as uint256)
9+
GROUP BY
10+
Bidder,
11+
amount
12+
ORDER BY
13+
bid_size DESC
14+
),
15+
decimals as (
16+
SELECT erc20.decimals
17+
FROM
18+
(SELECT from_hex(json_extract_scalar(sale, '$.biddingToken')) as biddingTokenContract
19+
FROM
20+
ipnft_{{chain}}.CrowdSale_evt_Bid
21+
WHERE
22+
saleId = cast('{{saleId}}' as uint256)
23+
) as sale
24+
LEFT JOIN tokens.erc20 as erc20
25+
ON erc20.blockchain = '{{chain}}'
26+
AND erc20.contract_address = sale.biddingTokenContract
27+
)
28+
select
29+
Bidder,
30+
bid_size / pow(10, COALESCE(decimals,18)) as bid_amount
31+
FROM bids, decimals
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SELECT
2+
bids.evt_block_time,
3+
SUM(previous_bids.amount) / 1e18 AS cumulative_growth
4+
FROM
5+
ipnft_{{chain}}.Crowdsale_evt_Bid as bids
6+
LEFT JOIN ipnft_{{chain}}.CrowdSale_evt_Bid
7+
AS previous_bids
8+
ON previous_bids.evt_block_time <= bids.evt_block_time
9+
AND previous_bids.saleId = cast('{{saleId}}' as uint256)
10+
WHERE
11+
bids.saleId = cast('{{saleId}}' as uint256)
12+
GROUP BY
13+
bids.evt_block_time,
14+
bids.amount
15+
ORDER BY
16+
bids.evt_block_time;
File renamed without changes.

periphery/tenderly/dune.js renamed to periphery/tenderly-actions/dune.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
import { ActionFn, Context, TransactionEvent, Event } from '@tenderly/actions'
12
import axios from 'axios'
23

3-
const triggerDuneQuery = async (context, event) => {
4+
const triggerDuneQuery: ActionFn = async (context: Context, event: Event) => {
5+
const transactionEvent = event as TransactionEvent
46
// keccak256(Bid(uint256 saleId,address bidder,uint256 amount));
57
const BID_EVENT_SIG =
68
'0xdcd726e11f8b5e160f00290f0fe3a1abb547474e53a8e7a8f49a85e7b1ca3199'
79

8-
const placeBidLog = event.logs.find((log) => log.topics[0] === BID_EVENT_SIG)
10+
const placeBidLog = transactionEvent.logs.find(
11+
(log) => log.topics[0] === BID_EVENT_SIG
12+
)
913
if (!placeBidLog) return
1014

1115
const saleId = BigInt(placeBidLog.topics[1]).toString()
1216
const DUNE_API_KEY = await context.secrets.get('DUNE_API_KEY')
1317

14-
//[Cumulative Bids, CrowdSale Bids]
15-
const duneQueryIds = [2709374, 2709364]
18+
//[Cumulative Bids, CrowdSale Bids, Plain Crowdsale Cumulative Bids, Plain Crowdsale Bids]
19+
const duneQueryIds = [2709374, 2709364, 4186294, 4186293]
1620

1721
const query_parameters = {
1822
saleId: saleId,
19-
chain: event.network === '5' ? 'goerli' : 'ethereum'
23+
chain: transactionEvent.network === '11155111' ? 'sepolia' : 'ethereum'
2024
}
2125

2226
for (const queryId of duneQueryIds) {

periphery/tenderly/package-lock.json renamed to periphery/tenderly-actions/package-lock.json

Lines changed: 33 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "tenderly-actions",
3+
"scripts": {
4+
"build": "tsc"
5+
},
6+
"devDependencies": {
7+
"typescript": "^4.3.5"
8+
},
9+
"dependencies": {
10+
"@tenderly/actions": "^0.2.57",
11+
"axios": "^1.7.7"
12+
},
13+
"private": true
14+
}

periphery/tenderly/tsconfig.json renamed to periphery/tenderly-actions/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"noImplicitReturns": true,
66
"noUnusedLocals": true,
77
"outDir": "out",
8+
"rootDir": "",
89
"sourceMap": true,
910
"strict": true,
1011
"target": "es2020"

periphery/tenderly.yaml

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,66 @@
11
account_id: ''
2-
project_slug: ''
32
actions:
4-
moleculeprotocol/project:
3+
tech_prod/catalyst:
54
runtime: v2
6-
sources: tenderly
5+
sources: tenderly-actions
76
specs:
8-
BidEventGoerli:
9-
description: BidEvent on Goerli StakedLockingCrowdSale contract
7+
bideventmainnet:
8+
description: BidEvent on Mainnet StakedLockingCrowdSale contract
9+
execution_type: ''
1010
function: dune:triggerDuneQuery
1111
trigger:
12-
type: transaction
1312
transaction:
1413
filters:
1514
- eventEmitted:
1615
contract:
17-
address: 0x46c3369dEce07176Ad7164906D3593AA4C126d35
16+
address: 0x35Bce29F52f51f547998717CD598068Afa2B29B7
1817
name: Bid
19-
network: 5
18+
network: 1
2019
status:
2120
- mined
21+
type: transaction
22+
bideventsepolia:
23+
description: BidEvent on Sepolia StakedLockingCrowdSale contract
2224
execution_type: ''
23-
BidEventMainnet:
24-
description: BidEvent on Mainnet StakedLockingCrowdSale contract
2525
function: dune:triggerDuneQuery
2626
trigger:
27+
transaction:
28+
filters:
29+
- eventEmitted:
30+
contract:
31+
address: 0xd1cE2EA7d3b0C9cAB025A4aD762FC00315141ad7
32+
name: Bid
33+
network: 11155111
34+
status:
35+
- mined
2736
type: transaction
37+
plainbideventmainnet:
38+
description: BidEvent on Mainnet PlainCrowdsale contract
39+
execution_type: ''
40+
function: dune:triggerDuneQuery
41+
trigger:
2842
transaction:
2943
filters:
3044
- eventEmitted:
3145
contract:
32-
address: 0x35Bce29F52f51f547998717CD598068Afa2B29B7
46+
address: 0xf0a8d23f38e9cbbe01c4ed37f23bd519b65bc6c2
3347
name: Bid
3448
network: 1
3549
status:
3650
- mined
51+
type: transaction
52+
plainbideventsepolia:
53+
description: BidEvent on Sepolia PlainCrowdsale contract
3754
execution_type: ''
38-
55+
function: dune:triggerDuneQuery
56+
trigger:
57+
transaction:
58+
filters:
59+
- eventEmitted:
60+
contract:
61+
address: 0x8cA737E2cdaE1Ceb332bEf7ba9eA711a3a2f8037
62+
name: Bid
63+
network: 11155111
64+
status:
65+
- mined
66+
type: transaction

periphery/tenderly/package.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)