@crypticdot/defituna-api 1.4.3 → 1.5.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 +156 -2
- package/dist/index.d.ts +156 -2
- package/dist/index.js +145 -0
- package/dist/index.mjs +145 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2187,6 +2187,150 @@ declare const StakingRevenueStatsGroup$1: z.ZodObject<{
|
|
|
2187
2187
|
runningTotalDepositsUsd: number;
|
|
2188
2188
|
runningTotalDepositsSol: bigint;
|
|
2189
2189
|
}>;
|
|
2190
|
+
declare const IncreaseSpotPositionQuote$1: z.ZodObject<{
|
|
2191
|
+
/** Required collateral amount */
|
|
2192
|
+
collateralAmount: z.ZodBigInt;
|
|
2193
|
+
/** Required amount to borrow */
|
|
2194
|
+
borrowAmount: z.ZodBigInt;
|
|
2195
|
+
/** Estimated position size in the position token. */
|
|
2196
|
+
estimatedAmount: z.ZodBigInt;
|
|
2197
|
+
/** Swap input amount. */
|
|
2198
|
+
swapInputAmount: z.ZodBigInt;
|
|
2199
|
+
/** Minimum swap output amount according to the provided slippage. */
|
|
2200
|
+
minSwapOutputAmount: z.ZodBigInt;
|
|
2201
|
+
/** Protocol fee in token A */
|
|
2202
|
+
protocolFeeA: z.ZodBigInt;
|
|
2203
|
+
/** Protocol fee in token B */
|
|
2204
|
+
protocolFeeB: z.ZodBigInt;
|
|
2205
|
+
/** Price impact in percents */
|
|
2206
|
+
priceImpact: z.ZodNumber;
|
|
2207
|
+
/** Liquidation price */
|
|
2208
|
+
uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
|
|
2209
|
+
}, "strip", z.ZodTypeAny, {
|
|
2210
|
+
collateralAmount: bigint;
|
|
2211
|
+
borrowAmount: bigint;
|
|
2212
|
+
estimatedAmount: bigint;
|
|
2213
|
+
swapInputAmount: bigint;
|
|
2214
|
+
minSwapOutputAmount: bigint;
|
|
2215
|
+
protocolFeeA: bigint;
|
|
2216
|
+
protocolFeeB: bigint;
|
|
2217
|
+
priceImpact: number;
|
|
2218
|
+
uiLiquidationPrice: number | null;
|
|
2219
|
+
}, {
|
|
2220
|
+
collateralAmount: bigint;
|
|
2221
|
+
borrowAmount: bigint;
|
|
2222
|
+
estimatedAmount: bigint;
|
|
2223
|
+
swapInputAmount: bigint;
|
|
2224
|
+
minSwapOutputAmount: bigint;
|
|
2225
|
+
protocolFeeA: bigint;
|
|
2226
|
+
protocolFeeB: bigint;
|
|
2227
|
+
priceImpact: number;
|
|
2228
|
+
uiLiquidationPrice: number | null;
|
|
2229
|
+
}>;
|
|
2230
|
+
declare const DecreaseSpotPositionQuote$1: z.ZodObject<{
|
|
2231
|
+
/** Position decrease percentage */
|
|
2232
|
+
decreasePercent: z.ZodBigInt;
|
|
2233
|
+
/** Collateral token of the new position */
|
|
2234
|
+
collateralToken: z.ZodNumber;
|
|
2235
|
+
/** Token of the new position */
|
|
2236
|
+
positionToken: z.ZodNumber;
|
|
2237
|
+
/** Required additional collateral amount */
|
|
2238
|
+
collateralAmount: z.ZodBigInt;
|
|
2239
|
+
/** Required amount to borrow */
|
|
2240
|
+
borrowAmount: z.ZodBigInt;
|
|
2241
|
+
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
2242
|
+
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
2243
|
+
*/
|
|
2244
|
+
decreaseAcceptableSwapAmount: z.ZodBigInt;
|
|
2245
|
+
/** The minimum swap output amount for position increase according to the provided slippage. */
|
|
2246
|
+
increaseMinSwapOutputAmount: z.ZodBigInt;
|
|
2247
|
+
/** Estimated total amount of the new position */
|
|
2248
|
+
estimatedAmount: z.ZodBigInt;
|
|
2249
|
+
/** Protocol fee in token A */
|
|
2250
|
+
protocolFeeA: z.ZodBigInt;
|
|
2251
|
+
/** Protocol fee in token B */
|
|
2252
|
+
protocolFeeB: z.ZodBigInt;
|
|
2253
|
+
/** Price impact in percents */
|
|
2254
|
+
priceImpact: z.ZodNumber;
|
|
2255
|
+
/** Liquidation price */
|
|
2256
|
+
uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
|
|
2257
|
+
}, "strip", z.ZodTypeAny, {
|
|
2258
|
+
collateralToken: number;
|
|
2259
|
+
positionToken: number;
|
|
2260
|
+
collateralAmount: bigint;
|
|
2261
|
+
borrowAmount: bigint;
|
|
2262
|
+
estimatedAmount: bigint;
|
|
2263
|
+
protocolFeeA: bigint;
|
|
2264
|
+
protocolFeeB: bigint;
|
|
2265
|
+
priceImpact: number;
|
|
2266
|
+
uiLiquidationPrice: number | null;
|
|
2267
|
+
decreasePercent: bigint;
|
|
2268
|
+
decreaseAcceptableSwapAmount: bigint;
|
|
2269
|
+
increaseMinSwapOutputAmount: bigint;
|
|
2270
|
+
}, {
|
|
2271
|
+
collateralToken: number;
|
|
2272
|
+
positionToken: number;
|
|
2273
|
+
collateralAmount: bigint;
|
|
2274
|
+
borrowAmount: bigint;
|
|
2275
|
+
estimatedAmount: bigint;
|
|
2276
|
+
protocolFeeA: bigint;
|
|
2277
|
+
protocolFeeB: bigint;
|
|
2278
|
+
priceImpact: number;
|
|
2279
|
+
uiLiquidationPrice: number | null;
|
|
2280
|
+
decreasePercent: bigint;
|
|
2281
|
+
decreaseAcceptableSwapAmount: bigint;
|
|
2282
|
+
increaseMinSwapOutputAmount: bigint;
|
|
2283
|
+
}>;
|
|
2284
|
+
declare const SwapByInputQuote$1: z.ZodObject<{
|
|
2285
|
+
estimatedAmountOut: z.ZodBigInt;
|
|
2286
|
+
minAmountOut: z.ZodBigInt;
|
|
2287
|
+
feeAmount: z.ZodBigInt;
|
|
2288
|
+
feeUsd: z.ZodNumber;
|
|
2289
|
+
/** Price impact in percents */
|
|
2290
|
+
priceImpact: z.ZodNumber;
|
|
2291
|
+
}, "strip", z.ZodTypeAny, {
|
|
2292
|
+
priceImpact: number;
|
|
2293
|
+
estimatedAmountOut: bigint;
|
|
2294
|
+
minAmountOut: bigint;
|
|
2295
|
+
feeAmount: bigint;
|
|
2296
|
+
feeUsd: number;
|
|
2297
|
+
}, {
|
|
2298
|
+
priceImpact: number;
|
|
2299
|
+
estimatedAmountOut: bigint;
|
|
2300
|
+
minAmountOut: bigint;
|
|
2301
|
+
feeAmount: bigint;
|
|
2302
|
+
feeUsd: number;
|
|
2303
|
+
}>;
|
|
2304
|
+
declare const SwapByOutputQuote$1: z.ZodObject<{
|
|
2305
|
+
estimatedAmountIn: z.ZodBigInt;
|
|
2306
|
+
maxAmountIn: z.ZodBigInt;
|
|
2307
|
+
feeAmount: z.ZodBigInt;
|
|
2308
|
+
feeUsd: z.ZodNumber;
|
|
2309
|
+
/** Price impact in percents */
|
|
2310
|
+
priceImpact: z.ZodNumber;
|
|
2311
|
+
}, "strip", z.ZodTypeAny, {
|
|
2312
|
+
priceImpact: number;
|
|
2313
|
+
feeAmount: bigint;
|
|
2314
|
+
feeUsd: number;
|
|
2315
|
+
estimatedAmountIn: bigint;
|
|
2316
|
+
maxAmountIn: bigint;
|
|
2317
|
+
}, {
|
|
2318
|
+
priceImpact: number;
|
|
2319
|
+
feeAmount: bigint;
|
|
2320
|
+
feeUsd: number;
|
|
2321
|
+
estimatedAmountIn: bigint;
|
|
2322
|
+
maxAmountIn: bigint;
|
|
2323
|
+
}>;
|
|
2324
|
+
declare const TradableAmount$1: z.ZodObject<{
|
|
2325
|
+
amount: z.ZodBigInt;
|
|
2326
|
+
usd: z.ZodNumber;
|
|
2327
|
+
}, "strip", z.ZodTypeAny, {
|
|
2328
|
+
amount: bigint;
|
|
2329
|
+
usd: number;
|
|
2330
|
+
}, {
|
|
2331
|
+
amount: bigint;
|
|
2332
|
+
usd: number;
|
|
2333
|
+
}>;
|
|
2190
2334
|
declare const UpdateStreamSubscriptionResult: z.ZodObject<{
|
|
2191
2335
|
status: z.ZodString;
|
|
2192
2336
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -6102,7 +6246,7 @@ declare const schemas_UpdateStreamSubscriptionResult: typeof UpdateStreamSubscri
|
|
|
6102
6246
|
declare const schemas_WalletSubscriptionTopic: typeof WalletSubscriptionTopic;
|
|
6103
6247
|
declare const schemas_WalletSubscriptionTopicSchema: typeof WalletSubscriptionTopicSchema;
|
|
6104
6248
|
declare namespace schemas {
|
|
6105
|
-
export { FeesStatsGroup$1 as FeesStatsGroup, 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, Tick$1 as Tick, TokenOraclePrice$1 as TokenOraclePrice, 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 };
|
|
6249
|
+
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 };
|
|
6106
6250
|
}
|
|
6107
6251
|
|
|
6108
6252
|
type PoolProviderType = z.infer<typeof PoolProviderSchema>;
|
|
@@ -6143,6 +6287,11 @@ type StakingPositionHistoryAction = z.infer<typeof StakingPositionHistoryAction$
|
|
|
6143
6287
|
type PoolPriceCandle = z.infer<typeof PoolPriceCandle$1>;
|
|
6144
6288
|
type FeesStatsGroup = z.infer<typeof FeesStatsGroup$1>;
|
|
6145
6289
|
type StakingRevenueStatsGroup = z.infer<typeof StakingRevenueStatsGroup$1>;
|
|
6290
|
+
type IncreaseSpotPositionQuote = z.infer<typeof IncreaseSpotPositionQuote$1>;
|
|
6291
|
+
type DecreaseSpotPositionQuote = z.infer<typeof DecreaseSpotPositionQuote$1>;
|
|
6292
|
+
type SwapByInputQuote = z.infer<typeof SwapByInputQuote$1>;
|
|
6293
|
+
type SwapByOutputQuote = z.infer<typeof SwapByOutputQuote$1>;
|
|
6294
|
+
type TradableAmount = z.infer<typeof TradableAmount$1>;
|
|
6146
6295
|
type PoolPriceUpdate = z.infer<typeof PoolPriceUpdate$1>;
|
|
6147
6296
|
type SubscriptionPayload = {
|
|
6148
6297
|
pools?: {
|
|
@@ -6260,10 +6409,15 @@ declare class TunaApiClient {
|
|
|
6260
6409
|
getUserStakingPositionHistory(userAddress: string): Promise<StakingPositionHistoryAction[]>;
|
|
6261
6410
|
getFeesStats(from: Date, to: Date, interval: string): Promise<FeesStatsGroup[]>;
|
|
6262
6411
|
getStakingRevenueStats(from: Date, to: Date): Promise<StakingRevenueStatsGroup[]>;
|
|
6412
|
+
getSwapQuoteByInput(pool: string, amountIn: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByInputQuote>;
|
|
6413
|
+
getSwapQuoteByOutput(pool: string, amountOut: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByInputQuote>;
|
|
6414
|
+
getIncreaseSpotPositionQuote(market: string, increaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, positionAmount?: number, positionDebt?: number, slippageTolerance?: number): Promise<IncreaseSpotPositionQuote>;
|
|
6415
|
+
getDecreaseSpotPositionQuote(market: string, decreaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, reduceOnly: boolean, positionAmount: bigint, positionDebt: bigint, slippageTolerance?: number): Promise<DecreaseSpotPositionQuote>;
|
|
6416
|
+
getTradableAmount(market: string, collateralToken: number, positionToken: number, newPositionToken: number, availableBalance: bigint, leverage: number, reduceOnly: boolean, positionAmount: bigint, positionDebt: bigint): Promise<TradableAmount>;
|
|
6263
6417
|
getUpdatesStream(): Promise<EventSource>;
|
|
6264
6418
|
updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
|
|
6265
6419
|
private buildURL;
|
|
6266
6420
|
private appendUrlSearchParams;
|
|
6267
6421
|
}
|
|
6268
6422
|
|
|
6269
|
-
export { type DurationInMs, type FeesStatsGroup, type GetPoolPriceCandlesOptions, type GetUserLimitOrdersOptions, type GetUserOrderHistoryOptions, type GetUserTradeHistoryOptions, 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 Tick, type TokenOraclePrice, 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 };
|
|
6423
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -2187,6 +2187,150 @@ declare const StakingRevenueStatsGroup$1: z.ZodObject<{
|
|
|
2187
2187
|
runningTotalDepositsUsd: number;
|
|
2188
2188
|
runningTotalDepositsSol: bigint;
|
|
2189
2189
|
}>;
|
|
2190
|
+
declare const IncreaseSpotPositionQuote$1: z.ZodObject<{
|
|
2191
|
+
/** Required collateral amount */
|
|
2192
|
+
collateralAmount: z.ZodBigInt;
|
|
2193
|
+
/** Required amount to borrow */
|
|
2194
|
+
borrowAmount: z.ZodBigInt;
|
|
2195
|
+
/** Estimated position size in the position token. */
|
|
2196
|
+
estimatedAmount: z.ZodBigInt;
|
|
2197
|
+
/** Swap input amount. */
|
|
2198
|
+
swapInputAmount: z.ZodBigInt;
|
|
2199
|
+
/** Minimum swap output amount according to the provided slippage. */
|
|
2200
|
+
minSwapOutputAmount: z.ZodBigInt;
|
|
2201
|
+
/** Protocol fee in token A */
|
|
2202
|
+
protocolFeeA: z.ZodBigInt;
|
|
2203
|
+
/** Protocol fee in token B */
|
|
2204
|
+
protocolFeeB: z.ZodBigInt;
|
|
2205
|
+
/** Price impact in percents */
|
|
2206
|
+
priceImpact: z.ZodNumber;
|
|
2207
|
+
/** Liquidation price */
|
|
2208
|
+
uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
|
|
2209
|
+
}, "strip", z.ZodTypeAny, {
|
|
2210
|
+
collateralAmount: bigint;
|
|
2211
|
+
borrowAmount: bigint;
|
|
2212
|
+
estimatedAmount: bigint;
|
|
2213
|
+
swapInputAmount: bigint;
|
|
2214
|
+
minSwapOutputAmount: bigint;
|
|
2215
|
+
protocolFeeA: bigint;
|
|
2216
|
+
protocolFeeB: bigint;
|
|
2217
|
+
priceImpact: number;
|
|
2218
|
+
uiLiquidationPrice: number | null;
|
|
2219
|
+
}, {
|
|
2220
|
+
collateralAmount: bigint;
|
|
2221
|
+
borrowAmount: bigint;
|
|
2222
|
+
estimatedAmount: bigint;
|
|
2223
|
+
swapInputAmount: bigint;
|
|
2224
|
+
minSwapOutputAmount: bigint;
|
|
2225
|
+
protocolFeeA: bigint;
|
|
2226
|
+
protocolFeeB: bigint;
|
|
2227
|
+
priceImpact: number;
|
|
2228
|
+
uiLiquidationPrice: number | null;
|
|
2229
|
+
}>;
|
|
2230
|
+
declare const DecreaseSpotPositionQuote$1: z.ZodObject<{
|
|
2231
|
+
/** Position decrease percentage */
|
|
2232
|
+
decreasePercent: z.ZodBigInt;
|
|
2233
|
+
/** Collateral token of the new position */
|
|
2234
|
+
collateralToken: z.ZodNumber;
|
|
2235
|
+
/** Token of the new position */
|
|
2236
|
+
positionToken: z.ZodNumber;
|
|
2237
|
+
/** Required additional collateral amount */
|
|
2238
|
+
collateralAmount: z.ZodBigInt;
|
|
2239
|
+
/** Required amount to borrow */
|
|
2240
|
+
borrowAmount: z.ZodBigInt;
|
|
2241
|
+
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
2242
|
+
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
2243
|
+
*/
|
|
2244
|
+
decreaseAcceptableSwapAmount: z.ZodBigInt;
|
|
2245
|
+
/** The minimum swap output amount for position increase according to the provided slippage. */
|
|
2246
|
+
increaseMinSwapOutputAmount: z.ZodBigInt;
|
|
2247
|
+
/** Estimated total amount of the new position */
|
|
2248
|
+
estimatedAmount: z.ZodBigInt;
|
|
2249
|
+
/** Protocol fee in token A */
|
|
2250
|
+
protocolFeeA: z.ZodBigInt;
|
|
2251
|
+
/** Protocol fee in token B */
|
|
2252
|
+
protocolFeeB: z.ZodBigInt;
|
|
2253
|
+
/** Price impact in percents */
|
|
2254
|
+
priceImpact: z.ZodNumber;
|
|
2255
|
+
/** Liquidation price */
|
|
2256
|
+
uiLiquidationPrice: z.ZodNullable<z.ZodNumber>;
|
|
2257
|
+
}, "strip", z.ZodTypeAny, {
|
|
2258
|
+
collateralToken: number;
|
|
2259
|
+
positionToken: number;
|
|
2260
|
+
collateralAmount: bigint;
|
|
2261
|
+
borrowAmount: bigint;
|
|
2262
|
+
estimatedAmount: bigint;
|
|
2263
|
+
protocolFeeA: bigint;
|
|
2264
|
+
protocolFeeB: bigint;
|
|
2265
|
+
priceImpact: number;
|
|
2266
|
+
uiLiquidationPrice: number | null;
|
|
2267
|
+
decreasePercent: bigint;
|
|
2268
|
+
decreaseAcceptableSwapAmount: bigint;
|
|
2269
|
+
increaseMinSwapOutputAmount: bigint;
|
|
2270
|
+
}, {
|
|
2271
|
+
collateralToken: number;
|
|
2272
|
+
positionToken: number;
|
|
2273
|
+
collateralAmount: bigint;
|
|
2274
|
+
borrowAmount: bigint;
|
|
2275
|
+
estimatedAmount: bigint;
|
|
2276
|
+
protocolFeeA: bigint;
|
|
2277
|
+
protocolFeeB: bigint;
|
|
2278
|
+
priceImpact: number;
|
|
2279
|
+
uiLiquidationPrice: number | null;
|
|
2280
|
+
decreasePercent: bigint;
|
|
2281
|
+
decreaseAcceptableSwapAmount: bigint;
|
|
2282
|
+
increaseMinSwapOutputAmount: bigint;
|
|
2283
|
+
}>;
|
|
2284
|
+
declare const SwapByInputQuote$1: z.ZodObject<{
|
|
2285
|
+
estimatedAmountOut: z.ZodBigInt;
|
|
2286
|
+
minAmountOut: z.ZodBigInt;
|
|
2287
|
+
feeAmount: z.ZodBigInt;
|
|
2288
|
+
feeUsd: z.ZodNumber;
|
|
2289
|
+
/** Price impact in percents */
|
|
2290
|
+
priceImpact: z.ZodNumber;
|
|
2291
|
+
}, "strip", z.ZodTypeAny, {
|
|
2292
|
+
priceImpact: number;
|
|
2293
|
+
estimatedAmountOut: bigint;
|
|
2294
|
+
minAmountOut: bigint;
|
|
2295
|
+
feeAmount: bigint;
|
|
2296
|
+
feeUsd: number;
|
|
2297
|
+
}, {
|
|
2298
|
+
priceImpact: number;
|
|
2299
|
+
estimatedAmountOut: bigint;
|
|
2300
|
+
minAmountOut: bigint;
|
|
2301
|
+
feeAmount: bigint;
|
|
2302
|
+
feeUsd: number;
|
|
2303
|
+
}>;
|
|
2304
|
+
declare const SwapByOutputQuote$1: z.ZodObject<{
|
|
2305
|
+
estimatedAmountIn: z.ZodBigInt;
|
|
2306
|
+
maxAmountIn: z.ZodBigInt;
|
|
2307
|
+
feeAmount: z.ZodBigInt;
|
|
2308
|
+
feeUsd: z.ZodNumber;
|
|
2309
|
+
/** Price impact in percents */
|
|
2310
|
+
priceImpact: z.ZodNumber;
|
|
2311
|
+
}, "strip", z.ZodTypeAny, {
|
|
2312
|
+
priceImpact: number;
|
|
2313
|
+
feeAmount: bigint;
|
|
2314
|
+
feeUsd: number;
|
|
2315
|
+
estimatedAmountIn: bigint;
|
|
2316
|
+
maxAmountIn: bigint;
|
|
2317
|
+
}, {
|
|
2318
|
+
priceImpact: number;
|
|
2319
|
+
feeAmount: bigint;
|
|
2320
|
+
feeUsd: number;
|
|
2321
|
+
estimatedAmountIn: bigint;
|
|
2322
|
+
maxAmountIn: bigint;
|
|
2323
|
+
}>;
|
|
2324
|
+
declare const TradableAmount$1: z.ZodObject<{
|
|
2325
|
+
amount: z.ZodBigInt;
|
|
2326
|
+
usd: z.ZodNumber;
|
|
2327
|
+
}, "strip", z.ZodTypeAny, {
|
|
2328
|
+
amount: bigint;
|
|
2329
|
+
usd: number;
|
|
2330
|
+
}, {
|
|
2331
|
+
amount: bigint;
|
|
2332
|
+
usd: number;
|
|
2333
|
+
}>;
|
|
2190
2334
|
declare const UpdateStreamSubscriptionResult: z.ZodObject<{
|
|
2191
2335
|
status: z.ZodString;
|
|
2192
2336
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -6102,7 +6246,7 @@ declare const schemas_UpdateStreamSubscriptionResult: typeof UpdateStreamSubscri
|
|
|
6102
6246
|
declare const schemas_WalletSubscriptionTopic: typeof WalletSubscriptionTopic;
|
|
6103
6247
|
declare const schemas_WalletSubscriptionTopicSchema: typeof WalletSubscriptionTopicSchema;
|
|
6104
6248
|
declare namespace schemas {
|
|
6105
|
-
export { FeesStatsGroup$1 as FeesStatsGroup, 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, Tick$1 as Tick, TokenOraclePrice$1 as TokenOraclePrice, 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 };
|
|
6249
|
+
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 };
|
|
6106
6250
|
}
|
|
6107
6251
|
|
|
6108
6252
|
type PoolProviderType = z.infer<typeof PoolProviderSchema>;
|
|
@@ -6143,6 +6287,11 @@ type StakingPositionHistoryAction = z.infer<typeof StakingPositionHistoryAction$
|
|
|
6143
6287
|
type PoolPriceCandle = z.infer<typeof PoolPriceCandle$1>;
|
|
6144
6288
|
type FeesStatsGroup = z.infer<typeof FeesStatsGroup$1>;
|
|
6145
6289
|
type StakingRevenueStatsGroup = z.infer<typeof StakingRevenueStatsGroup$1>;
|
|
6290
|
+
type IncreaseSpotPositionQuote = z.infer<typeof IncreaseSpotPositionQuote$1>;
|
|
6291
|
+
type DecreaseSpotPositionQuote = z.infer<typeof DecreaseSpotPositionQuote$1>;
|
|
6292
|
+
type SwapByInputQuote = z.infer<typeof SwapByInputQuote$1>;
|
|
6293
|
+
type SwapByOutputQuote = z.infer<typeof SwapByOutputQuote$1>;
|
|
6294
|
+
type TradableAmount = z.infer<typeof TradableAmount$1>;
|
|
6146
6295
|
type PoolPriceUpdate = z.infer<typeof PoolPriceUpdate$1>;
|
|
6147
6296
|
type SubscriptionPayload = {
|
|
6148
6297
|
pools?: {
|
|
@@ -6260,10 +6409,15 @@ declare class TunaApiClient {
|
|
|
6260
6409
|
getUserStakingPositionHistory(userAddress: string): Promise<StakingPositionHistoryAction[]>;
|
|
6261
6410
|
getFeesStats(from: Date, to: Date, interval: string): Promise<FeesStatsGroup[]>;
|
|
6262
6411
|
getStakingRevenueStats(from: Date, to: Date): Promise<StakingRevenueStatsGroup[]>;
|
|
6412
|
+
getSwapQuoteByInput(pool: string, amountIn: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByInputQuote>;
|
|
6413
|
+
getSwapQuoteByOutput(pool: string, amountOut: bigint, aToB: boolean, slippageToleranceBps?: number): Promise<SwapByInputQuote>;
|
|
6414
|
+
getIncreaseSpotPositionQuote(market: string, increaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, positionAmount?: number, positionDebt?: number, slippageTolerance?: number): Promise<IncreaseSpotPositionQuote>;
|
|
6415
|
+
getDecreaseSpotPositionQuote(market: string, decreaseAmount: bigint, collateralToken: number, positionToken: number, leverage: number, reduceOnly: boolean, positionAmount: bigint, positionDebt: bigint, slippageTolerance?: number): Promise<DecreaseSpotPositionQuote>;
|
|
6416
|
+
getTradableAmount(market: string, collateralToken: number, positionToken: number, newPositionToken: number, availableBalance: bigint, leverage: number, reduceOnly: boolean, positionAmount: bigint, positionDebt: bigint): Promise<TradableAmount>;
|
|
6263
6417
|
getUpdatesStream(): Promise<EventSource>;
|
|
6264
6418
|
updateStreamSubscription(streamId: string, subscription: SubscriptionPayload): Promise<unknown>;
|
|
6265
6419
|
private buildURL;
|
|
6266
6420
|
private appendUrlSearchParams;
|
|
6267
6421
|
}
|
|
6268
6422
|
|
|
6269
|
-
export { type DurationInMs, type FeesStatsGroup, type GetPoolPriceCandlesOptions, type GetUserLimitOrdersOptions, type GetUserOrderHistoryOptions, type GetUserTradeHistoryOptions, 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 Tick, type TokenOraclePrice, 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 };
|
|
6423
|
+
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 };
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,9 @@ 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
|
+
DecreaseSpotPositionQuote: () => DecreaseSpotPositionQuote,
|
|
49
50
|
FeesStatsGroup: () => FeesStatsGroup,
|
|
51
|
+
IncreaseSpotPositionQuote: () => IncreaseSpotPositionQuote,
|
|
50
52
|
LendingPosition: () => LendingPosition,
|
|
51
53
|
LendingPositionNotification: () => LendingPositionNotification,
|
|
52
54
|
LimitOrder: () => LimitOrder,
|
|
@@ -92,8 +94,11 @@ __export(schemas_exports, {
|
|
|
92
94
|
StakingPositionNotification: () => StakingPositionNotification,
|
|
93
95
|
StakingRevenueStatsGroup: () => StakingRevenueStatsGroup,
|
|
94
96
|
StakingTreasury: () => StakingTreasury,
|
|
97
|
+
SwapByInputQuote: () => SwapByInputQuote,
|
|
98
|
+
SwapByOutputQuote: () => SwapByOutputQuote,
|
|
95
99
|
Tick: () => Tick,
|
|
96
100
|
TokenOraclePrice: () => TokenOraclePrice,
|
|
101
|
+
TradableAmount: () => TradableAmount,
|
|
97
102
|
TradeHistoryAction: () => TradeHistoryAction,
|
|
98
103
|
TradeHistoryActionSchema: () => TradeHistoryActionSchema,
|
|
99
104
|
TradeHistoryEntry: () => TradeHistoryEntry,
|
|
@@ -640,6 +645,71 @@ var StakingRevenueStatsGroup = import_zod.z.object({
|
|
|
640
645
|
runningTotalDepositsUsd: import_zod.z.number(),
|
|
641
646
|
runningTotalDepositsSol: import_zod.z.coerce.bigint()
|
|
642
647
|
});
|
|
648
|
+
var IncreaseSpotPositionQuote = import_zod.z.object({
|
|
649
|
+
/** Required collateral amount */
|
|
650
|
+
collateralAmount: import_zod.z.coerce.bigint(),
|
|
651
|
+
/** Required amount to borrow */
|
|
652
|
+
borrowAmount: import_zod.z.coerce.bigint(),
|
|
653
|
+
/** Estimated position size in the position token. */
|
|
654
|
+
estimatedAmount: import_zod.z.coerce.bigint(),
|
|
655
|
+
/** Swap input amount. */
|
|
656
|
+
swapInputAmount: import_zod.z.coerce.bigint(),
|
|
657
|
+
/** Minimum swap output amount according to the provided slippage. */
|
|
658
|
+
minSwapOutputAmount: import_zod.z.coerce.bigint(),
|
|
659
|
+
/** Protocol fee in token A */
|
|
660
|
+
protocolFeeA: import_zod.z.coerce.bigint(),
|
|
661
|
+
/** Protocol fee in token B */
|
|
662
|
+
protocolFeeB: import_zod.z.coerce.bigint(),
|
|
663
|
+
/** Price impact in percents */
|
|
664
|
+
priceImpact: import_zod.z.number(),
|
|
665
|
+
/** Liquidation price */
|
|
666
|
+
uiLiquidationPrice: import_zod.z.nullable(import_zod.z.number())
|
|
667
|
+
});
|
|
668
|
+
var DecreaseSpotPositionQuote = import_zod.z.object({
|
|
669
|
+
/** Position decrease percentage */
|
|
670
|
+
decreasePercent: import_zod.z.coerce.bigint(),
|
|
671
|
+
/** Collateral token of the new position */
|
|
672
|
+
collateralToken: import_zod.z.number(),
|
|
673
|
+
/** Token of the new position */
|
|
674
|
+
positionToken: import_zod.z.number(),
|
|
675
|
+
/** Required additional collateral amount */
|
|
676
|
+
collateralAmount: import_zod.z.coerce.bigint(),
|
|
677
|
+
/** Required amount to borrow */
|
|
678
|
+
borrowAmount: import_zod.z.coerce.bigint(),
|
|
679
|
+
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
680
|
+
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
681
|
+
*/
|
|
682
|
+
decreaseAcceptableSwapAmount: import_zod.z.coerce.bigint(),
|
|
683
|
+
/** The minimum swap output amount for position increase according to the provided slippage. */
|
|
684
|
+
increaseMinSwapOutputAmount: import_zod.z.coerce.bigint(),
|
|
685
|
+
/** Estimated total amount of the new position */
|
|
686
|
+
estimatedAmount: import_zod.z.coerce.bigint(),
|
|
687
|
+
/** Protocol fee in token A */
|
|
688
|
+
protocolFeeA: import_zod.z.coerce.bigint(),
|
|
689
|
+
/** Protocol fee in token B */
|
|
690
|
+
protocolFeeB: import_zod.z.coerce.bigint(),
|
|
691
|
+
/** Price impact in percents */
|
|
692
|
+
priceImpact: import_zod.z.number(),
|
|
693
|
+
/** Liquidation price */
|
|
694
|
+
uiLiquidationPrice: import_zod.z.nullable(import_zod.z.number())
|
|
695
|
+
});
|
|
696
|
+
var SwapByInputQuote = import_zod.z.object({
|
|
697
|
+
estimatedAmountOut: import_zod.z.coerce.bigint(),
|
|
698
|
+
minAmountOut: import_zod.z.coerce.bigint(),
|
|
699
|
+
feeAmount: import_zod.z.coerce.bigint(),
|
|
700
|
+
feeUsd: import_zod.z.number(),
|
|
701
|
+
/** Price impact in percents */
|
|
702
|
+
priceImpact: import_zod.z.number()
|
|
703
|
+
});
|
|
704
|
+
var SwapByOutputQuote = import_zod.z.object({
|
|
705
|
+
estimatedAmountIn: import_zod.z.coerce.bigint(),
|
|
706
|
+
maxAmountIn: import_zod.z.coerce.bigint(),
|
|
707
|
+
feeAmount: import_zod.z.coerce.bigint(),
|
|
708
|
+
feeUsd: import_zod.z.number(),
|
|
709
|
+
/** Price impact in percents */
|
|
710
|
+
priceImpact: import_zod.z.number()
|
|
711
|
+
});
|
|
712
|
+
var TradableAmount = amountWithUsd;
|
|
643
713
|
var UpdateStreamSubscriptionResult = import_zod.z.object({
|
|
644
714
|
status: import_zod.z.string()
|
|
645
715
|
});
|
|
@@ -955,6 +1025,81 @@ var TunaApiClient = class {
|
|
|
955
1025
|
});
|
|
956
1026
|
return await this.httpRequest(url, StakingRevenueStatsGroup.array());
|
|
957
1027
|
}
|
|
1028
|
+
async getSwapQuoteByInput(pool, amountIn, aToB, slippageToleranceBps) {
|
|
1029
|
+
let query = {
|
|
1030
|
+
pool,
|
|
1031
|
+
amount_in: amountIn.toString(),
|
|
1032
|
+
a_to_b: aToB
|
|
1033
|
+
};
|
|
1034
|
+
if (slippageToleranceBps) {
|
|
1035
|
+
query.slippage_tolerance = slippageToleranceBps;
|
|
1036
|
+
}
|
|
1037
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-input`), query);
|
|
1038
|
+
return await this.httpRequest(url, SwapByInputQuote);
|
|
1039
|
+
}
|
|
1040
|
+
async getSwapQuoteByOutput(pool, amountOut, aToB, slippageToleranceBps) {
|
|
1041
|
+
let query = {
|
|
1042
|
+
pool,
|
|
1043
|
+
amount_out: amountOut.toString(),
|
|
1044
|
+
a_to_b: aToB
|
|
1045
|
+
};
|
|
1046
|
+
if (slippageToleranceBps) {
|
|
1047
|
+
query.slippage_tolerance = slippageToleranceBps;
|
|
1048
|
+
}
|
|
1049
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-output`), query);
|
|
1050
|
+
return await this.httpRequest(url, SwapByInputQuote);
|
|
1051
|
+
}
|
|
1052
|
+
async getIncreaseSpotPositionQuote(market, increaseAmount, collateralToken, positionToken, leverage, positionAmount, positionDebt, slippageTolerance) {
|
|
1053
|
+
let query = {
|
|
1054
|
+
market,
|
|
1055
|
+
increase_amount: increaseAmount.toString(),
|
|
1056
|
+
collateral_token: collateralToken,
|
|
1057
|
+
position_token: positionToken,
|
|
1058
|
+
leverage
|
|
1059
|
+
};
|
|
1060
|
+
if (slippageTolerance) {
|
|
1061
|
+
query.slippage_tolerance = slippageTolerance;
|
|
1062
|
+
}
|
|
1063
|
+
if (positionAmount) {
|
|
1064
|
+
query.position_amount = positionAmount.toString();
|
|
1065
|
+
}
|
|
1066
|
+
if (positionDebt) {
|
|
1067
|
+
query.position_debt = positionDebt.toString();
|
|
1068
|
+
}
|
|
1069
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/increase-spot-position`), query);
|
|
1070
|
+
return await this.httpRequest(url, IncreaseSpotPositionQuote);
|
|
1071
|
+
}
|
|
1072
|
+
async getDecreaseSpotPositionQuote(market, decreaseAmount, collateralToken, positionToken, leverage, reduceOnly, positionAmount, positionDebt, slippageTolerance) {
|
|
1073
|
+
let query = {
|
|
1074
|
+
market,
|
|
1075
|
+
decrease_amount: decreaseAmount.toString(),
|
|
1076
|
+
collateral_token: collateralToken,
|
|
1077
|
+
position_token: positionToken,
|
|
1078
|
+
leverage,
|
|
1079
|
+
reduce_only: reduceOnly,
|
|
1080
|
+
position_amount: positionAmount.toString(),
|
|
1081
|
+
position_debt: positionDebt.toString()
|
|
1082
|
+
};
|
|
1083
|
+
if (slippageTolerance) {
|
|
1084
|
+
query.slippage_tolerance = slippageTolerance;
|
|
1085
|
+
}
|
|
1086
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/decrease-spot-position`), query);
|
|
1087
|
+
return await this.httpRequest(url, DecreaseSpotPositionQuote);
|
|
1088
|
+
}
|
|
1089
|
+
async getTradableAmount(market, collateralToken, positionToken, newPositionToken, availableBalance, leverage, reduceOnly, positionAmount, positionDebt) {
|
|
1090
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/tradable-amount`), {
|
|
1091
|
+
market,
|
|
1092
|
+
collateral_token: collateralToken,
|
|
1093
|
+
position_token: positionToken,
|
|
1094
|
+
new_position_token: newPositionToken,
|
|
1095
|
+
available_balance: availableBalance.toString(),
|
|
1096
|
+
leverage,
|
|
1097
|
+
reduce_only: reduceOnly,
|
|
1098
|
+
position_amount: positionAmount.toString(),
|
|
1099
|
+
position_debt: positionDebt.toString()
|
|
1100
|
+
});
|
|
1101
|
+
return await this.httpRequest(url, TradableAmount);
|
|
1102
|
+
}
|
|
958
1103
|
async getUpdatesStream() {
|
|
959
1104
|
const url = this.buildURL(`streams/sse`);
|
|
960
1105
|
return new EventSource(url);
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,9 @@ import snakecaseKeys from "snakecase-keys";
|
|
|
11
11
|
// src/client/schemas.ts
|
|
12
12
|
var schemas_exports = {};
|
|
13
13
|
__export(schemas_exports, {
|
|
14
|
+
DecreaseSpotPositionQuote: () => DecreaseSpotPositionQuote,
|
|
14
15
|
FeesStatsGroup: () => FeesStatsGroup,
|
|
16
|
+
IncreaseSpotPositionQuote: () => IncreaseSpotPositionQuote,
|
|
15
17
|
LendingPosition: () => LendingPosition,
|
|
16
18
|
LendingPositionNotification: () => LendingPositionNotification,
|
|
17
19
|
LimitOrder: () => LimitOrder,
|
|
@@ -57,8 +59,11 @@ __export(schemas_exports, {
|
|
|
57
59
|
StakingPositionNotification: () => StakingPositionNotification,
|
|
58
60
|
StakingRevenueStatsGroup: () => StakingRevenueStatsGroup,
|
|
59
61
|
StakingTreasury: () => StakingTreasury,
|
|
62
|
+
SwapByInputQuote: () => SwapByInputQuote,
|
|
63
|
+
SwapByOutputQuote: () => SwapByOutputQuote,
|
|
60
64
|
Tick: () => Tick,
|
|
61
65
|
TokenOraclePrice: () => TokenOraclePrice,
|
|
66
|
+
TradableAmount: () => TradableAmount,
|
|
62
67
|
TradeHistoryAction: () => TradeHistoryAction,
|
|
63
68
|
TradeHistoryActionSchema: () => TradeHistoryActionSchema,
|
|
64
69
|
TradeHistoryEntry: () => TradeHistoryEntry,
|
|
@@ -605,6 +610,71 @@ var StakingRevenueStatsGroup = z.object({
|
|
|
605
610
|
runningTotalDepositsUsd: z.number(),
|
|
606
611
|
runningTotalDepositsSol: z.coerce.bigint()
|
|
607
612
|
});
|
|
613
|
+
var IncreaseSpotPositionQuote = z.object({
|
|
614
|
+
/** Required collateral amount */
|
|
615
|
+
collateralAmount: z.coerce.bigint(),
|
|
616
|
+
/** Required amount to borrow */
|
|
617
|
+
borrowAmount: z.coerce.bigint(),
|
|
618
|
+
/** Estimated position size in the position token. */
|
|
619
|
+
estimatedAmount: z.coerce.bigint(),
|
|
620
|
+
/** Swap input amount. */
|
|
621
|
+
swapInputAmount: z.coerce.bigint(),
|
|
622
|
+
/** Minimum swap output amount according to the provided slippage. */
|
|
623
|
+
minSwapOutputAmount: z.coerce.bigint(),
|
|
624
|
+
/** Protocol fee in token A */
|
|
625
|
+
protocolFeeA: z.coerce.bigint(),
|
|
626
|
+
/** Protocol fee in token B */
|
|
627
|
+
protocolFeeB: z.coerce.bigint(),
|
|
628
|
+
/** Price impact in percents */
|
|
629
|
+
priceImpact: z.number(),
|
|
630
|
+
/** Liquidation price */
|
|
631
|
+
uiLiquidationPrice: z.nullable(z.number())
|
|
632
|
+
});
|
|
633
|
+
var DecreaseSpotPositionQuote = z.object({
|
|
634
|
+
/** Position decrease percentage */
|
|
635
|
+
decreasePercent: z.coerce.bigint(),
|
|
636
|
+
/** Collateral token of the new position */
|
|
637
|
+
collateralToken: z.number(),
|
|
638
|
+
/** Token of the new position */
|
|
639
|
+
positionToken: z.number(),
|
|
640
|
+
/** Required additional collateral amount */
|
|
641
|
+
collateralAmount: z.coerce.bigint(),
|
|
642
|
+
/** Required amount to borrow */
|
|
643
|
+
borrowAmount: z.coerce.bigint(),
|
|
644
|
+
/** The maximum acceptable swap input amount for position decrease according to the provided slippage
|
|
645
|
+
* (if collateral_token == position_token) OR the minimum swap output amount (if collateral_token != position_token).
|
|
646
|
+
*/
|
|
647
|
+
decreaseAcceptableSwapAmount: z.coerce.bigint(),
|
|
648
|
+
/** The minimum swap output amount for position increase according to the provided slippage. */
|
|
649
|
+
increaseMinSwapOutputAmount: z.coerce.bigint(),
|
|
650
|
+
/** Estimated total amount of the new position */
|
|
651
|
+
estimatedAmount: z.coerce.bigint(),
|
|
652
|
+
/** Protocol fee in token A */
|
|
653
|
+
protocolFeeA: z.coerce.bigint(),
|
|
654
|
+
/** Protocol fee in token B */
|
|
655
|
+
protocolFeeB: z.coerce.bigint(),
|
|
656
|
+
/** Price impact in percents */
|
|
657
|
+
priceImpact: z.number(),
|
|
658
|
+
/** Liquidation price */
|
|
659
|
+
uiLiquidationPrice: z.nullable(z.number())
|
|
660
|
+
});
|
|
661
|
+
var SwapByInputQuote = z.object({
|
|
662
|
+
estimatedAmountOut: z.coerce.bigint(),
|
|
663
|
+
minAmountOut: z.coerce.bigint(),
|
|
664
|
+
feeAmount: z.coerce.bigint(),
|
|
665
|
+
feeUsd: z.number(),
|
|
666
|
+
/** Price impact in percents */
|
|
667
|
+
priceImpact: z.number()
|
|
668
|
+
});
|
|
669
|
+
var SwapByOutputQuote = z.object({
|
|
670
|
+
estimatedAmountIn: z.coerce.bigint(),
|
|
671
|
+
maxAmountIn: z.coerce.bigint(),
|
|
672
|
+
feeAmount: z.coerce.bigint(),
|
|
673
|
+
feeUsd: z.number(),
|
|
674
|
+
/** Price impact in percents */
|
|
675
|
+
priceImpact: z.number()
|
|
676
|
+
});
|
|
677
|
+
var TradableAmount = amountWithUsd;
|
|
608
678
|
var UpdateStreamSubscriptionResult = z.object({
|
|
609
679
|
status: z.string()
|
|
610
680
|
});
|
|
@@ -920,6 +990,81 @@ var TunaApiClient = class {
|
|
|
920
990
|
});
|
|
921
991
|
return await this.httpRequest(url, StakingRevenueStatsGroup.array());
|
|
922
992
|
}
|
|
993
|
+
async getSwapQuoteByInput(pool, amountIn, aToB, slippageToleranceBps) {
|
|
994
|
+
let query = {
|
|
995
|
+
pool,
|
|
996
|
+
amount_in: amountIn.toString(),
|
|
997
|
+
a_to_b: aToB
|
|
998
|
+
};
|
|
999
|
+
if (slippageToleranceBps) {
|
|
1000
|
+
query.slippage_tolerance = slippageToleranceBps;
|
|
1001
|
+
}
|
|
1002
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-input`), query);
|
|
1003
|
+
return await this.httpRequest(url, SwapByInputQuote);
|
|
1004
|
+
}
|
|
1005
|
+
async getSwapQuoteByOutput(pool, amountOut, aToB, slippageToleranceBps) {
|
|
1006
|
+
let query = {
|
|
1007
|
+
pool,
|
|
1008
|
+
amount_out: amountOut.toString(),
|
|
1009
|
+
a_to_b: aToB
|
|
1010
|
+
};
|
|
1011
|
+
if (slippageToleranceBps) {
|
|
1012
|
+
query.slippage_tolerance = slippageToleranceBps;
|
|
1013
|
+
}
|
|
1014
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/swap-by-output`), query);
|
|
1015
|
+
return await this.httpRequest(url, SwapByInputQuote);
|
|
1016
|
+
}
|
|
1017
|
+
async getIncreaseSpotPositionQuote(market, increaseAmount, collateralToken, positionToken, leverage, positionAmount, positionDebt, slippageTolerance) {
|
|
1018
|
+
let query = {
|
|
1019
|
+
market,
|
|
1020
|
+
increase_amount: increaseAmount.toString(),
|
|
1021
|
+
collateral_token: collateralToken,
|
|
1022
|
+
position_token: positionToken,
|
|
1023
|
+
leverage
|
|
1024
|
+
};
|
|
1025
|
+
if (slippageTolerance) {
|
|
1026
|
+
query.slippage_tolerance = slippageTolerance;
|
|
1027
|
+
}
|
|
1028
|
+
if (positionAmount) {
|
|
1029
|
+
query.position_amount = positionAmount.toString();
|
|
1030
|
+
}
|
|
1031
|
+
if (positionDebt) {
|
|
1032
|
+
query.position_debt = positionDebt.toString();
|
|
1033
|
+
}
|
|
1034
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/increase-spot-position`), query);
|
|
1035
|
+
return await this.httpRequest(url, IncreaseSpotPositionQuote);
|
|
1036
|
+
}
|
|
1037
|
+
async getDecreaseSpotPositionQuote(market, decreaseAmount, collateralToken, positionToken, leverage, reduceOnly, positionAmount, positionDebt, slippageTolerance) {
|
|
1038
|
+
let query = {
|
|
1039
|
+
market,
|
|
1040
|
+
decrease_amount: decreaseAmount.toString(),
|
|
1041
|
+
collateral_token: collateralToken,
|
|
1042
|
+
position_token: positionToken,
|
|
1043
|
+
leverage,
|
|
1044
|
+
reduce_only: reduceOnly,
|
|
1045
|
+
position_amount: positionAmount.toString(),
|
|
1046
|
+
position_debt: positionDebt.toString()
|
|
1047
|
+
};
|
|
1048
|
+
if (slippageTolerance) {
|
|
1049
|
+
query.slippage_tolerance = slippageTolerance;
|
|
1050
|
+
}
|
|
1051
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/decrease-spot-position`), query);
|
|
1052
|
+
return await this.httpRequest(url, DecreaseSpotPositionQuote);
|
|
1053
|
+
}
|
|
1054
|
+
async getTradableAmount(market, collateralToken, positionToken, newPositionToken, availableBalance, leverage, reduceOnly, positionAmount, positionDebt) {
|
|
1055
|
+
const url = this.appendUrlSearchParams(this.buildURL(`quotes/tradable-amount`), {
|
|
1056
|
+
market,
|
|
1057
|
+
collateral_token: collateralToken,
|
|
1058
|
+
position_token: positionToken,
|
|
1059
|
+
new_position_token: newPositionToken,
|
|
1060
|
+
available_balance: availableBalance.toString(),
|
|
1061
|
+
leverage,
|
|
1062
|
+
reduce_only: reduceOnly,
|
|
1063
|
+
position_amount: positionAmount.toString(),
|
|
1064
|
+
position_debt: positionDebt.toString()
|
|
1065
|
+
});
|
|
1066
|
+
return await this.httpRequest(url, TradableAmount);
|
|
1067
|
+
}
|
|
923
1068
|
async getUpdatesStream() {
|
|
924
1069
|
const url = this.buildURL(`streams/sse`);
|
|
925
1070
|
return new EventSource(url);
|