Skip to content

Commit

Permalink
autosniper bot (#7177)
Browse files Browse the repository at this point in the history
* autosniper bot

add autosniper bot demo

* push

* fixed seed

* fix: fix project name autosniper -> autosnipe

* chore: add to dex_solana_bot_trades

* fix: fix seed

* fix typo in schema name

---------

Co-authored-by: whale_hunter <[email protected]>
Co-authored-by: jeff-dude <[email protected]>
  • Loading branch information
3 people authored Nov 25, 2024
1 parent 30b95c5 commit e01fd4a
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 @@ -621,4 +621,26 @@ models:
- inner_instruction_index
- check_bot_trades_seed:
seed_file: ref('bloom_solana_trades_seed')
blockchain: solana

- name: autosnipe_solana_bot_trades
meta:
blockchain: solana
sector: dex
project: autosnipe
contributors: whale_hunter
config:
tags: ["solana", "dex", "autosnipe", "trades"]
description: >
Autosnipe 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('autosnipe_solana_trades_seed')
blockchain: solana
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
, ref('jupbot_solana_bot_trades')
, ref('looter_solana_bot_trades')
, ref('wifbot_solana_bot_trades')
, ref('autosnipe_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 = 'autosnipe_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-13' %}
{% set fee_receiver_1 = 'CWEfC6fLi552zE2KFxhPiBAZUWdT78gMd8NGENik2zfE' %}
{% 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,
'Autosnipe' 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

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-11-13 10:10:03.000 UTC,2024-11-13,2024-11-01,Autosnipe,solana,1.89099878996,Sell,0.009148076,SOL,So11111111111111111111111111111111111111112,131375.682942,POE,BNLkSqJMM8xmekwQ8nReaHu87RXhohHxMwxPkSUQpump,0.027996388980000005,0.000135438,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-POE,ApgQg6gGBDq9ciKPFe38V2XYywHyPgXSwerVHLSL7fyQ,8GHHSremAExPrXPCcmtcwSCteEQ3sFsvn3x4smJEseev,2GxsTynwW8vrxwy3q4GiNmFGuqEwgjiJBT8qaL2Jnvo3chhmEJPjSAHUtQdit6RmZEJkbKuiraG48HsTCajRvBkM,1553,5,0,true
2024-11-19 05:23:49.000 UTC,2024-11-19,2024-11-01,Autosnipe,solana,75.04771682688,Buy,274694.326486,GRIFT,DdWs9oFuGBTFVRbhxNkKQYYYdA6X1D3H5ZMY5TZLjhfG,0.310988384,SOL,So11111111111111111111111111111111111111112,0.75047696556,0.003109883,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFT,E7iXbCTyae2V2PYiuJNTC7xeJVAoiYMHY8L5TpHX9VYF,Buj7TH93zSKE8W7WvamsHMzmLuYXTekwvH4QqpLMcRxe,4BY97vyp8r24Dnqu2tyHbmi9K8orqhEuia2SAQmANtExicM3wNS3VDB8UMsVdNDPgLS5M85dH5hYwhG9QsyPU8GM,782,6,0,true
2024-11-14 08:40:53.000 UTC,2024-11-14,2024-11-01,Autosnipe,solana,2.1915,Buy,362.045614,RobinPepe,6mW4U4AXge8drs3omUg7o3b87hYizsRbPcWydS7FdRJa,0.01,SOL,So11111111111111111111111111111111111111112,0.021915,0.0001,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-RobinPepe,r7WRtpReP4deeYpcUCcaJWdVCs2PX2iLVoZN42e19Bz,Bu1K6z6ZxbKc6pe6Fbzq4A9Up4nmPg7CudYq8iFkj6L3,eAko78YHHEmWXaYSVJpqXHTCPy9T3xzhXoaz3hdvGTERgExjiYtmk9bVfFa96eSLnw2cY34KXi4AHeT1kRManjC,926,6,0,true
2024-11-20 14:22:07.000 UTC,2024-11-20,2024-11-01,Autosnipe,solana,4.4605925127,Sell,0.018424587,SOL,So11111111111111111111111111111111111111112,7962.065451,lucy,Cy7Nyi89q2HCt4wwxyLLJERNdjwBJVHJCnC8xGSQpump,0.050146415099999994,0.000207131,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-lucy,2fKxw5AhN7R8B1pzrtYp8poe98WdHm8PoboK1qxx2sKz,Hf8biWQwnk2X4LEAEiUWv351FQ23ZgwysUvUkMMCPBCk,jFNj3ohhJtKVrP3ox8BQB5BBAQTdJ4NJ89rZcB3qKNL4AbQDAu2Xm34W3H83SzBVwHfqdB3KZSKSu1GbBT6SnMu,429,5,0,true
2024-11-21 14:10:11.000 UTC,2024-11-21,2024-11-01,Autosnipe,solana,0.85967529,Sell,0.003494615,SOL,So11111111111111111111111111111111111111112,2053.81599,Mercal,ESn52mvYR7Yo1XyUe1zJRqfe3VorGXwndFB14H93pump,0.014268491999999999,0.000058002,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Mercal,C2vF8E1xcAPp8Ly2rn4V1ySxyYFyT5JSvYXWSFdb1Rxg,HCnXthqj7hQWJ6YDSYLPcmTU6HpFvQYZ2EMiBVWr3WCb,5gg3vWDSNgDJHWjHftNP42vNvWoENvi9EYJdx6dq95Vs63eK6U5vVZHkmNJNW6W3GH4BBHq2N5cFDo2UUaKw8ms5,365,5,0,true
2024-11-19 07:17:35.000 UTC,2024-11-19,2024-11-01,Autosnipe,solana,0.19324405122,Sell,0.000792406,SOL,So11111111111111111111111111111111111111112,60.581306,DOGECAST,EwgD3xXdEEMfSqTKtWU8XJzpncbdi8oSQ5VJV75X2FsW,0.09793697265,0.000401595,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-DOGECAST,BMyVgWdDdWRDpkVyoxWnNsMsP1VfsZdbJFnJXetk6pgt,HWP1ia8ydkH69kXgzAKuZRvEtX1bgAirUk6c1GsMqgjA,K7SijRGwsVy6NeSrsD5dC6sFnm6HCFJBfkvM6thm1YFHD7C4PKUbDUxT9ThKu9Kx45fRfszGVjKF9ZdWovsp1Lc,257,5,0,true
2024-11-19 23:12:29.000 UTC,2024-11-19,2024-11-01,Autosnipe,solana,1.58160693071,Sell,0.006704281,SOL,So11111111111111111111111111111111111111112,164600.628572,ΔΘGΞ,EkMAYuktJDkiioBLUxn7ToWrv4tfY8c1QjvzHwrcpump,0.02500646,0.000106,SOL,So11111111111111111111111111111111111111112,raydium,4,ΔΘGΞ-SOL,5efupJYTonpmrgyAURkgP8HgRmwYdnVc4EwXoL7P5jnr,Fm3RkHsY3ZkXNtaFyUxuDTyo5LuSkCNPhBW6ndqMf9Yy,4gQxg29RjrYLfDwNeM93fzAKDd3SD2GeqQ1Ko6Hpa5UdSmNKmEXVd19ze4A98TUcqQmxhwVYuPNZhexuFgk6QyML,545,5,0,true
2024-11-14 12:17:06.000 UTC,2024-11-14,2024-11-01,Autosnipe,solana,13.935083723410001,Sell,0.064374203,SOL,So11111111111111111111111111111111111111112,1613.92806,LESTER,5z3iCe53hUANTiG8Js8RjHNE2Arjik7L2CXLyr2rpump,0.14572370754,0.000673182,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LESTER,7TkVaEEG8CpMutTpkQMGDEdsRi1GxnjA1NzKiTPKbxnE,C4ZXEJWcJdu7HQGz6JhbRMGAHTnoYLaGMrGqgT2ojUFG,5woVu45pDVBjDnzmJsxD1aSJyBa69Zr7C82b5zLFULiz158ySdKuxPwbUDDe6nuTwXZjy26Trei8UAzc7Rhf8oTq,117,5,0,true
2024-11-20 08:58:17.000 UTC,2024-11-20,2024-11-01,Autosnipe,solana,2.3874,Buy,8510.344944,BADGUY,5JGi5RWDDjRNWBifuwavKGE7cPG8YhenDLxrTHAjpump,0.01,SOL,So11111111111111111111111111111111111111112,0.023874000000000003,0.0001,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BADGUY,Dt8yduTbFykpGZCSse1AYFU4Dd6CvyGWKFixrjXMN5UB,GtPCTuUg5xECqRiBwtzxDAYxUt7s6icrKuevrFKbo5sv,4rWCwWHiyu5qpUgf3LUwo9KLaKu8QiPzgZschtb7DpMbZ2jfMmdkRu4LCffEhLq1NK3PeW511BcFuy5zSckzoXbz,2090,6,0,true
2024-11-20 13:15:55.000 UTC,2024-11-20,2024-11-01,Autosnipe,solana,4.970279410720001,Sell,0.020972528,SOL,So11111111111111111111111111111111111111112,70407.335715,THABO,9SBt1dVSVWchvSo3g5RAZswg8VDz1Se4K4YMzVBwpump,0.0543275876,0.00022924,SOL,So11111111111111111111111111111111111111112,raydium,4,THABO-SOL,7BwRNp2jKpSza3kEb2XtAoXCMLSL78ZNvT7R6Z7YtdGz,BZqTgDxDGpmzQH5iVoHUXR9XMjwEiQqRdQZYaKgh1y7L,2LHpYhNoTjcaixpb1e4s12a9qiNranbj9yTAziLa6R27NH5owKqNcwAa4ikTHt5RKeZmzcc2bNEM2gGFtL1p5ZMh,2023,5,0,true
2024-11-18 08:10:07.000 UTC,2024-11-18,2024-11-01,Autosnipe,solana,2.5683426732499997,Sell,0.010659235,SOL,So11111111111111111111111111111111111111112,162766.933535,AM,Bsa3w4EePHJcf3aTvynmoRH4Bs5TfJzQhGPmWxXapump,0.031899370499999996,0.00013239,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-AM,6EL4FSLU5RuTA2K14HK8JwS8cBhNTSp5Q43RHZkaaZHb,AofQXWAJMxJ7DomHEVxZ9nmKJ2WH4LkBXo2wtK3W66D1,4ktk9pnrKvnVAMR6RfJay5YTycyVgoYxYaKErZCuqBpQxdknNNcFesEvTF3WanG3JGQ8Yxi1365Czat8LB9H8BLv,832,5,0,true
2024-11-16 22:20:45.000 UTC,2024-11-16,2024-11-01,Autosnipe,solana,1.86737437986,Buy,89814,Legacy,CEBcNKkGqwYcnQWK72NZBGNVLNtJDXWHVG1eAd8hpump,0.008594718,SOL,So11111111111111111111111111111111111111112,0.021727000000000003,0.0001,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Legacy,GnNMGBxxmQRHJ1bNPQXnW1Bmc5mAvvSj51pnw7QNtS9n,WnRP1tPZXFXMqYyhC1nftFLqmwffiNcVP113afRjBNQ,41qWs9e9NHr4mMGNGfbvCDEhPbU8h2ThvJfp85VKxPsWfBBasjCHQjQ2pGMW82xu5MhSbyD5nADEVGPqE1KDWfRz,1621,3,4,true
2024-11-13 06:37:26.000 UTC,2024-11-13,2024-11-01,Autosnipe,solana,2.0347,Buy,320.474911,PURE,E5DpUjFJtiyj8qK7eQtLVjiNxB9o2iHmQbMYVn93bfe4,0.01,SOL,So11111111111111111111111111111111111111112,0.020347,0.0001,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PURE,HykbwqpzEsBkcDrAhvZzCVXVLRTYL2pewizYiTkn5Bxw,5RFyzum4ybsfDp8qfF8J9bGeCpxsEspkLEPuyYjYprd9,376RghWJ4YGa97RSdPLstF2vMimBsezRYrCeaZP72USEQLT7QB2swXB7ATMLxAr3e9kBqbDPL18B4omCj1ArxzSS,1781,6,0,true
2024-11-19 04:26:06.000 UTC,2024-11-19,2024-11-01,Autosnipe,solana,2.4002000000000003,Buy,306.113528431,TUCKER,BDbhJUMgQBQ1bJTKhSS9NsxZdfaiBG6Hgp8qNKpc3YSX,0.01,SOL,So11111111111111111111111111111111111111112,0.024002000000000002,0.0001,SOL,So11111111111111111111111111111111111111112,raydium,4,TUCKER-SOL,43dhe8zqSXUkgmANm23sf1nJ3eSr1Z4q9AYPXER4XAmg,C2WhoXZpKiL8mU4ARxGYR1DMftwkpm6jTwnzva1zkZ91,4XCaQ6PG1M2dbMagLDzDtTzPCsswcMg19QS4XoZP6N5ezLxowoQyAet7saNaa4bQdzhxUx1Bin2vZX9qrucZX1JR,596,5,0,true
2024-11-19 09:46:24.000 UTC,2024-11-19,2024-11-01,Autosnipe,solana,0.43912312249999996,Sell,0.001810817,SOL,So11111111111111111111111111111111111111112,5590.36462,neoai16z,7e3a94ZrwhCsVaZRYBzm9KxfFsVLr7F853yjrxP4pump,0.0184831075,0.000076219,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-neoai16z,4UjKGDoVvu1LJNxcRtkceER52QHzKAav1PAtL7rqLCPL,8VcYNCpY6vmk6sfv3AqVKWbTpicYb35fAEoFHuXJ3CeV,3HmFPziTKF2CQtczcSQ25eJ1it2sxr4tP1VCFYsENKvoffkCV2vSM9kLsuP9EELyoZ3XsK1CnUtn7NWzTe1M26Cq,1448,5,0,true
2024-11-19 05:06:35.000 UTC,2024-11-19,2024-11-01,Autosnipe,solana,9.76544122232,Sell,0.040682558,SOL,So11111111111111111111111111111111111111112,1426470,Faggot,5pxpvP8S35SmRuwJTVVWioUvp7VJ4zfZcaBKRoqKpump,0.09929902707999999,0.000413677,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Faggot,5AnQ7GB795U5yCrgZi5AR2NWDSbu98S993mKzrJpB9gn,83nxnmuG2cMFXTobsZT6kEUbZySGgKryZ2tx7iouYoCE,24YW9bMpHmXbabW5sX6JMbKvwgNZaFY3fFKPd2uvkWjugbFzcpRpMWFUbXy4NvRxywJ1s6Jh35sLvsi2xaWCoMR7,107,3,2,true
2024-11-19 22:12:03.000 UTC,2024-11-19,2024-11-01,Autosnipe,solana,23.703000000000003,Buy,146116.568446,Rover,4uz44JLvsJahuk8LxJAinhRNpsNwB61UZCn4ygbeMGLK,0.1,SOL,So11111111111111111111111111111111111111112,0.23703000000000002,0.001,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Rover,2qcdnvYpajhbN8pXcRsqL5umddgd7yBVj97RzoAFnKc7,GwUGDuJ1aGQnbCaoXbv58TvVBmTbdiYRfxdXTHmN2uRS,5omxR5YPBrowTYhtPR3ShQ4Qd6YsHHqpZr8cVEC1UsiHvPFRH36iacsFd6tex9sNGWAH392wBpeyf77Ls55Ehogb,394,6,0,true
2024-11-15 19:40:28.000 UTC,2024-11-15,2024-11-01,Autosnipe,solana,32.07731663808,Sell,0.151087168,SOL,So11111111111111111111111111111111111111112,26776.416962,KENDROOK,3MJA1JZBpbPRXaCQLHFB6MGxfbzNSm8WPtUebwNhmphd,0.41221324053,0.001941563,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-KENDROOK,4oc6KXo3sRpVqz3ApNTZA2FW2FkLQEHyP3Ly7rf2eRcs,8aeuAMj1NLjPxBWKi8xNY2MsGc1tstFyrX8NX5rW6TBX,5jULAipB5jSSPMAH5TsLb2D6BdmXuN3yYkYfi1RwLMZvMsYypP77VvFpi53DnLArnxQW9Dxdghx3vfVVDUJV4W72,405,5,0,true
2024-11-13 19:26:47.000 UTC,2024-11-13,2024-11-01,Autosnipe,solana,1.287114624,Sell,0.005958864,SOL,So11111111111111111111111111111111111111112,35357.416118,Cedric,2ZAroijMWLZSUpBxSPAs5PL5HLdxHHPSomuenQCwpump,0.027981071999999996,0.000129542,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Cedric,FwxJhTG1Cphj6ZAzhdeFQDP4KdFHQhoM2pm3EqkhEEpz,2YR4j8Gk3povu3TSKF6RPyUvCKwUw9xy6JKduZyk5mPe,4dWcpjyUMxexXGGXFWHMxTLSLPdKWRyXZjwAV7NQrbFyNnaJAHnnmk3TwD2v3z4zgSiv8WXX1S8U9kMaBmHh6fdz,1737,5,0,true
2024-11-14 04:48:08.000 UTC,2024-11-14,2024-11-01,Autosnipe,solana,172.35345226364998,Sell,0.787181787,SOL,So11111111111111111111111111111111111111112,34189619.612266,FLIP,ABoVYKRK4Wvzijcxt6xxSzqxUFErFU4S1MvAY7MNpump,1.7279995984499998,0.007892211,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FLIP,EE6y8vm1MyTtisBRo97rJ64GUnuWv61TFQwAcXNFKYMM,6fFyvyrfaJzmPvBGr4P6oFkVAvYH4RLuTa4fZ7J1qYsa,67NtPxcecLAoj3GdAHS7AzC7YsYn2T7MsuhVaig7yCYVQmThxRUTWW5hnUpndYpw59DzBAdJPSa7LsaprpsodqFQ,1396,5,0,true

0 comments on commit e01fd4a

Please sign in to comment.