@parifi/sdk
Version:
Parifi SDK with common utility functions
187 lines (186 loc) • 4.6 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/subgraph/accounts/subgraphQueries.ts
var subgraphQueries_exports = {};
__export(subgraphQueries_exports, {
checkExistingUser: () => checkExistingUser,
depositedCollateralForSnxAccountsQuery: () => depositedCollateralForSnxAccountsQuery,
fetchAccountByWalletAddress: () => fetchAccountByWalletAddress,
fetchIntegratorFees: () => fetchIntegratorFees,
fetchLeaderboardUserData: () => fetchLeaderboardUserData,
fetchPortfolioData: () => fetchPortfolioData,
fetchRealizedPnlData: () => fetchRealizedPnlData
});
module.exports = __toCommonJS(subgraphQueries_exports);
var import_graphql_request = require("graphql-request");
var fetchRealizedPnlData = (userAddress) => import_graphql_request.gql`
{
account(id: "${userAddress.toLowerCase()}") {
id
totalRealizedPnlPositions
totalRealizedPnlVaults
}
}
`;
var fetchPortfolioData = (userAddresses) => import_graphql_request.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) => import_graphql_request.gql`
{
wallet(id: "${walletAddress}") {
id
}
}
`;
var fetchLeaderboardUserData = (userAddresses) => import_graphql_request.gql`
{
accounts(
where: {id_in: [${userAddresses.map((id) => `"${id}"`).join(", ")}]}
) {
id
totalOrdersCount
totalPositionsCount
countProfitablePositions
countLossPositions
countLiquidatedPositions
totalVolumeInUsd
totalVolumeInUsdLongs
totalVolumeInUsdShorts
totalRealizedPnlPositions
totalAccruedBorrowingFeesInUsd
}
}`;
var fetchIntegratorFees = (userAddresses) => import_graphql_request.gql`
{
snxAccounts(where:
{
owner_in: [${userAddresses.map((id) => `"${id}"`).join(", ")}],
type: PERP
}) {
id
accountId
owner {
id
}
integratorFeesGenerated
}
}
`;
var checkExistingUser = (userAddress) => import_graphql_request.gql`
{
snxAccounts(
where: {
owner: "${userAddress}",
type: PERP,
}
) {
id
accountId
totalOrdersCount
}
}
`;
var depositedCollateralForSnxAccountsQuery = (accountIds) => import_graphql_request.gql`
{
snxAccounts
(where :{
accountId_in : [${accountIds.map((id) => `"${id}"`).join(", ")}]
})
{
owner{
id
}
accountId
collateralDeposits {
totalAmountDeposited
totalAmountWithdrawn
totalAmountLiquidated
currentDepositedAmount
collateralName
collateralSymbol
collateralDecimals
}
}
}
`;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
checkExistingUser,
depositedCollateralForSnxAccountsQuery,
fetchAccountByWalletAddress,
fetchIntegratorFees,
fetchLeaderboardUserData,
fetchPortfolioData,
fetchRealizedPnlData
});
//# sourceMappingURL=subgraphQueries.js.map