Skip to content

Commit

Permalink
fix: make bonkbot spellbook entries unique again (#7083)
Browse files Browse the repository at this point in the history
* chore: trigger CI

* chore: remove prod_exclude tag

* chore: move start date closer to current date to allow spellbook run in CI

* fix: only fetch 1 fee payment per tx

* fix: different approach

* fix: amgibious column

* chore: retrigger CI

* revert start date to original

---------

Co-authored-by: jeff-dude <[email protected]>
Co-authored-by: 0xRob <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2024
1 parent 83cdaa4 commit 90fa32d
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{{ config(
alias = 'bot_trades',
schema = 'bonkbot_solana',
tags = ['prod_exclude'],
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
Expand Down Expand Up @@ -63,6 +62,33 @@ WITH
tx_id,
fee_token_mint_address
),
solFeePayments AS (
SELECT
*
FROM
allFeePayments
WHERE
feeTokenType = 'SOL'
),
splFeePayments AS (
SELECT
*
FROM
allFeePayments
WHERE
feeTokenType = 'SPL'
),
-- Eliminate duplicates (e.g. both SOL + SPL payment in a single transaction)
allFeePaymentsWithSOLPaymentPreferred AS (
SELECT
COALESCE(solFeePayments.tx_id, splFeePayments.tx_id) AS tx_id,
COALESCE(solFeePayments.feeTokenType, splFeePayments.feeTokenType) AS feeTokenType,
COALESCE(solFeePayments.fee_token_amount, splFeePayments.fee_token_amount) AS fee_token_amount,
COALESCE(solFeePayments.fee_token_mint_address, splFeePayments.fee_token_mint_address) AS fee_token_mint_address
FROM
solFeePayments
FULL JOIN splFeePayments ON solFeePayments.tx_id = splFeePayments.tx_id
),
botTrades AS (
SELECT
trades.block_time,
Expand Down Expand Up @@ -96,7 +122,7 @@ WITH
inner_instruction_index
FROM
{{ ref('dex_solana_trades') }} AS trades
JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id
JOIN allFeePaymentsWithSOLPaymentPreferred AS feePayments ON trades.tx_id = feePayments.tx_id
LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON (
feeTokenPrices.blockchain = 'solana'
AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address)
Expand Down

0 comments on commit 90fa32d

Please sign in to comment.