@crypticdot/defituna-api 1.5.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +140 -12
- package/dist/index.d.ts +140 -12
- package/dist/index.js +117 -16
- package/dist/index.mjs +117 -16
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -2231,28 +2231,58 @@ declare const IncreaseSpotPositionQuote$1: z.ZodObject<{
|
|
|
2231
2231
|
priceImpact: number;
|
|
2232
2232
|
}>;
|
|
2233
2233
|
declare const DecreaseSpotPositionQuote$1: z.ZodObject<{
|
|
2234
|
-
/**
|
|
2234
|
+
/** Confirmed position decrease percentage (100% = 1.0) */
|
|
2235
2235
|
decreasePercent: z.ZodNumber;
|
|
2236
2236
|
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
2237
2237
|
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
2238
2238
|
*/
|
|
2239
2239
|
requiredSwapAmount: z.ZodBigInt;
|
|
2240
|
+
/** Estimated total amount of the adjusted position */
|
|
2241
|
+
estimatedAmount: z.ZodBigInt;
|
|
2242
|
+
/** Estimated amount of the withdrawn collateral */
|
|
2243
|
+
estimatedWithdrawnCollateral: z.ZodBigInt;
|
|
2240
2244
|
/** Price impact in percents */
|
|
2241
2245
|
priceImpact: z.ZodNumber;
|
|
2242
2246
|
/** Liquidation price */
|
|
2243
2247
|
uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
|
|
2244
2248
|
}, "strip", z.ZodTypeAny, {
|
|
2245
2249
|
uiLiquidationPrice: number | null;
|
|
2250
|
+
estimatedAmount: bigint;
|
|
2246
2251
|
priceImpact: number;
|
|
2247
2252
|
decreasePercent: number;
|
|
2248
2253
|
requiredSwapAmount: bigint;
|
|
2254
|
+
estimatedWithdrawnCollateral: bigint;
|
|
2249
2255
|
}, {
|
|
2250
2256
|
uiLiquidationPrice: number | null;
|
|
2257
|
+
estimatedAmount: bigint;
|
|
2258
|
+
priceImpact: number;
|
|
2259
|
+
decreasePercent: number;
|
|
2260
|
+
requiredSwapAmount: bigint;
|
|
2261
|
+
estimatedWithdrawnCollateral: bigint;
|
|
2262
|
+
}>;
|
|
2263
|
+
declare const CloseSpotPositionQuote$1: z.ZodObject<{
|
|
2264
|
+
/** Position decrease percentage */
|
|
2265
|
+
decreasePercent: z.ZodNumber;
|
|
2266
|
+
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
2267
|
+
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
2268
|
+
*/
|
|
2269
|
+
requiredSwapAmount: z.ZodBigInt;
|
|
2270
|
+
/** Estimated amount of the withdrawn collateral */
|
|
2271
|
+
estimatedWithdrawnCollateral: z.ZodBigInt;
|
|
2272
|
+
/** Price impact in percents */
|
|
2273
|
+
priceImpact: z.ZodNumber;
|
|
2274
|
+
}, "strip", z.ZodTypeAny, {
|
|
2275
|
+
priceImpact: number;
|
|
2276
|
+
decreasePercent: number;
|
|
2277
|
+
requiredSwapAmount: bigint;
|
|
2278
|
+
estimatedWithdrawnCollateral: bigint;
|
|
2279
|
+
}, {
|
|
2251
2280
|
priceImpact: number;
|
|
2252
2281
|
decreasePercent: number;
|
|
2253
2282
|
requiredSwapAmount: bigint;
|
|
2283
|
+
estimatedWithdrawnCollateral: bigint;
|
|
2254
2284
|
}>;
|
|
2255
|
-
declare const
|
|
2285
|
+
declare const SwapQuoteByInput$1: z.ZodObject<{
|
|
2256
2286
|
estimatedAmountOut: z.ZodBigInt;
|
|
2257
2287
|
minAmountOut: z.ZodBigInt;
|
|
2258
2288
|
feeAmount: z.ZodBigInt;
|
|
@@ -2272,7 +2302,7 @@ declare const SwapByInputQuote$1: z.ZodObject<{
|
|
|
2272
2302
|
feeAmount: bigint;
|
|
2273
2303
|
feeUsd: number;
|
|
2274
2304
|
}>;
|
|
2275
|
-
declare const
|
|
2305
|
+
declare const SwapQuoteByOutput$1: z.ZodObject<{
|
|
2276
2306
|
estimatedAmountIn: z.ZodBigInt;
|
|
2277
2307
|
maxAmountIn: z.ZodBigInt;
|
|
2278
2308
|
feeAmount: z.ZodBigInt;
|
|
@@ -2292,6 +2322,20 @@ declare const SwapByOutputQuote$1: z.ZodObject<{
|
|
|
2292
2322
|
estimatedAmountIn: bigint;
|
|
2293
2323
|
maxAmountIn: bigint;
|
|
2294
2324
|
}>;
|
|
2325
|
+
declare const LimitOrderQuoteByInput$1: z.ZodObject<{
|
|
2326
|
+
amountOut: z.ZodBigInt;
|
|
2327
|
+
}, "strip", z.ZodTypeAny, {
|
|
2328
|
+
amountOut: bigint;
|
|
2329
|
+
}, {
|
|
2330
|
+
amountOut: bigint;
|
|
2331
|
+
}>;
|
|
2332
|
+
declare const LimitOrderQuoteByOutput$1: z.ZodObject<{
|
|
2333
|
+
amountIn: z.ZodBigInt;
|
|
2334
|
+
}, "strip", z.ZodTypeAny, {
|
|
2335
|
+
amountIn: bigint;
|
|
2336
|
+
}, {
|
|
2337
|
+
amountIn: bigint;
|
|
2338
|
+
}>;
|
|
2295
2339
|
declare const TradableAmount$1: z.ZodObject<{
|
|
2296
2340
|
amount: z.ZodBigInt;
|
|
2297
2341
|
usd: z.ZodNumber;
|
|
@@ -6227,7 +6271,7 @@ declare const schemas_UpdateStreamSubscriptionResult: typeof UpdateStreamSubscri
|
|
|
6227
6271
|
declare const schemas_WalletSubscriptionTopic: typeof WalletSubscriptionTopic;
|
|
6228
6272
|
declare const schemas_WalletSubscriptionTopicSchema: typeof WalletSubscriptionTopicSchema;
|
|
6229
6273
|
declare namespace schemas {
|
|
6230
|
-
export { DecreaseSpotPositionQuote$1 as DecreaseSpotPositionQuote, FeesStatsGroup$1 as FeesStatsGroup, IncreaseSpotPositionQuote$1 as IncreaseSpotPositionQuote, LendingPosition$1 as LendingPosition, schemas_LendingPositionNotification as LendingPositionNotification, LimitOrder$1 as LimitOrder, schemas_LimitOrderNotification as LimitOrderNotification, schemas_LimitOrderState as LimitOrderState, schemas_LimitOrderStateSchema as LimitOrderStateSchema, Market$1 as Market, Mint$1 as Mint, schemas_NotificationAction as NotificationAction, schemas_NotificationActionSchema as NotificationActionSchema, schemas_NotificationEntity as NotificationEntity, schemas_NotificationEntitySchema as NotificationEntitySchema, OrderBook$1 as OrderBook, OrderBookEntry$1 as OrderBookEntry, schemas_OrderBookNotification as OrderBookNotification, schemas_OrderBookNotificationMeta as OrderBookNotificationMeta, OrderHistoryEntry$1 as OrderHistoryEntry, schemas_OrderHistoryEntryNotification as OrderHistoryEntryNotification, schemas_OrderHistoryOrderType as OrderHistoryOrderType, schemas_OrderHistoryOrderTypeSchema as OrderHistoryOrderTypeSchema, schemas_OrderHistoryStatus as OrderHistoryStatus, schemas_OrderHistoryStatusSchema as OrderHistoryStatusSchema, schemas_OrderHistoryUIDirection as OrderHistoryUIDirection, schemas_OrderHistoryUIDirectionSchema as OrderHistoryUIDirectionSchema, PaginationMeta$1 as PaginationMeta, Pool$1 as Pool, PoolPriceCandle$1 as PoolPriceCandle, PoolPriceUpdate$1 as PoolPriceUpdate, schemas_PoolPriceUpdateNotification as PoolPriceUpdateNotification, schemas_PoolProvider as PoolProvider, schemas_PoolProviderSchema as PoolProviderSchema, schemas_PoolSubscriptionTopic as PoolSubscriptionTopic, schemas_PoolSubscriptionTopicSchema as PoolSubscriptionTopicSchema, PoolSwap$1 as PoolSwap, schemas_PoolSwapNotification as PoolSwapNotification, PoolTicks$1 as PoolTicks, StakingLeaderboardPage$1 as StakingLeaderboardPage, StakingLeaderboardPosition$1 as StakingLeaderboardPosition, StakingPosition$1 as StakingPosition, StakingPositionHistoryAction$1 as StakingPositionHistoryAction, StakingPositionHistoryActionType$1 as StakingPositionHistoryActionType, schemas_StakingPositionHistoryActionTypeSchema as StakingPositionHistoryActionTypeSchema, schemas_StakingPositionNotification as StakingPositionNotification, StakingRevenueStatsGroup$1 as StakingRevenueStatsGroup, StakingTreasury$1 as StakingTreasury,
|
|
6274
|
+
export { CloseSpotPositionQuote$1 as CloseSpotPositionQuote, DecreaseSpotPositionQuote$1 as DecreaseSpotPositionQuote, FeesStatsGroup$1 as FeesStatsGroup, IncreaseSpotPositionQuote$1 as IncreaseSpotPositionQuote, LendingPosition$1 as LendingPosition, schemas_LendingPositionNotification as LendingPositionNotification, LimitOrder$1 as LimitOrder, schemas_LimitOrderNotification as LimitOrderNotification, LimitOrderQuoteByInput$1 as LimitOrderQuoteByInput, LimitOrderQuoteByOutput$1 as LimitOrderQuoteByOutput, schemas_LimitOrderState as LimitOrderState, schemas_LimitOrderStateSchema as LimitOrderStateSchema, Market$1 as Market, Mint$1 as Mint, schemas_NotificationAction as NotificationAction, schemas_NotificationActionSchema as NotificationActionSchema, schemas_NotificationEntity as NotificationEntity, schemas_NotificationEntitySchema as NotificationEntitySchema, OrderBook$1 as OrderBook, OrderBookEntry$1 as OrderBookEntry, schemas_OrderBookNotification as OrderBookNotification, schemas_OrderBookNotificationMeta as OrderBookNotificationMeta, OrderHistoryEntry$1 as OrderHistoryEntry, schemas_OrderHistoryEntryNotification as OrderHistoryEntryNotification, schemas_OrderHistoryOrderType as OrderHistoryOrderType, schemas_OrderHistoryOrderTypeSchema as OrderHistoryOrderTypeSchema, schemas_OrderHistoryStatus as OrderHistoryStatus, schemas_OrderHistoryStatusSchema as OrderHistoryStatusSchema, schemas_OrderHistoryUIDirection as OrderHistoryUIDirection, schemas_OrderHistoryUIDirectionSchema as OrderHistoryUIDirectionSchema, PaginationMeta$1 as PaginationMeta, Pool$1 as Pool, PoolPriceCandle$1 as PoolPriceCandle, PoolPriceUpdate$1 as PoolPriceUpdate, schemas_PoolPriceUpdateNotification as PoolPriceUpdateNotification, schemas_PoolProvider as PoolProvider, schemas_PoolProviderSchema as PoolProviderSchema, schemas_PoolSubscriptionTopic as PoolSubscriptionTopic, schemas_PoolSubscriptionTopicSchema as PoolSubscriptionTopicSchema, PoolSwap$1 as PoolSwap, schemas_PoolSwapNotification as PoolSwapNotification, PoolTicks$1 as PoolTicks, StakingLeaderboardPage$1 as StakingLeaderboardPage, StakingLeaderboardPosition$1 as StakingLeaderboardPosition, StakingPosition$1 as StakingPosition, StakingPositionHistoryAction$1 as StakingPositionHistoryAction, StakingPositionHistoryActionType$1 as StakingPositionHistoryActionType, schemas_StakingPositionHistoryActionTypeSchema as StakingPositionHistoryActionTypeSchema, schemas_StakingPositionNotification as StakingPositionNotification, StakingRevenueStatsGroup$1 as StakingRevenueStatsGroup, StakingTreasury$1 as StakingTreasury, SwapQuoteByInput$1 as SwapQuoteByInput, SwapQuoteByOutput$1 as SwapQuoteByOutput, Tick$1 as Tick, TokenOraclePrice$1 as TokenOraclePrice, TradableAmount$1 as TradableAmount, schemas_TradeHistoryAction as TradeHistoryAction, schemas_TradeHistoryActionSchema as TradeHistoryActionSchema, TradeHistoryEntry$1 as TradeHistoryEntry, schemas_TradeHistoryEntryNotification as TradeHistoryEntryNotification, schemas_TradeHistoryUIDirection as TradeHistoryUIDirection, schemas_TradeHistoryUIDirectionSchema as TradeHistoryUIDirectionSchema, TunaPosition$1 as TunaPosition, schemas_TunaPositionNotification as TunaPositionNotification, schemas_TunaPositionState as TunaPositionState, schemas_TunaPositionStateSchema as TunaPositionStateSchema, TunaSpotPosition$1 as TunaSpotPosition, schemas_TunaSpotPositionNotification as TunaSpotPositionNotification, schemas_TunaSpotPositionState as TunaSpotPositionState, schemas_TunaSpotPositionStateSchema as TunaSpotPositionStateSchema, schemas_UpdateStreamSubscriptionResult as UpdateStreamSubscriptionResult, Vault$1 as Vault, VaultHistoricalStats$1 as VaultHistoricalStats, schemas_WalletSubscriptionTopic as WalletSubscriptionTopic, schemas_WalletSubscriptionTopicSchema as WalletSubscriptionTopicSchema };
|
|
6231
6275
|
}
|
|
6232
6276
|
|
|
6233
6277
|
type PoolProviderType = z.infer<typeof PoolProviderSchema>;
|
|
@@ -6268,10 +6312,13 @@ type StakingPositionHistoryAction = z.infer<typeof StakingPositionHistoryAction$
|
|
|
6268
6312
|
type PoolPriceCandle = z.infer<typeof PoolPriceCandle$1>;
|
|
6269
6313
|
type FeesStatsGroup = z.infer<typeof FeesStatsGroup$1>;
|
|
6270
6314
|
type StakingRevenueStatsGroup = z.infer<typeof StakingRevenueStatsGroup$1>;
|
|
6315
|
+
type LimitOrderQuoteByInput = z.infer<typeof LimitOrderQuoteByInput$1>;
|
|
6316
|
+
type LimitOrderQuoteByOutput = z.infer<typeof LimitOrderQuoteByOutput$1>;
|
|
6317
|
+
type SwapQuoteByInput = z.infer<typeof SwapQuoteByInput$1>;
|
|
6318
|
+
type SwapQuoteByOutput = z.infer<typeof SwapQuoteByOutput$1>;
|
|
6271
6319
|
type IncreaseSpotPositionQuote = z.infer<typeof IncreaseSpotPositionQuote$1>;
|
|
6272
6320
|
type DecreaseSpotPositionQuote = z.infer<typeof DecreaseSpotPositionQuote$1>;
|
|
6273
|
-
type
|
|
6274
|
-
type SwapByOutputQuote = z.infer<typeof SwapByOutputQuote$1>;
|
|
6321
|
+
type CloseSpotPositionQuote = z.infer<typeof CloseSpotPositionQuote$1>;
|
|
6275
6322
|
type TradableAmount = z.infer<typeof TradableAmount$1>;
|
|
6276
6323
|
type PoolPriceUpdate = z.infer<typeof PoolPriceUpdate$1>;
|
|
6277
6324
|
type SubscriptionPayload = {
|
|
@@ -6286,6 +6333,68 @@ type SubscriptionPayload = {
|
|
|
6286
6333
|
topics: WalletSubscriptionTopicType[];
|
|
6287
6334
|
};
|
|
6288
6335
|
};
|
|
6336
|
+
type GetLimitOrderQuoteByInputArgs = {
|
|
6337
|
+
pool: string;
|
|
6338
|
+
amountIn: bigint;
|
|
6339
|
+
aToB: boolean;
|
|
6340
|
+
tickIndex: number;
|
|
6341
|
+
};
|
|
6342
|
+
type GetLimitOrderQuoteByOutputArgs = {
|
|
6343
|
+
pool: string;
|
|
6344
|
+
amountOut: bigint;
|
|
6345
|
+
aToB: boolean;
|
|
6346
|
+
tickIndex: number;
|
|
6347
|
+
};
|
|
6348
|
+
type GetSwapQuoteByInputArgs = {
|
|
6349
|
+
pool: string;
|
|
6350
|
+
amountIn: bigint;
|
|
6351
|
+
aToB: boolean;
|
|
6352
|
+
slippageToleranceBps?: number;
|
|
6353
|
+
};
|
|
6354
|
+
type GetSwapQuoteByOutputArgs = {
|
|
6355
|
+
pool: string;
|
|
6356
|
+
amountOut: bigint;
|
|
6357
|
+
aToB: boolean;
|
|
6358
|
+
slippageToleranceBps?: number;
|
|
6359
|
+
};
|
|
6360
|
+
type GetIncreaseSpotPositionQuoteArgs = {
|
|
6361
|
+
market: string;
|
|
6362
|
+
increaseAmount: bigint;
|
|
6363
|
+
collateralToken: number;
|
|
6364
|
+
positionToken: number;
|
|
6365
|
+
leverage: number;
|
|
6366
|
+
positionAmount?: bigint;
|
|
6367
|
+
positionDebt?: bigint;
|
|
6368
|
+
slippageTolerance?: number;
|
|
6369
|
+
};
|
|
6370
|
+
type GetDecreaseSpotPositionQuoteArgs = {
|
|
6371
|
+
market: string;
|
|
6372
|
+
decreaseAmount: bigint;
|
|
6373
|
+
collateralToken: number;
|
|
6374
|
+
positionToken: number;
|
|
6375
|
+
leverage: number;
|
|
6376
|
+
positionAmount: bigint;
|
|
6377
|
+
positionDebt: bigint;
|
|
6378
|
+
slippageTolerance?: number;
|
|
6379
|
+
};
|
|
6380
|
+
type GetCloseSpotPositionQuoteArgs = {
|
|
6381
|
+
market: string;
|
|
6382
|
+
decreasePercent: number;
|
|
6383
|
+
collateralToken: number;
|
|
6384
|
+
positionToken: number;
|
|
6385
|
+
positionAmount: bigint;
|
|
6386
|
+
positionDebt: bigint;
|
|
6387
|
+
slippageTolerance?: number;
|
|
6388
|
+
};
|
|
6389
|
+
type GetTradableAmountArgs = {
|
|
6390
|
+
market: string;
|
|
6391
|
+
collateralToken: number;
|
|
6392
|
+
positionToken: number;
|
|
6393
|
+
availableBalance: bigint;
|
|
6394
|
+
leverage: number;
|
|
6395
|
+
positionAmount: bigint;
|
|
6396
|
+
increase: boolean;
|
|
6397
|
+
};
|
|
6289
6398
|
type GetUserLimitOrdersOptions = {
|
|
6290
6399
|
pool?: string[];
|
|
6291
6400
|
status?: LimitOrderStateType[];
|
|
@@ -6390,15 +6499,34 @@ declare class TunaApiClient {
|
|
|
6390
6499
|
getUserStakingPositionHistory(userAddress: string): Promise<StakingPositionHistoryAction[]>;
|
|
6391
6500
|
getFeesStats(from: Date, to: Date, interval: string): Promise<FeesStatsGroup[]>;
|
|
6392
6501
|
getStakingRevenueStats(from: Date, to: Date): Promise<StakingRevenueStatsGroup[]>;
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6502
|
+
getLimitOrderQuoteByInput(args: GetLimitOrderQuoteByInputArgs, config?: {
|
|
6503
|
+
abortSignal?: AbortSignal;
|
|
6504
|
+
}): Promise<LimitOrderQuoteByInput>;
|
|
6505
|
+
getLimitOrderQuoteByOutput(args: GetLimitOrderQuoteByOutputArgs, config?: {
|
|
6506
|
+
abortSignal?: AbortSignal;
|
|
6507
|
+
}): Promise<LimitOrderQuoteByOutput>;
|
|
6508
|
+
getSwapQuoteByInput(args: GetSwapQuoteByInputArgs, config?: {
|
|
6509
|
+
abortSignal?: AbortSignal;
|
|
6510
|
+
}): Promise<SwapQuoteByInput>;
|
|
6511
|
+
getSwapQuoteByOutput(args: GetSwapQuoteByOutputArgs, config?: {
|
|
6512
|
+
abortSignal?: AbortSignal;
|
|
6513
|
+
}): Promise<SwapQuoteByOutput>;
|
|
6514
|
+
getIncreaseSpotPositionQuote(args: GetIncreaseSpotPositionQuoteArgs, config?: {
|
|
6515
|
+
abortSignal?: AbortSignal;
|
|
6516
|
+
}): Promise<IncreaseSpotPositionQuote>;
|
|
6517
|
+
getDecreaseSpotPositionQuote(args: GetDecreaseSpotPositionQuoteArgs, config?: {
|
|
6518
|
+
abortSignal?: AbortSignal;
|
|
6519
|
+
}): Promise<DecreaseSpotPositionQuote>;
|
|
6520
|
+
getCloseSpotPositionQuote(args: GetCloseSpotPositionQuoteArgs, config?: {
|
|
6521
|
+
abortSignal?: AbortSignal;
|
|
6522
|
+
}): Promise<CloseSpotPositionQuote>;
|
|
6523
|
+
getTradableAmount(args: GetTradableAmountArgs, config?: {
|
|
6524
|
+
abortSignal?: AbortSignal;
|
|
6525
|
+
}): Promise<TradableAmount>;
|
|
6398
6526
|
getUpdatesStream(): Promise<EventSource>;
|
|
6399
6527
|
updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
|
|
6400
6528
|
private buildURL;
|
|
6401
6529
|
private appendUrlSearchParams;
|
|
6402
6530
|
}
|
|
6403
6531
|
|
|
6404
|
-
export { type DecreaseSpotPositionQuote, type DurationInMs, type FeesStatsGroup, type GetPoolPriceCandlesOptions, type GetUserLimitOrdersOptions, type GetUserOrderHistoryOptions, type GetUserTradeHistoryOptions, type IncreaseSpotPositionQuote, type LendingPosition, type LimitOrder, type LimitOrderStateType, type Market, type Mint, NotificationAction, NotificationEntity, type OrderBook, type OrderBookEntry, type OrderHistoryEntry, type OrderHistoryOrderTypeType, type OrderHistoryStatusType, type OrderHistoryUIDirectionType, type PaginationMeta, type Pool, type PoolPriceCandle, type PoolPriceUpdate, PoolProvider, type PoolProviderType, type PoolSubscriptionTopicType, type PoolSwap, type PoolTicks, ProviderFilter, type StakingLeaderboardPage, type StakingLeaderboardPosition, type StakingPosition, type StakingPositionHistoryAction, type StakingPositionHistoryActionType, type StakingRevenueStatsGroup, type StakingTreasury, type SubscriptionPayload, type
|
|
6532
|
+
export { type CloseSpotPositionQuote, type DecreaseSpotPositionQuote, type DurationInMs, type FeesStatsGroup, type GetCloseSpotPositionQuoteArgs, type GetDecreaseSpotPositionQuoteArgs, type GetIncreaseSpotPositionQuoteArgs, type GetLimitOrderQuoteByInputArgs, type GetLimitOrderQuoteByOutputArgs, type GetPoolPriceCandlesOptions, type GetSwapQuoteByInputArgs, type GetSwapQuoteByOutputArgs, type GetTradableAmountArgs, type GetUserLimitOrdersOptions, type GetUserOrderHistoryOptions, type GetUserTradeHistoryOptions, type IncreaseSpotPositionQuote, type LendingPosition, type LimitOrder, type LimitOrderQuoteByInput, type LimitOrderQuoteByOutput, type LimitOrderStateType, type Market, type Mint, NotificationAction, NotificationEntity, type OrderBook, type OrderBookEntry, type OrderHistoryEntry, type OrderHistoryOrderTypeType, type OrderHistoryStatusType, type OrderHistoryUIDirectionType, type PaginationMeta, type Pool, type PoolPriceCandle, type PoolPriceUpdate, PoolProvider, type PoolProviderType, type PoolSubscriptionTopicType, type PoolSwap, type PoolTicks, ProviderFilter, type StakingLeaderboardPage, type StakingLeaderboardPosition, type StakingPosition, type StakingPositionHistoryAction, type StakingPositionHistoryActionType, type StakingRevenueStatsGroup, type StakingTreasury, type SubscriptionPayload, type SwapQuoteByInput, type SwapQuoteByOutput, type Tick, type TokenOraclePrice, type TradableAmount, type TradeHistoryActionType, type TradeHistoryEntry, type TradeHistoryUIDirectionType, TunaApiClient, type TunaApiClientConfig, type TunaPosition, TunaPositionState, type TunaPositionStateType, type TunaSpotPosition, type TunaSpotPositionStateType, type Vault, type VaultHistoricalStats, type WalletSubscriptionTopicType, schemas };
|
package/dist/index.d.ts
CHANGED
|
@@ -2231,28 +2231,58 @@ declare const IncreaseSpotPositionQuote$1: z.ZodObject<{
|
|
|
2231
2231
|
priceImpact: number;
|
|
2232
2232
|
}>;
|
|
2233
2233
|
declare const DecreaseSpotPositionQuote$1: z.ZodObject<{
|
|
2234
|
-
/**
|
|
2234
|
+
/** Confirmed position decrease percentage (100% = 1.0) */
|
|
2235
2235
|
decreasePercent: z.ZodNumber;
|
|
2236
2236
|
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
2237
2237
|
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
2238
2238
|
*/
|
|
2239
2239
|
requiredSwapAmount: z.ZodBigInt;
|
|
2240
|
+
/** Estimated total amount of the adjusted position */
|
|
2241
|
+
estimatedAmount: z.ZodBigInt;
|
|
2242
|
+
/** Estimated amount of the withdrawn collateral */
|
|
2243
|
+
estimatedWithdrawnCollateral: z.ZodBigInt;
|
|
2240
2244
|
/** Price impact in percents */
|
|
2241
2245
|
priceImpact: z.ZodNumber;
|
|
2242
2246
|
/** Liquidation price */
|
|
2243
2247
|
uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
|
|
2244
2248
|
}, "strip", z.ZodTypeAny, {
|
|
2245
2249
|
uiLiquidationPrice: number | null;
|
|
2250
|
+
estimatedAmount: bigint;
|
|
2246
2251
|
priceImpact: number;
|
|
2247
2252
|
decreasePercent: number;
|
|
2248
2253
|
requiredSwapAmount: bigint;
|
|
2254
|
+
estimatedWithdrawnCollateral: bigint;
|
|
2249
2255
|
}, {
|
|
2250
2256
|
uiLiquidationPrice: number | null;
|
|
2257
|
+
estimatedAmount: bigint;
|
|
2258
|
+
priceImpact: number;
|
|
2259
|
+
decreasePercent: number;
|
|
2260
|
+
requiredSwapAmount: bigint;
|
|
2261
|
+
estimatedWithdrawnCollateral: bigint;
|
|
2262
|
+
}>;
|
|
2263
|
+
declare const CloseSpotPositionQuote$1: z.ZodObject<{
|
|
2264
|
+
/** Position decrease percentage */
|
|
2265
|
+
decreasePercent: z.ZodNumber;
|
|
2266
|
+
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
2267
|
+
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
2268
|
+
*/
|
|
2269
|
+
requiredSwapAmount: z.ZodBigInt;
|
|
2270
|
+
/** Estimated amount of the withdrawn collateral */
|
|
2271
|
+
estimatedWithdrawnCollateral: z.ZodBigInt;
|
|
2272
|
+
/** Price impact in percents */
|
|
2273
|
+
priceImpact: z.ZodNumber;
|
|
2274
|
+
}, "strip", z.ZodTypeAny, {
|
|
2275
|
+
priceImpact: number;
|
|
2276
|
+
decreasePercent: number;
|
|
2277
|
+
requiredSwapAmount: bigint;
|
|
2278
|
+
estimatedWithdrawnCollateral: bigint;
|
|
2279
|
+
}, {
|
|
2251
2280
|
priceImpact: number;
|
|
2252
2281
|
decreasePercent: number;
|
|
2253
2282
|
requiredSwapAmount: bigint;
|
|
2283
|
+
estimatedWithdrawnCollateral: bigint;
|
|
2254
2284
|
}>;
|
|
2255
|
-
declare const
|
|
2285
|
+
declare const SwapQuoteByInput$1: z.ZodObject<{
|
|
2256
2286
|
estimatedAmountOut: z.ZodBigInt;
|
|
2257
2287
|
minAmountOut: z.ZodBigInt;
|
|
2258
2288
|
feeAmount: z.ZodBigInt;
|
|
@@ -2272,7 +2302,7 @@ declare const SwapByInputQuote$1: z.ZodObject<{
|
|
|
2272
2302
|
feeAmount: bigint;
|
|
2273
2303
|
feeUsd: number;
|
|
2274
2304
|
}>;
|
|
2275
|
-
declare const
|
|
2305
|
+
declare const SwapQuoteByOutput$1: z.ZodObject<{
|
|
2276
2306
|
estimatedAmountIn: z.ZodBigInt;
|
|
2277
2307
|
maxAmountIn: z.ZodBigInt;
|
|
2278
2308
|
feeAmount: z.ZodBigInt;
|
|
@@ -2292,6 +2322,20 @@ declare const SwapByOutputQuote$1: z.ZodObject<{
|
|
|
2292
2322
|
estimatedAmountIn: bigint;
|
|
2293
2323
|
maxAmountIn: bigint;
|
|
2294
2324
|
}>;
|
|
2325
|
+
declare const LimitOrderQuoteByInput$1: z.ZodObject<{
|
|
2326
|
+
amountOut: z.ZodBigInt;
|
|
2327
|
+
}, "strip", z.ZodTypeAny, {
|
|
2328
|
+
amountOut: bigint;
|
|
2329
|
+
}, {
|
|
2330
|
+
amountOut: bigint;
|
|
2331
|
+
}>;
|
|
2332
|
+
declare const LimitOrderQuoteByOutput$1: z.ZodObject<{
|
|
2333
|
+
amountIn: z.ZodBigInt;
|
|
2334
|
+
}, "strip", z.ZodTypeAny, {
|
|
2335
|
+
amountIn: bigint;
|
|
2336
|
+
}, {
|
|
2337
|
+
amountIn: bigint;
|
|
2338
|
+
}>;
|
|
2295
2339
|
declare const TradableAmount$1: z.ZodObject<{
|
|
2296
2340
|
amount: z.ZodBigInt;
|
|
2297
2341
|
usd: z.ZodNumber;
|
|
@@ -6227,7 +6271,7 @@ declare const schemas_UpdateStreamSubscriptionResult: typeof UpdateStreamSubscri
|
|
|
6227
6271
|
declare const schemas_WalletSubscriptionTopic: typeof WalletSubscriptionTopic;
|
|
6228
6272
|
declare const schemas_WalletSubscriptionTopicSchema: typeof WalletSubscriptionTopicSchema;
|
|
6229
6273
|
declare namespace schemas {
|
|
6230
|
-
export { DecreaseSpotPositionQuote$1 as DecreaseSpotPositionQuote, FeesStatsGroup$1 as FeesStatsGroup, IncreaseSpotPositionQuote$1 as IncreaseSpotPositionQuote, LendingPosition$1 as LendingPosition, schemas_LendingPositionNotification as LendingPositionNotification, LimitOrder$1 as LimitOrder, schemas_LimitOrderNotification as LimitOrderNotification, schemas_LimitOrderState as LimitOrderState, schemas_LimitOrderStateSchema as LimitOrderStateSchema, Market$1 as Market, Mint$1 as Mint, schemas_NotificationAction as NotificationAction, schemas_NotificationActionSchema as NotificationActionSchema, schemas_NotificationEntity as NotificationEntity, schemas_NotificationEntitySchema as NotificationEntitySchema, OrderBook$1 as OrderBook, OrderBookEntry$1 as OrderBookEntry, schemas_OrderBookNotification as OrderBookNotification, schemas_OrderBookNotificationMeta as OrderBookNotificationMeta, OrderHistoryEntry$1 as OrderHistoryEntry, schemas_OrderHistoryEntryNotification as OrderHistoryEntryNotification, schemas_OrderHistoryOrderType as OrderHistoryOrderType, schemas_OrderHistoryOrderTypeSchema as OrderHistoryOrderTypeSchema, schemas_OrderHistoryStatus as OrderHistoryStatus, schemas_OrderHistoryStatusSchema as OrderHistoryStatusSchema, schemas_OrderHistoryUIDirection as OrderHistoryUIDirection, schemas_OrderHistoryUIDirectionSchema as OrderHistoryUIDirectionSchema, PaginationMeta$1 as PaginationMeta, Pool$1 as Pool, PoolPriceCandle$1 as PoolPriceCandle, PoolPriceUpdate$1 as PoolPriceUpdate, schemas_PoolPriceUpdateNotification as PoolPriceUpdateNotification, schemas_PoolProvider as PoolProvider, schemas_PoolProviderSchema as PoolProviderSchema, schemas_PoolSubscriptionTopic as PoolSubscriptionTopic, schemas_PoolSubscriptionTopicSchema as PoolSubscriptionTopicSchema, PoolSwap$1 as PoolSwap, schemas_PoolSwapNotification as PoolSwapNotification, PoolTicks$1 as PoolTicks, StakingLeaderboardPage$1 as StakingLeaderboardPage, StakingLeaderboardPosition$1 as StakingLeaderboardPosition, StakingPosition$1 as StakingPosition, StakingPositionHistoryAction$1 as StakingPositionHistoryAction, StakingPositionHistoryActionType$1 as StakingPositionHistoryActionType, schemas_StakingPositionHistoryActionTypeSchema as StakingPositionHistoryActionTypeSchema, schemas_StakingPositionNotification as StakingPositionNotification, StakingRevenueStatsGroup$1 as StakingRevenueStatsGroup, StakingTreasury$1 as StakingTreasury,
|
|
6274
|
+
export { CloseSpotPositionQuote$1 as CloseSpotPositionQuote, DecreaseSpotPositionQuote$1 as DecreaseSpotPositionQuote, FeesStatsGroup$1 as FeesStatsGroup, IncreaseSpotPositionQuote$1 as IncreaseSpotPositionQuote, LendingPosition$1 as LendingPosition, schemas_LendingPositionNotification as LendingPositionNotification, LimitOrder$1 as LimitOrder, schemas_LimitOrderNotification as LimitOrderNotification, LimitOrderQuoteByInput$1 as LimitOrderQuoteByInput, LimitOrderQuoteByOutput$1 as LimitOrderQuoteByOutput, schemas_LimitOrderState as LimitOrderState, schemas_LimitOrderStateSchema as LimitOrderStateSchema, Market$1 as Market, Mint$1 as Mint, schemas_NotificationAction as NotificationAction, schemas_NotificationActionSchema as NotificationActionSchema, schemas_NotificationEntity as NotificationEntity, schemas_NotificationEntitySchema as NotificationEntitySchema, OrderBook$1 as OrderBook, OrderBookEntry$1 as OrderBookEntry, schemas_OrderBookNotification as OrderBookNotification, schemas_OrderBookNotificationMeta as OrderBookNotificationMeta, OrderHistoryEntry$1 as OrderHistoryEntry, schemas_OrderHistoryEntryNotification as OrderHistoryEntryNotification, schemas_OrderHistoryOrderType as OrderHistoryOrderType, schemas_OrderHistoryOrderTypeSchema as OrderHistoryOrderTypeSchema, schemas_OrderHistoryStatus as OrderHistoryStatus, schemas_OrderHistoryStatusSchema as OrderHistoryStatusSchema, schemas_OrderHistoryUIDirection as OrderHistoryUIDirection, schemas_OrderHistoryUIDirectionSchema as OrderHistoryUIDirectionSchema, PaginationMeta$1 as PaginationMeta, Pool$1 as Pool, PoolPriceCandle$1 as PoolPriceCandle, PoolPriceUpdate$1 as PoolPriceUpdate, schemas_PoolPriceUpdateNotification as PoolPriceUpdateNotification, schemas_PoolProvider as PoolProvider, schemas_PoolProviderSchema as PoolProviderSchema, schemas_PoolSubscriptionTopic as PoolSubscriptionTopic, schemas_PoolSubscriptionTopicSchema as PoolSubscriptionTopicSchema, PoolSwap$1 as PoolSwap, schemas_PoolSwapNotification as PoolSwapNotification, PoolTicks$1 as PoolTicks, StakingLeaderboardPage$1 as StakingLeaderboardPage, StakingLeaderboardPosition$1 as StakingLeaderboardPosition, StakingPosition$1 as StakingPosition, StakingPositionHistoryAction$1 as StakingPositionHistoryAction, StakingPositionHistoryActionType$1 as StakingPositionHistoryActionType, schemas_StakingPositionHistoryActionTypeSchema as StakingPositionHistoryActionTypeSchema, schemas_StakingPositionNotification as StakingPositionNotification, StakingRevenueStatsGroup$1 as StakingRevenueStatsGroup, StakingTreasury$1 as StakingTreasury, SwapQuoteByInput$1 as SwapQuoteByInput, SwapQuoteByOutput$1 as SwapQuoteByOutput, Tick$1 as Tick, TokenOraclePrice$1 as TokenOraclePrice, TradableAmount$1 as TradableAmount, schemas_TradeHistoryAction as TradeHistoryAction, schemas_TradeHistoryActionSchema as TradeHistoryActionSchema, TradeHistoryEntry$1 as TradeHistoryEntry, schemas_TradeHistoryEntryNotification as TradeHistoryEntryNotification, schemas_TradeHistoryUIDirection as TradeHistoryUIDirection, schemas_TradeHistoryUIDirectionSchema as TradeHistoryUIDirectionSchema, TunaPosition$1 as TunaPosition, schemas_TunaPositionNotification as TunaPositionNotification, schemas_TunaPositionState as TunaPositionState, schemas_TunaPositionStateSchema as TunaPositionStateSchema, TunaSpotPosition$1 as TunaSpotPosition, schemas_TunaSpotPositionNotification as TunaSpotPositionNotification, schemas_TunaSpotPositionState as TunaSpotPositionState, schemas_TunaSpotPositionStateSchema as TunaSpotPositionStateSchema, schemas_UpdateStreamSubscriptionResult as UpdateStreamSubscriptionResult, Vault$1 as Vault, VaultHistoricalStats$1 as VaultHistoricalStats, schemas_WalletSubscriptionTopic as WalletSubscriptionTopic, schemas_WalletSubscriptionTopicSchema as WalletSubscriptionTopicSchema };
|
|
6231
6275
|
}
|
|
6232
6276
|
|
|
6233
6277
|
type PoolProviderType = z.infer<typeof PoolProviderSchema>;
|
|
@@ -6268,10 +6312,13 @@ type StakingPositionHistoryAction = z.infer<typeof StakingPositionHistoryAction$
|
|
|
6268
6312
|
type PoolPriceCandle = z.infer<typeof PoolPriceCandle$1>;
|
|
6269
6313
|
type FeesStatsGroup = z.infer<typeof FeesStatsGroup$1>;
|
|
6270
6314
|
type StakingRevenueStatsGroup = z.infer<typeof StakingRevenueStatsGroup$1>;
|
|
6315
|
+
type LimitOrderQuoteByInput = z.infer<typeof LimitOrderQuoteByInput$1>;
|
|
6316
|
+
type LimitOrderQuoteByOutput = z.infer<typeof LimitOrderQuoteByOutput$1>;
|
|
6317
|
+
type SwapQuoteByInput = z.infer<typeof SwapQuoteByInput$1>;
|
|
6318
|
+
type SwapQuoteByOutput = z.infer<typeof SwapQuoteByOutput$1>;
|
|
6271
6319
|
type IncreaseSpotPositionQuote = z.infer<typeof IncreaseSpotPositionQuote$1>;
|
|
6272
6320
|
type DecreaseSpotPositionQuote = z.infer<typeof DecreaseSpotPositionQuote$1>;
|
|
6273
|
-
type
|
|
6274
|
-
type SwapByOutputQuote = z.infer<typeof SwapByOutputQuote$1>;
|
|
6321
|
+
type CloseSpotPositionQuote = z.infer<typeof CloseSpotPositionQuote$1>;
|
|
6275
6322
|
type TradableAmount = z.infer<typeof TradableAmount$1>;
|
|
6276
6323
|
type PoolPriceUpdate = z.infer<typeof PoolPriceUpdate$1>;
|
|
6277
6324
|
type SubscriptionPayload = {
|
|
@@ -6286,6 +6333,68 @@ type SubscriptionPayload = {
|
|
|
6286
6333
|
topics: WalletSubscriptionTopicType[];
|
|
6287
6334
|
};
|
|
6288
6335
|
};
|
|
6336
|
+
type GetLimitOrderQuoteByInputArgs = {
|
|
6337
|
+
pool: string;
|
|
6338
|
+
amountIn: bigint;
|
|
6339
|
+
aToB: boolean;
|
|
6340
|
+
tickIndex: number;
|
|
6341
|
+
};
|
|
6342
|
+
type GetLimitOrderQuoteByOutputArgs = {
|
|
6343
|
+
pool: string;
|
|
6344
|
+
amountOut: bigint;
|
|
6345
|
+
aToB: boolean;
|
|
6346
|
+
tickIndex: number;
|
|
6347
|
+
};
|
|
6348
|
+
type GetSwapQuoteByInputArgs = {
|
|
6349
|
+
pool: string;
|
|
6350
|
+
amountIn: bigint;
|
|
6351
|
+
aToB: boolean;
|
|
6352
|
+
slippageToleranceBps?: number;
|
|
6353
|
+
};
|
|
6354
|
+
type GetSwapQuoteByOutputArgs = {
|
|
6355
|
+
pool: string;
|
|
6356
|
+
amountOut: bigint;
|
|
6357
|
+
aToB: boolean;
|
|
6358
|
+
slippageToleranceBps?: number;
|
|
6359
|
+
};
|
|
6360
|
+
type GetIncreaseSpotPositionQuoteArgs = {
|
|
6361
|
+
market: string;
|
|
6362
|
+
increaseAmount: bigint;
|
|
6363
|
+
collateralToken: number;
|
|
6364
|
+
positionToken: number;
|
|
6365
|
+
leverage: number;
|
|
6366
|
+
positionAmount?: bigint;
|
|
6367
|
+
positionDebt?: bigint;
|
|
6368
|
+
slippageTolerance?: number;
|
|
6369
|
+
};
|
|
6370
|
+
type GetDecreaseSpotPositionQuoteArgs = {
|
|
6371
|
+
market: string;
|
|
6372
|
+
decreaseAmount: bigint;
|
|
6373
|
+
collateralToken: number;
|
|
6374
|
+
positionToken: number;
|
|
6375
|
+
leverage: number;
|
|
6376
|
+
positionAmount: bigint;
|
|
6377
|
+
positionDebt: bigint;
|
|
6378
|
+
slippageTolerance?: number;
|
|
6379
|
+
};
|
|
6380
|
+
type GetCloseSpotPositionQuoteArgs = {
|
|
6381
|
+
market: string;
|
|
6382
|
+
decreasePercent: number;
|
|
6383
|
+
collateralToken: number;
|
|
6384
|
+
positionToken: number;
|
|
6385
|
+
positionAmount: bigint;
|
|
6386
|
+
positionDebt: bigint;
|
|
6387
|
+
slippageTolerance?: number;
|
|
6388
|
+
};
|
|
6389
|
+
type GetTradableAmountArgs = {
|
|
6390
|
+
market: string;
|
|
6391
|
+
collateralToken: number;
|
|
6392
|
+
positionToken: number;
|
|
6393
|
+
availableBalance: bigint;
|
|
6394
|
+
leverage: number;
|
|
6395
|
+
positionAmount: bigint;
|
|
6396
|
+
increase: boolean;
|
|
6397
|
+
};
|
|
6289
6398
|
type GetUserLimitOrdersOptions = {
|
|
6290
6399
|
pool?: string[];
|
|
6291
6400
|
status?: LimitOrderStateType[];
|
|
@@ -6390,15 +6499,34 @@ declare class TunaApiClient {
|
|
|
6390
6499
|
getUserStakingPositionHistory(userAddress: string): Promise<StakingPositionHistoryAction[]>;
|
|
6391
6500
|
getFeesStats(from: Date, to: Date, interval: string): Promise<FeesStatsGroup[]>;
|
|
6392
6501
|
getStakingRevenueStats(from: Date, to: Date): Promise<StakingRevenueStatsGroup[]>;
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6502
|
+
getLimitOrderQuoteByInput(args: GetLimitOrderQuoteByInputArgs, config?: {
|
|
6503
|
+
abortSignal?: AbortSignal;
|
|
6504
|
+
}): Promise<LimitOrderQuoteByInput>;
|
|
6505
|
+
getLimitOrderQuoteByOutput(args: GetLimitOrderQuoteByOutputArgs, config?: {
|
|
6506
|
+
abortSignal?: AbortSignal;
|
|
6507
|
+
}): Promise<LimitOrderQuoteByOutput>;
|
|
6508
|
+
getSwapQuoteByInput(args: GetSwapQuoteByInputArgs, config?: {
|
|
6509
|
+
abortSignal?: AbortSignal;
|
|
6510
|
+
}): Promise<SwapQuoteByInput>;
|
|
6511
|
+
getSwapQuoteByOutput(args: GetSwapQuoteByOutputArgs, config?: {
|
|
6512
|
+
abortSignal?: AbortSignal;
|
|
6513
|
+
}): Promise<SwapQuoteByOutput>;
|
|
6514
|
+
getIncreaseSpotPositionQuote(args: GetIncreaseSpotPositionQuoteArgs, config?: {
|
|
6515
|
+
abortSignal?: AbortSignal;
|
|
6516
|
+
}): Promise<IncreaseSpotPositionQuote>;
|
|
6517
|
+
getDecreaseSpotPositionQuote(args: GetDecreaseSpotPositionQuoteArgs, config?: {
|
|
6518
|
+
abortSignal?: AbortSignal;
|
|
6519
|
+
}): Promise<DecreaseSpotPositionQuote>;
|
|
6520
|
+
getCloseSpotPositionQuote(args: GetCloseSpotPositionQuoteArgs, config?: {
|
|
6521
|
+
abortSignal?: AbortSignal;
|
|
6522
|
+
}): Promise<CloseSpotPositionQuote>;
|
|
6523
|
+
getTradableAmount(args: GetTradableAmountArgs, config?: {
|
|
6524
|
+
abortSignal?: AbortSignal;
|
|
6525
|
+
}): Promise<TradableAmount>;
|
|
6398
6526
|
getUpdatesStream(): Promise<EventSource>;
|
|
6399
6527
|
updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
|
|
6400
6528
|
private buildURL;
|
|
6401
6529
|
private appendUrlSearchParams;
|
|
6402
6530
|
}
|
|
6403
6531
|
|
|
6404
|
-
export { type DecreaseSpotPositionQuote, type DurationInMs, type FeesStatsGroup, type GetPoolPriceCandlesOptions, type GetUserLimitOrdersOptions, type GetUserOrderHistoryOptions, type GetUserTradeHistoryOptions, type IncreaseSpotPositionQuote, type LendingPosition, type LimitOrder, type LimitOrderStateType, type Market, type Mint, NotificationAction, NotificationEntity, type OrderBook, type OrderBookEntry, type OrderHistoryEntry, type OrderHistoryOrderTypeType, type OrderHistoryStatusType, type OrderHistoryUIDirectionType, type PaginationMeta, type Pool, type PoolPriceCandle, type PoolPriceUpdate, PoolProvider, type PoolProviderType, type PoolSubscriptionTopicType, type PoolSwap, type PoolTicks, ProviderFilter, type StakingLeaderboardPage, type StakingLeaderboardPosition, type StakingPosition, type StakingPositionHistoryAction, type StakingPositionHistoryActionType, type StakingRevenueStatsGroup, type StakingTreasury, type SubscriptionPayload, type
|
|
6532
|
+
export { type CloseSpotPositionQuote, type DecreaseSpotPositionQuote, type DurationInMs, type FeesStatsGroup, type GetCloseSpotPositionQuoteArgs, type GetDecreaseSpotPositionQuoteArgs, type GetIncreaseSpotPositionQuoteArgs, type GetLimitOrderQuoteByInputArgs, type GetLimitOrderQuoteByOutputArgs, type GetPoolPriceCandlesOptions, type GetSwapQuoteByInputArgs, type GetSwapQuoteByOutputArgs, type GetTradableAmountArgs, type GetUserLimitOrdersOptions, type GetUserOrderHistoryOptions, type GetUserTradeHistoryOptions, type IncreaseSpotPositionQuote, type LendingPosition, type LimitOrder, type LimitOrderQuoteByInput, type LimitOrderQuoteByOutput, type LimitOrderStateType, type Market, type Mint, NotificationAction, NotificationEntity, type OrderBook, type OrderBookEntry, type OrderHistoryEntry, type OrderHistoryOrderTypeType, type OrderHistoryStatusType, type OrderHistoryUIDirectionType, type PaginationMeta, type Pool, type PoolPriceCandle, type PoolPriceUpdate, PoolProvider, type PoolProviderType, type PoolSubscriptionTopicType, type PoolSwap, type PoolTicks, ProviderFilter, type StakingLeaderboardPage, type StakingLeaderboardPosition, type StakingPosition, type StakingPositionHistoryAction, type StakingPositionHistoryActionType, type StakingRevenueStatsGroup, type StakingTreasury, type SubscriptionPayload, type SwapQuoteByInput, type SwapQuoteByOutput, type Tick, type TokenOraclePrice, type TradableAmount, type TradeHistoryActionType, type TradeHistoryEntry, type TradeHistoryUIDirectionType, TunaApiClient, type TunaApiClientConfig, type TunaPosition, TunaPositionState, type TunaPositionStateType, type TunaSpotPosition, type TunaSpotPositionStateType, type Vault, type VaultHistoricalStats, type WalletSubscriptionTopicType, schemas };
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ var import_snakecase_keys = __toESM(require("snakecase-keys"));
|
|
|
46
46
|
// src/client/schemas.ts
|
|
47
47
|
var schemas_exports = {};
|
|
48
48
|
__export(schemas_exports, {
|
|
49
|
+
CloseSpotPositionQuote: () => CloseSpotPositionQuote,
|
|
49
50
|
DecreaseSpotPositionQuote: () => DecreaseSpotPositionQuote,
|
|
50
51
|
FeesStatsGroup: () => FeesStatsGroup,
|
|
51
52
|
IncreaseSpotPositionQuote: () => IncreaseSpotPositionQuote,
|
|
@@ -53,6 +54,8 @@ __export(schemas_exports, {
|
|
|
53
54
|
LendingPositionNotification: () => LendingPositionNotification,
|
|
54
55
|
LimitOrder: () => LimitOrder,
|
|
55
56
|
LimitOrderNotification: () => LimitOrderNotification,
|
|
57
|
+
LimitOrderQuoteByInput: () => LimitOrderQuoteByInput,
|
|
58
|
+
LimitOrderQuoteByOutput: () => LimitOrderQuoteByOutput,
|
|
56
59
|
LimitOrderState: () => LimitOrderState,
|
|
57
60
|
LimitOrderStateSchema: () => LimitOrderStateSchema,
|
|
58
61
|
Market: () => Market,
|
|
@@ -94,8 +97,8 @@ __export(schemas_exports, {
|
|
|
94
97
|
StakingPositionNotification: () => StakingPositionNotification,
|
|
95
98
|
StakingRevenueStatsGroup: () => StakingRevenueStatsGroup,
|
|
96
99
|
StakingTreasury: () => StakingTreasury,
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
SwapQuoteByInput: () => SwapQuoteByInput,
|
|
101
|
+
SwapQuoteByOutput: () => SwapQuoteByOutput,
|
|
99
102
|
Tick: () => Tick,
|
|
100
103
|
TokenOraclePrice: () => TokenOraclePrice,
|
|
101
104
|
TradableAmount: () => TradableAmount,
|
|
@@ -667,18 +670,34 @@ var IncreaseSpotPositionQuote = import_zod.z.object({
|
|
|
667
670
|
uiLiquidationPrice: import_zod.z.nullable(import_zod.z.number())
|
|
668
671
|
});
|
|
669
672
|
var DecreaseSpotPositionQuote = import_zod.z.object({
|
|
670
|
-
/**
|
|
673
|
+
/** Confirmed position decrease percentage (100% = 1.0) */
|
|
671
674
|
decreasePercent: import_zod.z.number(),
|
|
672
675
|
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
673
676
|
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
674
677
|
*/
|
|
675
678
|
requiredSwapAmount: import_zod.z.coerce.bigint(),
|
|
679
|
+
/** Estimated total amount of the adjusted position */
|
|
680
|
+
estimatedAmount: import_zod.z.coerce.bigint(),
|
|
681
|
+
/** Estimated amount of the withdrawn collateral */
|
|
682
|
+
estimatedWithdrawnCollateral: import_zod.z.coerce.bigint(),
|
|
676
683
|
/** Price impact in percents */
|
|
677
684
|
priceImpact: import_zod.z.number(),
|
|
678
685
|
/** Liquidation price */
|
|
679
686
|
uiLiquidationPrice: import_zod.z.nullable(import_zod.z.number())
|
|
680
687
|
});
|
|
681
|
-
var
|
|
688
|
+
var CloseSpotPositionQuote = import_zod.z.object({
|
|
689
|
+
/** Position decrease percentage */
|
|
690
|
+
decreasePercent: import_zod.z.number(),
|
|
691
|
+
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
692
|
+
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
693
|
+
*/
|
|
694
|
+
requiredSwapAmount: import_zod.z.coerce.bigint(),
|
|
695
|
+
/** Estimated amount of the withdrawn collateral */
|
|
696
|
+
estimatedWithdrawnCollateral: import_zod.z.coerce.bigint(),
|
|
697
|
+
/** Price impact in percents */
|
|
698
|
+
priceImpact: import_zod.z.number()
|
|
699
|
+
});
|
|
700
|
+
var SwapQuoteByInput = import_zod.z.object({
|
|
682
701
|
estimatedAmountOut: import_zod.z.coerce.bigint(),
|
|
683
702
|
minAmountOut: import_zod.z.coerce.bigint(),
|
|
684
703
|
feeAmount: import_zod.z.coerce.bigint(),
|
|
@@ -686,7 +705,7 @@ var SwapByInputQuote = import_zod.z.object({
|
|
|
686
705
|
/** Price impact in percents */
|
|
687
706
|
priceImpact: import_zod.z.number()
|
|
688
707
|
});
|
|
689
|
-
var
|
|
708
|
+
var SwapQuoteByOutput = import_zod.z.object({
|
|
690
709
|
estimatedAmountIn: import_zod.z.coerce.bigint(),
|
|
691
710
|
maxAmountIn: import_zod.z.coerce.bigint(),
|
|
692
711
|
feeAmount: import_zod.z.coerce.bigint(),
|
|
@@ -694,6 +713,12 @@ var SwapByOutputQuote = import_zod.z.object({
|
|
|
694
713
|
/** Price impact in percents */
|
|
695
714
|
priceImpact: import_zod.z.number()
|
|
696
715
|
});
|
|
716
|
+
var LimitOrderQuoteByInput = import_zod.z.object({
|
|
717
|
+
amountOut: import_zod.z.coerce.bigint()
|
|
718
|
+
});
|
|
719
|
+
var LimitOrderQuoteByOutput = import_zod.z.object({
|
|
720
|
+
amountIn: import_zod.z.coerce.bigint()
|
|
721
|
+
});
|
|
697
722
|
var TradableAmount = amountWithUsd;
|
|
698
723
|
var UpdateStreamSubscriptionResult = import_zod.z.object({
|
|
699
724
|
status: import_zod.z.string()
|
|
@@ -1010,7 +1035,34 @@ var TunaApiClient = class {
|
|
|
1010
1035
|
});
|
|
1011
1036
|
return await this.httpRequest(url, StakingRevenueStatsGroup.array());
|
|
1012
1037
|
}
|
|
1013
|
-
async
|
|
1038
|
+
async getLimitOrderQuoteByInput(args, config) {
|
|
1039
|
+
const { pool, amountIn, aToB, tickIndex } = args;
|
|
1040
|
+
let query = {
|
|
1041
|
+
pool,
|
|
1042
|
+
amount_in: amountIn.toString(),
|
|
1043
|
+
a_to_b: aToB,
|
|
1044
|
+
tick_index: tickIndex
|
|
1045
|
+
};
|
|
1046
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/limit-order-by-input`), query);
|
|
1047
|
+
return await this.httpRequest(url, LimitOrderQuoteByInput, {
|
|
1048
|
+
signal: config?.abortSignal
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
async getLimitOrderQuoteByOutput(args, config) {
|
|
1052
|
+
const { pool, amountOut, aToB, tickIndex } = args;
|
|
1053
|
+
let query = {
|
|
1054
|
+
pool,
|
|
1055
|
+
amount_out: amountOut.toString(),
|
|
1056
|
+
a_to_b: aToB,
|
|
1057
|
+
tick_index: tickIndex
|
|
1058
|
+
};
|
|
1059
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/limit-order-by-output`), query);
|
|
1060
|
+
return await this.httpRequest(url, LimitOrderQuoteByOutput, {
|
|
1061
|
+
signal: config?.abortSignal
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
async getSwapQuoteByInput(args, config) {
|
|
1065
|
+
const { pool, amountIn, aToB, slippageToleranceBps } = args;
|
|
1014
1066
|
let query = {
|
|
1015
1067
|
pool,
|
|
1016
1068
|
amount_in: amountIn.toString(),
|
|
@@ -1020,9 +1072,12 @@ var TunaApiClient = class {
|
|
|
1020
1072
|
query.slippage_tolerance = slippageToleranceBps;
|
|
1021
1073
|
}
|
|
1022
1074
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-input`), query);
|
|
1023
|
-
return await this.httpRequest(url,
|
|
1075
|
+
return await this.httpRequest(url, SwapQuoteByInput, {
|
|
1076
|
+
signal: config?.abortSignal
|
|
1077
|
+
});
|
|
1024
1078
|
}
|
|
1025
|
-
async getSwapQuoteByOutput(
|
|
1079
|
+
async getSwapQuoteByOutput(args, config) {
|
|
1080
|
+
const { pool, amountOut, aToB, slippageToleranceBps } = args;
|
|
1026
1081
|
let query = {
|
|
1027
1082
|
pool,
|
|
1028
1083
|
amount_out: amountOut.toString(),
|
|
@@ -1032,9 +1087,21 @@ var TunaApiClient = class {
|
|
|
1032
1087
|
query.slippage_tolerance = slippageToleranceBps;
|
|
1033
1088
|
}
|
|
1034
1089
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-output`), query);
|
|
1035
|
-
return await this.httpRequest(url,
|
|
1090
|
+
return await this.httpRequest(url, SwapQuoteByOutput, {
|
|
1091
|
+
signal: config?.abortSignal
|
|
1092
|
+
});
|
|
1036
1093
|
}
|
|
1037
|
-
async getIncreaseSpotPositionQuote(
|
|
1094
|
+
async getIncreaseSpotPositionQuote(args, config) {
|
|
1095
|
+
const {
|
|
1096
|
+
market,
|
|
1097
|
+
increaseAmount,
|
|
1098
|
+
collateralToken,
|
|
1099
|
+
positionToken,
|
|
1100
|
+
leverage,
|
|
1101
|
+
positionAmount,
|
|
1102
|
+
positionDebt,
|
|
1103
|
+
slippageTolerance
|
|
1104
|
+
} = args;
|
|
1038
1105
|
let query = {
|
|
1039
1106
|
market,
|
|
1040
1107
|
increase_amount: increaseAmount.toString(),
|
|
@@ -1052,16 +1119,27 @@ var TunaApiClient = class {
|
|
|
1052
1119
|
query.position_debt = positionDebt.toString();
|
|
1053
1120
|
}
|
|
1054
1121
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/increase-spot-position`), query);
|
|
1055
|
-
return await this.httpRequest(url, IncreaseSpotPositionQuote
|
|
1122
|
+
return await this.httpRequest(url, IncreaseSpotPositionQuote, {
|
|
1123
|
+
signal: config?.abortSignal
|
|
1124
|
+
});
|
|
1056
1125
|
}
|
|
1057
|
-
async getDecreaseSpotPositionQuote(
|
|
1126
|
+
async getDecreaseSpotPositionQuote(args, config) {
|
|
1127
|
+
const {
|
|
1128
|
+
market,
|
|
1129
|
+
decreaseAmount,
|
|
1130
|
+
collateralToken,
|
|
1131
|
+
positionToken,
|
|
1132
|
+
leverage,
|
|
1133
|
+
positionAmount,
|
|
1134
|
+
positionDebt,
|
|
1135
|
+
slippageTolerance
|
|
1136
|
+
} = args;
|
|
1058
1137
|
let query = {
|
|
1059
1138
|
market,
|
|
1060
1139
|
decrease_amount: decreaseAmount.toString(),
|
|
1061
1140
|
collateral_token: collateralToken,
|
|
1062
1141
|
position_token: positionToken,
|
|
1063
1142
|
leverage,
|
|
1064
|
-
reduce_only: reduceOnly,
|
|
1065
1143
|
position_amount: positionAmount.toString(),
|
|
1066
1144
|
position_debt: positionDebt.toString()
|
|
1067
1145
|
};
|
|
@@ -1069,9 +1147,30 @@ var TunaApiClient = class {
|
|
|
1069
1147
|
query.slippage_tolerance = slippageTolerance;
|
|
1070
1148
|
}
|
|
1071
1149
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/decrease-spot-position`), query);
|
|
1072
|
-
return await this.httpRequest(url, DecreaseSpotPositionQuote
|
|
1150
|
+
return await this.httpRequest(url, DecreaseSpotPositionQuote, {
|
|
1151
|
+
signal: config?.abortSignal
|
|
1152
|
+
});
|
|
1073
1153
|
}
|
|
1074
|
-
async
|
|
1154
|
+
async getCloseSpotPositionQuote(args, config) {
|
|
1155
|
+
const { market, decreasePercent, collateralToken, positionToken, positionAmount, positionDebt, slippageTolerance } = args;
|
|
1156
|
+
let query = {
|
|
1157
|
+
market,
|
|
1158
|
+
decrease_percent: decreasePercent,
|
|
1159
|
+
collateral_token: collateralToken,
|
|
1160
|
+
position_token: positionToken,
|
|
1161
|
+
position_amount: positionAmount.toString(),
|
|
1162
|
+
position_debt: positionDebt.toString()
|
|
1163
|
+
};
|
|
1164
|
+
if (slippageTolerance) {
|
|
1165
|
+
query.slippage_tolerance = slippageTolerance;
|
|
1166
|
+
}
|
|
1167
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/close-spot-position`), query);
|
|
1168
|
+
return await this.httpRequest(url, CloseSpotPositionQuote, {
|
|
1169
|
+
signal: config?.abortSignal
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
async getTradableAmount(args, config) {
|
|
1173
|
+
const { market, collateralToken, positionToken, availableBalance, leverage, positionAmount, increase } = args;
|
|
1075
1174
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/tradable-amount`), {
|
|
1076
1175
|
market,
|
|
1077
1176
|
collateral_token: collateralToken,
|
|
@@ -1081,7 +1180,9 @@ var TunaApiClient = class {
|
|
|
1081
1180
|
position_amount: positionAmount.toString(),
|
|
1082
1181
|
increase
|
|
1083
1182
|
});
|
|
1084
|
-
return await this.httpRequest(url, TradableAmount
|
|
1183
|
+
return await this.httpRequest(url, TradableAmount, {
|
|
1184
|
+
signal: config?.abortSignal
|
|
1185
|
+
});
|
|
1085
1186
|
}
|
|
1086
1187
|
async getUpdatesStream() {
|
|
1087
1188
|
const url = this.buildURL(`streams/sse`);
|
package/dist/index.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import snakecaseKeys from "snakecase-keys";
|
|
|
11
11
|
// src/client/schemas.ts
|
|
12
12
|
var schemas_exports = {};
|
|
13
13
|
__export(schemas_exports, {
|
|
14
|
+
CloseSpotPositionQuote: () => CloseSpotPositionQuote,
|
|
14
15
|
DecreaseSpotPositionQuote: () => DecreaseSpotPositionQuote,
|
|
15
16
|
FeesStatsGroup: () => FeesStatsGroup,
|
|
16
17
|
IncreaseSpotPositionQuote: () => IncreaseSpotPositionQuote,
|
|
@@ -18,6 +19,8 @@ __export(schemas_exports, {
|
|
|
18
19
|
LendingPositionNotification: () => LendingPositionNotification,
|
|
19
20
|
LimitOrder: () => LimitOrder,
|
|
20
21
|
LimitOrderNotification: () => LimitOrderNotification,
|
|
22
|
+
LimitOrderQuoteByInput: () => LimitOrderQuoteByInput,
|
|
23
|
+
LimitOrderQuoteByOutput: () => LimitOrderQuoteByOutput,
|
|
21
24
|
LimitOrderState: () => LimitOrderState,
|
|
22
25
|
LimitOrderStateSchema: () => LimitOrderStateSchema,
|
|
23
26
|
Market: () => Market,
|
|
@@ -59,8 +62,8 @@ __export(schemas_exports, {
|
|
|
59
62
|
StakingPositionNotification: () => StakingPositionNotification,
|
|
60
63
|
StakingRevenueStatsGroup: () => StakingRevenueStatsGroup,
|
|
61
64
|
StakingTreasury: () => StakingTreasury,
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
SwapQuoteByInput: () => SwapQuoteByInput,
|
|
66
|
+
SwapQuoteByOutput: () => SwapQuoteByOutput,
|
|
64
67
|
Tick: () => Tick,
|
|
65
68
|
TokenOraclePrice: () => TokenOraclePrice,
|
|
66
69
|
TradableAmount: () => TradableAmount,
|
|
@@ -632,18 +635,34 @@ var IncreaseSpotPositionQuote = z.object({
|
|
|
632
635
|
uiLiquidationPrice: z.nullable(z.number())
|
|
633
636
|
});
|
|
634
637
|
var DecreaseSpotPositionQuote = z.object({
|
|
635
|
-
/**
|
|
638
|
+
/** Confirmed position decrease percentage (100% = 1.0) */
|
|
636
639
|
decreasePercent: z.number(),
|
|
637
640
|
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
638
641
|
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
639
642
|
*/
|
|
640
643
|
requiredSwapAmount: z.coerce.bigint(),
|
|
644
|
+
/** Estimated total amount of the adjusted position */
|
|
645
|
+
estimatedAmount: z.coerce.bigint(),
|
|
646
|
+
/** Estimated amount of the withdrawn collateral */
|
|
647
|
+
estimatedWithdrawnCollateral: z.coerce.bigint(),
|
|
641
648
|
/** Price impact in percents */
|
|
642
649
|
priceImpact: z.number(),
|
|
643
650
|
/** Liquidation price */
|
|
644
651
|
uiLiquidationPrice: z.nullable(z.number())
|
|
645
652
|
});
|
|
646
|
-
var
|
|
653
|
+
var CloseSpotPositionQuote = z.object({
|
|
654
|
+
/** Position decrease percentage */
|
|
655
|
+
decreasePercent: z.number(),
|
|
656
|
+
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
657
|
+
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
658
|
+
*/
|
|
659
|
+
requiredSwapAmount: z.coerce.bigint(),
|
|
660
|
+
/** Estimated amount of the withdrawn collateral */
|
|
661
|
+
estimatedWithdrawnCollateral: z.coerce.bigint(),
|
|
662
|
+
/** Price impact in percents */
|
|
663
|
+
priceImpact: z.number()
|
|
664
|
+
});
|
|
665
|
+
var SwapQuoteByInput = z.object({
|
|
647
666
|
estimatedAmountOut: z.coerce.bigint(),
|
|
648
667
|
minAmountOut: z.coerce.bigint(),
|
|
649
668
|
feeAmount: z.coerce.bigint(),
|
|
@@ -651,7 +670,7 @@ var SwapByInputQuote = z.object({
|
|
|
651
670
|
/** Price impact in percents */
|
|
652
671
|
priceImpact: z.number()
|
|
653
672
|
});
|
|
654
|
-
var
|
|
673
|
+
var SwapQuoteByOutput = z.object({
|
|
655
674
|
estimatedAmountIn: z.coerce.bigint(),
|
|
656
675
|
maxAmountIn: z.coerce.bigint(),
|
|
657
676
|
feeAmount: z.coerce.bigint(),
|
|
@@ -659,6 +678,12 @@ var SwapByOutputQuote = z.object({
|
|
|
659
678
|
/** Price impact in percents */
|
|
660
679
|
priceImpact: z.number()
|
|
661
680
|
});
|
|
681
|
+
var LimitOrderQuoteByInput = z.object({
|
|
682
|
+
amountOut: z.coerce.bigint()
|
|
683
|
+
});
|
|
684
|
+
var LimitOrderQuoteByOutput = z.object({
|
|
685
|
+
amountIn: z.coerce.bigint()
|
|
686
|
+
});
|
|
662
687
|
var TradableAmount = amountWithUsd;
|
|
663
688
|
var UpdateStreamSubscriptionResult = z.object({
|
|
664
689
|
status: z.string()
|
|
@@ -975,7 +1000,34 @@ var TunaApiClient = class {
|
|
|
975
1000
|
});
|
|
976
1001
|
return await this.httpRequest(url, StakingRevenueStatsGroup.array());
|
|
977
1002
|
}
|
|
978
|
-
async
|
|
1003
|
+
async getLimitOrderQuoteByInput(args, config) {
|
|
1004
|
+
const { pool, amountIn, aToB, tickIndex } = args;
|
|
1005
|
+
let query = {
|
|
1006
|
+
pool,
|
|
1007
|
+
amount_in: amountIn.toString(),
|
|
1008
|
+
a_to_b: aToB,
|
|
1009
|
+
tick_index: tickIndex
|
|
1010
|
+
};
|
|
1011
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/limit-order-by-input`), query);
|
|
1012
|
+
return await this.httpRequest(url, LimitOrderQuoteByInput, {
|
|
1013
|
+
signal: config?.abortSignal
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
async getLimitOrderQuoteByOutput(args, config) {
|
|
1017
|
+
const { pool, amountOut, aToB, tickIndex } = args;
|
|
1018
|
+
let query = {
|
|
1019
|
+
pool,
|
|
1020
|
+
amount_out: amountOut.toString(),
|
|
1021
|
+
a_to_b: aToB,
|
|
1022
|
+
tick_index: tickIndex
|
|
1023
|
+
};
|
|
1024
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/limit-order-by-output`), query);
|
|
1025
|
+
return await this.httpRequest(url, LimitOrderQuoteByOutput, {
|
|
1026
|
+
signal: config?.abortSignal
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
async getSwapQuoteByInput(args, config) {
|
|
1030
|
+
const { pool, amountIn, aToB, slippageToleranceBps } = args;
|
|
979
1031
|
let query = {
|
|
980
1032
|
pool,
|
|
981
1033
|
amount_in: amountIn.toString(),
|
|
@@ -985,9 +1037,12 @@ var TunaApiClient = class {
|
|
|
985
1037
|
query.slippage_tolerance = slippageToleranceBps;
|
|
986
1038
|
}
|
|
987
1039
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-input`), query);
|
|
988
|
-
return await this.httpRequest(url,
|
|
1040
|
+
return await this.httpRequest(url, SwapQuoteByInput, {
|
|
1041
|
+
signal: config?.abortSignal
|
|
1042
|
+
});
|
|
989
1043
|
}
|
|
990
|
-
async getSwapQuoteByOutput(
|
|
1044
|
+
async getSwapQuoteByOutput(args, config) {
|
|
1045
|
+
const { pool, amountOut, aToB, slippageToleranceBps } = args;
|
|
991
1046
|
let query = {
|
|
992
1047
|
pool,
|
|
993
1048
|
amount_out: amountOut.toString(),
|
|
@@ -997,9 +1052,21 @@ var TunaApiClient = class {
|
|
|
997
1052
|
query.slippage_tolerance = slippageToleranceBps;
|
|
998
1053
|
}
|
|
999
1054
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-output`), query);
|
|
1000
|
-
return await this.httpRequest(url,
|
|
1055
|
+
return await this.httpRequest(url, SwapQuoteByOutput, {
|
|
1056
|
+
signal: config?.abortSignal
|
|
1057
|
+
});
|
|
1001
1058
|
}
|
|
1002
|
-
async getIncreaseSpotPositionQuote(
|
|
1059
|
+
async getIncreaseSpotPositionQuote(args, config) {
|
|
1060
|
+
const {
|
|
1061
|
+
market,
|
|
1062
|
+
increaseAmount,
|
|
1063
|
+
collateralToken,
|
|
1064
|
+
positionToken,
|
|
1065
|
+
leverage,
|
|
1066
|
+
positionAmount,
|
|
1067
|
+
positionDebt,
|
|
1068
|
+
slippageTolerance
|
|
1069
|
+
} = args;
|
|
1003
1070
|
let query = {
|
|
1004
1071
|
market,
|
|
1005
1072
|
increase_amount: increaseAmount.toString(),
|
|
@@ -1017,16 +1084,27 @@ var TunaApiClient = class {
|
|
|
1017
1084
|
query.position_debt = positionDebt.toString();
|
|
1018
1085
|
}
|
|
1019
1086
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/increase-spot-position`), query);
|
|
1020
|
-
return await this.httpRequest(url, IncreaseSpotPositionQuote
|
|
1087
|
+
return await this.httpRequest(url, IncreaseSpotPositionQuote, {
|
|
1088
|
+
signal: config?.abortSignal
|
|
1089
|
+
});
|
|
1021
1090
|
}
|
|
1022
|
-
async getDecreaseSpotPositionQuote(
|
|
1091
|
+
async getDecreaseSpotPositionQuote(args, config) {
|
|
1092
|
+
const {
|
|
1093
|
+
market,
|
|
1094
|
+
decreaseAmount,
|
|
1095
|
+
collateralToken,
|
|
1096
|
+
positionToken,
|
|
1097
|
+
leverage,
|
|
1098
|
+
positionAmount,
|
|
1099
|
+
positionDebt,
|
|
1100
|
+
slippageTolerance
|
|
1101
|
+
} = args;
|
|
1023
1102
|
let query = {
|
|
1024
1103
|
market,
|
|
1025
1104
|
decrease_amount: decreaseAmount.toString(),
|
|
1026
1105
|
collateral_token: collateralToken,
|
|
1027
1106
|
position_token: positionToken,
|
|
1028
1107
|
leverage,
|
|
1029
|
-
reduce_only: reduceOnly,
|
|
1030
1108
|
position_amount: positionAmount.toString(),
|
|
1031
1109
|
position_debt: positionDebt.toString()
|
|
1032
1110
|
};
|
|
@@ -1034,9 +1112,30 @@ var TunaApiClient = class {
|
|
|
1034
1112
|
query.slippage_tolerance = slippageTolerance;
|
|
1035
1113
|
}
|
|
1036
1114
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/decrease-spot-position`), query);
|
|
1037
|
-
return await this.httpRequest(url, DecreaseSpotPositionQuote
|
|
1115
|
+
return await this.httpRequest(url, DecreaseSpotPositionQuote, {
|
|
1116
|
+
signal: config?.abortSignal
|
|
1117
|
+
});
|
|
1038
1118
|
}
|
|
1039
|
-
async
|
|
1119
|
+
async getCloseSpotPositionQuote(args, config) {
|
|
1120
|
+
const { market, decreasePercent, collateralToken, positionToken, positionAmount, positionDebt, slippageTolerance } = args;
|
|
1121
|
+
let query = {
|
|
1122
|
+
market,
|
|
1123
|
+
decrease_percent: decreasePercent,
|
|
1124
|
+
collateral_token: collateralToken,
|
|
1125
|
+
position_token: positionToken,
|
|
1126
|
+
position_amount: positionAmount.toString(),
|
|
1127
|
+
position_debt: positionDebt.toString()
|
|
1128
|
+
};
|
|
1129
|
+
if (slippageTolerance) {
|
|
1130
|
+
query.slippage_tolerance = slippageTolerance;
|
|
1131
|
+
}
|
|
1132
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/close-spot-position`), query);
|
|
1133
|
+
return await this.httpRequest(url, CloseSpotPositionQuote, {
|
|
1134
|
+
signal: config?.abortSignal
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
async getTradableAmount(args, config) {
|
|
1138
|
+
const { market, collateralToken, positionToken, availableBalance, leverage, positionAmount, increase } = args;
|
|
1040
1139
|
const url = this.appendUrlSearchParams(this.buildURL(`quotes/tradable-amount`), {
|
|
1041
1140
|
market,
|
|
1042
1141
|
collateral_token: collateralToken,
|
|
@@ -1046,7 +1145,9 @@ var TunaApiClient = class {
|
|
|
1046
1145
|
position_amount: positionAmount.toString(),
|
|
1047
1146
|
increase
|
|
1048
1147
|
});
|
|
1049
|
-
return await this.httpRequest(url, TradableAmount
|
|
1148
|
+
return await this.httpRequest(url, TradableAmount, {
|
|
1149
|
+
signal: config?.abortSignal
|
|
1150
|
+
});
|
|
1050
1151
|
}
|
|
1051
1152
|
async getUpdatesStream() {
|
|
1052
1153
|
const url = this.buildURL(`streams/sse`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crypticdot/defituna-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@crypticdot/prettier-config": "^1.0.0",
|
|
20
20
|
"@crypticdot/typescript-config": "^1.0.0",
|
|
21
21
|
"@crypticdot/fusionamm-client": "^1.0.62",
|
|
22
|
+
"@crypticdot/fusionamm-core": "^1.0.62",
|
|
22
23
|
"@solana/kit": "^2.1.0",
|
|
23
24
|
"@types/node": "^22.13.14",
|
|
24
25
|
"decimal.js": "^10.5.0",
|