@crypticdot/defituna-api 1.5.2 → 1.5.3

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,56 +2233,24 @@ 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 */
2251
- estimatedAmount: z.ZodBigInt;
2252
- /** Protocol fee in token A */
2253
- protocolFeeA: z.ZodBigInt;
2254
- /** Protocol fee in token B */
2255
- protocolFeeB: z.ZodBigInt;
2239
+ requiredSwapAmount: z.ZodBigInt;
2256
2240
  /** Price impact in percents */
2257
2241
  priceImpact: z.ZodNumber;
2258
2242
  /** Liquidation price */
2259
2243
  uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
2260
2244
  }, "strip", z.ZodTypeAny, {
2261
- collateralToken: number;
2262
- positionToken: number;
2263
2245
  uiLiquidationPrice: number | null;
2264
- collateralAmount: bigint;
2265
- borrowAmount: bigint;
2266
- estimatedAmount: bigint;
2267
- protocolFeeA: bigint;
2268
- protocolFeeB: bigint;
2269
2246
  priceImpact: number;
2270
2247
  decreasePercent: number;
2271
- decreaseAcceptableSwapAmount: bigint;
2272
- increaseMinSwapOutputAmount: bigint;
2248
+ requiredSwapAmount: bigint;
2273
2249
  }, {
2274
- collateralToken: number;
2275
- positionToken: number;
2276
2250
  uiLiquidationPrice: number | null;
2277
- collateralAmount: bigint;
2278
- borrowAmount: bigint;
2279
- estimatedAmount: bigint;
2280
- protocolFeeA: bigint;
2281
- protocolFeeB: bigint;
2282
2251
  priceImpact: number;
2283
2252
  decreasePercent: number;
2284
- decreaseAcceptableSwapAmount: bigint;
2285
- increaseMinSwapOutputAmount: bigint;
2253
+ requiredSwapAmount: bigint;
2286
2254
  }>;
