@parifi/sdk
Version:
Parifi SDK with common utility functions
156 lines • 3 kB
JavaScript
// src/subgraph/accounts/subgraphQueries.ts
import { gql } from "graphql-request";
var fetchRealizedPnlData = (userAddress) => gql`
{
account(id: "${userAddress.toLowerCase()}") {
id
totalRealizedPnlPositions
totalRealizedPnlVaults
}
}
`;
var fetchPortfolioData = (userAddresses) => gql`
{
accounts(where: {id_in: [${userAddresses.map((id) => `"${id.toLowerCase()}"`).join(", ")}]}) {
id
totalRealizedPnlPositions
totalRealizedPnlVaults
}
positions(
first: 1000
orderBy: positionCollateral
orderDirection: desc
where: {
user_in: [${userAddresses.map((id) => `"${id.toLowerCase()}"`).join(", ")}],
status: OPEN
}
) {
id
user {
id
}
netUnrealizedPnlInUsd
positionCollateral
market {
depositToken {
decimals
pyth {
id
price
}
}
}
}
vaultPositions(
first: 1000
orderBy: sharesBalance
orderDirection: desc
where: {user_in: [${userAddresses.map((id) => `"${id.toLowerCase()}"`).join(", ")}]}
) {
user {
id
}
vault {
id
assetsPerShare
sharesPerAsset
depositToken {
decimals
pyth {
id
price
}
}
}
sharesBalance
}
}
`;
var fetchAccountByWalletAddress = (walletAddress) => gql`
{
wallet(id: "${walletAddress}") {
id
}
}
`;
var fetchLeaderboardUserData = (userAddresses) => gql`
{
accounts(
where: {id_in: [${userAddresses.map((id) => `"${id}"`).join(", ")}]}
) {
id
totalOrdersCount
totalPositionsCount
countProfitablePositions
countLossPositions
countLiquidatedPositions
totalVolumeInUsd
totalVolumeInUsdLongs
totalVolumeInUsdShorts
totalRealizedPnlPositions
totalAccruedBorrowingFeesInUsd
}
}`;
var fetchIntegratorFees = (userAddresses) => gql`
{
snxAccounts(where:
{
owner_in: [${userAddresses.map((id) => `"${id}"`).join(", ")}],
type: PERP
}) {
id
accountId
owner {
id
}
integratorFeesGenerated
}
}
`;
var checkExistingUser = (userAddress) => gql`
{
snxAccounts(
where: {
owner: "${userAddress}",
type: PERP,
}
) {
id
accountId
totalOrdersCount
}
}
`;
var depositedCollateralForSnxAccountsQuery = (accountIds) => gql`
{
snxAccounts
(where :{
accountId_in : [${accountIds.map((id) => `"${id}"`).join(", ")}]
})
{
owner{
id
}
accountId
collateralDeposits {
totalAmountDeposited
totalAmountWithdrawn
totalAmountLiquidated
currentDepositedAmount
collateralName
collateralSymbol
collateralDecimals
}
}
}
`;
export {
checkExistingUser,
depositedCollateralForSnxAccountsQuery,
fetchAccountByWalletAddress,
fetchIntegratorFees,
fetchLeaderboardUserData,
fetchPortfolioData,
fetchRealizedPnlData
};
//# sourceMappingURL=subgraphQueries.mjs.map