@parifi/sdk
Version:
Parifi SDK with common utility functions
262 lines (260 loc) • 6.76 kB
TypeScript
declare enum OrderType {
OPEN_NEW_POSITION = "OPEN_NEW_POSITION",
CLOSE_POSITION = "CLOSE_POSITION",
INCREASE_POSITION = "INCREASE_POSITION",
DECREASE_POSITION = "DECREASE_POSITION",
CANCEL_ORDER = "CANCEL_ORDER"
}
declare enum OrderStatus {
PENDING = "PENDING",
CANCELLED = "CANCELLED",
SETTLED = "SETTLED",
INVALID = "INVALID"
}
declare enum PositionStatus {
OPEN = "OPEN",
CLOSED = "CLOSED",
LIQUIDATED = "LIQUIDATED"
}
declare enum SnxAccountType {
/** Core Proxy Account */
CORE = "CORE",
/** Perps Market Proxy Account */
PERP = "PERP"
}
interface WalletSubgraph {
/** User wallet address */
id?: string;
snxAccounts?: SnxAccountSubgraph[];
}
type SnxAccountSubgraph = {
id: string;
type?: SnxAccountType;
accountId?: string;
owner?: WalletSubgraph;
totalOrdersCount?: string;
totalPositionsCount?: string;
openPositionCount?: string;
countProfitablePositions?: string;
countLossPositions?: string;
countLiquidatedPositions?: string;
totalRealizedPnlPositions?: string;
totalVolumeInUsd?: string;
totalVolumeInUsdLongs?: string;
totalVolumeInUsdShorts?: string;
totalAccruedBorrowingFeesInUsd?: string;
integratorFeesGenerated?: string;
orders?: OrderSubgraph[];
positions?: PositionSubgraph[];
collateralDeposits?: CollateralDepositSubgraph[];
};
type CollateralDepositSubgraph = {
id: string;
snxAccountId?: string;
collateralId?: string;
collateralName?: string;
collateralSymbol?: string;
collateralDecimals?: string;
collateralAddress?: string;
currentDepositedAmount?: string;
totalAmountDeposited?: string;
totalAmountWithdrawn?: string;
totalAmountLiquidated?: string;
};
type SynthSubgraph = {
id: string;
name?: string;
symbol?: string;
decimals?: number;
synthAddress?: string;
};
type MarketSubgraph = {
id: string;
marketName?: string;
marketSymbol?: string;
feedId?: string;
skew?: string;
size?: string;
maxOpenInterest?: string;
interestRate?: string;
currentFundingRate?: string;
currentFundingVelocity?: string;
indexPrice?: string;
skewScale?: string;
maxFundingVelocity?: string;
makerFee?: string;
takerFee?: string;
maxMarketValue?: string;
marketPrice?: string;
initialMarginRatioD18?: string;
maintenanceMarginRatioD18?: string;
minimumInitialMarginRatioD18?: string;
flagRewardRatioD18?: string;
minimumPositionMargin?: string;
};
type OrderSubgraph = {
id: string;
market?: MarketSubgraph;
snxAccountId?: string;
isLimitOrder?: boolean;
acceptablePrice?: string;
commitmentTime?: string;
expectedPriceTime?: string;
settlementTime?: string;
expirationTime?: string;
trackingCode?: string;
deltaSize?: string;
deltaSizeUsd?: string;
executionPrice?: string;
collectedFees?: string;
settlementReward?: string;
referralFees?: string;
partnerAddress?: string;
txHash?: string;
createdTimestamp?: string;
status?: OrderStatus;
settledTxHash?: string;
settledTimestamp?: string;
settledTimestampISO: string;
settledBy?: WalletSubgraph;
};
type PositionSubgraph = {
id: string;
market?: MarketSubgraph;
snxAccountId?: string;
isLong?: boolean;
positionSize?: string;
avgPrice?: string;
avgPriceDec?: string;
status?: PositionStatus;
txHash?: string;
liquidationTxHash?: string;
closingPrice?: string;
realizedPnl?: string;
realizedFee?: string;
netRealizedPnl?: string;
createdTimestamp?: string;
lastRefresh?: string;
lastRefreshISO?: string;
accruedBorrowingFees?: string;
canBeLiquidated?: boolean;
};
interface TokenSubgraph {
id?: string;
name?: string;
symbol?: string;
decimals?: string;
pyth?: PythData;
lastPriceUSD?: string;
lastPriceTimestamp?: string;
}
interface PythPrice {
price: string;
conf: string;
expo: number;
publish_time: number;
}
interface PythPriceResponse {
id: string;
price: PythPrice;
ema_price: PythPrice;
}
interface PriceFeedSnapshot {
id?: string;
priceId?: string;
publishTime?: string;
price?: string;
confidence?: string;
}
interface PythData {
id?: string;
marketId?: string;
tokenAddress?: string;
price?: string;
lastUpdatedTimestamp?: string;
}
interface BatchExecute {
id: string;
priceUpdateData: string[];
}
interface collateralDepositsPortfolioData {
depositedAmount: string;
collateralSymbol: string;
collateralName: string;
collateralDecimals: string;
}
interface positionsPortfolio {
snxAccount?: {
accountId: string;
};
status: string;
market: {
marketSymbol: string;
};
positionSize: string;
avgPrice: string;
realizedPnl: string;
realizedFee: string;
user?: {
id: string;
};
}
interface PortfolioWallet {
id: string;
snxAccounts: Array<{
collateralDeposits: collateralDepositsPortfolioData[];
positions: positionsPortfolio[];
}>;
}
interface PorfolioDataSubgraph {
wallets: PortfolioWallet[];
}
type PriceObject = {
id: string;
price: {
price: string;
conf: string;
expo: number;
publish_time: number;
};
ema_price: {
price: string;
conf: string;
expo: number;
publish_time: number;
};
};
type LeaderBoardClosedPosition = {
id: string;
user: {
id: string;
};
positionSize: string;
avgPriceDec: string;
status: string;
netRealizedPnl: string;
realizedPnl: string;
snxAccount: {
accountId: string;
};
};
type LeaderBoardOpenPosition = {
positionSize: string;
avgPriceDec: string;
id: string;
market: {
id: string;
};
user: {
id: string;
};
snxAccount: {
id: string;
accountId: string;
};
};
type LiquidatePositionCollateral = {
accountId: string;
collateralDeposits: collateralDepositsPortfolioData[];
};
export { type BatchExecute, type CollateralDepositSubgraph, type LeaderBoardClosedPosition, type LeaderBoardOpenPosition, type LiquidatePositionCollateral, type MarketSubgraph, OrderStatus, type OrderSubgraph, OrderType, type PorfolioDataSubgraph, type PortfolioWallet, PositionStatus, type PositionSubgraph, type PriceFeedSnapshot, type PriceObject, type PythData, type PythPrice, type PythPriceResponse, type SnxAccountSubgraph, SnxAccountType, type SynthSubgraph, type TokenSubgraph, type WalletSubgraph, type collateralDepositsPortfolioData, type positionsPortfolio };