Skip to content

Commit

Permalink
add sanji (#7337)
Browse files Browse the repository at this point in the history
* add sanji

* fixed seed

---------

Co-authored-by: 0xRob <[email protected]>
  • Loading branch information
clizzard7 and 0xRobin authored Dec 16, 2024
1 parent a22be37 commit 1ca58e9
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -733,3 +733,25 @@ models:
- check_bot_trades_seed:
seed_file: ref('prophetbots_solana_trades_seed')
blockchain: solana

- name: sanji_solana_bot_trades
meta:
blockchain: solana
sector: dex
project: sanji
contributors: whale_hunter
config:
tags: ["solana", "dex", "sanji", "trades"]
description: >
Sanji trades on Solana
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- tx_id
- tx_index
- outer_instruction_index
- inner_instruction_index
- check_bot_trades_seed:
seed_file: ref('sanji_solana_trades_seed')
blockchain: solana
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
, ref('bitfoot_solana_bot_trades')
, ref('tradewiz_solana_bot_trades')
, ref('prophetbots_solana_bot_trades')
, ref('sanji_solana_bot_trades')
] %}

{% for bot in solana_trading_bot %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{{ config(
alias = 'bot_trades',
schema = 'sanji_solana',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index']
)
}}

{% set project_start_date = '2024-11-21' %}
{% set fee_receiver_1 = '4E64WX4EARRMfHsvL4ZXbrbpiPcBUyrC62uawGofhdNN' %}
{% set wsol_token = 'So11111111111111111111111111111111111111112' %}

WITH
allFeePayments AS (
SELECT
tx_id,
'SOL' AS feeTokenType,
balance_change / 1e9 AS fee_token_amount,
'{{wsol_token}}' AS fee_token_mint_address
FROM
{{ source('solana','account_activity') }}
WHERE
{% if is_incremental() %}
{{ incremental_predicate('block_time') }}
{% else %}
block_time >= TIMESTAMP '{{project_start_date}}'
{% endif %}
AND tx_success
AND balance_change > 0
AND (
address = '{{fee_receiver_1}}'
)
),
botTrades AS (
SELECT
trades.block_time,
CAST(date_trunc('day', trades.block_time) AS date) AS block_date,
CAST(date_trunc('month', trades.block_time) AS date) AS block_month,
'solana' AS blockchain,
amount_usd,
IF(
token_sold_mint_address = '{{wsol_token}}',
'Buy',
'Sell'
) AS type,
token_bought_amount,
token_bought_symbol,
token_bought_mint_address AS token_bought_address,
token_sold_amount,
token_sold_symbol,
token_sold_mint_address AS token_sold_address,
fee_token_amount * price AS fee_usd,
fee_token_amount,
IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol,
fee_token_mint_address AS fee_token_address,
project,
version,
token_pair,
project_program_id AS project_contract_address,
trader_id AS user,
trades.tx_id,
tx_index,
outer_instruction_index,
inner_instruction_index
FROM
{{ ref('dex_solana_trades') }} AS trades
JOIN allFeePayments 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)
AND date_trunc('minute', block_time) = minute
{% if is_incremental() %}
AND {{ incremental_predicate('minute') }}
{% else %}
AND minute >= TIMESTAMP '{{project_start_date}}'
{% endif %}
)
JOIN {{ source('solana','transactions') }} AS transactions ON (
trades.tx_id = id
{% if is_incremental() %}
AND {{ incremental_predicate('transactions.block_time') }}
{% else %}
AND transactions.block_time >= TIMESTAMP '{{project_start_date}}'
{% endif %}
)
WHERE
trades.trader_id != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet
AND transactions.signer != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet
{% if is_incremental() %}
AND {{ incremental_predicate('trades.block_time') }}
{% else %}
AND trades.block_time >= TIMESTAMP '{{project_start_date}}'
{% endif %}
),
highestInnerInstructionIndexForEachTrade AS (
SELECT
tx_id,
outer_instruction_index,
MAX(inner_instruction_index) AS highestInnerInstructionIndex
FROM
botTrades
GROUP BY
tx_id,
outer_instruction_index
)
SELECT
block_time,
block_date,
block_month,
'Sanji' as bot,
blockchain,
amount_usd,
type,
token_bought_amount,
token_bought_symbol,
token_bought_address,
token_sold_amount,
token_sold_symbol,
token_sold_address,
fee_usd,
fee_token_amount,
fee_token_symbol,
fee_token_address,
project,
version,
token_pair,
project_contract_address,
user,
botTrades.tx_id,
tx_index,
botTrades.outer_instruction_index,
COALESCE(inner_instruction_index, 0) AS inner_instruction_index,
IF(
inner_instruction_index = highestInnerInstructionIndex,
true,
false
) AS is_last_trade_in_transaction
FROM
botTrades
JOIN highestInnerInstructionIndexForEachTrade ON (
botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id
AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index
)
ORDER BY
block_time DESC,
tx_index DESC,
outer_instruction_index DESC,
inner_instruction_index DESC
21 changes: 21 additions & 0 deletions dbt_subprojects/solana/seeds/sanji/sanji_solana_trades_seed.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction
2024-12-15 07:06:47.000 UTC,2024-12-15,2024-12-01,Sanji,solana,2.12730476036,Sell,0.009734612,SOL,So11111111111111111111111111111111111111112,632.120372,timmy,4MH3cmHGELMSWeWsYVQJFgb9tmed26ZTUVQ3jkANpump,0.014851298800000001,0.00006796,SOL,So11111111111111111111111111111111111111112,raydium,4,timmy-SOL,a5cEyYEG1RaBTpsY1QapYKDv6ixvbD6CVkisSvT5Ufo,7rqre26G9XjaEjbwtSHCU97LoU1KY7LGAthXNDyygLUD,4GdbkGaaMWoPM14vJsNWCMQ4vpnMKzJAow2ZZEXe1BnGtzoMyBq5GfLBK8X6W1XihZBPV7x677z47DAtYvv7Qwt4,1263,5,0,true
2024-12-14 21:57:46.000 UTC,2024-12-14,2024-12-01,Sanji,solana,10.8765,Buy,108399.066862,ROJO,HANuXquoXxPQuUdWq2pSonH3GUwjfwg9wwxeP8do6bWV,0.05,SOL,So11111111111111111111111111111111111111112,0.0761355,0.00035,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-ROJO,27gMxh6F68GoctWNp3YyLhrMwaZsLzwK6WDLyVQCQUmd,FAZuZgyYsYQjkJD6o3YaVwz4MdvitFDWoA4DvWmR8mS5,62qqXEMGk6uiSLBfscjbcLP7aAPHtK7uvmUmxq5akQ7FE6eHeM5axrZk6J18Wc11GstxEdgoMEKn8akZwApXjmDM,1632,6,0,true
2024-12-13 23:30:55.000 UTC,2024-12-13,2024-12-01,Sanji,solana,1.25854035633,Sell,0.005622751,SOL,So11111111111111111111111111111111111111112,19013.576389,ipod,5wQPBazUaVtMTqtAGXYPdDSenxDqM5vJiDsEfov7pump,0.007536356100000001,0.00003367,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-ipod,A7LAumFoyJFTR8V9ChoSP8iSpquVacpZHva1oZ2JqS16,8Z4zvnXqR7bgJttHKpAP2SUa1TuzmXjqLj7pEbEzMmkd,2kgteAdXaZYthVsUoxHGmQGJKBGbgEahA4nGSaYh3eqzYVGKm6ovtm3UynpcKqSPX21Zdz6GfyEnGtUDdShRS2FB,2946,3,2,true
2024-12-07 16:58:50.000 UTC,2024-12-07,2024-12-01,Sanji,solana,190.39411413672,Sell,0.786817564,SOL,So11111111111111111111111111111111111111112,856847975790.57,DNA,DiSetnR7k57wmfvywJhUVjPwWfg54SdQKxQdJEBYW23B,1.3498394538,0.00557831,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-DNA,45L3EuUJKyqhkNDfocrd3yAZu8nzMPXiHtwhjCvidgua,B273T7o6o1Cn9uy4uByzKxpHGqqALAPo9JuZBp9ctZbK,5vBFyx35NGM1Z8r8iB8TLDpVA3mK7LhqqUu5E2iTbJU6UNxPxmMFTTwspqa2Zh6FUKizddQVH2vtEQELWz3rLXbS,617,5,0,true
2024-12-06 01:33:22.000 UTC,2024-12-06,2024-12-01,Sanji,solana,2.48840085109,Sell,0.010124917,SOL,So11111111111111111111111111111111111111112,2.5,USDT,Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB,0.0174201776,0.00007088,SOL,So11111111111111111111111111111111111111112,raydium,4,USDT-SOL,7XawhbbxtsRcQA8KTkHT9f9nc6d69UwqCDh6U5EEbEmX,EYzmfW4iqDGNhgTiyA71ETMLnSRPJEKykYzDwNWBQFYv,5sY1pA9d1NY7byu4pK6FAtNGjASU51zv5guRb31HNws5pGVg88XEpMNbPULSCo3GbYhbzgRgKynyejhxfWNodBHg,895,5,0,true
2024-12-07 06:41:44.000 UTC,2024-12-07,2024-12-01,Sanji,solana,0.0774845692,Sell,0.00032884,SOL,So11111111111111111111111111111111111111112,6503.817475,Trump47,PfzhpjdDd2rHLRLWyTQBbqB6KBJfx8yVVGqSYkq5bqC,0.000541949,0.0000023,SOL,So11111111111111111111111111111111111111112,raydium,4,Trump47-SOL,2kcuRFMvJvqe82E7byJBCDMn4LT4zNFb2FpPhVbdqCw2,BLZ2UfxRoJ8arGKgAtArQ1SDFDttFA8c6v4qyPGpZLaq,4MNycd2wXRvzR8hikbS5Wsudn3tmf2vHjzxsuXSk5fvBzWW5oYFGLfv7pH1Pdo1eTL2kno7jwsDbVEFz5izKRboM,1480,5,0,true
2024-12-12 22:57:10.000 UTC,2024-12-12,2024-12-01,Sanji,solana,45.932176694949995,Sell,0.201342115,SOL,So11111111111111111111111111111111111111112,7151571.722822,JAILFORJAY,3KSkAdFbPHfGREVEo3DcGDBHEdZ8Ey3zGgFSajYVpump,0.1618422659,0.00070943,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-JAILFORJAY,Exj9V36qy1esrknFo4SAi8728BEGcrXPLwquDHfLtNqZ,8ChErCicUoNVmKbMuzVzoSoVn9s9Fkrsf8f2PoFKWrbZ,5un9ZXyeZfrYrEutX3dVG2dY76GWViTmVR4KVhfKBJQoqixsW2aZisRr31mEz86pfhoUoTWnVsqBqW5qrpyL8RPX,164,3,2,true
2024-12-12 03:19:52.000 UTC,2024-12-12,2024-12-01,Sanji,solana,67.28554651878,Sell,0.293643827,SOL,So11111111111111111111111111111111111111112,629457.273508496,CHILLSLUT,4F33vogWv87XcpGYL4pPXBfmXc5XBEKqPTVYrJrFpump,0.4643155476,0.00202634,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHILLSLUT,CYHPMpq6paZHLe24um42WPQMNRGNGTK4Q2LgDFWPZEdS,Ghcb5NXNE8KwvRYob3b8oGy6g5GF9z3Gd4rfrujCRAuL,TckxHyY7orvMD2Aidin1yWhpZM6L614TP8wV4zJTxN1nwgpSmS9AXyzrhG5i7vNp7DJvuurs1aQwPXyqwKEvHc1,757,5,0,true
2024-12-08 02:52:58.000 UTC,2024-12-08,2024-12-01,Sanji,solana,200.38093529355,Sell,0.831697735,SOL,So11111111111111111111111111111111111111112,1748801.699025,T51,4zGCj2Rq16sp3fFdzZHbVUdAqeS4p9buThjKKRQGpump,1.4026679577,0.00582189,SOL,So11111111111111111111111111111111111111112,raydium,4,T51-SOL,GAjizQ2pXjkT962BU9ge7iKkaJtVYvQyHvPfV4vVR9YN,4o3DSxj7rj6mJUNYYCy4vm3dKDwteZVR27K1XT8eSrqu,4BwNnddS7SJpi2oUGH4F9KWo4sQp7RoHERbJtn7eevAshAToZagzR4neQHc867ueKvFa2aU7PmYS3L3xJtEJnbyN,1722,5,0,true
2024-12-07 16:58:51.000 UTC,2024-12-07,2024-12-01,Sanji,solana,7.07179338996,Sell,0.029224702,SOL,So11111111111111111111111111111111111111112,3750224.749119,USA,69kdRLyP5DTRkpHraaSZAQbWmAwzF9guKjZfzMXzcbAs,0.0494800704,0.00020448,SOL,So11111111111111111111111111111111111111112,raydium,4,USA-SOL,HKprCtGbnh1j8xeQggzWhhVd3kwDUdphqPqDP8vMay8b,7wyuQVaYkPxu7oTp1juBXCpmjXM1JvjtBH2bDmWWjddp,xXHQ2v53E2fDymBmad8vQtQZCapEX3MFMr2k5vLgB3vjZV5sdKFtxnGaL8e7JrnYLLcA4cT5t2BbnYZGfhdaDqP,391,5,0,true
2024-12-01 04:48:17.000 UTC,2024-12-01,2024-12-01,Sanji,solana,1.5498037895799999,Sell,0.006555299,SOL,So11111111111111111111111111111111111111112,2707.23956,SNOOPY,CSh9t2fx2TAE25AiZ9oagdcuHomTQoCE1PGxaMjfpump,0.0112039438,0.00004739,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SNOOPY,6NZ8USQQCiy2dAe6Qg7GZGMRS1z86qq2iH8bokD271ht,BcGqkk3QVi4XmN4BN4deJSvGL1ss8AwiM3n1L7BouFr1,47fBahJ11QJTSkcn2qqdMTc69nQ53yZW5yqu48DzTiLckYu2hwMJATMmQsjhoAGVUDSsUphocrPsFmH7VgL6nEUb,987,5,0,true
2024-12-12 06:28:07.000 UTC,2024-12-12,2024-12-01,Sanji,solana,93.99705161856001,Sell,0.408540732,SOL,So11111111111111111111111111111111111111112,2598.06085,APPLE,H33XL6HHDReCVRgSApZpsXM7Hy7JGyLztRJaGxjapump,0.6579804832,0.00285979,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-APPLE,BEMi9yKdXLL9rNY43cU8CVxZZP4hmr7w7odwtxAMKAzD,vv7iSWi5CFuP9GCv1ufASHBDz6kFNDEWq5nhnpKaLUt,3xS9c2bGTWoTkXfFtRriP8DYTUTm29tqdkpEvCWLe6KJtMDdqvJjgmer3QWffWVYijwkp9ouDTBVVfvjKLmeRnZc,1708,5,0,true
2024-12-04 03:46:15.000 UTC,2024-12-04,2024-12-01,Sanji,solana,7.153499999999999,Buy,99989.752594,JIZZ,Ggx1nVeY23M16r2YqgeJfXMqA5WCGmTQN8RqhaXWPbTL,0.03,SOL,So11111111111111111111111111111111111111112,0.0500745,0.00021,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-JIZZ,EhY8JFCUyPuqJpdNiU9shKjToQb1b6qycmMwdx1o2LSv,2fBwpC4QGeExBWDfpGSqTNMC8xqWMu4Q8gSJYDYiSxta,3QUbFCvFCRDcarhnprUfwDpMFd5mJc7Mp9RXAyqRmmgJWydnQgaBe8i9VgyjKDp3JbL2JwUjqBQhN8qzgd65ugGa,1605,6,0,true
2024-12-12 14:40:20.000 UTC,2024-12-12,2024-12-01,Sanji,solana,4.125138145739999,Sell,0.017878638,SOL,So11111111111111111111111111111111111111112,234.904987,TRUST,EqeEBGHQhQy6SqeaJcnqAsNs3qaG19sdF89Xsarpump,0.02884125,0.000125,SOL,So11111111111111111111111111111111111111112,raydium,4,TRUST-SOL,9dkWXEmCvQGLazzbWZiSDExoPKiw7HkwPSM5bJW8qymL,BtZ1iVeH6h98fgi88pF6qj9oG41v42n3yndpSMDif4kh,5fx2StwS691CMAcJgk7jSPwuUVg1nuWtyKbdfrTNVg62r3uqzejo8yH3o4vYGUGht2yG84HXTJEEFSFtMkcgcqk7,3037,5,0,true
2024-12-12 00:13:26.000 UTC,2024-12-12,2024-12-01,Sanji,solana,3.06566549352,Sell,0.013495622,SOL,So11111111111111111111111111111111111111112,476869.372056,AWWTIC,BPcCs1fer87KzqgkHHCvR36SkfDqaEcLGxt62fkkpump,0.0214620768,0.00009448,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-AWWTIC,4icnNdfDN3FyzTpXBBJWZ5BRHnjvLRAkgK5QhhxDHSD7,8UWDczTGjzjnwmQ3Ah6jcN5qPxCT9oWB3BKhfWyW9G6R,59nJmeny6UzHEeRdUMG1UhVY1xE74yJrR7o9rLauHfPUAsg2yR38oK3mM8sDGtYV8uxXAFmFtmTqH7zmW4FQtLuj,1926,5,0,true
2024-12-12 20:06:07.000 UTC,2024-12-12,2024-12-01,Sanji,solana,6.8361,Buy,37511.994306,CHAINSAW,7nFvyQr2mwHLjBBECj3MsUxeAbP2D89p7Tx6bQtBpump,0.03,SOL,So11111111111111111111111111111111111111112,0.047852700000000005,0.00021,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHAINSAW,Eg4hFsUc2MwiBumykUe5dnQws37M3P3WzdGFKpQuqp5t,AQLntiBeqNvynXjrWJv4MSmMFURSfrSbasjUbqwHyWN1,uhCyivWoQUksTryEegnTYxRjrXAp3aeBWRyc8q8Kr99FPj3m1rGZm8tq67fRsbqBSkUs6y4NL7jFGhMEoG9Ke5v,2138,6,0,true
2024-12-13 20:05:17.000 UTC,2024-12-13,2024-12-01,Sanji,solana,0.67938346075,Sell,0.003043151,SOL,So11111111111111111111111111111111111111112,2200.998928,EVOLVE,HQ7NoKrgxcep1hSnNKGbWRtpMf59As5eVKeuwyCzpump,0.0043690025,0.00001957,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-EVOLVE,6J3DXzGB9Ndw795pAfH65HQSDo4MwgRbFDpSF27L3g4S,9zxuSu9cp5euiHaB9NAZ1Y6PhtASWmpetDhvrAUhZBZm,44UWzYjiCcsG6RS81CdCbzQjFaih8ppkkxedMUoZJ2qroSn8Tqov1EXzQfiPvh8cPABK3sCXCdmBppoHSXMFxTFx,1962,5,0,true
2024-12-12 20:47:31.000 UTC,2024-12-12,2024-12-01,Sanji,solana,0.01325559392,Sell,0.000057814,SOL,So11111111111111111111111111111111111111112,0.00000341,WETH,7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs,0.0000940048,4.1e-7,SOL,So11111111111111111111111111111111111111112,raydium,4,WETH-SOL,4yrHms7ekgTBgJg77zJ33TsWrraqHsCXDtuSZqUsuGHb,6VvTvxNoZzHVgivqeFrzBcKK8N9ckMGbMTxcNgbB8MVo,2YjFHGk3YnWdLukUzUmZBZhtQbh7rhoVtSxDDEKtuCVqun85E2DG7tE13D8S9XuiEs58PbfHcBF7BJ61DKWY8wyP,1634,5,0,true
2024-12-12 13:26:56.000 UTC,2024-12-12,2024-12-01,Sanji,solana,0.0017850892199999999,Sell,0.000007698,SOL,So11111111111111111111111111111111111111112,4.5e-7,WETH,7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs,0.000013681509999999998,5.9e-8,SOL,So11111111111111111111111111111111111111112,raydium,4,WETH-SOL,4yrHms7ekgTBgJg77zJ33TsWrraqHsCXDtuSZqUsuGHb,6VvTvxNoZzHVgivqeFrzBcKK8N9ckMGbMTxcNgbB8MVo,FQBE9S8LZTiSvtMCU6qYwtRbvDCG2syeLGXUMq2whe4ALcYHNixAYxSsNY67F3QLACHYjhM1HojoeU7nPvko9J8,1019,5,0,true
2024-12-01 00:19:25.000 UTC,2024-12-01,2024-12-01,Sanji,solana,11.9225,Buy,345972.31649,GRINCHWIF,BoQPkPXdNqRuwyPpkC47Ac9mCk2WwhbgbDG5dt7spump,0.05,SOL,So11111111111111111111111111111111111111112,0.08345749999999999,0.00035,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRINCHWIF,ALkGqJ7inoN4n2wW6exur43YQRSHZ5dP3DpQ879DwM85,77PPF9tCqn3PsrYs7WhgKEpy76b3Uzh1i4B93BmoSq2G,4caUnR34GpNUDzeYWDWJZQEP7B6rycCLAoL6sDnYuzDF8ti7wXqsxDqoYuocumX4B7Nmzup8RyZxschkB9ZAQ2tu,1180,6,0,true

0 comments on commit 1ca58e9

Please sign in to comment.