From e120fb8ab057501e25d010ceed0aa7d68ff21270 Mon Sep 17 00:00:00 2001 From: tienna Date: Mon, 10 Mar 2025 18:35:12 +0700 Subject: [PATCH] add Add queries related to DREP, SPO --- .../delegation_votes/delegationVotes.graphql | 21 +++++++++++++++++++ .../delegation_votes/drepInfo.graphql | 12 +++++++++++ .../stake_pools/queryDelegators.graphql | 14 +++++++++++++ .../stake_pools/stakePool_ActiveStake.graphql | 16 ++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 packages/api-cardano-db-hasura/src/example_queries/delegation_votes/delegationVotes.graphql create mode 100644 packages/api-cardano-db-hasura/src/example_queries/delegation_votes/drepInfo.graphql create mode 100644 packages/api-cardano-db-hasura/src/example_queries/stake_pools/queryDelegators.graphql create mode 100644 packages/api-cardano-db-hasura/src/example_queries/stake_pools/stakePool_ActiveStake.graphql diff --git a/packages/api-cardano-db-hasura/src/example_queries/delegation_votes/delegationVotes.graphql b/packages/api-cardano-db-hasura/src/example_queries/delegation_votes/delegationVotes.graphql new file mode 100644 index 00000000..bfc47ceb --- /dev/null +++ b/packages/api-cardano-db-hasura/src/example_queries/delegation_votes/delegationVotes.graphql @@ -0,0 +1,21 @@ +#This query allows to find out which address is delegating votes to which DREP at what epoch. +query Delegation_Vote ( + $addr: String + $epoch: Int +) { + delegationVotes (where: {address:{_eq:$addr} + , transaction:{block:{epoch:{number:{_eq:$epoch}}}} + } ) { + address + drep { + view + } + transaction { + block { + epochNo + } + + } + + } +} \ No newline at end of file diff --git a/packages/api-cardano-db-hasura/src/example_queries/delegation_votes/drepInfo.graphql b/packages/api-cardano-db-hasura/src/example_queries/delegation_votes/drepInfo.graphql new file mode 100644 index 00000000..803aaf25 --- /dev/null +++ b/packages/api-cardano-db-hasura/src/example_queries/delegation_votes/drepInfo.graphql @@ -0,0 +1,12 @@ +#Look up descriptive information about DREP based on DREP Name +query dRep_Offchain( + $drep_name: String +){ + offChainVoteDrepData ( limit: 1, where:{given_name:{_eq:$drep_name}}){ + motivations + objectives + qualifications + + } + } + \ No newline at end of file diff --git a/packages/api-cardano-db-hasura/src/example_queries/stake_pools/queryDelegators.graphql b/packages/api-cardano-db-hasura/src/example_queries/stake_pools/queryDelegators.graphql new file mode 100644 index 00000000..d0e70056 --- /dev/null +++ b/packages/api-cardano-db-hasura/src/example_queries/stake_pools/queryDelegators.graphql @@ -0,0 +1,14 @@ +# This query is used to find all stake addresses that are delegating to a stake pool (PoolID) at a given EpochNo +query active_delegators_to_SPO ( + $poolID: StakePoolID + $epochNo: Int +) { + activeStake ( + where: { + stakePoolId: {_eq: $poolID}, + epoch: {number: {_eq: $epochNo} } + } + ) { + address + } +} \ No newline at end of file diff --git a/packages/api-cardano-db-hasura/src/example_queries/stake_pools/stakePool_ActiveStake.graphql b/packages/api-cardano-db-hasura/src/example_queries/stake_pools/stakePool_ActiveStake.graphql new file mode 100644 index 00000000..67597ecd --- /dev/null +++ b/packages/api-cardano-db-hasura/src/example_queries/stake_pools/stakePool_ActiveStake.graphql @@ -0,0 +1,16 @@ +# Calculate the total number of active stakes in a stake pool at a given epoch +query stakePool_activeStake( + $poolID: StakePoolID + $epochNo: Int +) { + activeStake_aggregate (where:{ + epochNo:{_eq:$epochNo}, + stakePoolId:{_eq:$poolID}}) + { + aggregate { + sum { + amount + } + } +} +} \ No newline at end of file