2287
2255
  declare const SwapByInputQuote$1: z.ZodObject<{
2288
2256
  estimatedAmountOut: z.ZodBigInt;
@@ -6426,7 +6394,7 @@ declare class TunaApiClient {
6426
6394
  getSwapQuoteByOutput(pool: string, amountOut: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByOutputQuote>;
6427
6395
  getIncreaseSpotPositionQuote(market: string, increaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, positionAmount?: bigint, positionDebt?: bigint, slippageTolerance?: number): Promise<IncreaseSpotPositionQuote>;
6428
6396
  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>;
6397
+ getTradableAmount(market: string, collateralToken: number, positionToken: number, availableBalance: bigint, leverage: number, positionAmount: bigint, increase: boolean): Promise<TradableAmount>;
6430
6398
  getUpdatesStream(): Promise<EventSource>;
6431
6399
  updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
6432
6400
  private buildURL;
package/dist/index.d.ts CHANGED
@@ -2233,56 +2233,24 @@ 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 */
2251
- estimatedAmount: z.ZodBigInt;
2252
- /** Protocol fee in token A */
2253
- protocolFeeA: z.ZodBigInt;
2254
- /** Protocol fee in token B */
2255
- protocolFeeB: z.ZodBigInt;
2239
+ requiredSwapAmount: z.ZodBigInt;
2256
2240
  /** Price impact in percents */
2257
2241
  priceImpact: z.ZodNumber;
2258
2242
  /** Liquidation price */
2259
2243
  uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
2260
2244
  }, "strip", z.ZodTypeAny, {
2261
- collateralToken: number;
2262
- positionToken: number;
2263
2245
  uiLiquidationPrice: number | null;
2264
- collateralAmount: bigint;
2265
- borrowAmount: bigint;
2266
- estimatedAmount: bigint;
2267
- protocolFeeA: bigint;
2268
- protocolFeeB: bigint;
2269
2246
  priceImpact: number;
2270
2247
  decreasePercent: number;
2271
- decreaseAcceptableSwapAmount: bigint;
2272
- increaseMinSwapOutputAmount: bigint;
2248
+ requiredSwapAmount: bigint;
2273
2249
  }, {
2274
- collateralToken: number;
2275
- positionToken: number;
2276
2250
  uiLiquidationPrice: number | null;
2277
- collateralAmount: bigint;
2278
- borrowAmount: bigint;
2279
- estimatedAmount: bigint;
2280
- protocolFeeA: bigint;
2281
- protocolFeeB: bigint;
2282
2251
  priceImpact: number;
2283
2252
  decreasePercent: number;
2284
- decreaseAcceptableSwapAmount: bigint;
2285
- increaseMinSwapOutputAmount: bigint;
2253
+ requiredSwapAmount: bigint;
2286
2254
  }>;
2287
2255
  declare const SwapByInputQuote$1: z.ZodObject<{
2288
2256
  estimatedAmountOut: z.ZodBigInt;
@@ -6426,7 +6394,7 @@ declare class TunaApiClient {
6426
6394
  getSwapQuoteByOutput(pool: string, amountOut: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByOutputQuote>;
6427
6395
  getIncreaseSpotPositionQuote(market: string, increaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, positionAmount?: bigint, positionDebt?: bigint, slippageTolerance?: number): Promise<IncreaseSpotPositionQuote>;
6428
6396
  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>;
6397
+ getTradableAmount(market: string, collateralToken: number, positionToken: number, availableBalance: bigint, leverage: number, positionAmount: bigint, increase: boolean): Promise<TradableAmount>;
6430
6398
  getUpdatesStream(): Promise<EventSource>;
6431
6399
  updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
6432
6400
  private buildURL;
package/dist/index.js CHANGED
@@ -669,26 +669,10 @@ var IncreaseSpotPositionQuote = import_zod.z.object({
669
669
  var DecreaseSpotPositionQuote = import_zod.z.object({
670
670
  /** Position decrease percentage */
671
671
  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
672
  /** The maximum acceptable swap input amount for position decrease according to the provided slippage
681
673
  * (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
682
674
  */
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 */
687
- 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(),
675
+ requiredSwapAmount: import_zod.z.coerce.bigint(),
692
676
  /** Price impact in percents */
693
677
  priceImpact: import_zod.z.number(),
694
678
  /** Liquidation price */
@@ -1087,17 +1071,15 @@ var TunaApiClient = class {
1087
1071
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/decrease-spot-position`), query);
1088
1072
  return await this.httpRequest(url, DecreaseSpotPositionQuote);
1089
1073
  }
1090
- async getTradableAmount(market, collateralToken, positionToken, newPositionToken, availableBalance, leverage, reduceOnly, positionAmount, positionDebt) {
1074
+ async getTradableAmount(market, collateralToken, positionToken, availableBalance, leverage, positionAmount, increase) {
1091
1075
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/tradable-amount`), {
1092
1076
  market,
1093
1077
  collateral_token: collateralToken,
1094
1078
  position_token: positionToken,
1095
- new_position_token: newPositionToken,
1096
1079
  available_balance: availableBalance.toString(),
1097
1080
  leverage,
1098
- reduce_only: reduceOnly,
1099
1081
  position_amount: positionAmount.toString(),
1100
- position_debt: positionDebt.toString()
1082
+ increase
1101
1083
  });
1102
1084
  return await this.httpRequest(url, TradableAmount);
1103
1085
  }
package/dist/index.mjs CHANGED
@@ -634,26 +634,10 @@ var IncreaseSpotPositionQuote = z.object({
634
634
  var DecreaseSpotPositionQuote = z.object({
635
635
  /** Position decrease percentage */
636
636
  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
637
  /** The maximum acceptable swap input amount for position decrease according to the provided slippage
646
638
  * (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
647
639
  */
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 */
652
- 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(),
640
+ requiredSwapAmount: z.coerce.bigint(),
657
641
  /** Price impact in percents */
658
642
  priceImpact: z.number(),
659
643
  /** Liquidation price */
@@ -1052,17 +1036,15 @@ var TunaApiClient = class {
1052
1036
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/decrease-spot-position`), query);
1053
1037
  return await this.httpRequest(url, DecreaseSpotPositionQuote);
1054
1038
  }
1055
- async getTradableAmount(market, collateralToken, positionToken, newPositionToken, availableBalance, leverage, reduceOnly, positionAmount, positionDebt) {
1039
+ async getTradableAmount(market, collateralToken, positionToken, availableBalance, leverage, positionAmount, increase) {
1056
1040
  const url = this.appendUrlSearchParams(this.buildURL(`quotes/tradable-amount`), {
1057
1041
  market,
1058
1042
  collateral_token: collateralToken,
1059
1043
  position_token: positionToken,
1060
- new_position_token: newPositionToken,
1061
1044
  available_balance: availableBalance.toString(),
1062
1045
  leverage,
1063
- reduce_only: reduceOnly,
1064
1046
  position_amount: positionAmount.toString(),
1065
- position_debt: positionDebt.toString()
1047
+ increase
1066
1048
  });
1067
1049
  return await this.httpRequest(url, TradableAmount);
1068
1050
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crypticdot/defituna-api",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",