@crypticdot/defituna-api 1.5.2 → 1.6.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 CHANGED
@@ -2233,58 +2233,30 @@ declare const IncreaseSpotPositionQuote$1: z.ZodObject<{
2233
2233
  declare const DecreaseSpotPositionQuote$1: z.ZodObject<{
2234
2234
  /** Position decrease percentage */
2235
2235
  decreasePercent: z.ZodNumber;
2236
- /** Collateral token of the new position */
2237
- collateralToken: z.ZodNumber;
2238
- /** Token of the new position */
2239
- positionToken: z.ZodNumber;
2240
- /** Required additional collateral amount */
2241
- collateralAmount: z.ZodBigInt;
2242
- /** Required amount to borrow */
2243
- borrowAmount: z.ZodBigInt;
2244
2236
  /** The maximum acceptable swap input amount for position decrease according to the provided slippage
2245
2237
  * (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
2246
2238
  */
2247
- decreaseAcceptableSwapAmount: z.ZodBigInt;
2248
- /** The minimum swap output amount for position increase according to the provided slippage. */
2249
- increaseMinSwapOutputAmount: z.ZodBigInt;
2250
- /** Estimated total amount of the new position */
2239
+ requiredSwapAmount: z.ZodBigInt;
2240
+ /** Estimated total amount of the adjusted position */
2251
2241
  estimatedAmount: z.ZodBigInt;
2252
- /** Protocol fee in token A */
2253
- protocolFeeA: z.ZodBigInt;
2254
- /** Protocol fee in token B */
2255
- protocolFeeB: z.ZodBigInt;
2256
2242
  /** Price impact in percents */
2257
2243
  priceImpact: z.ZodNumber;
2258
2244
  /** Liquidation price */
2259
2245
  uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
2260
2246
  }, "strip", z.ZodTypeAny, {
2261
- collateralToken: number;
2262
- positionToken: number;
2263
2247
  uiLiquidationPrice: number | null;
2264
- collateralAmount: bigint;
2265
- borrowAmount: bigint;
2266
2248
  estimatedAmount: bigint;
2267
- protocolFeeA: bigint;
2268
- protocolFeeB: bigint;
2269
2249
  priceImpact: number;
2270
2250
  decreasePercent: number;
2271
- decreaseAcceptableSwapAmount: bigint;
2272
- increaseMinSwapOutputAmount: bigint;
2251
+ requiredSwapAmount: bigint;
2273
2252
  }, {
2274
- collateralToken: number;
2275
- positionToken: number;
2276
2253
  uiLiquidationPrice: number | null;
2277
- collateralAmount: bigint;
2278
- borrowAmount: bigint;
2279
2254
  estimatedAmount: bigint;
2280
- protocolFeeA: bigint;
2281
- protocolFeeB: bigint;
2282
2255
  priceImpact: number;
2283
2256
  decreasePercent: number;
2284
- decreaseAcceptableSwapAmount: bigint;
2285
- increaseMinSwapOutputAmount: bigint;
2257
+ requiredSwapAmount: bigint;
2286
2258
  }>;
2287
- declare const SwapByInputQuote$1: z.ZodObject<{
2259
+ declare const SwapQuoteByInput$1: z.ZodObject<{
2288
2260
  estimatedAmountOut: z.ZodBigInt;
2289
2261
  minAmountOut: z.ZodBigInt;
2290
2262
  feeAmount: z.ZodBigInt;
@@ -2304,7 +2276,7 @@ declare const SwapByInputQuote$1: z.ZodObject<{
2304
2276
  feeAmount: bigint;
2305
2277
  feeUsd: number;
2306
2278
  }>;
2307
- declare const SwapByOutputQuote$1: z.ZodObject<{
2279
+ declare const SwapQuoteByOutput$1: z.ZodObject<{
2308
2280
  estimatedAmountIn: z.ZodBigInt;
2309
2281
  maxAmountIn: z.ZodBigInt;
2310
2282
  feeAmount: z.ZodBigInt;
@@ -2324,6 +2296,20 @@ declare const SwapByOutputQuote$1: z.ZodObject<{
2324
2296
  estimatedAmountIn: bigint;
2325
2297
  maxAmountIn: bigint;
2326
2298
  }>;
2299
+ declare const LimitOrderQuoteByInput$1: z.ZodObject<{
2300
+ amountOut: z.ZodBigInt;
2301
+ }, "strip", z.ZodTypeAny, {
2302
+ amountOut: bigint;
2303
+ }, {
2304
+ amountOut: bigint;
2305
+ }>;
2306
+ declare const LimitOrderQuoteByOutput$1: z.ZodObject<{
2307
+ amountIn: z.ZodBigInt;
2308
+ }, "strip", z.ZodTypeAny, {
2309
+ amountIn: bigint;
2310
+ }, {
2311
+ amountIn: bigint;
2312
+ }>;
2327
2313
  declare const TradableAmount$1: z.ZodObject<{
2328
2314
  amount: z.ZodBigInt;
2329
2315
  usd: z.ZodNumber;
@@ -6259,7 +6245,7 @@ declare const schemas_UpdateStreamSubscriptionResult: typeof UpdateStreamSubscri
6259
6245
  declare const schemas_WalletSubscriptionTopic: typeof WalletSubscriptionTopic;
6260
6246
  declare const schemas_WalletSubscriptionTopicSchema: typeof WalletSubscriptionTopicSchema;
6261
6247
  declare namespace schemas {
6262
- 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, SwapByInputQuote$1 as SwapByInputQuote, SwapByOutputQuote$1 as SwapByOutputQuote, 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 };
6248
+ 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, 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 };
6263
6249
  }
6264
6250
 
6265
6251
  type PoolProviderType = z.infer<typeof PoolProviderSchema>;
@@ -6300,10 +6286,12 @@ type StakingPositionHistoryAction = z.infer<typeof StakingPositionHistoryAction$
6300
6286
  type PoolPriceCandle = z.infer<typeof PoolPriceCandle$1>;
6301
6287
  type FeesStatsGroup = z.infer<typeof FeesStatsGroup$1>;
6302
6288
  type StakingRevenueStatsGroup = z.infer<typeof StakingRevenueStatsGroup$1>;
6289
+ type LimitOrderQuoteByInput = z.infer<typeof LimitOrderQuoteByInput$1>;
6290
+ type LimitOrderQuoteByOutput = z.infer<typeof LimitOrderQuoteByOutput$1>;
6291
+ type SwapQuoteByInput = z.infer<typeof SwapQuoteByInput$1>;
6292
+ type SwapQuoteByOutput = z.infer<typeof SwapQuoteByOutput$1>;
6303
6293
  type IncreaseSpotPositionQuote = z.infer<typeof IncreaseSpotPositionQuote$1>;
6304
6294
  type DecreaseSpotPositionQuote = z.infer<typeof DecreaseSpotPositionQuote$1>;
6305
- type SwapByInputQuote = z.infer<typeof SwapByInputQuote$1>;
6306
- type SwapByOutputQuote = z.infer<typeof SwapByOutputQuote$1>;
6307
6295
  type TradableAmount = z.infer<typeof TradableAmount$1>;
6308
6296
  type PoolPriceUpdate = z.infer<typeof PoolPriceUpdate$1>;
6309
6297
  type SubscriptionPayload = {
@@ -6318,6 +6306,59 @@ type SubscriptionPayload = {
6318
6306
  topics: WalletSubscriptionTopicType[];
6319
6307
  };
6320
6308
  };
6309
+ type GetLimitOrderQuoteByInputArgs = {
6310
+ pool: string;
6311
+ amountIn: bigint;
6312
+ aToB: boolean;
6313
+ tickIndex: number;
6314
+ };
6315
+ type GetLimitOrderQuoteByOutputArgs = {
6316
+ pool: string;
6317
+ amountOut: bigint;
6318
+ aToB: boolean;
6319
+ tickIndex: number;
6320
+ };
6321
+ type GetSwapQuoteByInputArgs = {
6322
+ pool: string;
6323
+ amountIn: bigint;
6324
+ aToB: boolean;
6325
+ slippageToleranceBps?: number;
6326
+ };
6327
+ type GetSwapQuoteByOutputArgs = {
6328
+ pool: string;
6329
+ amountOut: bigint;
6330
+ aToB: boolean;
6331
+ slippageToleranceBps?: number;
6332
+ };
6333
+ type GetIncreaseSpotPositionQuoteArgs = {
6334
+ market: string;
6335
+ increaseAmount: bigint;
6336
+ collateralToken: number;
6337
+ positionToken: number;
6338
+ leverage: number;
6339
+ positionAmount?: bigint;
6340
+ positionDebt?: bigint;
6341
+ slippageTolerance?: number;
6342
+ };
6343
+ type GetDecreaseSpotPositionQuoteArgs = {
6344
+ market: string;
6345
+ decreaseAmount: bigint;
6346
+ collateralToken: number;
6347
+ positionToken: number;
6348
+ leverage: number;
6349
+ positionAmount: bigint;
6350
+ positionDebt: bigint;
6351
+ slippageTolerance?: number;
6352
+ };
6353
+ type GetTradableAmountArgs = {
6354
+ market: string;
6355
+ collateralToken: number;
6356
+ positionToken: number;
6357
+ availableBalance: bigint;
6358
+ leverage: number;
6359
+ positionAmount: bigint;
6360
+ increase: boolean;
6361
+ };
6321
6362
  type GetUserLimitOrdersOptions = {
6322
6363
  pool?: string[];
6323
6364
  status?: LimitOrderStateType[];
@@ -6422,15 +6463,31 @@ declare class TunaApiClient {
6422
6463
  getUserStakingPositionHistory(userAddress: string): Promise<StakingPositionHistoryAction[]>;
6423
6464
  getFeesStats(from: Date, to: Date, interval: string): Promise<FeesStatsGroup[]>;
6424
6465
  getStakingRevenueStats(from: Date, to: Date): Promise<StakingRevenueStatsGroup[]>;
6425
- getSwapQuoteByInput(pool: string, amountIn: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByInputQuote>;
6426
- getSwapQuoteByOutput(pool: string, amountOut: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByOutputQuote>;
6427
- getIncreaseSpotPositionQuote(market: string, increaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, positionAmount?: bigint, positionDebt?: bigint, slippageTolerance?: number): Promise<IncreaseSpotPositionQuote>;
6428
- getDecreaseSpotPositionQuote(market: string, decreaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, reduceOnly: boolean, positionAmount: bigint, positionDebt: bigint, slippageTolerance?: number): Promise<DecreaseSpotPositionQuote>;
6429
- getTradableAmount(market: string, collateralToken: number, positionToken: number, newPositionToken: number, availableBalance: bigint, leverage: number, reduceOnly: boolean, positionAmount: bigint, positionDebt: bigint): Promise<TradableAmount>;
6466
+ getLimitOrderQuoteByInput(args: GetLimitOrderQuoteByInputArgs, config?: {
6467
+ abortSignal?: AbortSignal;
6468
+ }): Promise<LimitOrderQuoteByInput>;
6469
+ getLimitOrderQuoteByOutput(args: GetLimitOrderQuoteByOutputArgs, config?: {
6470
+ abortSignal?: AbortSignal;
6471
+ }): Promise<LimitOrderQuoteByOutput>;
6472
+ getSwapQuoteByInput(args: GetSwapQuoteByInputArgs, config?: {
6473
+ abortSignal?: AbortSignal;
6474
+ }): Promise<SwapQuoteByInput>;
6475
+ getSwapQuoteByOutput(args: GetSwapQuoteByOutputArgs, config?: {
6476
+ abortSignal?: AbortSignal;
6477
+ }): Promise<SwapQuoteByOutput>;
6478
+ getIncreaseSpotPositionQuote(args: GetIncreaseSpotPositionQuoteArgs, config?: {
6479
+ abortSignal?: AbortSignal;
6480
+ }): Promise<IncreaseSpotPositionQuote>;
6481
+ getDecreaseSpotPositionQuote(args: GetDecreaseSpotPositionQuoteArgs, config?: {
6482
+ abortSignal?: AbortSignal;
6483
+ }): Promise<DecreaseSpotPositionQuote>;
6484
+ getTradableAmount(args: GetTradableAmountArgs, config?: {
6485
+ abortSignal?: AbortSignal;
6486
+ }): Promise<TradableAmount>;
6430
6487
  getUpdatesStream(): Promise<EventSource>;
6431
6488
  updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
6432
6489
  private buildURL;
6433
6490
  private appendUrlSearchParams;
6434
6491
  }
6435
6492
 
6436
- 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 SwapByInputQuote, type SwapByOutputQuote, 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 };
6493
+ export { type DecreaseSpotPositionQuote, type DurationInMs, type FeesStatsGroup, 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
@@ -2233,58 +2233,30 @@ declare const IncreaseSpotPositionQuote$1: z.ZodObject<{
2233
2233
  declare const DecreaseSpotPositionQuote$1: z.ZodObject<{
2234
2234
  /** Position decrease percentage */
2235
2235
  decreasePercent: z.ZodNumber;
2236
- /** Collateral token of the new position */
2237
- collateralToken: z.ZodNumber;
2238
- /** Token of the new position */
2239
- positionToken: z.ZodNumber;
2240
- /** Required additional collateral amount */
2241
- collateralAmount: z.ZodBigInt;
2242
- /** Required amount to borrow */
2243
- borrowAmount: z.ZodBigInt;
2244
2236
  /** The maximum acceptable swap input amount for position decrease according to the provided slippage
2245
2237
  * (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
2246
2238
  */
2247
- decreaseAcceptableSwapAmount: z.ZodBigInt;
2248
- /** The minimum swap output amount for position increase according to the provided slippage. */
2249
- increaseMinSwapOutputAmount: z.ZodBigInt;
2250
- /** Estimated total amount of the new position */
2239
+ requiredSwapAmount: z.ZodBigInt;
2240
+ /** Estimated total amount of the adjusted position */
2251
2241
  estimatedAmount: z.ZodBigInt;
2252
- /** Protocol fee in token A */
2253
- protocolFeeA: z.ZodBigInt;
2254
- /** Protocol fee in token B */
2255
- protocolFeeB: z.ZodBigInt;
2256
2242
  /** Price impact in percents */
2257
2243
  priceImpact: z.ZodNumber;
2258
2244
  /** Liquidation price */
2259
2245
  uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
2260
2246
  }, "strip", z.ZodTypeAny, {
2261
- collateralToken: number;
2262
- positionToken: number;
2263
2247
  uiLiquidationPrice: number | null;
2264
- collateralAmount: bigint;
2265
- borrowAmount: bigint;
2266
2248
  estimatedAmount: bigint;
2267
- protocolFeeA: bigint;
2268
- protocolFeeB: bigint;
2269
2249
  priceImpact: number;
2270
2250
  decreasePercent: number;
2271
- decreaseAcceptableSwapAmount: bigint;
2272
- increaseMinSwapOutputAmount: bigint;
2251
+ requiredSwapAmount: bigint;
2273
2252
  }, {
2274
- collateralToken: number;
2275
- positionToken: number;
2276
2253
  uiLiquidationPrice: number | null;
2277
- collateralAmount: bigint;
2278
- borrowAmount: bigint;
2279
2254
  estimatedAmount: bigint;
2280
- protocolFeeA: bigint;
2281
- protocolFeeB: bigint;
2282
2255
  priceImpact: number;
2283
2256
  decreasePercent: number;
2284
- decreaseAcceptableSwapAmount: bigint;
2285
- increaseMinSwapOutputAmount: bigint;
2257
+ requiredSwapAmount: bigint;
2286
2258
  }>;
2287
- declare const SwapByInputQuote$1: z.ZodObject<{
2259
+ declare const SwapQuoteByInput$1: z.ZodObject<{
2288
2260
  estimatedAmountOut: z.ZodBigInt;
2289
2261
  minAmountOut: z.ZodBigInt;
2290
2262
  feeAmount: z.ZodBigInt;
@@ -2304,7 +2276,7 @@ declare const SwapByInputQuote$1: z.ZodObject<{
2304
2276
  feeAmount: bigint;
2305
2277
  feeUsd: number;
2306
2278
  }>;
2307
- declare const SwapByOutputQuote$1: z.ZodObject<{
2279
+ declare const SwapQuoteByOutput$1: z.ZodObject<{
2308
2280
  estimatedAmountIn: z.ZodBigInt;
2309
2281
  maxAmountIn: z.ZodBigInt;
2310
2282
  feeAmount: z.ZodBigInt;
@@ -2324,6 +2296,20 @@ declare const SwapByOutputQuote$1: z.ZodObject<{
2324
2296
  estimatedAmountIn: bigint;
2325
2297
  maxAmountIn: bigint;
2326
2298
  }>;
2299
+ declare const LimitOrderQuoteByInput$1: z.ZodObject<{
2300
+ amountOut: z.ZodBigInt;
2301
+ }, "strip", z.ZodTypeAny, {
2302
+ amountOut: bigint;
2303
+ }, {
2304
+ amountOut: bigint;
2305
+ }>;
2306
+ declare const LimitOrderQuoteByOutput$1: z.ZodObject<{
2307
+ amountIn: z.ZodBigInt;
2308
+ }, "strip", z.ZodTypeAny, {
2309
+ amountIn: bigint;
2310
+ }, {
2311
+ amountIn: bigint;
2312
+ }>;
2327
2313
  declare const TradableAmount$1: z.ZodObject<{
2328
2314
  amount: z.ZodBigInt;
2329
2315
  usd: z.ZodNumber;
@@ -6259,7 +6245,7 @@ declare const schemas_UpdateStreamSubscriptionResult: typeof UpdateStreamSubscri
6259
6245
  declare const schemas_WalletSubscriptionTopic: typeof WalletSubscriptionTopic;
6260
6246
  declare const schemas_WalletSubscriptionTopicSchema: typeof WalletSubscriptionTopicSchema;
6261
6247
  declare namespace schemas {
6262
- 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, SwapByInputQuote$1 as SwapByInputQuote, SwapByOutputQuote$1 as SwapByOutputQuote, 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 };
6248
+ 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, 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 };
6263
6249
  }
6264
6250
 
6265
6251
  type PoolProviderType = z.infer<typeof PoolProviderSchema>;
@@ -6300,10 +6286,12 @@ type StakingPositionHistoryAction = z.infer<typeof StakingPositionHistoryAction$
6300
6286
  type PoolPriceCandle = z.infer<typeof PoolPriceCandle$1>;
6301
6287
  type FeesStatsGroup = z.infer<typeof FeesStatsGroup$1>;
6302
6288
  type StakingRevenueStatsGroup = z.infer<typeof StakingRevenueStatsGroup$1>;
6289
+ type LimitOrderQuoteByInput = z.infer<typeof LimitOrderQuoteByInput$1>;
6290
+ type LimitOrderQuoteByOutput = z.infer<typeof LimitOrderQuoteByOutput$1>;
6291
+ type SwapQuoteByInput = z.infer<typeof SwapQuoteByInput$1>;
6292
+ type SwapQuoteByOutput = z.infer<typeof SwapQuoteByOutput$1>;
6303
6293
  type IncreaseSpotPositionQuote = z.infer<typeof IncreaseSpotPositionQuote$1>;
6304
6294
  type DecreaseSpotPositionQuote = z.infer<typeof DecreaseSpotPositionQuote$1>;
6305
- type SwapByInputQuote = z.infer<typeof SwapByInputQuote$1>;
6306
- type SwapByOutputQuote = z.infer<typeof SwapByOutputQuote$1>;
6307
6295
  type TradableAmount = z.infer<typeof TradableAmount$1>;
6308
6296
  type PoolPriceUpdate = z.infer<typeof PoolPriceUpdate$1>;
6309
6297
  type SubscriptionPayload = {
@@ -6318,6 +6306,59 @@ type SubscriptionPayload = {
6318
6306
  topics: WalletSubscriptionTopicType[];
6319
6307
  };
6320
6308
  };
6309
+ type GetLimitOrderQuoteByInputArgs = {
6310
+ pool: string;
6311
+ amountIn: bigint;
6312
+ aToB: boolean;
6313
+ tickIndex: number;
6314
+ };
6315
+ type GetLimitOrderQuoteByOutputArgs = {
6316
+ pool: string;
6317
+ amountOut: bigint;
6318
+ aToB: boolean;
6319
+ tickIndex: number;
6320
+ };
6321
+ type GetSwapQuoteByInputArgs = {
6322
+ pool: string;
6323
+ amountIn: bigint;
6324
+ aToB: boolean;
6325
+ slippageToleranceBps?: number;
6326
+ };
6327
+ type GetSwapQuoteByOutputArgs = {
6328
+ pool: string;
6329
+ amountOut: bigint;
6330
+ aToB: boolean;
6331
+ slippageToleranceBps?: number;
6332
+ };
6333
+ type GetIncreaseSpotPositionQuoteArgs = {
6334
+ market: string;
6335
+ increaseAmount: bigint;
6336
+ collateralToken: number;
6337
+ positionToken: number;
6338
+ leverage: number;
6339
+ positionAmount?: bigint;
6340
+ positionDebt?: bigint;
6341
+ slippageTolerance?: number;
6342
+ };
6343
+ type GetDecreaseSpotPositionQuoteArgs = {
6344
+ market: string;
6345
+ decreaseAmount: bigint;
6346
+ collateralToken: number;
6347
+ positionToken: number;
6348
+ leverage: number;
6349
+ positionAmount: bigint;
6350
+ positionDebt: bigint;
6351
+ slippageTolerance?: number;
6352
+ };
6353
+ type GetTradableAmountArgs = {
6354
+ market: string;
6355
+ collateralToken: number;
6356
+ positionToken: number;
6357
+ availableBalance: bigint;
6358
+ leverage: number;
6359
+ positionAmount: bigint;
6360
+ increase: boolean;
6361
+ };
6321
6362
  type GetUserLimitOrdersOptions = {
6322
6363
  pool?: string[];
6323
6364
  status?: LimitOrderStateType[];
@@ -6422,15 +6463,31 @@ declare class TunaApiClient {
6422
6463
  getUserStakingPositionHistory(userAddress: string): Promise<StakingPositionHistoryAction[]>;
6423
6464
  getFeesStats(from: Date, to: Date, interval: string): Promise<FeesStatsGroup[]>;
6424
6465
  getStakingRevenueStats(from: Date, to: Date): Promise<StakingRevenueStatsGroup[]>;
6425
- getSwapQuoteByInput(pool: string, amountIn: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByInputQuote>;
6426
- getSwapQuoteByOutput(pool: string, amountOut: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByOutputQuote>;
6427
- getIncreaseSpotPositionQuote(market: string, increaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, positionAmount?: bigint, positionDebt?: bigint, slippageTolerance?: number): Promise<IncreaseSpotPositionQuote>;
6428
- getDecreaseSpotPositionQuote(market: string, decreaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, reduceOnly: boolean, positionAmount: bigint, positionDebt: bigint, slippageTolerance?: number): Promise<DecreaseSpotPositionQuote>;
6429
- getTradableAmount(market: string, collateralToken: number, positionToken: number, newPositionToken: number, availableBalance: bigint, leverage: number, reduceOnly: boolean, positionAmount: bigint, positionDebt: bigint): Promise<TradableAmount>;
6466
+ getLimitOrderQuoteByInput(args: GetLimitOrderQuoteByInputArgs, config?: {
6467
+ abortSignal?: AbortSignal;
6468
+ }): Promise<LimitOrderQuoteByInput>;
6469
+ getLimitOrderQuoteByOutput(args: GetLimitOrderQuoteByOutputArgs, config?: {
6470
+ abortSignal?: AbortSignal;
6471
+ }): Promise<LimitOrderQuoteByOutput>;
6472
+ getSwapQuoteByInput(args: GetSwapQuoteByInputArgs, config?: {
6473
+ abortSignal?: AbortSignal;
6474
+ }): Promise<SwapQuoteByInput>;
6475
+ getSwapQuoteByOutput(args: GetSwapQuoteByOutputArgs, config?: {
6476
+ abortSignal?: AbortSignal;
6477
+ }): Promise<SwapQuoteByOutput>;
6478
+ getIncreaseSpotPositionQuote(args: GetIncreaseSpotPositionQuoteArgs, config?: {
6479
+ abortSignal?: AbortSignal;
6480
+ }): Promise<IncreaseSpotPositionQuote>;
6481
+ getDecreaseSpotPositionQuote(args: GetDecreaseSpotPositionQuoteArgs, config?: {
6482
+ abortSignal?: AbortSignal;
6483
+ }): Promise<DecreaseSpotPositionQuote>;
6484
+ getTradableAmount(args: GetTradableAmountArgs, config?: {
6485
+ abortSignal?: AbortSignal;
6486
+ }): Promise<TradableAmount>;
6430
6487
  getUpdatesStream(): Promise<EventSource>;
6431
6488
  updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
6432
6489
  private buildURL;
6433
6490
  private appendUrlSearchParams;
6434
6491
  }
6435
6492
 
6436
- 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 SwapByInputQuote, type SwapByOutputQuote, 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 };
6493
+ export { type DecreaseSpotPositionQuote, type DurationInMs, type FeesStatsGroup, 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
@@ -53,6 +53,8 @@ __export(schemas_exports, {
53
53
  LendingPositionNotification: () => LendingPositionNotification,
54
54
  LimitOrder: () => LimitOrder,
55
55
  LimitOrderNotification: () => LimitOrderNotification,
56
+ LimitOrderQuoteByInput: () => LimitOrderQuoteByInput,
57
+ LimitOrderQuoteByOutput: () => LimitOrderQuoteByOutput,
56
58
  LimitOrderState: () => LimitOrderState,
57
59
  LimitOrderStateSchema: () => LimitOrderStateSchema,
58
60
  Market: () => Market,
@@ -94,8 +96,8 @@ __export(schemas_exports, {
94
96
  StakingPositionNotification: () => StakingPositionNotification,
95
97
  StakingRevenueStatsGroup: () => StakingRevenueStatsGroup,
96
98
  StakingTreasury: () => StakingTreasury,
97
- SwapByInputQuote: () => SwapByInputQuote,
98
- SwapByOutputQuote: () => SwapByOutputQuote,
99
+ SwapQuoteByInput: () => SwapQuoteByInput,
100
+ SwapQuoteByOutput: () => SwapQuoteByOutput,
99
101
  Tick: () => Tick,
100
102
  TokenOraclePrice: () => TokenOraclePrice,
101
103
  TradableAmount: () => TradableAmount,
@@ -669,32 +671,18 @@ var IncreaseSpotPositionQuote = import_zod.z.object({
669
671
  var DecreaseSpotPositionQuote = import_zod.z.object({
670
672
  /** Position decrease percentage */
671
673
  decreasePercent: import_zod.z.number(),
672
- /** Collateral token of the new position */
673
- collateralToken: import_zod.z.number(),
674
- /** Token of the new position */
675
- positionToken: import_zod.z.number(),
676
- /** Required additional collateral amount */
677
- collateralAmount: import_zod.z.coerce.bigint(),
678
- /** Required amount to borrow */
679
- borrowAmount: import_zod.z.coerce.bigint(),
680
674
  /** The maximum acceptable swap input amount for position decrease according to the provided slippage
681
675
  * (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
682
676
  */
683
- decreaseAcceptableSwapAmount: import_zod.z.coerce.bigint(),
684
- /** The minimum swap output amount for position increase according to the provided slippage. */
685
- increaseMinSwapOutputAmount: import_zod.z.coerce.bigint(),
686
- /** Estimated total amount of the new position */
677
+ requiredSwapAmount: import_zod.z.coerce.bigint(),
678
+ /** Estimated total amount of the adjusted position */
687
679
  estimatedAmount: import_zod.z.coerce.bigint(),
688
- /** Protocol fee in token A */
689
- protocolFeeA: import_zod.z.coerce.bigint(),
690
- /** Protocol fee in token B */
691
- protocolFeeB: import_zod.z.coerce.bigint(),
692
680
  /** Price impact in percents */
693
681
  priceImpact: import_zod.z.number(),
694
682
  /** Liquidation price */
695
683
  uiLiquidationPrice: import_zod.z.nullable(import_zod.z.number())
696
684
  });
697
- var SwapByInputQuote = import_zod.z.object({
685
+ var SwapQuoteByInput = import_zod.z.object({
698
686
  estimatedAmountOut: import_zod.z.coerce.bigint(),
699
687
  minAmountOut: import_zod.z.coerce.bigint(),
700
688
  feeAmount: import_zod.z.coerce.bigint(),
@@ -702,7 +690,7 @@ var SwapByInputQuote = import_zod.z.object({
702
690
  /** Price impact in percents */
703
691
  priceImpact: import_zod.z.number()
704
692
  });
705
- var SwapByOutputQuote = import_zod.z.object({
693
+ var SwapQuoteByOutput = import_zod.z.object({
706
694
  estimatedAmountIn: import_zod.z.coerce.bigint(),
707
695
  maxAmountIn: import_zod.z.coerce.bigint(),
708
696
  feeAmount: import_zod.z.coerce.bigint(),
@@ -710,6 +698,12 @@ var SwapByOutputQuote = import_zod.z.object({
710
698
  /** Price impact in percents */
711
699
  priceImpact: import_zod.z.number()
712
700
  });
701
+ var LimitOrderQuoteByInput = import_zod.z.object({
702
+ amountOut: import_zod.z.coerce.bigint()
703
+ });
704
+ var LimitOrderQuoteByOutput = import_zod.z.object({
705
+ amountIn: import_zod.z.coerce.bigint()
706
+ });
713
707
  var TradableAmount = amountWithUsd;
714
708
  var UpdateStreamSubscriptionResult = import_zod.z.object({
715
709
  status: import_zod.z.string()
@@ -1026,7 +1020,34 @@ var TunaApiClient = class {
1026
1020
  });
1027
1021
  return await this.httpRequest(url, StakingRevenueStatsGroup.array());
1028
1022
  }
1029
- async getSwapQuoteByInput(pool, amountIn, aToB, slippageToleranceBps) {
1023
+ async getLimitOrderQuoteByInput(args, config) {
1024
+ const { pool, amountIn, aToB, tickIndex } = args;
1025
+ let query = {
1026
+ pool,
1027
+ amount_in: amountIn.toString(),
1028
+ a_to_b: aToB,
1029
+ tick_index: tickIndex
1030
+ };
1031
+ const url = this.appendUrlSearchParams(this.buildURL(`quotes/limit-order-by-input`), query);
1032
+ return await this.httpRequest(url, LimitOrderQuoteByInput, {
1033
+ signal: config?.abortSignal
1034
+ });
1035
+ }
1036
+ async getLimitOrderQuoteByOutput(args, config) {
1037
+ const { pool, amountOut, aToB, tickIndex } = args;
1038
+ let query = {
1039
+ pool,
1040
+ amount_out: amountOut.toString(),
1041
+ a_to_b: aToB,
1042
+ tick_index: tickIndex
1043
+ };
1044
+ const url = this.appendUrlSearchParams(this.buildURL(`quotes/limit-order-by-output`), query);
1045
+ return await this.httpRequest(url, LimitOrderQuoteByOutput, {
1046
+ signal: config?.abortSignal
1047
+ });
1048
+ }
1049
+ async getSwapQuoteByInput(args, config) {
1050
+ const { pool, amountIn, aToB, slippageToleranceBps } = args;
1030
1051
  let query = {
1031
1052
  pool,
1032
1053
  amount_in: amountIn.toString(),
@@ -1036,9 +1057,12 @@ var TunaApiClient = class {
1036
1057
  query.slippage_tolerance = slippageToleranceBps;
1037
1058
  }
1038
1059
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-input`), query);
1039
- return await this.httpRequest(url, SwapByInputQuote);
1060
+ return await this.httpRequest(url, SwapQuoteByInput, {
1061
+ signal: config?.abortSignal
1062
+ });
1040
1063
  }
1041
- async getSwapQuoteByOutput(pool, amountOut, aToB, slippageToleranceBps) {
1064
+ async getSwapQuoteByOutput(args, config) {
1065
+ const { pool, amountOut, aToB, slippageToleranceBps } = args;
1042
1066
  let query = {
1043
1067
  pool,
1044
1068
  amount_out: amountOut.toString(),
@@ -1048,9 +1072,21 @@ var TunaApiClient = class {
1048
1072
  query.slippage_tolerance = slippageToleranceBps;
1049
1073
  }
1050
1074
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-output`), query);
1051
- return await this.httpRequest(url, SwapByOutputQuote);
1075
+ return await this.httpRequest(url, SwapQuoteByOutput, {
1076
+ signal: config?.abortSignal
1077
+ });
1052
1078
  }
1053
- async getIncreaseSpotPositionQuote(market, increaseAmount, collateralToken, positionToken, leverage, positionAmount, positionDebt, slippageTolerance) {
1079
+ async getIncreaseSpotPositionQuote(args, config) {
1080
+ const {
1081
+ market,
1082
+ increaseAmount,
1083
+ collateralToken,
1084
+ positionToken,
1085
+ leverage,
1086
+ positionAmount,
1087
+ positionDebt,
1088
+ slippageTolerance
1089
+ } = args;
1054
1090
  let query = {
1055
1091
  market,
1056
1092
  increase_amount: increaseAmount.toString(),
@@ -1068,16 +1104,27 @@ var TunaApiClient = class {
1068
1104
  query.position_debt = positionDebt.toString();
1069
1105
  }
1070
1106
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/increase-spot-position`), query);
1071
- return await this.httpRequest(url, IncreaseSpotPositionQuote);
1107
+ return await this.httpRequest(url, IncreaseSpotPositionQuote, {
1108
+ signal: config?.abortSignal
1109
+ });
1072
1110
  }
1073
- async getDecreaseSpotPositionQuote(market, decreaseAmount, collateralToken, positionToken, leverage, reduceOnly, positionAmount, positionDebt, slippageTolerance) {
1111
+ async getDecreaseSpotPositionQuote(args, config) {
1112
+ const {
1113
+ market,
1114
+ decreaseAmount,
1115
+ collateralToken,
1116
+ positionToken,
1117
+ leverage,
1118
+ positionAmount,
1119
+ positionDebt,
1120
+ slippageTolerance
1121
+ } = args;
1074
1122
  let query = {
1075
1123
  market,
1076
1124
  decrease_amount: decreaseAmount.toString(),
1077
1125
  collateral_token: collateralToken,
1078
1126
  position_token: positionToken,
1079
1127
  leverage,
1080
- reduce_only: reduceOnly,
1081
1128
  position_amount: positionAmount.toString(),
1082
1129
  position_debt: positionDebt.toString()
1083
1130
  };
@@ -1085,21 +1132,24 @@ var TunaApiClient = class {
1085
1132
  query.slippage_tolerance = slippageTolerance;
1086
1133
  }
1087
1134
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/decrease-spot-position`), query);
1088
- return await this.httpRequest(url, DecreaseSpotPositionQuote);
1135
+ return await this.httpRequest(url, DecreaseSpotPositionQuote, {
1136
+ signal: config?.abortSignal
1137
+ });
1089
1138
  }
1090
- async getTradableAmount(market, collateralToken, positionToken, newPositionToken, availableBalance, leverage, reduceOnly, positionAmount, positionDebt) {
1139
+ async getTradableAmount(args, config) {
1140
+ const { market, collateralToken, positionToken, availableBalance, leverage, positionAmount, increase } = args;
1091
1141
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/tradable-amount`), {
1092
1142
  market,
1093
1143
  collateral_token: collateralToken,
1094
1144
  position_token: positionToken,
1095
- new_position_token: newPositionToken,
1096
1145
  available_balance: availableBalance.toString(),
1097
1146
  leverage,
1098
- reduce_only: reduceOnly,
1099
1147
  position_amount: positionAmount.toString(),
1100
- position_debt: positionDebt.toString()
1148
+ increase
1149
+ });
1150
+ return await this.httpRequest(url, TradableAmount, {
1151
+ signal: config?.abortSignal
1101
1152
  });
1102
- return await this.httpRequest(url, TradableAmount);
1103
1153
  }
1104
1154
  async getUpdatesStream() {
1105
1155
  const url = this.buildURL(`streams/sse`);
package/dist/index.mjs CHANGED
@@ -18,6 +18,8 @@ __export(schemas_exports, {
18
18
  LendingPositionNotification: () => LendingPositionNotification,
19
19
  LimitOrder: () => LimitOrder,
20
20
  LimitOrderNotification: () => LimitOrderNotification,
21
+ LimitOrderQuoteByInput: () => LimitOrderQuoteByInput,
22
+ LimitOrderQuoteByOutput: () => LimitOrderQuoteByOutput,
21
23
  LimitOrderState: () => LimitOrderState,
22
24
  LimitOrderStateSchema: () => LimitOrderStateSchema,
23
25
  Market: () => Market,
@@ -59,8 +61,8 @@ __export(schemas_exports, {
59
61
  StakingPositionNotification: () => StakingPositionNotification,
60
62
  StakingRevenueStatsGroup: () => StakingRevenueStatsGroup,
61
63
  StakingTreasury: () => StakingTreasury,
62
- SwapByInputQuote: () => SwapByInputQuote,
63
- SwapByOutputQuote: () => SwapByOutputQuote,
64
+ SwapQuoteByInput: () => SwapQuoteByInput,
65
+ SwapQuoteByOutput: () => SwapQuoteByOutput,
64
66
  Tick: () => Tick,
65
67
  TokenOraclePrice: () => TokenOraclePrice,
66
68
  TradableAmount: () => TradableAmount,
@@ -634,32 +636,18 @@ var IncreaseSpotPositionQuote = z.object({
634
636
  var DecreaseSpotPositionQuote = z.object({
635
637
  /** Position decrease percentage */
636
638
  decreasePercent: z.number(),
637
- /** Collateral token of the new position */
638
- collateralToken: z.number(),
639
- /** Token of the new position */
640
- positionToken: z.number(),
641
- /** Required additional collateral amount */
642
- collateralAmount: z.coerce.bigint(),
643
- /** Required amount to borrow */
644
- borrowAmount: z.coerce.bigint(),
645
639
  /** The maximum acceptable swap input amount for position decrease according to the provided slippage
646
640
  * (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
647
641
  */
648
- decreaseAcceptableSwapAmount: z.coerce.bigint(),
649
- /** The minimum swap output amount for position increase according to the provided slippage. */
650
- increaseMinSwapOutputAmount: z.coerce.bigint(),
651
- /** Estimated total amount of the new position */
642
+ requiredSwapAmount: z.coerce.bigint(),
643
+ /** Estimated total amount of the adjusted position */
652
644
  estimatedAmount: z.coerce.bigint(),
653
- /** Protocol fee in token A */
654
- protocolFeeA: z.coerce.bigint(),
655
- /** Protocol fee in token B */
656
- protocolFeeB: z.coerce.bigint(),
657
645
  /** Price impact in percents */
658
646
  priceImpact: z.number(),
659
647
  /** Liquidation price */
660
648
  uiLiquidationPrice: z.nullable(z.number())
661
649
  });
662
- var SwapByInputQuote = z.object({
650
+ var SwapQuoteByInput = z.object({
663
651
  estimatedAmountOut: z.coerce.bigint(),
664
652
  minAmountOut: z.coerce.bigint(),
665
653
  feeAmount: z.coerce.bigint(),
@@ -667,7 +655,7 @@ var SwapByInputQuote = z.object({
667
655
  /** Price impact in percents */
668
656
  priceImpact: z.number()
669
657
  });
670
- var SwapByOutputQuote = z.object({
658
+ var SwapQuoteByOutput = z.object({
671
659
  estimatedAmountIn: z.coerce.bigint(),
672
660
  maxAmountIn: z.coerce.bigint(),
673
661
  feeAmount: z.coerce.bigint(),
@@ -675,6 +663,12 @@ var SwapByOutputQuote = z.object({
675
663
  /** Price impact in percents */
676
664
  priceImpact: z.number()
677
665
  });
666
+ var LimitOrderQuoteByInput = z.object({
667
+ amountOut: z.coerce.bigint()
668
+ });
669
+ var LimitOrderQuoteByOutput = z.object({
670
+ amountIn: z.coerce.bigint()
671
+ });
678
672
  var TradableAmount = amountWithUsd;
679
673
  var UpdateStreamSubscriptionResult = z.object({
680
674
  status: z.string()
@@ -991,7 +985,34 @@ var TunaApiClient = class {
991
985
  });
992
986
  return await this.httpRequest(url, StakingRevenueStatsGroup.array());
993
987
  }
994
- async getSwapQuoteByInput(pool, amountIn, aToB, slippageToleranceBps) {
988
+ async getLimitOrderQuoteByInput(args, config) {
989
+ const { pool, amountIn, aToB, tickIndex } = args;
990
+ let query = {
991
+ pool,
992
+ amount_in: amountIn.toString(),
993
+ a_to_b: aToB,
994
+ tick_index: tickIndex
995
+ };
996
+ const url = this.appendUrlSearchParams(this.buildURL(`quotes/limit-order-by-input`), query);
997
+ return await this.httpRequest(url, LimitOrderQuoteByInput, {
998
+ signal: config?.abortSignal
999
+ });
1000
+ }
1001
+ async getLimitOrderQuoteByOutput(args, config) {
1002
+ const { pool, amountOut, aToB, tickIndex } = args;
1003
+ let query = {
1004
+ pool,
1005
+ amount_out: amountOut.toString(),
1006
+ a_to_b: aToB,
1007
+ tick_index: tickIndex
1008
+ };
1009
+ const url = this.appendUrlSearchParams(this.buildURL(`quotes/limit-order-by-output`), query);
1010
+ return await this.httpRequest(url, LimitOrderQuoteByOutput, {
1011
+ signal: config?.abortSignal
1012
+ });
1013
+ }
1014
+ async getSwapQuoteByInput(args, config) {
1015
+ const { pool, amountIn, aToB, slippageToleranceBps } = args;
995
1016
  let query = {
996
1017
  pool,
997
1018
  amount_in: amountIn.toString(),
@@ -1001,9 +1022,12 @@ var TunaApiClient = class {
1001
1022
  query.slippage_tolerance = slippageToleranceBps;
1002
1023
  }
1003
1024
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-input`), query);
1004
- return await this.httpRequest(url, SwapByInputQuote);
1025
+ return await this.httpRequest(url, SwapQuoteByInput, {
1026
+ signal: config?.abortSignal
1027
+ });
1005
1028
  }
1006
- async getSwapQuoteByOutput(pool, amountOut, aToB, slippageToleranceBps) {
1029
+ async getSwapQuoteByOutput(args, config) {
1030
+ const { pool, amountOut, aToB, slippageToleranceBps } = args;
1007
1031
  let query = {
1008
1032
  pool,
1009
1033
  amount_out: amountOut.toString(),
@@ -1013,9 +1037,21 @@ var TunaApiClient = class {
1013
1037
  query.slippage_tolerance = slippageToleranceBps;
1014
1038
  }
1015
1039
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-output`), query);
1016
- return await this.httpRequest(url, SwapByOutputQuote);
1040
+ return await this.httpRequest(url, SwapQuoteByOutput, {
1041
+ signal: config?.abortSignal
1042
+ });
1017
1043
  }
1018
- async getIncreaseSpotPositionQuote(market, increaseAmount, collateralToken, positionToken, leverage, positionAmount, positionDebt, slippageTolerance) {
1044
+ async getIncreaseSpotPositionQuote(args, config) {
1045
+ const {
1046
+ market,
1047
+ increaseAmount,
1048
+ collateralToken,
1049
+ positionToken,
1050
+ leverage,
1051
+ positionAmount,
1052
+ positionDebt,
1053
+ slippageTolerance
1054
+ } = args;
1019
1055
  let query = {
1020
1056
  market,
1021
1057
  increase_amount: increaseAmount.toString(),
@@ -1033,16 +1069,27 @@ var TunaApiClient = class {
1033
1069
  query.position_debt = positionDebt.toString();
1034
1070
  }
1035
1071
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/increase-spot-position`), query);
1036
- return await this.httpRequest(url, IncreaseSpotPositionQuote);
1072
+ return await this.httpRequest(url, IncreaseSpotPositionQuote, {
1073
+ signal: config?.abortSignal
1074
+ });
1037
1075
  }
1038
- async getDecreaseSpotPositionQuote(market, decreaseAmount, collateralToken, positionToken, leverage, reduceOnly, positionAmount, positionDebt, slippageTolerance) {
1076
+ async getDecreaseSpotPositionQuote(args, config) {
1077
+ const {
1078
+ market,
1079
+ decreaseAmount,
1080
+ collateralToken,
1081
+ positionToken,
1082
+ leverage,
1083
+ positionAmount,
1084
+ positionDebt,
1085
+ slippageTolerance
1086
+ } = args;
1039
1087
  let query = {
1040
1088
  market,
1041
1089
  decrease_amount: decreaseAmount.toString(),
1042
1090
  collateral_token: collateralToken,
1043
1091
  position_token: positionToken,
1044
1092
  leverage,
1045
- reduce_only: reduceOnly,
1046
1093
  position_amount: positionAmount.toString(),
1047
1094
  position_debt: positionDebt.toString()
1048
1095
  };
@@ -1050,21 +1097,24 @@ var TunaApiClient = class {
1050
1097
  query.slippage_tolerance = slippageTolerance;
1051
1098
  }
1052
1099
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/decrease-spot-position`), query);
1053
- return await this.httpRequest(url, DecreaseSpotPositionQuote);
1100
+ return await this.httpRequest(url, DecreaseSpotPositionQuote, {
1101
+ signal: config?.abortSignal
1102
+ });
1054
1103
  }
1055
- async getTradableAmount(market, collateralToken, positionToken, newPositionToken, availableBalance, leverage, reduceOnly, positionAmount, positionDebt) {
1104
+ async getTradableAmount(args, config) {
1105
+ const { market, collateralToken, positionToken, availableBalance, leverage, positionAmount, increase } = args;
1056
1106
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/tradable-amount`), {
1057
1107
  market,
1058
1108
  collateral_token: collateralToken,
1059
1109
  position_token: positionToken,
1060
- new_position_token: newPositionToken,
1061
1110
  available_balance: availableBalance.toString(),
1062
1111
  leverage,
1063
- reduce_only: reduceOnly,
1064
1112
  position_amount: positionAmount.toString(),
1065
- position_debt: positionDebt.toString()
1113
+ increase
1114
+ });
1115
+ return await this.httpRequest(url, TradableAmount, {
1116
+ signal: config?.abortSignal
1066
1117
  });
1067
- return await this.httpRequest(url, TradableAmount);
1068
1118
  }
1069
1119
  async getUpdatesStream() {
1070
1120
  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.5.2",
3
+ "version": "1.6.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",