mirror of
https://github.com/FlipsideCrypto/solana-models.git
synced 2026-02-06 09:22:01 +00:00
An 2324/stake pool actions (#147)
* intial lido model * wip * change action words, add more pools * wip' * redo deposit stake logic * initial socean model * stake pool column descriptions * wip * force dbt to 0.9.2 * fix model syntax, update test * socean tests * match output columns with other models, add tests * marinade stake pool model * update description to specify SOL * initial core view * eversol wip * eversol actions and tests * add core stake pool
This commit is contained in:
parent
0febc2400d
commit
8a8262e9ec
11
data/testing__stake_pool_actions_eversol.csv
Normal file
11
data/testing__stake_pool_actions_eversol.csv
Normal file
@ -0,0 +1,11 @@
|
||||
tx_id,index,action,stake_pool,stake_pool_withdraw_authority,stake_pool_deposit_authority,address,reserve_stake_address,amount
|
||||
216FXs3ZY5f8gFTXtrCdbJkr3QNNFu3S1dbuTaaQU3dodTQd5cs7sE8v561su4xnRC8B5JtijT3kR9GySiASM4aM,4,deposit_dao,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,CgQN2YQ6TvoEoWimw3vcDo5e9sXBYiNKVym4saTEC4yp,100000000
|
||||
DhWuYAZAuEkfLGJ4H7q4wWLjUNwdB4w5v4mZco5znduVT1Nib5WdcViNmXS2TTEsEmcaXNAr2tZ783oA9Za6Ebi,1,deposit_dao,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,CgQN2YQ6TvoEoWimw3vcDo5e9sXBYiNKVym4saTEC4yp,100000000
|
||||
5bRaq6XXdF7sQ7wAZBkz9BejkqdGxwXFQYSc5NPBPsf2Aqhi3FPuwYzRtJXVszo9KvQX3oxfzzysPg8ESedfm55Q,2,withdraw_dao_stake,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,,199896593
|
||||
4yEPy188HUustcjtDX4NMijHTPdNjz6XkMUBRdy6QXrR8Q5pRBt6sQaX4tsp2PRC8nR3YtNxTEV7GwfKDbg3oNXX,1,deposit,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,J7egxbTrrw8qg78VXdGax7ExQABAEiBpLAcwLz1Tes4q,CgQN2YQ6TvoEoWimw3vcDo5e9sXBYiNKVym4saTEC4yp,997945720
|
||||
2zzqbjTKJBRGfRghrshLEXmerUUCxen15uxgcnE1rihisgkXNTd9bV2SyGdR55Swm721MzyCdw7q6sin124U13Nu,4,deposit_dao_with_referrer,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,EuTp2BiKTGYN7bMrxYhKUwmqYoTM4MhGYV86bjQjFr5k,CgQN2YQ6TvoEoWimw3vcDo5e9sXBYiNKVym4saTEC4yp,1000000000
|
||||
Nau1Psy363PeTon1E9qFsJu6BMJ2h4WdLcQwhzLMJJNcLXqPwcsBjPEZrgqZPsVyNtAu4BeXDCVboUTF3pp8d1J,4,deposit_dao_stake,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,CgQN2YQ6TvoEoWimw3vcDo5e9sXBYiNKVym4saTEC4yp,102413074
|
||||
53U11neiXTjsMZPjRKrKF81zmn3KyJB75wcWzFzAy5XgAhdi3kQzRfLdyMgUEnvE63B8i37VUKzCHxV7KZvX4Cv6,1,withdraw,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,opuCM5KxMoapE3JuzQo56vyVzKTceXx4HunK8wE2TFA,CgQN2YQ6TvoEoWimw3vcDo5e9sXBYiNKVym4saTEC4yp,1014795
|
||||
33YV1cGrrKCVCEFnwHsNoZuyCFMYNJJS9EeC1C2b68GYKpfzCDvj2HkL7irqPCeB2aAtjcSimSU6z9BYSCbiWXKk,2,withdraw_stake,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,E9Y6mP85iRWkx47m6THG7SaedLhV1TtDF83zipzjDZ9P,,52350763411
|
||||
2ebQP2sxr8iwvHu7FboUEQ2pNka1yxCZjbaQ6PkZi12iYD6CQUrDqa9xL5dUbFtzPc7JgwyFiyNKzHFBuRD17r8a,3,withdraw_dao_stake,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,E9Y6mP85iRWkx47m6THG7SaedLhV1TtDF83zipzjDZ9P,,10102782383
|
||||
4HT8Z9NuxLUnoAotLEHiPVZVkk7MnjSkd9Cd9EuBktKJXXByjuxVnjUjMACCiKpfErPAXEijj7kFAva8HXm84CMJ,1,withdraw_dao,GUAMR8ciiaijraJeLDEDrFVaueLm9YzWWY9R7CBPL9rA,C4NeuptywfXuyWB9A7H7g5jHVDE8L6Nj2hS53tA71KPn,,6VX8ACEdTTqW88aQE2GnCL3PxvykEw77z52aNpu61VLX,CgQN2YQ6TvoEoWimw3vcDo5e9sXBYiNKVym4saTEC4yp,103638980
|
||||
|
13
data/testing__stake_pool_actions_generic.csv
Normal file
13
data/testing__stake_pool_actions_generic.csv
Normal file
@ -0,0 +1,13 @@
|
||||
tx_id,index,action,stake_pool,stake_pool_withdraw_authority,stake_pool_deposit_authority,address,reserve_stake_address,amount
|
||||
4ocHzNQ161VnXFEbkmxMLFT6VwMDAGpVCSpLDnRD3hgA8Fvq3pgHpbKmZ3UuRni2tiXzksRSpYVQtNgHuzeHKphn,1,deposit,7ge2xKsZXmqPxa3YmXxXmzCp9Hc2ezrTxh6PECaxCwrL,BbyX1GwUNsfbcoWwnkZDo8sqGmwNDzs2765RpjyQ1pQb,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,D9v6nTJiXBqERkMbe7c6eKXr7gSZToPgukAq2UxN2P96,50000000
|
||||
2g7khYUxEMVvs5oMHf9XJkXwWV72kE7VFGHcvgjGUWWSiWRRJvYuK6EaEbnH67vThFsJX3W6sUDQfcrHc1h8FMK3,0,deposit,7ge2xKsZXmqPxa3YmXxXmzCp9Hc2ezrTxh6PECaxCwrL,BbyX1GwUNsfbcoWwnkZDo8sqGmwNDzs2765RpjyQ1pQb,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,D9v6nTJiXBqERkMbe7c6eKXr7gSZToPgukAq2UxN2P96,50000000
|
||||
35W6m5tPp1EjMZR1xZ1W8PgiK678TDGf2AEnRrg5pY7orafmz5JAeFmcFnm7wkMvicDceJKmRWWyANvC8LrVt5g6,0,withdraw,7ge2xKsZXmqPxa3YmXxXmzCp9Hc2ezrTxh6PECaxCwrL,BbyX1GwUNsfbcoWwnkZDo8sqGmwNDzs2765RpjyQ1pQb,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,D9v6nTJiXBqERkMbe7c6eKXr7gSZToPgukAq2UxN2P96,93498109
|
||||
5NXr4gb2yN7wVLP7NDTPzJej3T9MtP1dqJ6GKgB2YGRUptTgQQa7S3dYfN4KYuQ92iDcx64GiRPY5sdGuw6CDDYd,2,deposit,stk9ApL5HeVAwPLr3TLhDXdZS8ptVu7zp6ov8HFDuMi,6WecYymEARvjG5ZyqkrVQ6YkhPfujNzWpSPwNKXHCbV2,,7zND8YAtCYehNoa1JrfDLQZi44xJkEuPWK5b4CkiuFpo,rsrxDvYUXjH1RQj2Ke36LNZEVqGztATxFkqNukERqFT,50000000
|
||||
23e5jGgkCib1iKFVWgNwaShRUf6nHjhH6gHegkTiRDUhqeGJVVbyCwo38VkaRe6Lzq2AoEaGeM7hvV2pd5rteCyz,3,withdraw_stake,stk9ApL5HeVAwPLr3TLhDXdZS8ptVu7zp6ov8HFDuMi,6WecYymEARvjG5ZyqkrVQ6YkhPfujNzWpSPwNKXHCbV2,,DpmY8CacDtzkLXnMFkFiMGmm1mf7yuyENiTAC8XWXKQD,,2946811454
|
||||
23e5jGgkCib1iKFVWgNwaShRUf6nHjhH6gHegkTiRDUhqeGJVVbyCwo38VkaRe6Lzq2AoEaGeM7hvV2pd5rteCyz,5,withdraw_stake,stk9ApL5HeVAwPLr3TLhDXdZS8ptVu7zp6ov8HFDuMi,6WecYymEARvjG5ZyqkrVQ6YkhPfujNzWpSPwNKXHCbV2,,DpmY8CacDtzkLXnMFkFiMGmm1mf7yuyENiTAC8XWXKQD,,2946749671
|
||||
XpspJcvGjC4xtd6d3jvL7uFKtBWbH1R6hMoRrhtkc8Jj7iZQK1LbUMBJhi7zMBHzPxfzoMPtS8wVJjd6sPSzfLn,2,withdraw,stk9ApL5HeVAwPLr3TLhDXdZS8ptVu7zp6ov8HFDuMi,6WecYymEARvjG5ZyqkrVQ6YkhPfujNzWpSPwNKXHCbV2,,uUHHTEWn2HhuxbHeziJQXVzKe8H8jmS2qPErYGJYJNR,rsrxDvYUXjH1RQj2Ke36LNZEVqGztATxFkqNukERqFT,4980015000
|
||||
48nEgEm7WQ5UMy4bqyX2nnvFtmnmE5vhSboHNvNjiM16cQtRBBDT4cSoVZMpcCqybwwpLcpt8VQez61fAsJS4iWD,1,deposit,CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1,HbJTxftxnXgpePCshA8FubsRj9MW4kfPscfuUfn44fnt,,xCyGtTiJeeo4JtNowub9YzahvtPDyhkYd2aJM4QUgye,AXu3DTw9AFq9FDTzX4vqA3XiT7LjrS5DpbsZaPpEx6qR,254990000
|
||||
wfBbfWMo9dFb912bLFFKioJr9vYu9ihbCJCCEhJZakF7WyA4pFYuV8cmqikPQRUbT9BHAPwYvz9LBXCCV5mSUM7,1,withdraw,CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1,HbJTxftxnXgpePCshA8FubsRj9MW4kfPscfuUfn44fnt,,449bbdcH2TDeaXM3dg1LEVnx45LNnMNhYb1uAtptVPmk,AXu3DTw9AFq9FDTzX4vqA3XiT7LjrS5DpbsZaPpEx6qR,200477319
|
||||
34vDDmQMPuupNKSgVRQyXrrBsMpJpQGZXagPN4xcQmMa1ebJLkfzYuXu5AsKhy6HiKN1vtfUQGLxgkqPumGxCNLz,2,deposit_stake,CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1,HbJTxftxnXgpePCshA8FubsRj9MW4kfPscfuUfn44fnt,GCjhUMwq9TxMDG6omiWq2qmjikSDE6jEqU7M6HQA16nT,8cTo55bRnB1fVURbqvdBJbM5nbxoQKvSh1ojQNagUFHs,AXu3DTw9AFq9FDTzX4vqA3XiT7LjrS5DpbsZaPpEx6qR,20105446381
|
||||
PLaj4us6K5nR3wzvy78CKdChUwTBXVnwuuq2AEMje92YkAzfBnkbiZ6JAnDWenbfrCRnnGmpyk8YFhssDEZgAGb,2,withdraw_stake,CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1,HbJTxftxnXgpePCshA8FubsRj9MW4kfPscfuUfn44fnt,,YoUqcx1VdF4d5othDYbJhfFLvorBQGTKcFUKkRHH9ue,,1000004010
|
||||
PLaj4us6K5nR3wzvy78CKdChUwTBXVnwuuq2AEMje92YkAzfBnkbiZ6JAnDWenbfrCRnnGmpyk8YFhssDEZgAGb,4,withdraw_stake,CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1,HbJTxftxnXgpePCshA8FubsRj9MW4kfPscfuUfn44fnt,,YoUqcx1VdF4d5othDYbJhfFLvorBQGTKcFUKkRHH9ue,,107125913
|
||||
|
6
data/testing__stake_pool_actions_lido.csv
Normal file
6
data/testing__stake_pool_actions_lido.csv
Normal file
@ -0,0 +1,6 @@
|
||||
tx_id,index,action,stake_pool,stake_pool_withdraw_authority,stake_pool_deposit_authority,address,reserve_stake_address,amount
|
||||
5NzsaC4sXduB4Q9JwWNuUfxmKyUmQQsrLJTxtuiXGkD1Eb9evZE5BhafXv5vuRxSnEPj2ZtyPftapnZf4cevh4WX,1,deposit,49Yi1TKkNyYjPAFdR9LBvoHcUjuPX4Df5T5yv39w2XTn,,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,3Kwv3pEAuoe4WevPB4rgMBTZndGDb53XT7qwQKnvHPfX,50000000
|
||||
2n9aKrgL7GT22DTUpzfoYSSELDuwdxVLgjX17dubTL6tWbtkjXNUfYc1rnT9Hy4Ga7spoKYnWgzTU72D7GvRBCxG,0,deposit,49Yi1TKkNyYjPAFdR9LBvoHcUjuPX4Df5T5yv39w2XTn,,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,3Kwv3pEAuoe4WevPB4rgMBTZndGDb53XT7qwQKnvHPfX,50000000
|
||||
35bZ29SXpyLpG45AyXXufxa1uFStQGV5pmk3tfi1bSMbmQksaPJpNF55bzFHhj9odAeBsdgZHLQvkmwdGrJsR4Qk,0,withdraw,49Yi1TKkNyYjPAFdR9LBvoHcUjuPX4Df5T5yv39w2XTn,W1ZQRwUfSkDKy2oefRBUWph82Vr2zg9txWMA8RQazN5,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,,99974857
|
||||
22WgmSkrMYkjhyatxhK3Riv6Jdnjmf29aJWdbYmJ1aJpSi619PoAYrFBknCRZ3xVwFX6oR9wZrcPaHSh6gzBMzwg,2,deposit,49Yi1TKkNyYjPAFdR9LBvoHcUjuPX4Df5T5yv39w2XTn,,,34jQqmbb6STqfnpWp1kJxTuTCJEFj7otVX1vBymb1Bj4,3Kwv3pEAuoe4WevPB4rgMBTZndGDb53XT7qwQKnvHPfX,499997900000
|
||||
3L3PwGmkXa3fJj71ps7uPhWzNQA3Fs4k769cMQHD54usuR8rjfJFZTPAE1bmbg3N3FpgRaksoSfTehvYx3md3VPE,0,withdraw,49Yi1TKkNyYjPAFdR9LBvoHcUjuPX4Df5T5yv39w2XTn,W1ZQRwUfSkDKy2oefRBUWph82Vr2zg9txWMA8RQazN5,,T2dv7qceZRMnHQkUXH7nBek3vH1kaBK63tCZWwq8KFZ,,258949100000
|
||||
|
7
data/testing__stake_pool_actions_marinade.csv
Normal file
7
data/testing__stake_pool_actions_marinade.csv
Normal file
@ -0,0 +1,7 @@
|
||||
tx_id,index,action,stake_pool,stake_pool_withdraw_authority,stake_pool_deposit_authority,address,reserve_stake_address,claim_ticket_address,amount
|
||||
3cudBDjWrhQo1AcL7kp6VYwR5FMwNaqcfSRMKxYuVLSU4En8tGcaNCefNCSm8XCcoGcsm4bkQHLhmkBVHsHKa2mk,0,deposit_stake,8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC,,4bZ6o3eUUNXhKuqjdCnCoPAoLgWiuLYixKaxoa8PpiKk,GNbvTVxDDC52Rc9WWMtUKF33d89EotcSw6dEKk9nh6mX,,,156049675238
|
||||
DwuAeLFnvBhg1uckZe3tAWBq2pSbAjATdhAptwpRbxALzQkNH9EiEwr985PdHqEvesaRyhPL7iV2EhmgFoBXSG9,1,order_unstake,8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC,,,AgaVCudHEvkayRnEZ8qTusmNAVe5Bfj3ZDtgPaYL1DDZ,,AJUJTNX7217SZSveYPZRkm7yyw7zb1ZDr5CVzMm7t1AF,
|
||||
3t9HvLgvv42CDDp4DmGFMX44CgaoTtYMfyX5kDs6z4jwEPqWAFmXQ3bKknY1oymqrTjgw9Ax7RU8kn5XdFCsyviJ,0,claim,8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC,,,AgaVCudHEvkayRnEZ8qTusmNAVe5Bfj3ZDtgPaYL1DDZ,Du3Ysj1wKbxPKkuPPnvzQLQh8oMSVifs3jGZjJWXFmHN,AJUJTNX7217SZSveYPZRkm7yyw7zb1ZDr5CVzMm7t1AF,501495754
|
||||
Z43TJRkym3QqKyjdqLFsHY3DSZXJeHsYJNU63hGbpcX2ERxaK5XGfjqZXEqv5x149QR2ZDTsjqdMcM4MRSF4weF,0,claim,8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC,,,H58zveXJ7E6oTtmSGxgKmSyxtuBsDFEekAEbseRCnJXP,Du3Ysj1wKbxPKkuPPnvzQLQh8oMSVifs3jGZjJWXFmHN,9zPpKWtn3BREDkCpurE44rKd2Fb5Vi8S4moGzjJvUq6P,2065767649593
|
||||
4xDDzJGkm6uhomMoVcGdvsPUt1sveYv7u2k6P8ocGi9ecsheACw6oGEEzpZQJdFzYm5e8r8rRjBNyqabJN63zdmM,0.1,deposit,8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC,,,TZ7g3id6KocGgfL7gmGPkDF4AE3NZJNnvdZz2rppkBB,Du3Ysj1wKbxPKkuPPnvzQLQh8oMSVifs3jGZjJWXFmHN,,1847770723929
|
||||
4xDDzJGkm6uhomMoVcGdvsPUt1sveYv7u2k6P8ocGi9ecsheACw6oGEEzpZQJdFzYm5e8r8rRjBNyqabJN63zdmM,0.2,deposit,8szGkuLTAux9XMgZ2vtY39jVSowEcpBfFfD8hXSEqdGC,,,TZ7g3id6KocGgfL7gmGPkDF4AE3NZJNnvdZz2rppkBB,Du3Ysj1wKbxPKkuPPnvzQLQh8oMSVifs3jGZjJWXFmHN,,4152229276071
|
||||
|
6
data/testing__stake_pool_actions_socean.csv
Normal file
6
data/testing__stake_pool_actions_socean.csv
Normal file
@ -0,0 +1,6 @@
|
||||
tx_id,index,action,stake_pool,stake_pool_withdraw_authority,stake_pool_deposit_authority,address,reserve_stake_address,amount
|
||||
4pCtKHgugzwsXJ3HVRSyQroMkSVu9Uq5xXa92wm8qk3uzPBspJMyFSpS7K6zwUTGLrwtTufuppNKBMgbFGT1ntNC,1,deposit,5oc4nmbNTda9fx8Tw57ShLD132aqDK65vuHH4RU1K4LZ,AzZRvyyMHBm8EHEksWxq4ozFL7JxLMydCDMGhqM6BVck,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,4sDXGroVt7ba45rzXtNto97QjG1rHm8Py3v56Mgg16Nc,50000000
|
||||
4RG4VM2c7zVVL1pNzyojNquEHm9eK5tFxC3BYdxjsbXv6R7YgMv34r2qo79t2nmTXg4fPTfat2MbYrNMUCAyxkP3,1,withdraw_stake,5oc4nmbNTda9fx8Tw57ShLD132aqDK65vuHH4RU1K4LZ,AzZRvyyMHBm8EHEksWxq4ozFL7JxLMydCDMGhqM6BVck,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,,99939999
|
||||
2uSppNnHD25xVpawL8TgYACBsLAKXDTUBLWMwUupEjFMA4DScKrozcXJdurvJHh3AZwLoQzW3swov1bX5TtWKFTj,0,deposit,5oc4nmbNTda9fx8Tw57ShLD132aqDK65vuHH4RU1K4LZ,AzZRvyyMHBm8EHEksWxq4ozFL7JxLMydCDMGhqM6BVck,,5e27Qkimu9pB4R5eUEagxMd1tpHz951J7AwcJNwdtMH1,4sDXGroVt7ba45rzXtNto97QjG1rHm8Py3v56Mgg16Nc,50000000
|
||||
4KdY9xd6dbEx5F5zEN5Vy5qAN4ZTgWP8zscSoWj9xjd5fxwTWHn4xbVfnT1Nm39a3bpcq1Wcv3g6TNB9HoyTquAN,4,deposit_stake,5oc4nmbNTda9fx8Tw57ShLD132aqDK65vuHH4RU1K4LZ,AzZRvyyMHBm8EHEksWxq4ozFL7JxLMydCDMGhqM6BVck,Hf1kZVQhQSYqjn9p2AYwxpGuMq8MDvXRxS3zbygwHU7p,8GVtCCqaG9SRNDzPKXQH6XuRiMRTBTjsDjbfcYXpGRXc,4sDXGroVt7ba45rzXtNto97QjG1rHm8Py3v56Mgg16Nc,1980000000
|
||||
2BvmWkeogYu2rWiBmKE3zvXy73odpyQ4yC6LTcebhpDuZBXYryuCTTpURQ1Fqdgun1j3k7ueZwsxMXmYQGyBLtXt,2,withdraw_stake,5oc4nmbNTda9fx8Tw57ShLD132aqDK65vuHH4RU1K4LZ,AzZRvyyMHBm8EHEksWxq4ozFL7JxLMydCDMGhqM6BVck,,8rWUUytNc5UEnoj4AYcGYXnT92YdupgE72XUycgtWuU1,,37511641048031
|
||||
|
34
models/core/core__fact_stake_pool_actions.sql
Normal file
34
models/core/core__fact_stake_pool_actions.sql
Normal file
@ -0,0 +1,34 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'STAKING' }}}
|
||||
) }}
|
||||
|
||||
{% for model_suffix in ["generic","socean","lido","marinade","eversol"] %}
|
||||
|
||||
SELECT
|
||||
CASE
|
||||
WHEN '{{ model_suffix }}' = 'generic' THEN CASE
|
||||
WHEN stake_pool = '7ge2xKsZXmqPxa3YmXxXmzCp9Hc2ezrTxh6PECaxCwrL' THEN 'daopool'
|
||||
WHEN stake_pool = 'CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1' THEN 'jpool'
|
||||
WHEN stake_pool = 'stk9ApL5HeVAwPLr3TLhDXdZS8ptVu7zp6ov8HFDuMi' THEN 'blazestake'
|
||||
END
|
||||
ELSE '{{ model_suffix }}'
|
||||
END AS stake_pool_name,
|
||||
tx_id,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
INDEX,
|
||||
succeeded,
|
||||
action,
|
||||
address,
|
||||
stake_pool,
|
||||
amount
|
||||
FROM
|
||||
{{ ref(
|
||||
'silver__stake_pool_actions_' + model_suffix
|
||||
) }}
|
||||
|
||||
{% if not loop.last %}
|
||||
UNION ALL
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
45
models/core/core__fact_stake_pool_actions.yml
Normal file
45
models/core/core__fact_stake_pool_actions.yml
Normal file
@ -0,0 +1,45 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: core__fact_stake_pool_actions
|
||||
description: Deposit and withdraw actions with a given stake pool
|
||||
columns:
|
||||
- name: STAKE_POOL_NAME
|
||||
description: "Name of stake pool action is performed against"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INDEX
|
||||
description: Location of the stake pool action within a transaction
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: ACTION
|
||||
description: "{{ doc('stake_pool_action') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: STAKE_POOL
|
||||
description: "{{ doc('stake_pool') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: ADDRESS
|
||||
description: "{{ doc('stake_pool_address') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('stake_pool_amount') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
5
models/descriptions/stake_pool.md
Normal file
5
models/descriptions/stake_pool.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs stake_pool %}
|
||||
|
||||
Address for a given stake pool
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/stake_pool_action.md
Normal file
5
models/descriptions/stake_pool_action.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs stake_pool_action %}
|
||||
|
||||
Action performed against a given stake pool
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/stake_pool_address.md
Normal file
5
models/descriptions/stake_pool_address.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs stake_pool_address %}
|
||||
|
||||
Wallet address initiating the deposit/stake or withdraw/unstake
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/stake_pool_amount.md
Normal file
5
models/descriptions/stake_pool_amount.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs stake_pool_amount %}
|
||||
|
||||
Amount of SOL being deposited/staked or withdrawn/unstaked
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/stake_pool_deposit_authority.md
Normal file
5
models/descriptions/stake_pool_deposit_authority.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs stake_pool_deposit_authority %}
|
||||
|
||||
System address with authority to deposit into stake pool
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/stake_pool_reserve_stake_address.md
Normal file
5
models/descriptions/stake_pool_reserve_stake_address.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs stake_pool_reserve_stake_address %}
|
||||
|
||||
Address holding the reserved stake pool SOL
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/stake_pool_withdraw_authority.md
Normal file
5
models/descriptions/stake_pool_withdraw_authority.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs stake_pool_withdraw_authority %}
|
||||
|
||||
System address with authority to withdraw from stake pool
|
||||
|
||||
{% enddocs %}
|
||||
377
models/silver/staking/silver__stake_pool_actions_eversol.sql
Normal file
377
models/silver/staking/silver__stake_pool_actions_eversol.sql
Normal file
@ -0,0 +1,377 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "_unique_key",
|
||||
incremental_strategy = 'merge',
|
||||
cluster_by = ['block_timestamp::DATE','_inserted_timestamp::date']
|
||||
) }}
|
||||
|
||||
WITH base_stake_pool_events AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__events') }}
|
||||
WHERE
|
||||
program_id = 'EverSFw9uN5t1V8kS3ficHUcKffSjwpGzUSGd7mgmSks'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
AND
|
||||
block_timestamp :: DATE >= '2021-12-23'
|
||||
{% endif %}
|
||||
),
|
||||
base_balances AS (
|
||||
SELECT
|
||||
t.tx_id,
|
||||
signers,
|
||||
pre_balances,
|
||||
post_balances,
|
||||
account_keys
|
||||
FROM
|
||||
{{ ref('silver__transactions') }}
|
||||
t
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
DISTINCT tx_id,
|
||||
block_timestamp :: DATE AS b_date
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
) e
|
||||
ON e.b_date = t.block_timestamp :: DATE
|
||||
AND e.tx_id = t.tx_id
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
WHERE
|
||||
t.block_timestamp :: DATE >= '2021-12-23'
|
||||
{% endif %}
|
||||
),
|
||||
deposit_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) IN (10,11)
|
||||
AND instruction :accounts [8] :: STRING = '11111111111111111111111111111111'
|
||||
AND instruction :accounts [9] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
deposit_dao_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) in (14,15)
|
||||
AND instruction :accounts [9] :: STRING = '11111111111111111111111111111111'
|
||||
AND instruction :accounts [10] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
deposit_dao_with_referrer_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) in (15,16)
|
||||
AND instruction :accounts [10] :: STRING = '11111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
deposit_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 13
|
||||
AND instruction :accounts [9] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [10] :: STRING = 'SysvarStakeHistory1111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [12] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
deposit_dao_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) >= 13
|
||||
AND instruction :accounts [10] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'SysvarStakeHistory1111111111111111111111111'
|
||||
AND instruction :accounts [12] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [13] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
withdraw_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 12
|
||||
AND instruction :accounts [8] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [9] :: STRING = 'SysvarStakeHistory1111111111111111111111111'
|
||||
AND instruction :accounts [10] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
withdraw_dao_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 16
|
||||
AND instruction :accounts [9] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [10] :: STRING = 'SysvarStakeHistory1111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
AND instruction :accounts [12] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
withdraw_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 13
|
||||
AND instruction :accounts [10] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [12] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
withdraw_dao_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 17
|
||||
AND instruction :accounts [10] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [12] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
deposit_dao_stake_merge AS (
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit_dao_stake' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [2] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [16] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
e.instruction :accounts [5] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :destination :: STRING AS merge_destination,
|
||||
silver.udf_get_account_balances_index(
|
||||
merge_destination,
|
||||
b.account_keys
|
||||
) AS merge_destination_balances_index,
|
||||
silver.udf_get_account_balances_index(
|
||||
reserve_stake_address,
|
||||
b.account_keys
|
||||
) AS reserve_stake_balances_index,
|
||||
b.post_balances [merge_destination_balances_index] - b.pre_balances [merge_destination_balances_index] + b.post_balances [reserve_stake_balances_index] - b.pre_balances [reserve_stake_balances_index] AS amount,
|
||||
e._inserted_timestamp
|
||||
FROM
|
||||
deposit_dao_stake_events e
|
||||
LEFT OUTER JOIN base_balances b
|
||||
ON b.tx_id = e.tx_id
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :type = 'merge'
|
||||
AND i.value :programId = 'Stake11111111111111111111111111111111111111'
|
||||
)
|
||||
select
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [1] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
b.signers[0] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
e.instruction :accounts [2] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',e.tx_id,e.index) as _unique_key
|
||||
from deposit_events e
|
||||
LEFT OUTER JOIN base_balances b
|
||||
ON b.tx_id = e.tx_id
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
union
|
||||
select
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit_dao' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [1] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [12] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
e.instruction :accounts [2] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',e.tx_id,e.index) as _unique_key
|
||||
from deposit_dao_events e
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
union
|
||||
select
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit_dao_with_referrer' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [1] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [13] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
e.instruction :accounts [2] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',e.tx_id,e.index) as _unique_key
|
||||
from deposit_dao_with_referrer_events e
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
-- union
|
||||
-- select 'deposit_stake' as action, *
|
||||
-- from deposit_stake_events
|
||||
union
|
||||
select
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit_dao_stake' AS action,
|
||||
e.stake_pool,
|
||||
e.stake_pool_withdraw_authority,
|
||||
e.stake_pool_deposit_authority,
|
||||
e.address,
|
||||
e.reserve_stake_address,
|
||||
e.amount :: NUMBER AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
e.tx_id,
|
||||
e.index
|
||||
) AS _unique_key
|
||||
from deposit_dao_stake_merge e
|
||||
union
|
||||
select
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'withdraw' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [1] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [5] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
e.instruction :accounts [4] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',e.tx_id,e.index) as _unique_key
|
||||
from withdraw_events e
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
union
|
||||
select
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'withdraw_dao' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [1] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [14] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
e.instruction :accounts [5] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',e.tx_id,e.index) as _unique_key
|
||||
from withdraw_dao_events e
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
union
|
||||
select
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'withdraw_stake' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [2] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [5] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
NULL AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',e.tx_id,e.index) as _unique_key
|
||||
from withdraw_stake_events e
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
union
|
||||
select
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'withdraw_dao_stake' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [2] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [15] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
NULL AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',e.tx_id,e.index) as _unique_key
|
||||
from withdraw_dao_stake_events e
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
87
models/silver/staking/silver__stake_pool_actions_eversol.yml
Normal file
87
models/silver/staking/silver__stake_pool_actions_eversol.yml
Normal file
@ -0,0 +1,87 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__stake_pool_actions_eversol
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _UNIQUE_KEY
|
||||
- compare_model_subset:
|
||||
name: silver__stake_pool_actions_eversol_business_logic_test
|
||||
compare_model: ref('testing__stake_pool_actions_eversol')
|
||||
compare_columns:
|
||||
- tx_id
|
||||
- index
|
||||
- action
|
||||
- stake_pool
|
||||
- stake_pool_withdraw_authority
|
||||
- stake_pool_deposit_authority
|
||||
- address
|
||||
- reserve_stake_address
|
||||
- amount
|
||||
model_condition: "where tx_id in ('216FXs3ZY5f8gFTXtrCdbJkr3QNNFu3S1dbuTaaQU3dodTQd5cs7sE8v561su4xnRC8B5JtijT3kR9GySiASM4aM',
|
||||
'DhWuYAZAuEkfLGJ4H7q4wWLjUNwdB4w5v4mZco5znduVT1Nib5WdcViNmXS2TTEsEmcaXNAr2tZ783oA9Za6Ebi',
|
||||
'5bRaq6XXdF7sQ7wAZBkz9BejkqdGxwXFQYSc5NPBPsf2Aqhi3FPuwYzRtJXVszo9KvQX3oxfzzysPg8ESedfm55Q',
|
||||
'4yEPy188HUustcjtDX4NMijHTPdNjz6XkMUBRdy6QXrR8Q5pRBt6sQaX4tsp2PRC8nR3YtNxTEV7GwfKDbg3oNXX',
|
||||
'2zzqbjTKJBRGfRghrshLEXmerUUCxen15uxgcnE1rihisgkXNTd9bV2SyGdR55Swm721MzyCdw7q6sin124U13Nu',
|
||||
'Nau1Psy363PeTon1E9qFsJu6BMJ2h4WdLcQwhzLMJJNcLXqPwcsBjPEZrgqZPsVyNtAu4BeXDCVboUTF3pp8d1J',
|
||||
'53U11neiXTjsMZPjRKrKF81zmn3KyJB75wcWzFzAy5XgAhdi3kQzRfLdyMgUEnvE63B8i37VUKzCHxV7KZvX4Cv6',
|
||||
'33YV1cGrrKCVCEFnwHsNoZuyCFMYNJJS9EeC1C2b68GYKpfzCDvj2HkL7irqPCeB2aAtjcSimSU6z9BYSCbiWXKk',
|
||||
'2ebQP2sxr8iwvHu7FboUEQ2pNka1yxCZjbaQ6PkZi12iYD6CQUrDqa9xL5dUbFtzPc7JgwyFiyNKzHFBuRD17r8a',
|
||||
'4HT8Z9NuxLUnoAotLEHiPVZVkk7MnjSkd9Cd9EuBktKJXXByjuxVnjUjMACCiKpfErPAXEijj7kFAva8HXm84CMJ')"
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: INDEX
|
||||
description: Location of the stake pool action within a transaction
|
||||
tests:
|
||||
- not_null
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: ACTION
|
||||
description: "{{ doc('stake_pool_action') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL
|
||||
description: "{{ doc('stake_pool') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL_WITHDRAW_AUTHORITY
|
||||
description: "{{ doc('stake_pool_withdraw_authority') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL_DEPOSIT_AUTHORITY
|
||||
description: "{{ doc('stake_pool_deposit_authority') }}"
|
||||
- name: ADDRESS
|
||||
description: "{{ doc('stake_pool_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: RESERVE_STAKE_ADDRESS
|
||||
description: "{{ doc('stake_pool_reserve_stake_address') }}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: action not in ('withdraw_stake','withdraw_dao_stake')
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('stake_pool_amount') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _UNIQUE_KEY
|
||||
description: "Concatenation of columns to be used on merge for incremental loads"
|
||||
311
models/silver/staking/silver__stake_pool_actions_generic.sql
Normal file
311
models/silver/staking/silver__stake_pool_actions_generic.sql
Normal file
@ -0,0 +1,311 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "_unique_key",
|
||||
incremental_strategy = 'merge',
|
||||
cluster_by = ['block_timestamp::DATE','_inserted_timestamp::date']
|
||||
) }}
|
||||
|
||||
WITH base_stake_pool_events AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__events') }}
|
||||
WHERE
|
||||
program_id = 'SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy'
|
||||
AND instruction :accounts [0] :: STRING IN (
|
||||
-- daopool stake pool
|
||||
'7ge2xKsZXmqPxa3YmXxXmzCp9Hc2ezrTxh6PECaxCwrL',
|
||||
-- blazestake stake pool
|
||||
'stk9ApL5HeVAwPLr3TLhDXdZS8ptVu7zp6ov8HFDuMi',
|
||||
-- jpool stake pool
|
||||
'CtMyWsrUtAwXWiGr9WjHT5fC3p3fgV8cyGpLTo2LJzG1'
|
||||
)
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
AND
|
||||
block_timestamp :: DATE >= '2021-10-11'
|
||||
{% endif %}
|
||||
),
|
||||
base_balances AS (
|
||||
SELECT
|
||||
t.tx_id,
|
||||
signers,
|
||||
pre_balances,
|
||||
post_balances,
|
||||
account_keys
|
||||
FROM
|
||||
{{ ref('silver__transactions') }}
|
||||
t
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
DISTINCT tx_id,
|
||||
block_timestamp :: DATE AS b_date
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
) e
|
||||
ON e.b_date = t.block_timestamp :: DATE
|
||||
AND e.tx_id = t.tx_id
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
WHERE
|
||||
t.block_timestamp :: DATE >= '2021-10-11'
|
||||
{% endif %}
|
||||
),
|
||||
deposit_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) IN (
|
||||
10,
|
||||
11
|
||||
)
|
||||
AND instruction :accounts [8] :: STRING = '11111111111111111111111111111111'
|
||||
AND instruction :accounts [9] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
deposit_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 15
|
||||
AND instruction :accounts [11] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [12] :: STRING = 'SysvarStakeHistory1111111111111111111111111'
|
||||
AND instruction :accounts [13] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [14] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
withdraw_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) IN (
|
||||
12,
|
||||
13
|
||||
)
|
||||
AND instruction :accounts [8] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [9] :: STRING = 'SysvarStakeHistory1111111111111111111111111'
|
||||
AND instruction :accounts [10] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
withdraw_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 13
|
||||
AND instruction :accounts [10] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [12] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
increase_validator_stake_events AS (
|
||||
select *
|
||||
from base_stake_pool_events
|
||||
where ARRAY_SIZE(instruction :accounts) = 13
|
||||
and instruction:accounts[7] = 'SysvarC1ock11111111111111111111111111111111'
|
||||
and instruction:accounts[8] = 'SysvarRent111111111111111111111111111111111'
|
||||
and instruction:accounts[9] = 'SysvarStakeHistory1111111111111111111111111'
|
||||
and instruction:accounts[10] = 'StakeConfig11111111111111111111111111111111'
|
||||
and instruction:accounts[11] = '11111111111111111111111111111111'
|
||||
and instruction:accounts[12] = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
decrease_validator_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(instruction :accounts) = 10
|
||||
and instruction:accounts[6] = 'SysvarC1ock11111111111111111111111111111111'
|
||||
and instruction:accounts[7] = 'SysvarRent111111111111111111111111111111111'
|
||||
and instruction:accounts[8] = '11111111111111111111111111111111'
|
||||
and instruction:accounts[9] = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
deposit_stake_merge AS (
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [3] :: STRING AS stake_pool_withdraw_authority,
|
||||
e.instruction :accounts [2] :: STRING AS stake_pool_deposit_authority,
|
||||
b.signers [0] :: STRING AS address,
|
||||
e.instruction :accounts [6] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :destination :: STRING AS merge_destination,
|
||||
silver.udf_get_account_balances_index(
|
||||
merge_destination,
|
||||
b.account_keys
|
||||
) AS merge_destination_balances_index,
|
||||
silver.udf_get_account_balances_index(
|
||||
reserve_stake_address,
|
||||
b.account_keys
|
||||
) AS reserve_stake_balances_index,
|
||||
b.post_balances [merge_destination_balances_index] - b.pre_balances [merge_destination_balances_index] + b.post_balances [reserve_stake_balances_index] - b.pre_balances [reserve_stake_balances_index] AS amount,
|
||||
e._inserted_timestamp
|
||||
FROM
|
||||
deposit_stake_events e
|
||||
LEFT OUTER JOIN base_balances b
|
||||
ON b.tx_id = e.tx_id
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :type = 'merge'
|
||||
AND i.value :programId = 'Stake11111111111111111111111111111111111111'
|
||||
)
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [1] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
b.signers[0] :: STRING AS address, -- use signers instead of instruction account because of "passthrough" wallets
|
||||
e.instruction :accounts [2] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',e.tx_id,e.index) as _unique_key
|
||||
FROM
|
||||
deposit_events e
|
||||
LEFT OUTER JOIN base_balances b
|
||||
ON b.tx_id = e.tx_id
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'withdraw' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [1] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [5] :: STRING AS address,
|
||||
e.instruction :accounts [4] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',tx_id,e.index) as _unique_key
|
||||
FROM
|
||||
withdraw_events e,
|
||||
TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit_stake' AS action,
|
||||
e.stake_pool,
|
||||
e.stake_pool_withdraw_authority,
|
||||
e.stake_pool_deposit_authority,
|
||||
e.address,
|
||||
e.reserve_stake_address,
|
||||
e.amount :: NUMBER AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
e.tx_id,
|
||||
e.index
|
||||
) AS _unique_key
|
||||
FROM
|
||||
deposit_stake_merge e
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'withdraw_stake' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [2] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL as stake_pool_deposit_authority,
|
||||
e.instruction :accounts [5] :: STRING AS address,
|
||||
NULL AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',tx_id,e.index) as _unique_key
|
||||
FROM
|
||||
withdraw_stake_events e,
|
||||
TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
-- UNION
|
||||
-- SELECT
|
||||
-- e.tx_id,
|
||||
-- e.block_id,
|
||||
-- e.block_timestamp,
|
||||
-- e.index,
|
||||
-- e.succeeded,
|
||||
-- 'increase_validator_stake' AS action,
|
||||
-- e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
-- e.instruction :accounts [2] :: STRING AS stake_pool_withdraw_authority,
|
||||
-- NULL as stake_pool_deposit_authority,
|
||||
-- NULL AS address,
|
||||
-- e.instruction :accounts [4] :: STRING AS reserve_stake_address,
|
||||
-- i.value :parsed :info :lamports AS amount,
|
||||
-- e._inserted_timestamp,
|
||||
-- concat_ws('-',tx_id,e.index) as _unique_key
|
||||
-- FROM
|
||||
-- increase_validator_stake_events e,
|
||||
-- TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
-- WHERE
|
||||
-- i.value :parsed :info :lamports IS NOT NULL
|
||||
-- UNION
|
||||
-- SELECT
|
||||
-- e.tx_id,
|
||||
-- e.block_id,
|
||||
-- e.block_timestamp,
|
||||
-- e.index,
|
||||
-- e.succeeded,
|
||||
-- 'decrease_validator_stake' AS action,
|
||||
-- e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
-- e.instruction :accounts [2] :: STRING AS stake_pool_withdraw_authority,
|
||||
-- NULL as stake_pool_deposit_authority,
|
||||
-- NULL AS address,
|
||||
-- NULL AS reserve_stake_address,
|
||||
-- i.value :parsed :info :lamports AS amount,
|
||||
-- e._inserted_timestamp,
|
||||
-- concat_ws('-',tx_id,e.index) as _unique_key
|
||||
-- FROM
|
||||
-- decrease_validator_stake_events e,
|
||||
-- TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
-- WHERE
|
||||
-- i.value :parsed :info :lamports IS NOT NULL
|
||||
87
models/silver/staking/silver__stake_pool_actions_generic.yml
Normal file
87
models/silver/staking/silver__stake_pool_actions_generic.yml
Normal file
@ -0,0 +1,87 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__stake_pool_actions_generic
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _UNIQUE_KEY
|
||||
- compare_model_subset:
|
||||
name: silver__stake_pool_actions_generic_business_logic_test
|
||||
compare_model: ref('testing__stake_pool_actions_generic')
|
||||
compare_columns:
|
||||
- tx_id
|
||||
- index
|
||||
- action
|
||||
- stake_pool
|
||||
- stake_pool_withdraw_authority
|
||||
- stake_pool_deposit_authority
|
||||
- address
|
||||
- reserve_stake_address
|
||||
- amount
|
||||
model_condition: "where tx_id in ('4ocHzNQ161VnXFEbkmxMLFT6VwMDAGpVCSpLDnRD3hgA8Fvq3pgHpbKmZ3UuRni2tiXzksRSpYVQtNgHuzeHKphn',
|
||||
'2g7khYUxEMVvs5oMHf9XJkXwWV72kE7VFGHcvgjGUWWSiWRRJvYuK6EaEbnH67vThFsJX3W6sUDQfcrHc1h8FMK3',
|
||||
'35W6m5tPp1EjMZR1xZ1W8PgiK678TDGf2AEnRrg5pY7orafmz5JAeFmcFnm7wkMvicDceJKmRWWyANvC8LrVt5g6',
|
||||
'5NXr4gb2yN7wVLP7NDTPzJej3T9MtP1dqJ6GKgB2YGRUptTgQQa7S3dYfN4KYuQ92iDcx64GiRPY5sdGuw6CDDYd',
|
||||
'23e5jGgkCib1iKFVWgNwaShRUf6nHjhH6gHegkTiRDUhqeGJVVbyCwo38VkaRe6Lzq2AoEaGeM7hvV2pd5rteCyz',
|
||||
'XpspJcvGjC4xtd6d3jvL7uFKtBWbH1R6hMoRrhtkc8Jj7iZQK1LbUMBJhi7zMBHzPxfzoMPtS8wVJjd6sPSzfLn',
|
||||
'48nEgEm7WQ5UMy4bqyX2nnvFtmnmE5vhSboHNvNjiM16cQtRBBDT4cSoVZMpcCqybwwpLcpt8VQez61fAsJS4iWD',
|
||||
'wfBbfWMo9dFb912bLFFKioJr9vYu9ihbCJCCEhJZakF7WyA4pFYuV8cmqikPQRUbT9BHAPwYvz9LBXCCV5mSUM7',
|
||||
'34vDDmQMPuupNKSgVRQyXrrBsMpJpQGZXagPN4xcQmMa1ebJLkfzYuXu5AsKhy6HiKN1vtfUQGLxgkqPumGxCNLz',
|
||||
'PLaj4us6K5nR3wzvy78CKdChUwTBXVnwuuq2AEMje92YkAzfBnkbiZ6JAnDWenbfrCRnnGmpyk8YFhssDEZgAGb')"
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: INDEX
|
||||
description: Location of the stake pool action within a transaction
|
||||
tests:
|
||||
- not_null
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: ACTION
|
||||
description: "{{ doc('stake_pool_action') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL
|
||||
description: "{{ doc('stake_pool') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL_WITHDRAW_AUTHORITY
|
||||
description: "{{ doc('stake_pool_withdraw_authority') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL_DEPOSIT_AUTHORITY
|
||||
description: "{{ doc('stake_pool_deposit_authority') }}"
|
||||
- name: ADDRESS
|
||||
description: "{{ doc('stake_pool_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: RESERVE_STAKE_ADDRESS
|
||||
description: "{{ doc('stake_pool_reserve_stake_address') }}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: action <> 'withdraw_stake'
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('stake_pool_amount') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _UNIQUE_KEY
|
||||
description: "Concatenation of columns to be used on merge for incremental loads"
|
||||
149
models/silver/staking/silver__stake_pool_actions_lido.sql
Normal file
149
models/silver/staking/silver__stake_pool_actions_lido.sql
Normal file
@ -0,0 +1,149 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "_unique_key",
|
||||
incremental_strategy = 'merge',
|
||||
cluster_by = ['block_timestamp::DATE','_inserted_timestamp::date']
|
||||
) }}
|
||||
|
||||
WITH base_lido_events AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__events') }}
|
||||
WHERE
|
||||
program_id = 'CrX7kMhLC3cSsXJdT7JDgqrRVWGnUpX3gfEfxxU2NVLi'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
deposit_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_lido_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 8
|
||||
AND instruction :accounts [6] = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [7] = '11111111111111111111111111111111'
|
||||
),
|
||||
withdraw_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_lido_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 12
|
||||
AND instruction :accounts [8] = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [9] = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [10] = '11111111111111111111111111111111'
|
||||
AND instruction :accounts [11] = 'Stake11111111111111111111111111111111111111'
|
||||
)
|
||||
--,
|
||||
-- stake_events AS (
|
||||
-- select *
|
||||
-- from base_lido_events
|
||||
-- where ARRAY_SIZE(instruction :accounts) = 13
|
||||
-- and instruction:accounts[7] = 'SysvarC1ock11111111111111111111111111111111'
|
||||
-- and instruction:accounts[8] = '11111111111111111111111111111111'
|
||||
-- and instruction:accounts[9] = 'SysvarRent111111111111111111111111111111111'
|
||||
-- and instruction:accounts[10] = 'Stake11111111111111111111111111111111111111'
|
||||
-- and instruction:accounts[11] = 'SysvarStakeHistory1111111111111111111111111'
|
||||
-- and instruction:accounts[12] = 'StakeConfig11111111111111111111111111111111'
|
||||
-- ),
|
||||
-- unstake_events AS (
|
||||
-- SELECT
|
||||
-- *
|
||||
-- FROM
|
||||
-- base_lido_events
|
||||
-- WHERE
|
||||
-- ARRAY_SIZE(
|
||||
-- instruction :accounts
|
||||
-- ) = 9
|
||||
-- AND instruction :accounts [6] = 'SysvarC1ock11111111111111111111111111111111'
|
||||
-- AND instruction :accounts [7] = '11111111111111111111111111111111'
|
||||
-- AND instruction :accounts [8] = 'Stake11111111111111111111111111111111111111'
|
||||
-- )
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
NULL AS stake_pool_withdraw_authority,
|
||||
NULL AS stake_pool_deposit_authority,
|
||||
e.instruction :accounts [1] :: STRING AS address,
|
||||
e.instruction :accounts [4] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',tx_id,e.index) as _unique_key
|
||||
FROM
|
||||
deposit_events e,
|
||||
TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'withdraw' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [7] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL AS stake_pool_deposit_authority,
|
||||
e.instruction :accounts [1] :: STRING AS address,
|
||||
NULL AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws('-',tx_id,e.index) as _unique_key
|
||||
FROM
|
||||
withdraw_events e,
|
||||
TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
-- UNION
|
||||
-- SELECT
|
||||
-- e.tx_id,
|
||||
-- e.block_timestamp,
|
||||
-- e.index,
|
||||
-- e.succeeded,
|
||||
-- 'deposit_stake' AS action,
|
||||
-- NULL AS delegator_address,
|
||||
-- i.value :parsed :info :lamports AS amount,
|
||||
-- e._inserted_timestamp,
|
||||
-- concat_ws('-',tx_id,e.index) as _unique_key
|
||||
-- FROM
|
||||
-- stake_events e,
|
||||
-- TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
-- WHERE
|
||||
-- i.value :parsed :info :lamports IS NOT NULL
|
||||
-- UNION
|
||||
-- SELECT
|
||||
-- e.tx_id,
|
||||
-- e.block_timestamp,
|
||||
-- e.index,
|
||||
-- e.succeeded,
|
||||
-- 'unstake' AS action,
|
||||
-- NULL AS delegator_address,
|
||||
-- i.value :parsed :info :lamports AS amount,
|
||||
-- e._inserted_timestamp,
|
||||
-- concat_ws('-',tx_id,e.index) as _unique_key
|
||||
-- FROM
|
||||
-- unstake_events e,
|
||||
-- TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
-- WHERE
|
||||
-- i.value :parsed :info :lamports IS NOT NULL
|
||||
83
models/silver/staking/silver__stake_pool_actions_lido.yml
Normal file
83
models/silver/staking/silver__stake_pool_actions_lido.yml
Normal file
@ -0,0 +1,83 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__stake_pool_actions_lido
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _UNIQUE_KEY
|
||||
- compare_model_subset:
|
||||
name: silver__stake_pool_actions_lido_business_logic_test
|
||||
compare_model: ref('testing__stake_pool_actions_lido')
|
||||
compare_columns:
|
||||
- tx_id
|
||||
- index
|
||||
- action
|
||||
- stake_pool
|
||||
- stake_pool_withdraw_authority
|
||||
- stake_pool_deposit_authority
|
||||
- address
|
||||
- reserve_stake_address
|
||||
- amount
|
||||
model_condition: "where tx_id in ('5NzsaC4sXduB4Q9JwWNuUfxmKyUmQQsrLJTxtuiXGkD1Eb9evZE5BhafXv5vuRxSnEPj2ZtyPftapnZf4cevh4WX',
|
||||
'2n9aKrgL7GT22DTUpzfoYSSELDuwdxVLgjX17dubTL6tWbtkjXNUfYc1rnT9Hy4Ga7spoKYnWgzTU72D7GvRBCxG',
|
||||
'35bZ29SXpyLpG45AyXXufxa1uFStQGV5pmk3tfi1bSMbmQksaPJpNF55bzFHhj9odAeBsdgZHLQvkmwdGrJsR4Qk',
|
||||
'3L3PwGmkXa3fJj71ps7uPhWzNQA3Fs4k769cMQHD54usuR8rjfJFZTPAE1bmbg3N3FpgRaksoSfTehvYx3md3VPE',
|
||||
'22WgmSkrMYkjhyatxhK3Riv6Jdnjmf29aJWdbYmJ1aJpSi619PoAYrFBknCRZ3xVwFX6oR9wZrcPaHSh6gzBMzwg')"
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: INDEX
|
||||
description: Location of the stake pool action within a transaction
|
||||
tests:
|
||||
- not_null
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: ACTION
|
||||
description: "{{ doc('stake_pool_action') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL
|
||||
description: "{{ doc('stake_pool') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL_WITHDRAW_AUTHORITY
|
||||
description: "{{ doc('stake_pool_withdraw_authority') }}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: action = 'withdraw'
|
||||
- name: STAKE_POOL_DEPOSIT_AUTHORITY
|
||||
description: "{{ doc('stake_pool_deposit_authority') }}"
|
||||
- name: ADDRESS
|
||||
description: "{{ doc('stake_pool_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: RESERVE_STAKE_ADDRESS
|
||||
description: "{{ doc('stake_pool_reserve_stake_address') }}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: action <> 'withdraw'
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('stake_pool_amount') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _UNIQUE_KEY
|
||||
description: "Concatenation of columns to be used on merge for incremental loads"
|
||||
250
models/silver/staking/silver__stake_pool_actions_marinade.sql
Normal file
250
models/silver/staking/silver__stake_pool_actions_marinade.sql
Normal file
@ -0,0 +1,250 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "_unique_key",
|
||||
incremental_strategy = 'merge',
|
||||
cluster_by = ['block_timestamp::DATE','_inserted_timestamp::date']
|
||||
) }}
|
||||
|
||||
WITH base_marinade_stake_events AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__events') }}
|
||||
WHERE
|
||||
program_id = 'MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
AND block_timestamp :: DATE >= '2021-08-01'
|
||||
{% endif %}
|
||||
),
|
||||
base_balances AS (
|
||||
SELECT
|
||||
t.tx_id,
|
||||
signers,
|
||||
pre_balances,
|
||||
post_balances,
|
||||
account_keys
|
||||
FROM
|
||||
{{ ref('silver__transactions') }}
|
||||
t
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
DISTINCT tx_id,
|
||||
block_timestamp :: DATE AS b_date
|
||||
FROM
|
||||
base_marinade_stake_events
|
||||
) e
|
||||
ON e.b_date = t.block_timestamp :: DATE
|
||||
AND e.tx_id = t.tx_id
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
WHERE
|
||||
t.block_timestamp :: DATE >= '2021-08-01'
|
||||
{% endif %}
|
||||
),
|
||||
deposit_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_marinade_stake_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 11
|
||||
AND instruction :accounts [9] = '11111111111111111111111111111111'
|
||||
AND instruction :accounts [10] = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
deposit_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_marinade_stake_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 15
|
||||
AND instruction :accounts [10] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'SysvarRent111111111111111111111111111111111'
|
||||
AND instruction :accounts [12] :: STRING = '11111111111111111111111111111111'
|
||||
AND instruction :accounts [13] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [14] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
order_unstake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_marinade_stake_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 8
|
||||
AND instruction :accounts [5] = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [6] = 'SysvarRent111111111111111111111111111111111'
|
||||
AND instruction :accounts [7] = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
claim_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_marinade_stake_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 6
|
||||
AND instruction :accounts [4] = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [5] = '11111111111111111111111111111111'
|
||||
),
|
||||
deposit_stake_authorize AS (
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
NULL AS stake_pool_withdraw_authority,
|
||||
i.value :parsed :info :newAuthority :: STRING AS stake_pool_deposit_authority,
|
||||
e.instruction :accounts [4] :: STRING AS address,
|
||||
NULL AS reserve_stake_address,
|
||||
e.instruction :accounts [3] :: STRING AS stake_account,
|
||||
silver.udf_get_account_balances_index(
|
||||
stake_account,
|
||||
b.account_keys
|
||||
) AS stake_account_balances_index,
|
||||
b.post_balances [stake_account_balances_index] AS amount,
|
||||
e._inserted_timestamp
|
||||
FROM
|
||||
deposit_stake_events e
|
||||
LEFT OUTER JOIN base_balances b
|
||||
ON b.tx_id = e.tx_id
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :type :: STRING = 'authorize'
|
||||
AND i.value :parsed :info :authorityType :: STRING = 'Staker'
|
||||
AND i.value :programId = 'Stake11111111111111111111111111111111111111'
|
||||
)
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
CONCAT(
|
||||
e.index,
|
||||
'.',
|
||||
i.index
|
||||
) AS INDEX,
|
||||
e.succeeded,
|
||||
'deposit' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
NULL AS stake_pool_withdraw_authority,
|
||||
NULL AS stake_pool_deposit_authority,
|
||||
e.instruction :accounts [6] :: STRING AS address,
|
||||
e.instruction :accounts [5] :: STRING AS reserve_stake_address,
|
||||
NULL AS claim_ticket_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
tx_id,
|
||||
CONCAT(
|
||||
e.index,
|
||||
'.',
|
||||
i.index
|
||||
)
|
||||
) AS _unique_key
|
||||
FROM
|
||||
deposit_events e,
|
||||
TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit_stake' AS action,
|
||||
e.stake_pool,
|
||||
e.stake_pool_withdraw_authority,
|
||||
e.stake_pool_deposit_authority,
|
||||
e.address,
|
||||
e.reserve_stake_address,
|
||||
NULL AS claim_ticket_address,
|
||||
e.amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
tx_id,
|
||||
e.index
|
||||
) AS _unique_key
|
||||
FROM
|
||||
deposit_stake_authorize e
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'order_unstake' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
NULL AS stake_pool_withdraw_authority,
|
||||
NULL AS stake_pool_deposit_authority,
|
||||
e.instruction :accounts [3] :: STRING AS address,
|
||||
NULL AS reserve_stake_address,
|
||||
e.instruction :accounts [4] :: STRING AS claim_ticket_address,
|
||||
NULL AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
tx_id,
|
||||
e.index
|
||||
) AS _unique_key
|
||||
FROM
|
||||
order_unstake_events e
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'claim' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
NULL AS stake_pool_withdraw_authority,
|
||||
NULL AS stake_pool_deposit_authority,
|
||||
e.instruction :accounts [3] :: STRING AS address,
|
||||
e.instruction :accounts [1] :: STRING AS reserve_stake_address,
|
||||
e.instruction :accounts [2] :: STRING AS claim_ticket_address,
|
||||
(
|
||||
i.value :parsed :info :lamports + b.pre_balances [silver.udf_get_account_balances_index( claim_ticket_address, b.account_keys)]
|
||||
) :: NUMBER AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
e.tx_id,
|
||||
e.index
|
||||
) AS _unique_key
|
||||
FROM
|
||||
claim_events e
|
||||
LEFT OUTER JOIN base_balances b
|
||||
ON b.tx_id = e.tx_id
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
@ -0,0 +1,90 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__stake_pool_actions_marinade
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _UNIQUE_KEY
|
||||
- compare_model_subset:
|
||||
name: silver__stake_pool_actions_marinade_business_logic_test
|
||||
compare_model: ref('testing__stake_pool_actions_marinade')
|
||||
compare_columns:
|
||||
- tx_id
|
||||
- index
|
||||
- action
|
||||
- stake_pool
|
||||
- stake_pool_withdraw_authority
|
||||
- stake_pool_deposit_authority
|
||||
- address
|
||||
- reserve_stake_address
|
||||
- claim_ticket_address
|
||||
- amount
|
||||
model_condition: "where tx_id in ('3cudBDjWrhQo1AcL7kp6VYwR5FMwNaqcfSRMKxYuVLSU4En8tGcaNCefNCSm8XCcoGcsm4bkQHLhmkBVHsHKa2mk',
|
||||
'DwuAeLFnvBhg1uckZe3tAWBq2pSbAjATdhAptwpRbxALzQkNH9EiEwr985PdHqEvesaRyhPL7iV2EhmgFoBXSG9',
|
||||
'3t9HvLgvv42CDDp4DmGFMX44CgaoTtYMfyX5kDs6z4jwEPqWAFmXQ3bKknY1oymqrTjgw9Ax7RU8kn5XdFCsyviJ',
|
||||
'Z43TJRkym3QqKyjdqLFsHY3DSZXJeHsYJNU63hGbpcX2ERxaK5XGfjqZXEqv5x149QR2ZDTsjqdMcM4MRSF4weF',
|
||||
'4xDDzJGkm6uhomMoVcGdvsPUt1sveYv7u2k6P8ocGi9ecsheACw6oGEEzpZQJdFzYm5e8r8rRjBNyqabJN63zdmM')"
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: INDEX
|
||||
description: Location of the stake pool action within a transaction
|
||||
tests:
|
||||
- not_null
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: ACTION
|
||||
description: "{{ doc('stake_pool_action') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL
|
||||
description: "{{ doc('stake_pool') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL_WITHDRAW_AUTHORITY
|
||||
description: "{{ doc('stake_pool_withdraw_authority') }}"
|
||||
- name: STAKE_POOL_DEPOSIT_AUTHORITY
|
||||
tests:
|
||||
- not_null:
|
||||
where: action = 'deposit_stake'
|
||||
description: "{{ doc('stake_pool_deposit_authority') }}"
|
||||
- name: ADDRESS
|
||||
description: "{{ doc('stake_pool_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: RESERVE_STAKE_ADDRESS
|
||||
description: "{{ doc('stake_pool_reserve_stake_address') }}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: action in ('deposit','claim')
|
||||
- name: CLAIM_TICKET_ADDRESS
|
||||
description: "Address to be used to claim unstaked SOL when it is available in n+(1 or 2) epochs after an order_unstake action"
|
||||
tests:
|
||||
- not_null:
|
||||
where: action in ('order_unstake','claim')
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('stake_pool_amount') }}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: action <> 'order_unstake'
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _UNIQUE_KEY
|
||||
description: "Concatenation of columns to be used on merge for incremental loads"
|
||||
206
models/silver/staking/silver__stake_pool_actions_socean.sql
Normal file
206
models/silver/staking/silver__stake_pool_actions_socean.sql
Normal file
@ -0,0 +1,206 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
unique_key = "_unique_key",
|
||||
incremental_strategy = 'merge',
|
||||
cluster_by = ['block_timestamp::DATE','_inserted_timestamp::date']
|
||||
) }}
|
||||
|
||||
WITH base_stake_pool_events AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__events') }}
|
||||
WHERE
|
||||
program_id = '5ocnV1qiCgaQR8Jb8xWnVbApfaygJ8tNoZfgPwsgx9kx'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
AND block_timestamp :: DATE >= '2021-09-04'
|
||||
{% endif %}
|
||||
),
|
||||
base_balances AS (
|
||||
SELECT
|
||||
t.tx_id,
|
||||
signers,
|
||||
pre_balances,
|
||||
post_balances,
|
||||
account_keys
|
||||
FROM
|
||||
{{ ref('silver__transactions') }}
|
||||
t
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
DISTINCT tx_id,
|
||||
block_timestamp :: DATE AS b_date
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
) e
|
||||
ON e.b_date = t.block_timestamp :: DATE
|
||||
AND e.tx_id = t.tx_id
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp)
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% else %}
|
||||
WHERE
|
||||
t.block_timestamp :: DATE >= '2021-09-04'
|
||||
{% endif %}
|
||||
),
|
||||
deposit_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) IN (
|
||||
11,
|
||||
12
|
||||
)
|
||||
AND instruction :accounts [8] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [9] :: STRING = '11111111111111111111111111111111'
|
||||
AND instruction :accounts [10] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
),
|
||||
deposit_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 15
|
||||
AND instruction :accounts [11] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [12] :: STRING = 'SysvarStakeHistory1111111111111111111111111'
|
||||
AND instruction :accounts [13] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [14] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
withdraw_stake_events AS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
base_stake_pool_events
|
||||
WHERE
|
||||
ARRAY_SIZE(
|
||||
instruction :accounts
|
||||
) = 13
|
||||
AND instruction :accounts [10] :: STRING = 'SysvarC1ock11111111111111111111111111111111'
|
||||
AND instruction :accounts [11] :: STRING = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
|
||||
AND instruction :accounts [12] :: STRING = 'Stake11111111111111111111111111111111111111'
|
||||
),
|
||||
deposit_stake_merge AS (
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [3] :: STRING AS stake_pool_withdraw_authority,
|
||||
e.instruction :accounts [2] :: STRING AS stake_pool_deposit_authority,
|
||||
b.signers [0] :: STRING AS address,
|
||||
e.instruction :accounts [6] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :destination :: STRING AS merge_destination,
|
||||
silver.udf_get_account_balances_index(
|
||||
merge_destination,
|
||||
b.account_keys
|
||||
) AS merge_destination_balances_index,
|
||||
silver.udf_get_account_balances_index(
|
||||
reserve_stake_address,
|
||||
b.account_keys
|
||||
) AS reserve_stake_balances_index,
|
||||
b.post_balances [merge_destination_balances_index] - b.pre_balances [merge_destination_balances_index] + b.post_balances [reserve_stake_balances_index] - b.pre_balances [reserve_stake_balances_index] AS amount,
|
||||
e._inserted_timestamp
|
||||
FROM
|
||||
deposit_stake_events e
|
||||
LEFT OUTER JOIN base_balances b
|
||||
ON b.tx_id = e.tx_id
|
||||
LEFT OUTER JOIN TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :type = 'merge'
|
||||
AND i.value :programId = 'Stake11111111111111111111111111111111111111'
|
||||
)
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [1] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL AS stake_pool_deposit_authority,
|
||||
e.instruction :accounts [3] :: STRING AS address,
|
||||
e.instruction :accounts [2] :: STRING AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
tx_id,
|
||||
e.index
|
||||
) AS _unique_key
|
||||
FROM
|
||||
deposit_events e,
|
||||
TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'deposit_stake' AS action,
|
||||
e.stake_pool,
|
||||
e.stake_pool_withdraw_authority,
|
||||
e.stake_pool_deposit_authority,
|
||||
e.address,
|
||||
e.reserve_stake_address,
|
||||
e.amount :: NUMBER AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
e.tx_id,
|
||||
e.index
|
||||
) AS _unique_key
|
||||
FROM
|
||||
deposit_stake_merge e
|
||||
UNION
|
||||
SELECT
|
||||
e.tx_id,
|
||||
e.block_id,
|
||||
e.block_timestamp,
|
||||
e.index,
|
||||
e.succeeded,
|
||||
'withdraw_stake' AS action,
|
||||
e.instruction :accounts [0] :: STRING AS stake_pool,
|
||||
e.instruction :accounts [2] :: STRING AS stake_pool_withdraw_authority,
|
||||
NULL AS stake_pool_deposit_authority,
|
||||
e.instruction :accounts [5] :: STRING AS address,
|
||||
NULL AS reserve_stake_address,
|
||||
i.value :parsed :info :lamports AS amount,
|
||||
e._inserted_timestamp,
|
||||
concat_ws(
|
||||
'-',
|
||||
tx_id,
|
||||
e.index
|
||||
) AS _unique_key
|
||||
FROM
|
||||
withdraw_stake_events e,
|
||||
TABLE(FLATTEN(inner_instruction :instructions)) i
|
||||
WHERE
|
||||
i.value :parsed :info :lamports IS NOT NULL
|
||||
82
models/silver/staking/silver__stake_pool_actions_socean.yml
Normal file
82
models/silver/staking/silver__stake_pool_actions_socean.yml
Normal file
@ -0,0 +1,82 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: silver__stake_pool_actions_socean
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- _UNIQUE_KEY
|
||||
- compare_model_subset:
|
||||
name: silver__stake_pool_actions_socean_business_logic_test
|
||||
compare_model: ref('testing__stake_pool_actions_socean')
|
||||
compare_columns:
|
||||
- tx_id
|
||||
- index
|
||||
- action
|
||||
- stake_pool
|
||||
- stake_pool_withdraw_authority
|
||||
- stake_pool_deposit_authority
|
||||
- address
|
||||
- reserve_stake_address
|
||||
- amount
|
||||
model_condition: "where tx_id in ('4pCtKHgugzwsXJ3HVRSyQroMkSVu9Uq5xXa92wm8qk3uzPBspJMyFSpS7K6zwUTGLrwtTufuppNKBMgbFGT1ntNC',
|
||||
'4RG4VM2c7zVVL1pNzyojNquEHm9eK5tFxC3BYdxjsbXv6R7YgMv34r2qo79t2nmTXg4fPTfat2MbYrNMUCAyxkP3',
|
||||
'2uSppNnHD25xVpawL8TgYACBsLAKXDTUBLWMwUupEjFMA4DScKrozcXJdurvJHh3AZwLoQzW3swov1bX5TtWKFTj',
|
||||
'4KdY9xd6dbEx5F5zEN5Vy5qAN4ZTgWP8zscSoWj9xjd5fxwTWHn4xbVfnT1Nm39a3bpcq1Wcv3g6TNB9HoyTquAN',
|
||||
'2BvmWkeogYu2rWiBmKE3zvXy73odpyQ4yC6LTcebhpDuZBXYryuCTTpURQ1Fqdgun1j3k7ueZwsxMXmYQGyBLtXt')"
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 2
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: INDEX
|
||||
description: Location of the stake pool action within a transaction
|
||||
tests:
|
||||
- not_null
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: ACTION
|
||||
description: "{{ doc('stake_pool_action') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL
|
||||
description: "{{ doc('stake_pool') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL_WITHDRAW_AUTHORITY
|
||||
description: "{{ doc('stake_pool_withdraw_authority') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: STAKE_POOL_DEPOSIT_AUTHORITY
|
||||
description: "{{ doc('stake_pool_deposit_authority') }}"
|
||||
- name: ADDRESS
|
||||
description: "{{ doc('stake_pool_address') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: RESERVE_STAKE_ADDRESS
|
||||
description: "{{ doc('stake_pool_reserve_stake_address') }}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: action <> 'withdraw_stake'
|
||||
- name: AMOUNT
|
||||
description: "{{ doc('stake_pool_amount') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- name: _UNIQUE_KEY
|
||||
description: "Concatenation of columns to be used on merge for incremental loads"
|
||||
Loading…
Reference in New Issue
Block a user