@parifi/sdk
Version:
Parifi SDK with common utility functions
1 lines • 10.1 kB
Source Map (JSON)
{"version":3,"sources":["../../src/interfaces/subgraphTypes.ts"],"sourcesContent":["//// NOTE: All fields from the subgraph interfaces have their type as string\n//// and are marked as optional. This is because the logic to fetch these data might\n//// differ based on the requirement or function, and only required fields are fetched\n//// with queries to keep it concise and avoid fetching unnecessary data.\n\n////////////////////////////////////////////////////////////////\n//////////////////// ENUMS //////////////////////////////\n////////////////////////////////////////////////////////////////\nexport enum OrderType {\n OPEN_NEW_POSITION = 'OPEN_NEW_POSITION',\n CLOSE_POSITION = 'CLOSE_POSITION',\n INCREASE_POSITION = 'INCREASE_POSITION',\n DECREASE_POSITION = 'DECREASE_POSITION',\n CANCEL_ORDER = 'CANCEL_ORDER',\n}\n\nexport enum OrderStatus {\n PENDING = 'PENDING',\n CANCELLED = 'CANCELLED',\n SETTLED = 'SETTLED',\n INVALID = 'INVALID',\n}\n\nexport enum PositionStatus {\n OPEN = 'OPEN',\n CLOSED = 'CLOSED',\n LIQUIDATED = 'LIQUIDATED',\n}\nexport enum SnxAccountType {\n /** Core Proxy Account */\n CORE = 'CORE',\n\n /** Perps Market Proxy Account */\n PERP = 'PERP',\n}\n\n////////////////////////////////////////////////////////////////\n////////////////////// ACCOUNT ////////////////////////////\n////////////////////////////////////////////////////////////////\n\nexport interface WalletSubgraph {\n /** User wallet address */\n id?: string;\n\n snxAccounts?: SnxAccountSubgraph[];\n}\n////////////////////////////////////////////////////////////////\n////////////////////// SNX ACCOUNT //////////////////////////\n////////////////////////////////////////////////////////////////\nexport type SnxAccountSubgraph = {\n id: string;\n type?: SnxAccountType;\n accountId?: string;\n owner?: WalletSubgraph;\n totalOrdersCount?: string;\n totalPositionsCount?: string;\n openPositionCount?: string;\n countProfitablePositions?: string;\n countLossPositions?: string;\n countLiquidatedPositions?: string;\n totalRealizedPnlPositions?: string;\n totalVolumeInUsd?: string;\n totalVolumeInUsdLongs?: string;\n totalVolumeInUsdShorts?: string;\n totalAccruedBorrowingFeesInUsd?: string;\n integratorFeesGenerated?: string;\n orders?: OrderSubgraph[];\n positions?: PositionSubgraph[];\n collateralDeposits?: CollateralDepositSubgraph[];\n};\n\n////////////////////////////////////////////////////////////////\n//////////////////// Collaterals //////////////////////////\n////////////////////////////////////////////////////////////////\n\nexport type CollateralDepositSubgraph = {\n id: string;\n snxAccountId?: string; // \" SNX Account id including the type PERP/CORE\"\n collateralId?: string;\n collateralName?: string;\n collateralSymbol?: string;\n collateralDecimals?: string;\n collateralAddress?: string;\n currentDepositedAmount?: string;\n totalAmountDeposited?: string;\n totalAmountWithdrawn?: string;\n totalAmountLiquidated?: string;\n};\n\nexport type SynthSubgraph = { id: string; name?: string; symbol?: string; decimals?: number; synthAddress?: string };\n\n////////////////////////////////////////////////////////////////\n///////////////////////// Market //////////////////////////\n////////////////////////////////////////////////////////////////\n\nexport type MarketSubgraph = {\n id: string;\n marketName?: string;\n marketSymbol?: string;\n feedId?: string;\n skew?: string;\n size?: string;\n maxOpenInterest?: string;\n interestRate?: string;\n currentFundingRate?: string;\n currentFundingVelocity?: string;\n indexPrice?: string;\n skewScale?: string;\n maxFundingVelocity?: string;\n makerFee?: string;\n takerFee?: string;\n maxMarketValue?: string;\n marketPrice?: string;\n initialMarginRatioD18?: string;\n maintenanceMarginRatioD18?: string;\n minimumInitialMarginRatioD18?: string;\n flagRewardRatioD18?: string;\n minimumPositionMargin?: string;\n};\n\n////////////////////////////////////////////////////////////////\n///////////////////////// Orders //////////////////////////\n////////////////////////////////////////////////////////////////\n\nexport type OrderSubgraph = {\n id: string;\n market?: MarketSubgraph;\n snxAccountId?: string; // \" SNX Account id including the type PERP/CORE\"\n isLimitOrder?: boolean;\n acceptablePrice?: string;\n commitmentTime?: string;\n expectedPriceTime?: string;\n settlementTime?: string;\n expirationTime?: string;\n trackingCode?: string;\n deltaSize?: string;\n deltaSizeUsd?: string;\n executionPrice?: string;\n collectedFees?: string;\n settlementReward?: string;\n referralFees?: string;\n partnerAddress?: string;\n txHash?: string;\n createdTimestamp?: string;\n status?: OrderStatus;\n settledTxHash?: string;\n settledTimestamp?: string;\n settledTimestampISO: string;\n settledBy?: WalletSubgraph;\n};\n\n////////////////////////////////////////////////////////////////\n/////////////////////// Positions /////////////////////////\n////////////////////////////////////////////////////////////////\n\nexport type PositionSubgraph = {\n id: string;\n market?: MarketSubgraph;\n snxAccountId?: string; // \" SNX Account id including the type PERP/CORE\"\n isLong?: boolean;\n positionSize?: string;\n avgPrice?: string;\n avgPriceDec?: string;\n status?: PositionStatus;\n txHash?: string;\n liquidationTxHash?: string;\n closingPrice?: string;\n realizedPnl?: string;\n realizedFee?: string;\n netRealizedPnl?: string;\n createdTimestamp?: string;\n lastRefresh?: string;\n lastRefreshISO?: string;\n accruedBorrowingFees?: string;\n canBeLiquidated?: boolean;\n};\n\n////////////////////////////////////////////////////////////////\n////////////////////// TOKEN /////////////////////////////\n////////////////////////////////////////////////////////////////\nexport interface TokenSubgraph {\n // //\" Smart contract address of the token \"\n id?: string;\n\n // //\" Token name \"\n name?: string;\n\n // //\" Token Symbol \"\n symbol?: string;\n\n // //\" The string of decimal places for token \"\n decimals?: string;\n\n // //\" Reference to Pyth and price data \"\n pyth?: PythData;\n\n // //\" To store price snapshots of the token on price updates from Pyth \"\n lastPriceUSD?: string;\n\n // //\" Timestamp of lastPriceUsd \"\n lastPriceTimestamp?: string;\n}\n\n////////////////////////////////////////////////////////////////\n//////////////////////// PYTH ////////////////////////////\n////////////////////////////////////////////////////////////////\n\n// Pyth price data interface for prices received from Pyth\nexport interface PythPrice {\n price: string;\n\n conf: string;\n\n expo: number;\n\n publish_time: number;\n}\n\n// Interface for response received for Pyth Price data\nexport interface PythPriceResponse {\n // Pyth Price ID\n id: string;\n\n price: PythPrice;\n\n ema_price: PythPrice;\n}\n\n// \" The entity saves all the price feed updates on-chain (by Parifi) \"\nexport interface PriceFeedSnapshot {\n //\" Price ID + Timestamp \"\n id?: string;\n\n //\" Pyth network price ID \"\n priceId?: string;\n\n //\" Publish Timestamp \"\n publishTime?: string;\n\n //\" Price \"\n price?: string;\n\n //\" Price confidence \"\n confidence?: string;\n}\n\n// \" Pyth Feeds for Parifi market IDs/Token addresses \"\nexport interface PythData {\n // \" Pyth Price ID for market/token \"\n id?: string;\n\n // \" Market ID \"\n marketId?: string;\n\n // \" Token Address \"\n tokenAddress?: string;\n\n // \" Price \"\n price?: string;\n\n // \" Last updated timestamp \"\n lastUpdatedTimestamp?: string;\n}\n\nexport interface BatchExecute {\n id: string;\n priceUpdateData: string[];\n}\n\nexport interface collateralDepositsPortfolioData {\n depositedAmount: string;\n collateralSymbol: string;\n collateralName: string;\n collateralDecimals: string;\n}\n\nexport interface positionsPortfolio {\n snxAccount?: { accountId: string };\n status: string;\n market: {\n marketSymbol: string;\n };\n positionSize: string;\n avgPrice: string;\n realizedPnl: string;\n realizedFee: string;\n user?: {\n id: string;\n };\n}\n\nexport interface PortfolioWallet {\n id: string; // Wallet ID\n snxAccounts: Array<{\n collateralDeposits: collateralDepositsPortfolioData[];\n positions: positionsPortfolio[];\n }>;\n}\nexport interface PorfolioDataSubgraph {\n wallets: PortfolioWallet[]; // Array of Wallet objects\n}\n\nexport type PriceObject = {\n id: string;\n price: {\n price: string;\n conf: string;\n expo: number;\n publish_time: number;\n };\n ema_price: {\n price: string;\n conf: string;\n expo: number;\n publish_time: number;\n };\n};\n\nexport type LeaderBoardClosedPosition = {\n id: string;\n user: {\n id: string;\n };\n positionSize: string;\n avgPriceDec: string;\n status: string;\n netRealizedPnl: string;\n realizedPnl: string;\n snxAccount: {\n accountId: string;\n };\n};\n\nexport type LeaderBoardOpenPosition = {\n positionSize: string;\n avgPriceDec: string;\n id: string;\n market: {\n id: string;\n };\n user: {\n id: string;\n };\n snxAccount: {\n id: string;\n accountId: string;\n };\n};\n\nexport type LiquidatePositionCollateral = {\n accountId: string;\n collateralDeposits: collateralDepositsPortfolioData[];\n};\n"],"mappings":";AAQO,IAAK,YAAL,kBAAKA,eAAL;AACL,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,oBAAiB;AACjB,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,uBAAoB;AACpB,EAAAA,WAAA,kBAAe;AALL,SAAAA;AAAA,GAAA;AAQL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,eAAY;AACZ,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,aAAU;AAJA,SAAAA;AAAA,GAAA;AAOL,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,UAAO;AACP,EAAAA,gBAAA,YAAS;AACT,EAAAA,gBAAA,gBAAa;AAHH,SAAAA;AAAA,GAAA;AAKL,IAAK,iBAAL,kBAAKC,oBAAL;AAEL,EAAAA,gBAAA,UAAO;AAGP,EAAAA,gBAAA,UAAO;AALG,SAAAA;AAAA,GAAA;","names":["OrderType","OrderStatus","PositionStatus","SnxAccountType"]}