@katanaperps/katana-perps-sdk 0.0.0-placeholder
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/.nvmrc +1 -0
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/abis/ERC20.json +288 -0
- package/dist/abis/EarningsEscrow.json +468 -0
- package/dist/abis/Exchange_v1.json +3644 -0
- package/dist/abis/IOFT.json +447 -0
- package/dist/bridge/config.d.ts +262 -0
- package/dist/bridge/config.d.ts.map +1 -0
- package/dist/bridge/config.js +221 -0
- package/dist/bridge/deposit.d.ts +107 -0
- package/dist/bridge/deposit.d.ts.map +1 -0
- package/dist/bridge/deposit.js +284 -0
- package/dist/bridge/index.d.ts +5 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +7 -0
- package/dist/bridge/utils.d.ts +140 -0
- package/dist/bridge/utils.d.ts.map +1 -0
- package/dist/bridge/utils.js +66 -0
- package/dist/bridge/withdraw.d.ts +42 -0
- package/dist/bridge/withdraw.d.ts.map +1 -0
- package/dist/bridge/withdraw.js +86 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +6 -0
- package/dist/client/orderBook/index.d.ts +2 -0
- package/dist/client/orderBook/index.d.ts.map +1 -0
- package/dist/client/orderBook/index.js +4 -0
- package/dist/client/orderBook/realTime.d.ts +180 -0
- package/dist/client/orderBook/realTime.d.ts.map +1 -0
- package/dist/client/orderBook/realTime.js +344 -0
- package/dist/client/orderBook/utils.d.ts +15 -0
- package/dist/client/orderBook/utils.d.ts.map +1 -0
- package/dist/client/orderBook/utils.js +77 -0
- package/dist/client/rest/authenticated.d.ts +1199 -0
- package/dist/client/rest/authenticated.d.ts.map +1 -0
- package/dist/client/rest/authenticated.js +1311 -0
- package/dist/client/rest/index.d.ts +3 -0
- package/dist/client/rest/index.d.ts.map +1 -0
- package/dist/client/rest/index.js +5 -0
- package/dist/client/rest/public.d.ts +436 -0
- package/dist/client/rest/public.d.ts.map +1 -0
- package/dist/client/rest/public.js +502 -0
- package/dist/client/webSocket/guards.d.ts +15 -0
- package/dist/client/webSocket/guards.d.ts.map +1 -0
- package/dist/client/webSocket/guards.js +37 -0
- package/dist/client/webSocket/index.d.ts +632 -0
- package/dist/client/webSocket/index.d.ts.map +1 -0
- package/dist/client/webSocket/index.js +1048 -0
- package/dist/client/webSocket/transform.d.ts +3 -0
- package/dist/client/webSocket/transform.d.ts.map +1 -0
- package/dist/client/webSocket/transform.js +244 -0
- package/dist/constants.d.ts +34 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +38 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/orderbook/apiConversions.d.ts +8 -0
- package/dist/orderbook/apiConversions.d.ts.map +1 -0
- package/dist/orderbook/apiConversions.js +100 -0
- package/dist/orderbook/demo.d.ts +2 -0
- package/dist/orderbook/demo.d.ts.map +1 -0
- package/dist/orderbook/demo.js +68 -0
- package/dist/orderbook/index.d.ts +3 -0
- package/dist/orderbook/index.d.ts.map +1 -0
- package/dist/orderbook/index.js +5 -0
- package/dist/orderbook/quantities.d.ts +112 -0
- package/dist/orderbook/quantities.d.ts.map +1 -0
- package/dist/orderbook/quantities.js +257 -0
- package/dist/orderbook/utils.d.ts +8 -0
- package/dist/orderbook/utils.d.ts.map +1 -0
- package/dist/orderbook/utils.js +28 -0
- package/dist/pipmath.d.ts +21 -0
- package/dist/pipmath.d.ts.map +1 -0
- package/dist/pipmath.js +110 -0
- package/dist/signatures.d.ts +37 -0
- package/dist/signatures.d.ts.map +1 -0
- package/dist/signatures.js +450 -0
- package/dist/tests/orderbook/quantities/calculateInitialMarginFractionWithOverride.test.d.ts +2 -0
- package/dist/tests/orderbook/quantities/calculateInitialMarginFractionWithOverride.test.d.ts.map +1 -0
- package/dist/tests/orderbook/quantities/calculateInitialMarginFractionWithOverride.test.js +49 -0
- package/dist/tests/orderbook/quantities/calculateMaximumInitialMarginFractionOverride.test.d.ts +2 -0
- package/dist/tests/orderbook/quantities/calculateMaximumInitialMarginFractionOverride.test.d.ts.map +1 -0
- package/dist/tests/orderbook/quantities/calculateMaximumInitialMarginFractionOverride.test.js +122 -0
- package/dist/tests/orderbook/quantities/determineMaximumReduceOnlyQuantityAvailableAtPriceLevel.test.d.ts +2 -0
- package/dist/tests/orderbook/quantities/determineMaximumReduceOnlyQuantityAvailableAtPriceLevel.test.d.ts.map +1 -0
- package/dist/tests/orderbook/quantities/determineMaximumReduceOnlyQuantityAvailableAtPriceLevel.test.js +138 -0
- package/dist/tests/orderbook/quantities.test.d.ts +2 -0
- package/dist/tests/orderbook/quantities.test.d.ts.map +1 -0
- package/dist/tests/orderbook/quantities.test.js +310 -0
- package/dist/tests/testHelpers.d.ts +2 -0
- package/dist/tests/testHelpers.d.ts.map +1 -0
- package/dist/tests/testHelpers.js +16 -0
- package/dist/tests/utils/deriveBaseURL.test.d.ts +2 -0
- package/dist/tests/utils/deriveBaseURL.test.d.ts.map +1 -0
- package/dist/tests/utils/deriveBaseURL.test.js +46 -0
- package/dist/typechain-types/ERC20.d.ts +170 -0
- package/dist/typechain-types/ERC20.d.ts.map +1 -0
- package/dist/typechain-types/ERC20.js +2 -0
- package/dist/typechain-types/EarningsEscrow.d.ts +210 -0
- package/dist/typechain-types/EarningsEscrow.d.ts.map +1 -0
- package/dist/typechain-types/EarningsEscrow.js +2 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter.d.ts +253 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter.d.ts.map +1 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter.js +2 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v2.d.ts +338 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v2.d.ts.map +1 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v2.js +2 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v3.d.ts +413 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v3.d.ts.map +1 -0
- package/dist/typechain-types/ExchangeLayerZeroAdapter_v3.js +2 -0
- package/dist/typechain-types/Exchange_v1.d.ts +2172 -0
- package/dist/typechain-types/Exchange_v1.d.ts.map +1 -0
- package/dist/typechain-types/Exchange_v1.js +2 -0
- package/dist/typechain-types/Exchange_v2.d.ts +2148 -0
- package/dist/typechain-types/Exchange_v2.d.ts.map +1 -0
- package/dist/typechain-types/Exchange_v2.js +2 -0
- package/dist/typechain-types/FixedIncomeVaultProviderStateAggregator_v1.d.ts +148 -0
- package/dist/typechain-types/FixedIncomeVaultProviderStateAggregator_v1.d.ts.map +1 -0
- package/dist/typechain-types/FixedIncomeVaultProviderStateAggregator_v1.js +2 -0
- package/dist/typechain-types/FixedIncomeVaultProvider_v1.d.ts +1204 -0
- package/dist/typechain-types/FixedIncomeVaultProvider_v1.d.ts.map +1 -0
- package/dist/typechain-types/FixedIncomeVaultProvider_v1.js +2 -0
- package/dist/typechain-types/IOFT.d.ts +247 -0
- package/dist/typechain-types/IOFT.d.ts.map +1 -0
- package/dist/typechain-types/IOFT.js +2 -0
- package/dist/typechain-types/IRewardVault.d.ts +649 -0
- package/dist/typechain-types/IRewardVault.d.ts.map +1 -0
- package/dist/typechain-types/IRewardVault.js +2 -0
- package/dist/typechain-types/KumaOFTAdapterUSDC.d.ts +638 -0
- package/dist/typechain-types/KumaOFTAdapterUSDC.d.ts.map +1 -0
- package/dist/typechain-types/KumaOFTAdapterUSDC.js +2 -0
- package/dist/typechain-types/KumaOFTUSDC.d.ts +756 -0
- package/dist/typechain-types/KumaOFTUSDC.d.ts.map +1 -0
- package/dist/typechain-types/KumaOFTUSDC.js +2 -0
- package/dist/typechain-types/KumaStargateForwarder_v1.d.ts +252 -0
- package/dist/typechain-types/KumaStargateForwarder_v1.d.ts.map +1 -0
- package/dist/typechain-types/KumaStargateForwarder_v1.js +2 -0
- package/dist/typechain-types/KumaStargateForwarder_v2.d.ts +252 -0
- package/dist/typechain-types/KumaStargateForwarder_v2.d.ts.map +1 -0
- package/dist/typechain-types/KumaStargateForwarder_v2.js +2 -0
- package/dist/typechain-types/ProfitShareVaultProvider_v1.d.ts +1095 -0
- package/dist/typechain-types/ProfitShareVaultProvider_v1.d.ts.map +1 -0
- package/dist/typechain-types/ProfitShareVaultProvider_v1.js +2 -0
- package/dist/typechain-types/StargatePoolUSDC.d.ts +956 -0
- package/dist/typechain-types/StargatePoolUSDC.d.ts.map +1 -0
- package/dist/typechain-types/StargatePoolUSDC.js +2 -0
- package/dist/typechain-types/common.d.ts +51 -0
- package/dist/typechain-types/common.d.ts.map +1 -0
- package/dist/typechain-types/common.js +2 -0
- package/dist/typechain-types/factories/ERC20__factory.d.ts +226 -0
- package/dist/typechain-types/factories/ERC20__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/ERC20__factory.js +305 -0
- package/dist/typechain-types/factories/EarningsEscrow__factory.d.ts +370 -0
- package/dist/typechain-types/factories/EarningsEscrow__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/EarningsEscrow__factory.js +485 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter__factory.d.ts +359 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter__factory.js +471 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v2__factory.d.ts +419 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v2__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v2__factory.js +545 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v3__factory.d.ts +546 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v3__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/ExchangeLayerZeroAdapter_v3__factory.js +710 -0
- package/dist/typechain-types/factories/Exchange_v1__factory.d.ts +2852 -0
- package/dist/typechain-types/factories/Exchange_v1__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/Exchange_v1__factory.js +3661 -0
- package/dist/typechain-types/factories/Exchange_v2__factory.d.ts +2832 -0
- package/dist/typechain-types/factories/Exchange_v2__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/Exchange_v2__factory.js +3636 -0
- package/dist/typechain-types/factories/FixedIncomeVaultProviderStateAggregator_v1__factory.d.ts +180 -0
- package/dist/typechain-types/factories/FixedIncomeVaultProviderStateAggregator_v1__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/FixedIncomeVaultProviderStateAggregator_v1__factory.js +246 -0
- package/dist/typechain-types/factories/FixedIncomeVaultProvider_v1__factory.d.ts +2092 -0
- package/dist/typechain-types/factories/FixedIncomeVaultProvider_v1__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/FixedIncomeVaultProvider_v1__factory.js +2702 -0
- package/dist/typechain-types/factories/IOFT__factory.d.ts +352 -0
- package/dist/typechain-types/factories/IOFT__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/IOFT__factory.js +464 -0
- package/dist/typechain-types/factories/IRewardVault__factory.d.ts +1019 -0
- package/dist/typechain-types/factories/IRewardVault__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/IRewardVault__factory.js +1311 -0
- package/dist/typechain-types/factories/KumaOFTAdapterUSDC__factory.d.ts +996 -0
- package/dist/typechain-types/factories/KumaOFTAdapterUSDC__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/KumaOFTAdapterUSDC__factory.js +1306 -0
- package/dist/typechain-types/factories/KumaOFTUSDC__factory.d.ts +1234 -0
- package/dist/typechain-types/factories/KumaOFTUSDC__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/KumaOFTUSDC__factory.js +1619 -0
- package/dist/typechain-types/factories/KumaStargateForwarder_v1__factory.d.ts +354 -0
- package/dist/typechain-types/factories/KumaStargateForwarder_v1__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/KumaStargateForwarder_v1__factory.js +464 -0
- package/dist/typechain-types/factories/KumaStargateForwarder_v2__factory.d.ts +370 -0
- package/dist/typechain-types/factories/KumaStargateForwarder_v2__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/KumaStargateForwarder_v2__factory.js +486 -0
- package/dist/typechain-types/factories/ProfitShareVaultProvider_v1__factory.d.ts +1914 -0
- package/dist/typechain-types/factories/ProfitShareVaultProvider_v1__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/ProfitShareVaultProvider_v1__factory.js +2475 -0
- package/dist/typechain-types/factories/StargatePoolUSDC__factory.d.ts +1557 -0
- package/dist/typechain-types/factories/StargatePoolUSDC__factory.d.ts.map +1 -0
- package/dist/typechain-types/factories/StargatePoolUSDC__factory.js +2019 -0
- package/dist/typechain-types/factories/index.d.ts +5 -0
- package/dist/typechain-types/factories/index.d.ts.map +1 -0
- package/dist/typechain-types/factories/index.js +13 -0
- package/dist/typechain-types/index.d.ts +10 -0
- package/dist/typechain-types/index.d.ts.map +1 -0
- package/dist/typechain-types/index.js +15 -0
- package/dist/types/delegatedKeys.d.ts +44 -0
- package/dist/types/delegatedKeys.d.ts.map +1 -0
- package/dist/types/delegatedKeys.js +2 -0
- package/dist/types/enums/index.d.ts +4 -0
- package/dist/types/enums/index.d.ts.map +1 -0
- package/dist/types/enums/index.js +6 -0
- package/dist/types/enums/request.d.ts +980 -0
- package/dist/types/enums/request.d.ts.map +1 -0
- package/dist/types/enums/request.js +906 -0
- package/dist/types/enums/response.d.ts +329 -0
- package/dist/types/enums/response.d.ts.map +1 -0
- package/dist/types/enums/response.js +296 -0
- package/dist/types/enums/signature.d.ts +118 -0
- package/dist/types/enums/signature.d.ts.map +1 -0
- package/dist/types/enums/signature.js +131 -0
- package/dist/types/errors.d.ts +5 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +2 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/orderBook.d.ts +72 -0
- package/dist/types/orderBook.d.ts.map +1 -0
- package/dist/types/orderBook.js +2 -0
- package/dist/types/rest/common/common.d.ts +118 -0
- package/dist/types/rest/common/common.d.ts.map +1 -0
- package/dist/types/rest/common/common.js +2 -0
- package/dist/types/rest/common/guards.d.ts +8 -0
- package/dist/types/rest/common/guards.d.ts.map +1 -0
- package/dist/types/rest/common/guards.js +14 -0
- package/dist/types/rest/endpoints/AssociateWallet.d.ts +40 -0
- package/dist/types/rest/endpoints/AssociateWallet.d.ts.map +1 -0
- package/dist/types/rest/endpoints/AssociateWallet.js +2 -0
- package/dist/types/rest/endpoints/CancelOrders.d.ts +134 -0
- package/dist/types/rest/endpoints/CancelOrders.d.ts.map +1 -0
- package/dist/types/rest/endpoints/CancelOrders.js +2 -0
- package/dist/types/rest/endpoints/CreateOrder.d.ts +401 -0
- package/dist/types/rest/endpoints/CreateOrder.d.ts.map +1 -0
- package/dist/types/rest/endpoints/CreateOrder.js +2 -0
- package/dist/types/rest/endpoints/GetAuthenticationToken.d.ts +39 -0
- package/dist/types/rest/endpoints/GetAuthenticationToken.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetAuthenticationToken.js +2 -0
- package/dist/types/rest/endpoints/GetCandles.d.ts +115 -0
- package/dist/types/rest/endpoints/GetCandles.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetCandles.js +2 -0
- package/dist/types/rest/endpoints/GetDeposits.d.ts +109 -0
- package/dist/types/rest/endpoints/GetDeposits.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetDeposits.js +2 -0
- package/dist/types/rest/endpoints/GetExchange.d.ts +78 -0
- package/dist/types/rest/endpoints/GetExchange.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetExchange.js +9 -0
- package/dist/types/rest/endpoints/GetFills.d.ts +178 -0
- package/dist/types/rest/endpoints/GetFills.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetFills.js +2 -0
- package/dist/types/rest/endpoints/GetFundingPayments.d.ts +52 -0
- package/dist/types/rest/endpoints/GetFundingPayments.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetFundingPayments.js +2 -0
- package/dist/types/rest/endpoints/GetFundingRates.d.ts +34 -0
- package/dist/types/rest/endpoints/GetFundingRates.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetFundingRates.js +2 -0
- package/dist/types/rest/endpoints/GetGasFees.d.ts +23 -0
- package/dist/types/rest/endpoints/GetGasFees.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetGasFees.js +2 -0
- package/dist/types/rest/endpoints/GetHistoricalPnL.d.ts +39 -0
- package/dist/types/rest/endpoints/GetHistoricalPnL.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetHistoricalPnL.js +2 -0
- package/dist/types/rest/endpoints/GetInitialMarginFractionOverride.d.ts +31 -0
- package/dist/types/rest/endpoints/GetInitialMarginFractionOverride.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetInitialMarginFractionOverride.js +2 -0
- package/dist/types/rest/endpoints/GetLiquidations.d.ts +52 -0
- package/dist/types/rest/endpoints/GetLiquidations.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetLiquidations.js +2 -0
- package/dist/types/rest/endpoints/GetMarketMakerRewardsEpochs.d.ts +534 -0
- package/dist/types/rest/endpoints/GetMarketMakerRewardsEpochs.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetMarketMakerRewardsEpochs.js +2 -0
- package/dist/types/rest/endpoints/GetMarkets.d.ts +161 -0
- package/dist/types/rest/endpoints/GetMarkets.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetMarkets.js +2 -0
- package/dist/types/rest/endpoints/GetOrderBook.d.ts +176 -0
- package/dist/types/rest/endpoints/GetOrderBook.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetOrderBook.js +2 -0
- package/dist/types/rest/endpoints/GetOrders.d.ts +188 -0
- package/dist/types/rest/endpoints/GetOrders.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetOrders.js +2 -0
- package/dist/types/rest/endpoints/GetPing.d.ts +8 -0
- package/dist/types/rest/endpoints/GetPing.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetPing.js +2 -0
- package/dist/types/rest/endpoints/GetPositions.d.ts +104 -0
- package/dist/types/rest/endpoints/GetPositions.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetPositions.js +2 -0
- package/dist/types/rest/endpoints/GetTickers.d.ts +129 -0
- package/dist/types/rest/endpoints/GetTickers.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetTickers.js +2 -0
- package/dist/types/rest/endpoints/GetTime.d.ts +14 -0
- package/dist/types/rest/endpoints/GetTime.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetTime.js +2 -0
- package/dist/types/rest/endpoints/GetTrades.d.ts +62 -0
- package/dist/types/rest/endpoints/GetTrades.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetTrades.js +2 -0
- package/dist/types/rest/endpoints/GetWallets.d.ts +121 -0
- package/dist/types/rest/endpoints/GetWallets.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetWallets.js +2 -0
- package/dist/types/rest/endpoints/GetWithdrawals.d.ts +98 -0
- package/dist/types/rest/endpoints/GetWithdrawals.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetWithdrawals.js +2 -0
- package/dist/types/rest/endpoints/GetWithdrawalsFromManagedAccount.d.ts +98 -0
- package/dist/types/rest/endpoints/GetWithdrawalsFromManagedAccount.d.ts.map +1 -0
- package/dist/types/rest/endpoints/GetWithdrawalsFromManagedAccount.js +2 -0
- package/dist/types/rest/endpoints/Payouts.d.ts +199 -0
- package/dist/types/rest/endpoints/Payouts.d.ts.map +1 -0
- package/dist/types/rest/endpoints/Payouts.js +2 -0
- package/dist/types/rest/endpoints/SetInitialMarginFractionOverride.d.ts +83 -0
- package/dist/types/rest/endpoints/SetInitialMarginFractionOverride.d.ts.map +1 -0
- package/dist/types/rest/endpoints/SetInitialMarginFractionOverride.js +2 -0
- package/dist/types/rest/endpoints/WithdrawFunds.d.ts +144 -0
- package/dist/types/rest/endpoints/WithdrawFunds.d.ts.map +1 -0
- package/dist/types/rest/endpoints/WithdrawFunds.js +2 -0
- package/dist/types/rest/endpoints/WithdrawFundsFromManagedAccountByQuantity.d.ts +161 -0
- package/dist/types/rest/endpoints/WithdrawFundsFromManagedAccountByQuantity.d.ts.map +1 -0
- package/dist/types/rest/endpoints/WithdrawFundsFromManagedAccountByQuantity.js +2 -0
- package/dist/types/rest/endpoints/WithdrawFundsFromManagedAccountByShares.d.ts +160 -0
- package/dist/types/rest/endpoints/WithdrawFundsFromManagedAccountByShares.d.ts.map +1 -0
- package/dist/types/rest/endpoints/WithdrawFundsFromManagedAccountByShares.js +2 -0
- package/dist/types/rest/endpoints/index.d.ts +33 -0
- package/dist/types/rest/endpoints/index.d.ts.map +1 -0
- package/dist/types/rest/endpoints/index.js +35 -0
- package/dist/types/rest/endpoints/internal.d.ts +329 -0
- package/dist/types/rest/endpoints/internal.d.ts.map +1 -0
- package/dist/types/rest/endpoints/internal.js +14 -0
- package/dist/types/rest/index.d.ts +4 -0
- package/dist/types/rest/index.d.ts.map +1 -0
- package/dist/types/rest/index.js +6 -0
- package/dist/types/swaps.d.ts +11 -0
- package/dist/types/swaps.d.ts.map +1 -0
- package/dist/types/swaps.js +2 -0
- package/dist/types/utils.d.ts +67 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/utils.js +3 -0
- package/dist/types/webSocket/base.d.ts +83 -0
- package/dist/types/webSocket/base.d.ts.map +1 -0
- package/dist/types/webSocket/base.js +2 -0
- package/dist/types/webSocket/constants.d.ts +41 -0
- package/dist/types/webSocket/constants.d.ts.map +1 -0
- package/dist/types/webSocket/constants.js +54 -0
- package/dist/types/webSocket/index.d.ts +6 -0
- package/dist/types/webSocket/index.d.ts.map +1 -0
- package/dist/types/webSocket/index.js +8 -0
- package/dist/types/webSocket/options.d.ts +276 -0
- package/dist/types/webSocket/options.d.ts.map +1 -0
- package/dist/types/webSocket/options.js +2 -0
- package/dist/types/webSocket/request/index.d.ts +3 -0
- package/dist/types/webSocket/request/index.d.ts.map +1 -0
- package/dist/types/webSocket/request/index.js +5 -0
- package/dist/types/webSocket/request/request.d.ts +137 -0
- package/dist/types/webSocket/request/request.d.ts.map +1 -0
- package/dist/types/webSocket/request/request.js +2 -0
- package/dist/types/webSocket/request/subscriptions.d.ts +498 -0
- package/dist/types/webSocket/request/subscriptions.d.ts.map +1 -0
- package/dist/types/webSocket/request/subscriptions.js +2 -0
- package/dist/types/webSocket/response/candles.d.ts +138 -0
- package/dist/types/webSocket/response/candles.d.ts.map +1 -0
- package/dist/types/webSocket/response/candles.js +2 -0
- package/dist/types/webSocket/response/deposits.d.ts +80 -0
- package/dist/types/webSocket/response/deposits.d.ts.map +1 -0
- package/dist/types/webSocket/response/deposits.js +2 -0
- package/dist/types/webSocket/response/fundingPayments.d.ts +78 -0
- package/dist/types/webSocket/response/fundingPayments.d.ts.map +1 -0
- package/dist/types/webSocket/response/fundingPayments.js +2 -0
- package/dist/types/webSocket/response/index.d.ts +13 -0
- package/dist/types/webSocket/response/index.d.ts.map +1 -0
- package/dist/types/webSocket/response/index.js +15 -0
- package/dist/types/webSocket/response/liquidations.d.ts +78 -0
- package/dist/types/webSocket/response/liquidations.d.ts.map +1 -0
- package/dist/types/webSocket/response/liquidations.js +2 -0
- package/dist/types/webSocket/response/orderbook.d.ts +214 -0
- package/dist/types/webSocket/response/orderbook.d.ts.map +1 -0
- package/dist/types/webSocket/response/orderbook.js +2 -0
- package/dist/types/webSocket/response/orders.d.ts +355 -0
- package/dist/types/webSocket/response/orders.d.ts.map +1 -0
- package/dist/types/webSocket/response/orders.js +2 -0
- package/dist/types/webSocket/response/ordersFill.d.ts +138 -0
- package/dist/types/webSocket/response/ordersFill.d.ts.map +1 -0
- package/dist/types/webSocket/response/ordersFill.js +2 -0
- package/dist/types/webSocket/response/positions.d.ts +120 -0
- package/dist/types/webSocket/response/positions.d.ts.map +1 -0
- package/dist/types/webSocket/response/positions.js +2 -0
- package/dist/types/webSocket/response/tickers.d.ts +131 -0
- package/dist/types/webSocket/response/tickers.d.ts.map +1 -0
- package/dist/types/webSocket/response/tickers.js +2 -0
- package/dist/types/webSocket/response/trades.d.ts +90 -0
- package/dist/types/webSocket/response/trades.d.ts.map +1 -0
- package/dist/types/webSocket/response/trades.js +2 -0
- package/dist/types/webSocket/response/webclient/base.d.ts +24 -0
- package/dist/types/webSocket/response/webclient/base.d.ts.map +1 -0
- package/dist/types/webSocket/response/webclient/base.js +2 -0
- package/dist/types/webSocket/response/webclient/events/exchangeStatus.d.ts +31 -0
- package/dist/types/webSocket/response/webclient/events/exchangeStatus.d.ts.map +1 -0
- package/dist/types/webSocket/response/webclient/events/exchangeStatus.js +2 -0
- package/dist/types/webSocket/response/webclient/events/index.d.ts +4 -0
- package/dist/types/webSocket/response/webclient/events/index.d.ts.map +1 -0
- package/dist/types/webSocket/response/webclient/events/index.js +6 -0
- package/dist/types/webSocket/response/webclient/events/reloadBanners.d.ts +17 -0
- package/dist/types/webSocket/response/webclient/events/reloadBanners.d.ts.map +1 -0
- package/dist/types/webSocket/response/webclient/events/reloadBanners.js +2 -0
- package/dist/types/webSocket/response/webclient/events/transactionSettled.d.ts +76 -0
- package/dist/types/webSocket/response/webclient/events/transactionSettled.d.ts.map +1 -0
- package/dist/types/webSocket/response/webclient/events/transactionSettled.js +2 -0
- package/dist/types/webSocket/response/webclient/index.d.ts +3 -0
- package/dist/types/webSocket/response/webclient/index.d.ts.map +1 -0
- package/dist/types/webSocket/response/webclient/index.js +5 -0
- package/dist/types/webSocket/response/webclient/webclient.d.ts +13 -0
- package/dist/types/webSocket/response/webclient/webclient.d.ts.map +1 -0
- package/dist/types/webSocket/response/webclient/webclient.js +2 -0
- package/dist/types/webSocket/response/withdrawals.d.ts +83 -0
- package/dist/types/webSocket/response/withdrawals.d.ts.map +1 -0
- package/dist/types/webSocket/response/withdrawals.js +2 -0
- package/dist/utils.d.ts +63 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +136 -0
- package/package.json +200 -0
|
@@ -0,0 +1,1311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RestAuthenticatedClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/* eslint-disable lines-between-class-members */
|
|
6
|
+
const http = tslib_1.__importStar(require("http"));
|
|
7
|
+
const https = tslib_1.__importStar(require("https"));
|
|
8
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
9
|
+
const bignumber_js_1 = tslib_1.__importDefault(require("bignumber.js"));
|
|
10
|
+
const ethers_1 = require("ethers");
|
|
11
|
+
const _constants_1 = require("#constants");
|
|
12
|
+
const _signatures_1 = require("#signatures");
|
|
13
|
+
const _utils_1 = require("#utils");
|
|
14
|
+
const public_1 = require("#client/rest/public");
|
|
15
|
+
/**
|
|
16
|
+
* The {@link RestAuthenticatedClient} is used to make authenticated requests to the Katana Perps API. It includes
|
|
17
|
+
* methods that make requests on behalf of a specific wallet such as creating and cancelling orders.
|
|
18
|
+
*
|
|
19
|
+
* - The client requires the following properties to automatically handle authentication
|
|
20
|
+
* of requests:
|
|
21
|
+
* - {@link RestAuthenticatedClientOptions.apiKey apiKey}
|
|
22
|
+
* - {@link RestAuthenticatedClientOptions.apiSecret apiSecret}
|
|
23
|
+
* - {@link RestAuthenticatedClientOptions.walletPrivateKey walletPrivateKey}
|
|
24
|
+
* - Optionally, a {@link RestAuthenticatedClientOptions.sandbox sandbox} option can
|
|
25
|
+
* be set to `true` in order to point to the Katana Perps Sandbox API.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import { RestAuthenticatedClient } from '@katanaperps/katana-perps-sdk';
|
|
30
|
+
*
|
|
31
|
+
* // Edit the values before for your environment
|
|
32
|
+
* const authenticatedClient = new RestAuthenticatedClient({
|
|
33
|
+
* sandbox: false,
|
|
34
|
+
* apiKey: '1f7c4f52-4af7-4e1b-aa94-94fac8d931aa',
|
|
35
|
+
* apiSecret: 'axuh3ywgg854aq7m73oy6gnnpj5ar9a67szuw5lclbz77zqu0j',
|
|
36
|
+
* walletPrivateKey: '0x...'
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* <br />
|
|
41
|
+
*
|
|
42
|
+
* ---
|
|
43
|
+
*
|
|
44
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html)
|
|
45
|
+
* @see options {@link RestAuthenticatedClientOptions}
|
|
46
|
+
*
|
|
47
|
+
* @category API Clients
|
|
48
|
+
* @category KatanaPerps - Get Market Maker Rewards Epochs
|
|
49
|
+
* @category KatanaPerps - Get Wallets
|
|
50
|
+
* @category KatanaPerps - Get Positions
|
|
51
|
+
* @category KatanaPerps - Associate Wallet
|
|
52
|
+
* @category KatanaPerps - Create Order
|
|
53
|
+
* @category KatanaPerps - Cancel Order
|
|
54
|
+
* @category KatanaPerps - Get Orders
|
|
55
|
+
* @category KatanaPerps - Get Fills
|
|
56
|
+
* @category KatanaPerps - Get Payouts
|
|
57
|
+
* @category KatanaPerps - Authorize Payout
|
|
58
|
+
* @category KatanaPerps - Get Deposits
|
|
59
|
+
* @category KatanaPerps - Get Withdrawals
|
|
60
|
+
* @category KatanaPerps - Withdraw Funds
|
|
61
|
+
* @category KatanaPerps - Get Funding Payments
|
|
62
|
+
* @category KatanaPerps - Get Historical PnL
|
|
63
|
+
* @category KatanaPerps - Get WebSocket Token
|
|
64
|
+
*/
|
|
65
|
+
class RestAuthenticatedClient {
|
|
66
|
+
/**
|
|
67
|
+
* When creating an authenticated client, a {@link katanaperps.RestPublicClient RestPublicClient} is automatically
|
|
68
|
+
* created and can be used based on the config given for this client.
|
|
69
|
+
*
|
|
70
|
+
* - Can be utilized to fetch public data instead of creating both clients.
|
|
71
|
+
* - Used when fetching the {@link katanaperps.KatanaPerpsExchange.exchangeContractAddress exchangeContractAddress}
|
|
72
|
+
* and {@link katanaperps.KatanaPerpsExchange.chainId chainId} properties from the public client's
|
|
73
|
+
* {@link RestPublicClient.getExchange getExchange} method.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { RestAuthenticatedClient } from '@katanaperps/katana-perps-sdk';
|
|
78
|
+
*
|
|
79
|
+
* // Edit the values before for your environment
|
|
80
|
+
* const client = new RestAuthenticatedClient({
|
|
81
|
+
* sandbox: true,
|
|
82
|
+
* apiKey: '1f7c4f52-4af7-4e1b-aa94-94fac8d931aa',
|
|
83
|
+
* apiSecret: 'axuh3ywgg854aq7m73oy6gnnpj5ar9a67szuw5lclbz77zqu0j',
|
|
84
|
+
* walletPrivateKey: '0x...'
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* const wallets = await client.getWallets();
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* <br />
|
|
91
|
+
*
|
|
92
|
+
* ---
|
|
93
|
+
*
|
|
94
|
+
* @see client {@link katanaperps.RestPublicClient RestPublicClient}
|
|
95
|
+
*
|
|
96
|
+
* @category Accessors
|
|
97
|
+
*/
|
|
98
|
+
public;
|
|
99
|
+
#exchange = null;
|
|
100
|
+
#signer = undefined;
|
|
101
|
+
#apiSecret;
|
|
102
|
+
#axiosConfig;
|
|
103
|
+
axios;
|
|
104
|
+
#config;
|
|
105
|
+
/**
|
|
106
|
+
* Gets the current configured options for the client.
|
|
107
|
+
*
|
|
108
|
+
* - The `baseURL` is automatically derived from the {@link sandbox} option during construction
|
|
109
|
+
* unless a custom `baseURL` is given.
|
|
110
|
+
* - The `sandbox` will either default to `false` unless provided in the client constructor.
|
|
111
|
+
* - Both `exchangeContractAddress` and `chainId` use the provided values during construction
|
|
112
|
+
* or are automatically fetched from the {@link public} client.
|
|
113
|
+
*
|
|
114
|
+
* @category Accessors
|
|
115
|
+
*
|
|
116
|
+
* @internal
|
|
117
|
+
*/
|
|
118
|
+
get config() {
|
|
119
|
+
return Object.freeze({
|
|
120
|
+
...this.#config,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The {@link RestAuthenticatedClient} is used to make authenticated requests to the Katana Perps API. It includes
|
|
125
|
+
* methods that make requests on behalf of a specific wallet such as creating and cancelling orders.
|
|
126
|
+
*
|
|
127
|
+
* - The client requires the following properties to automatically handle authentication
|
|
128
|
+
* of requests:
|
|
129
|
+
* - {@link RestAuthenticatedClientOptions.apiKey apiKey}
|
|
130
|
+
* - {@link RestAuthenticatedClientOptions.apiSecret apiSecret}
|
|
131
|
+
* - {@link RestAuthenticatedClientOptions.walletPrivateKey walletPrivateKey}
|
|
132
|
+
* - Optionally, a {@link RestAuthenticatedClientOptions.sandbox sandbox} option can
|
|
133
|
+
* be set to `true` in order to point to the Katana Perps Sandbox API.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* import { RestAuthenticatedClient } from '@katanaperps/katana-perps-sdk';
|
|
138
|
+
*
|
|
139
|
+
* // Edit the values before for your environment
|
|
140
|
+
* const client = new RestAuthenticatedClient({
|
|
141
|
+
* sandbox: true,
|
|
142
|
+
* apiKey: '1f7c4f52-4af7-4e1b-aa94-94fac8d931aa',
|
|
143
|
+
* apiSecret: 'axuh3ywgg854aq7m73oy6gnnpj5ar9a67szuw5lclbz77zqu0j',
|
|
144
|
+
* walletPrivateKey: '0x...'
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* const wallets = await client.getWallets();
|
|
148
|
+
* ```
|
|
149
|
+
*
|
|
150
|
+
* <br />
|
|
151
|
+
*
|
|
152
|
+
* ---
|
|
153
|
+
*
|
|
154
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/WebSocketClient.html)
|
|
155
|
+
* @see options {@link RestAuthenticatedClientOptions}
|
|
156
|
+
*
|
|
157
|
+
* @category Constructor
|
|
158
|
+
*/
|
|
159
|
+
constructor(options) {
|
|
160
|
+
const { sandbox = false, exchangeContractAddress, chainId, bridgeAdapterContractAddress, autoCreateHmacHeader = true, } = options;
|
|
161
|
+
const baseURL = (0, _utils_1.deriveBaseURL)({
|
|
162
|
+
sandbox,
|
|
163
|
+
api: 'rest',
|
|
164
|
+
overrideBaseURL: options.baseURL ?? options.axiosConfig?.baseURL,
|
|
165
|
+
});
|
|
166
|
+
if (!baseURL) {
|
|
167
|
+
throw new Error(`Invalid configuration, baseURL could not be derived (sandbox? ${String(sandbox)})`);
|
|
168
|
+
}
|
|
169
|
+
this.#config = {
|
|
170
|
+
baseURL,
|
|
171
|
+
sandbox,
|
|
172
|
+
bridgeAdapterContractAddress,
|
|
173
|
+
exchangeContractAddress,
|
|
174
|
+
chainId,
|
|
175
|
+
autoCreateHmacHeader,
|
|
176
|
+
};
|
|
177
|
+
this.public = new public_1.RestPublicClient({
|
|
178
|
+
apiKey: options.apiKey,
|
|
179
|
+
baseURL,
|
|
180
|
+
sandbox,
|
|
181
|
+
});
|
|
182
|
+
this.#axiosConfig = Object.freeze({
|
|
183
|
+
paramsSerializer(params) {
|
|
184
|
+
return (0, _utils_1.sanitizeSearchParams)(params ?? {}).toString();
|
|
185
|
+
},
|
|
186
|
+
...(_utils_1.isNode ?
|
|
187
|
+
{
|
|
188
|
+
httpAgent: options.axiosConfig?.httpAgent ??
|
|
189
|
+
new http.Agent({ keepAlive: true }),
|
|
190
|
+
httpsAgent: options.axiosConfig?.httpsAgent ??
|
|
191
|
+
new https.Agent({ keepAlive: true }),
|
|
192
|
+
}
|
|
193
|
+
: {}),
|
|
194
|
+
...(options.axiosConfig ?? {}),
|
|
195
|
+
baseURL,
|
|
196
|
+
headers: {
|
|
197
|
+
...(options.axiosConfig?.headers ?? {
|
|
198
|
+
[_constants_1.REST_API_KEY_HEADER]: options.apiKey,
|
|
199
|
+
}),
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
this.#apiSecret = options.apiSecret;
|
|
203
|
+
if (options.walletPrivateKey) {
|
|
204
|
+
this.#signer = (0, _signatures_1.createPrivateKeyTypedDataSigner)(options.walletPrivateKey);
|
|
205
|
+
}
|
|
206
|
+
this.axios = axios_1.default.create(this.#axiosConfig);
|
|
207
|
+
if (options.axiosConfig?.headers) {
|
|
208
|
+
Object.assign(this.axios.defaults.headers.common, options.axiosConfig.headers);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async getMarketMakerRewardsEpoch(params) {
|
|
212
|
+
return this.get('/marketMakerRewardsV1/epoch', params);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The Get Epochs endpoint provides a list of the defined
|
|
216
|
+
* market maker rewards epochs.
|
|
217
|
+
*
|
|
218
|
+
* ---
|
|
219
|
+
* **Endpoint Parameters**
|
|
220
|
+
*
|
|
221
|
+
* > - HTTP Request: `GET /v1/marketMakerRewardsV1/epochs`
|
|
222
|
+
* > - Endpoint Security: [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
223
|
+
* > - API Key Scope: [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
224
|
+
* ---
|
|
225
|
+
*
|
|
226
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getMarketMakerRewardsEpochs)
|
|
227
|
+
* @see request {@link katanaperps.RestRequestGetMarketMakerRewardsEpochs RestRequestGetMarketMakerRewardsEpochs}
|
|
228
|
+
* @see response {@link katanaperps.RestResponseGetMarketMakerRewardsEpochs RestResponseGetMarketMakerRewardsEpochs}
|
|
229
|
+
* @see type {@link katanaperps.KatanaPerpsMarketMakerRewardsEpochSummary KatanaPerpsMarketMakerRewardsEpochSummary}
|
|
230
|
+
* @see related {@link getMarketMakerRewardsEpoch client.getMarketMakerRewardsEpoch}
|
|
231
|
+
*
|
|
232
|
+
* @category Rewards & Payouts
|
|
233
|
+
*/
|
|
234
|
+
async getMarketMakerRewardsEpochs(params = {}) {
|
|
235
|
+
return this.get('/marketMakerRewardsV1/epochs', params);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Associates a wallet with an API account, allowing access to private data such as fills.
|
|
239
|
+
* Associating a wallet with an API account is often the first step in interacting with private
|
|
240
|
+
* read endpoints.
|
|
241
|
+
*
|
|
242
|
+
* ---
|
|
243
|
+
* **Endpoint Parameters**
|
|
244
|
+
*
|
|
245
|
+
* > - **HTTP Request:** `POST /v1/wallets`
|
|
246
|
+
* > - **Endpoint Security:** [Trade](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
247
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
248
|
+
* > - **Pagination:** `None`
|
|
249
|
+
* ---
|
|
250
|
+
*
|
|
251
|
+
* @returns
|
|
252
|
+
* - Returns the {@link katanaperps.KatanaPerpsWallet KatanaPerpsWallet} which was associated by the request.
|
|
253
|
+
*
|
|
254
|
+
* ---
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const wallet = await client.associateWallet({
|
|
259
|
+
* nonce: uuidv1(),
|
|
260
|
+
* wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
|
|
261
|
+
* });
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* <br />
|
|
265
|
+
*
|
|
266
|
+
* ---
|
|
267
|
+
*
|
|
268
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#associateWallet)
|
|
269
|
+
* @see request {@link katanaperps.RestRequestAssociateWallet RestRequestAssociateWallet}
|
|
270
|
+
* @see response {@link katanaperps.RestResponseAssociateWallet RestResponseAssociateWallet}
|
|
271
|
+
* @see type {@link katanaperps.KatanaPerpsWallet KatanaPerpsWallet}
|
|
272
|
+
*
|
|
273
|
+
* @category Wallets & Positions
|
|
274
|
+
*/
|
|
275
|
+
async associateWallet(params, referralCode, signer = this.#signer) {
|
|
276
|
+
ensureSigner(signer);
|
|
277
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
278
|
+
return this.post('/wallets', {
|
|
279
|
+
referralCode,
|
|
280
|
+
parameters: params,
|
|
281
|
+
signature: await signer(...(0, _signatures_1.getWalletAssociationSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Returns information about the wallets associated with the API account.
|
|
286
|
+
*
|
|
287
|
+
* ---
|
|
288
|
+
* **Endpoint Parameters**
|
|
289
|
+
*
|
|
290
|
+
* > - **HTTP Request:** `GET /v1/wallets`
|
|
291
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
292
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
293
|
+
* > - **Pagination:** `None`
|
|
294
|
+
* ---
|
|
295
|
+
*
|
|
296
|
+
* @returns
|
|
297
|
+
* - An array of {@link katanaperps.KatanaPerpsWallet KatanaPerpsWallet} objects representing all associated wallets.
|
|
298
|
+
*
|
|
299
|
+
* ---
|
|
300
|
+
*
|
|
301
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getWallets)
|
|
302
|
+
* @see request {@link katanaperps.RestRequestGetWallets RestRequestGetWallets}
|
|
303
|
+
* @see response {@link katanaperps.RestResponseGetWallets RestResponseGetWallets}
|
|
304
|
+
* @see type {@link katanaperps.KatanaPerpsWallet KatanaPerpsWallet}
|
|
305
|
+
*
|
|
306
|
+
* @category Wallets & Positions
|
|
307
|
+
*/
|
|
308
|
+
async getWallets(params) {
|
|
309
|
+
return this.get('/wallets', params);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Get Positions
|
|
313
|
+
*
|
|
314
|
+
* ---
|
|
315
|
+
* **Endpoint Parameters**
|
|
316
|
+
*
|
|
317
|
+
* > - **HTTP Request:** `GET /v1/positions`
|
|
318
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
319
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
320
|
+
* > - **Pagination:** `None`
|
|
321
|
+
* ---
|
|
322
|
+
*
|
|
323
|
+
* @returns
|
|
324
|
+
* - An array of {@link katanaperps.KatanaPerpsPosition KatanaPerpsPosition} objects representing all matching positions based
|
|
325
|
+
* on your requested params.
|
|
326
|
+
*
|
|
327
|
+
* ---
|
|
328
|
+
*
|
|
329
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getPositions)
|
|
330
|
+
* @see request {@link katanaperps.RestRequestGetPositions RestRequestGetPositions}
|
|
331
|
+
* @see response {@link katanaperps.RestResponseGetPositions RestResponseGetPositions}
|
|
332
|
+
* @see type {@link katanaperps.KatanaPerpsPosition KatanaPerpsPosition}
|
|
333
|
+
*
|
|
334
|
+
* @category Wallets & Positions
|
|
335
|
+
*/
|
|
336
|
+
async getPositions(params) {
|
|
337
|
+
return this.get('/positions', params);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Create and submit an order to the matching engine.
|
|
341
|
+
*
|
|
342
|
+
* - It is recommended to use the {@link katanaPerps.OrderType OrderType} enum when creating
|
|
343
|
+
* your requests. This provides inline documentation and ensures accuracy of the values.
|
|
344
|
+
* - Check out the {@link katanaperps.RestRequestOrder RestRequestOrder} type for an overview
|
|
345
|
+
* of the various parameters needed for different order types.
|
|
346
|
+
*
|
|
347
|
+
* ---
|
|
348
|
+
* **Endpoint Parameters**
|
|
349
|
+
*
|
|
350
|
+
* > - **HTTP Request:** `POST /v1/orders`
|
|
351
|
+
* > - **Endpoint Security:** [Trade](https://api-docs-v1-perps.katana.network/#endpointSecurityTrade)
|
|
352
|
+
* > - **API Key Scope:** [Trade](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
353
|
+
* > - **Pagination:** `None`
|
|
354
|
+
* ---
|
|
355
|
+
*
|
|
356
|
+
* @returns
|
|
357
|
+
* - Returns the {@link katanaPerps.KatanaPerpsOrder KatanaPerpsOrder} which was created by the request.
|
|
358
|
+
*
|
|
359
|
+
* ---
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* import { OrderType, OrderSide } from '@katanaperps/katana-perps-sdk';
|
|
364
|
+
*
|
|
365
|
+
* try {
|
|
366
|
+
* const order = await client.createOrder({
|
|
367
|
+
* // always use the enum and define it first so that
|
|
368
|
+
* // the type of this params object change to the
|
|
369
|
+
* // appropriate interface with completion hints in IDE!
|
|
370
|
+
* type: OrderType.market,
|
|
371
|
+
* // this object is now narrowed to
|
|
372
|
+
* // interface: RestRequestOrderTypeMarket
|
|
373
|
+
* side: OrderSide.buy,
|
|
374
|
+
* nonce: uuidv1(),
|
|
375
|
+
* wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
|
|
376
|
+
* market: 'ETH-USD',
|
|
377
|
+
* quantity: '10.00000000'
|
|
378
|
+
* });
|
|
379
|
+
* } catch(e) {
|
|
380
|
+
* // order placement failed with an unexpected error
|
|
381
|
+
* // you may use isAxiosError(e) for stronger typing here if desired
|
|
382
|
+
* if (e.response?.data?.code === 'INSUFFICIENT_FUNDS') {
|
|
383
|
+
* // handle insufficient funds errors
|
|
384
|
+
* console.log('Insufficient funds to create order');
|
|
385
|
+
* }
|
|
386
|
+
* }
|
|
387
|
+
* ```
|
|
388
|
+
*
|
|
389
|
+
* <br />
|
|
390
|
+
*
|
|
391
|
+
* ---
|
|
392
|
+
*
|
|
393
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#createOrder)
|
|
394
|
+
* @see request {@link katanaperps.RestRequestOrder RestRequestOrder}
|
|
395
|
+
* @see response {@link katanaperps.RestResponseGetOrder RestResponseGetOrder}
|
|
396
|
+
* @see type {@link katanaPerps.KatanaPerpsOrder KatanaPerpsOrder}
|
|
397
|
+
*
|
|
398
|
+
* @category Orders
|
|
399
|
+
*/
|
|
400
|
+
async createOrder(params, signer = this.#signer) {
|
|
401
|
+
ensureSigner(signer);
|
|
402
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
403
|
+
return this.post('/orders', {
|
|
404
|
+
parameters: params,
|
|
405
|
+
signature: await signer(...(0, _signatures_1.getOrderSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Cancel multiple matching orders using one of the following methods:
|
|
410
|
+
*
|
|
411
|
+
* - By {@link katanaperps.RestRequestCancelOrdersByWallet.wallet wallet} (params: {@link katanaperps.RestRequestCancelOrdersByWallet RestRequestCancelOrdersByWallet})
|
|
412
|
+
* - By {@link katanaperps.RestRequestCancelOrdersByMarket.wallet wallet} & {@link katanaperps.RestRequestCancelOrdersByMarket.market market} (params: {@link katanaperps.RestRequestCancelOrdersByMarket RestRequestCancelOrdersByMarket})
|
|
413
|
+
* - By {@link katanaperps.RestRequestCancelOrdersByMarket.wallet wallet} & {@link katanaperps.RestRequestCancelOrdersByOrderIds.orderIds orderIds} (params: {@link katanaperps.RestRequestCancelOrdersByOrderIds RestRequestCancelOrdersByOrderIds})
|
|
414
|
+
*
|
|
415
|
+
* ---
|
|
416
|
+
* **Endpoint Parameters**
|
|
417
|
+
*
|
|
418
|
+
* > - **HTTP Request:** `DELETE /v1/orders`
|
|
419
|
+
* > - **Endpoint Security:** [Trade](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
420
|
+
* > - **API Key Scope:** [Trade](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
421
|
+
* > - **Pagination:** `None`
|
|
422
|
+
* ---
|
|
423
|
+
*
|
|
424
|
+
* @returns
|
|
425
|
+
* - Returns an array of cancelled orders matching {@link katanaperps.KatanaPerpsCanceledOrder KatanaPerpsCanceledOrder}
|
|
426
|
+
*
|
|
427
|
+
* ---
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```typescript
|
|
431
|
+
* const allOrders = client.cancelOrders({
|
|
432
|
+
* nonce: uuidv1(),
|
|
433
|
+
* wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
|
|
434
|
+
* });
|
|
435
|
+
*
|
|
436
|
+
* const ordersForMarket = client.cancelOrders({
|
|
437
|
+
* nonce: uuidv1(),
|
|
438
|
+
* wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
|
|
439
|
+
* market: 'ETH-USD'
|
|
440
|
+
* });
|
|
441
|
+
* ```
|
|
442
|
+
*
|
|
443
|
+
* <br />
|
|
444
|
+
*
|
|
445
|
+
* ---
|
|
446
|
+
*
|
|
447
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#cancelOrders)
|
|
448
|
+
* @see request {@link katanaperps.RestRequestCancelOrders RestRequestCancelOrders}
|
|
449
|
+
* @see response {@link katanaperps.RestResponseCancelOrders RestResponseCancelOrders}
|
|
450
|
+
* @see type {@link katanaperps.KatanaPerpsCanceledOrder KatanaPerpsCanceledOrder}
|
|
451
|
+
* @see related {@link cancelOrder client.cancelOrder}
|
|
452
|
+
*
|
|
453
|
+
* @category Orders
|
|
454
|
+
*/
|
|
455
|
+
async cancelOrders(params, signer = this.#signer) {
|
|
456
|
+
return this.makeCancelOrdersRequest('/orders', params, signer);
|
|
457
|
+
}
|
|
458
|
+
async makeCancelOrdersRequest(endpoint, params, signer = this.#signer) {
|
|
459
|
+
ensureSigner(signer);
|
|
460
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
461
|
+
return this.delete(endpoint, {
|
|
462
|
+
parameters: params,
|
|
463
|
+
signature: await signer(...(0, _signatures_1.getOrderCancellationSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Returns an order matching your {@link katanaperps.RestRequestGetOrder.orderId orderId} request parameter.
|
|
468
|
+
*
|
|
469
|
+
* - Can be an order's {@link katanaPerps.KatanaPerpsOrder.orderId orderId}
|
|
470
|
+
* - To get an order by its {@link katanaPerps.KatanaPerpsOrder.clientOrderId clientOrderId},
|
|
471
|
+
* you should prefix the value with `client:`.
|
|
472
|
+
*
|
|
473
|
+
* ---
|
|
474
|
+
* **Endpoint Parameters**
|
|
475
|
+
*
|
|
476
|
+
* > - **HTTP Request:** `GET /v1/orders`
|
|
477
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
478
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
479
|
+
* > - **Pagination:** `None`
|
|
480
|
+
* ---
|
|
481
|
+
*
|
|
482
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getOrder)
|
|
483
|
+
* @see request {@link katanaperps.RestRequestGetOrder RestRequestGetOrder}
|
|
484
|
+
* @see response {@link katanaperps.RestResponseGetOrder RestResponseGetOrder}
|
|
485
|
+
* @see type {@link katanaPerps.KatanaPerpsOrder KatanaPerpsOrder}
|
|
486
|
+
* @see related {@link getOrders client.getOrders}
|
|
487
|
+
*
|
|
488
|
+
* @category Orders
|
|
489
|
+
*/
|
|
490
|
+
async getOrder(params) {
|
|
491
|
+
return this.get('/orders', params);
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Returns information about open and past {@link katanaPerps.KatanaPerpsOrder orders}.
|
|
495
|
+
*
|
|
496
|
+
* ---
|
|
497
|
+
* **Endpoint Parameters**
|
|
498
|
+
*
|
|
499
|
+
* > - **HTTP Request:** `GET /v1/orders`
|
|
500
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
501
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
502
|
+
* > - **Pagination:**
|
|
503
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.start start},
|
|
504
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.end end},
|
|
505
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.limit limit},
|
|
506
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.fromId fromId}
|
|
507
|
+
* ---
|
|
508
|
+
*
|
|
509
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getOrders)
|
|
510
|
+
* @see request {@link katanaperps.RestRequestGetOrders RestRequestGetOrders}
|
|
511
|
+
* @see response {@link katanaperps.RestResponseGetOrders RestResponseGetOrders}
|
|
512
|
+
* @see type {@link katanaPerps.KatanaPerpsOrder KatanaPerpsOrder}
|
|
513
|
+
* @see related {@link getOrder client.getOrder}
|
|
514
|
+
*
|
|
515
|
+
* @category Orders
|
|
516
|
+
*/
|
|
517
|
+
async getOrders(params) {
|
|
518
|
+
return this.get('/orders', params);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get a single fill from the API by your requests {@link katanaperps.RestRequestGetFill.fillId fillId}
|
|
522
|
+
* parameter.
|
|
523
|
+
*
|
|
524
|
+
* ---
|
|
525
|
+
* **Endpoint Parameters**
|
|
526
|
+
*
|
|
527
|
+
* > - **HTTP Request:** `GET /v1/fills`
|
|
528
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
529
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
530
|
+
* > - **Pagination:** `None`
|
|
531
|
+
* ---
|
|
532
|
+
*
|
|
533
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getFill)
|
|
534
|
+
* @see request {@link katanaperps.RestRequestGetFill RestRequestGetFill}
|
|
535
|
+
* @see response {@link katanaperps.RestResponseGetFill RestResponseGetFill}
|
|
536
|
+
* @see type {@link katanaperps.KatanaPerpsFill KatanaPerpsFill}
|
|
537
|
+
* @see related {@link getFills client.getFills}
|
|
538
|
+
*
|
|
539
|
+
* @category Fills & Historical
|
|
540
|
+
*/
|
|
541
|
+
async getFill(params) {
|
|
542
|
+
return this.get('/fills', params);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Get an array of {@link KatanaPerpsFill} objects matching your request parameters.
|
|
546
|
+
*
|
|
547
|
+
* ---
|
|
548
|
+
* **Endpoint Parameters**
|
|
549
|
+
*
|
|
550
|
+
* > - **HTTP Request:** `GET /v1/fills`
|
|
551
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
552
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
553
|
+
* > - **Pagination:**
|
|
554
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.start start},
|
|
555
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.end end},
|
|
556
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.limit limit},
|
|
557
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.fromId fromId}
|
|
558
|
+
* ---
|
|
559
|
+
*
|
|
560
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getFills)
|
|
561
|
+
* @see request {@link katanaperps.RestRequestGetFills RestRequestGetFills}
|
|
562
|
+
* @see response {@link katanaperps.RestResponseGetFills RestResponseGetFills}
|
|
563
|
+
* @see type {@link katanaperps.KatanaPerpsFill KatanaPerpsFill}
|
|
564
|
+
* @see related {@link getFill client.getFill}
|
|
565
|
+
*
|
|
566
|
+
* @category Fills & Historical
|
|
567
|
+
*/
|
|
568
|
+
async getFills(params) {
|
|
569
|
+
return this.get('/fills', params);
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Returns information about a payout program and the requested wallets earned/paid amounts for
|
|
573
|
+
* the program.
|
|
574
|
+
*
|
|
575
|
+
* - Includes the data required to authorize a payout using the `distribute`
|
|
576
|
+
* function of the escrow contract.
|
|
577
|
+
* - Throws an error if the {@link katanaperps.KatanaPerpsPayoutProgram.quantityOwed quantityOwed}
|
|
578
|
+
* is `0`
|
|
579
|
+
*
|
|
580
|
+
* ---
|
|
581
|
+
* **Endpoint Parameters**
|
|
582
|
+
*
|
|
583
|
+
* > - **HTTP Request:** `POST /v1/payouts`
|
|
584
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
585
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
586
|
+
* > - **Pagination:** `None`
|
|
587
|
+
* ---
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```typescript
|
|
591
|
+
* import { PayoutProgram } from '@katanaperps/katana-perps-sdk';
|
|
592
|
+
*
|
|
593
|
+
* // create client
|
|
594
|
+
*
|
|
595
|
+
* await client.authorizePayout({
|
|
596
|
+
* wallet: '0x...',
|
|
597
|
+
* nonce: uuidv1(),
|
|
598
|
+
* // use the PayoutProgram enum for inline auto completion
|
|
599
|
+
* program: PayoutProgram.tradingRewardsV2
|
|
600
|
+
* });
|
|
601
|
+
* ```
|
|
602
|
+
*
|
|
603
|
+
*
|
|
604
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#authorizePayout)
|
|
605
|
+
* @see request {@link katanaperps.RestRequestAuthorizePayout RestRequestAuthorizePayout}
|
|
606
|
+
* @see response {@link katanaperps.RestResponseAuthorizePayout RestResponseAuthorizePayout}
|
|
607
|
+
* @see type {@link katanaperps.KatanaPerpsPayoutProgramAuthorization KatanaPerpsPayoutProgramAuthorization}
|
|
608
|
+
*
|
|
609
|
+
* @category Rewards & Payouts
|
|
610
|
+
*/
|
|
611
|
+
async authorizePayout(params) {
|
|
612
|
+
return this.post('/payouts', params);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Returns information about a payout program and the requested wallets
|
|
616
|
+
* earned/paid amounts for the program.
|
|
617
|
+
*
|
|
618
|
+
* ---
|
|
619
|
+
* **Endpoint Parameters**
|
|
620
|
+
*
|
|
621
|
+
* > - **HTTP Request:** `GET /v1/payouts`
|
|
622
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
623
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
624
|
+
* > - **Pagination:** `None`
|
|
625
|
+
* ---
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* ```typescript
|
|
629
|
+
* import { PayoutProgram } from '@katanaperps/katana-perps-sdk';
|
|
630
|
+
*
|
|
631
|
+
* // create client
|
|
632
|
+
*
|
|
633
|
+
* await client.getPayouts({
|
|
634
|
+
* wallet: '0x...',
|
|
635
|
+
* nonce: uuidv1(),
|
|
636
|
+
* // use the PayoutProgram enum for inline auto completion
|
|
637
|
+
* program: PayoutProgram.tradingRewardsV2
|
|
638
|
+
* });
|
|
639
|
+
* ```
|
|
640
|
+
*
|
|
641
|
+
* <br />
|
|
642
|
+
*
|
|
643
|
+
* ---
|
|
644
|
+
*
|
|
645
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getPayouts)
|
|
646
|
+
* @see request {@link katanaperps.RestRequestGetPayouts RestRequestGetPayouts}
|
|
647
|
+
* @see response {@link katanaperps.RestResponseGetPayouts RestResponseGetPayouts}
|
|
648
|
+
* @see type {@link katanaperps.KatanaPerpsPayoutProgram KatanaPerpsPayoutProgram}
|
|
649
|
+
*
|
|
650
|
+
* @category Rewards & Payouts
|
|
651
|
+
*/
|
|
652
|
+
async getPayouts(params) {
|
|
653
|
+
return this.get('/payouts', params);
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Returns information about deposits made by a wallet.
|
|
657
|
+
*
|
|
658
|
+
* ---
|
|
659
|
+
* **Endpoint Parameters**
|
|
660
|
+
*
|
|
661
|
+
* > - **HTTP Request:** `GET /v1/deposits`
|
|
662
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
663
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
664
|
+
* > - **Pagination:** `None`
|
|
665
|
+
* ---
|
|
666
|
+
*
|
|
667
|
+
* @returns
|
|
668
|
+
* - Returns a single {@link katanaperps.KatanaPerpsDeposit KatanaPerpsDeposit} object matching your parameters.
|
|
669
|
+
*
|
|
670
|
+
* ---
|
|
671
|
+
*
|
|
672
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getDeposit)
|
|
673
|
+
* @see request {@link katanaperps.RestRequestGetDeposit RestRequestGetDeposit}
|
|
674
|
+
* @see response {@link katanaperps.RestResponseGetDeposit RestResponseGetDeposit}
|
|
675
|
+
* @see type {@link katanaperps.KatanaPerpsDeposit KatanaPerpsDeposit}
|
|
676
|
+
* @see related {@link getDeposits client.getDeposits}
|
|
677
|
+
*
|
|
678
|
+
* @category Deposits & Withdrawals
|
|
679
|
+
*/
|
|
680
|
+
async getDeposit(params) {
|
|
681
|
+
return this.get('/deposits', params);
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Returns information about deposits made by a wallet.
|
|
685
|
+
*
|
|
686
|
+
* ---
|
|
687
|
+
* **Endpoint Parameters**
|
|
688
|
+
*
|
|
689
|
+
* > - **HTTP Request:** `GET /v1/deposits`
|
|
690
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
691
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
692
|
+
* > - **Pagination:**
|
|
693
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.start start},
|
|
694
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.end end},
|
|
695
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.limit limit},
|
|
696
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.fromId fromId}
|
|
697
|
+
* ---
|
|
698
|
+
*
|
|
699
|
+
* @returns
|
|
700
|
+
* - Returns an array of {@link katanaperps.KatanaPerpsDeposit KatanaPerpsDeposit} objects matching your parameters.
|
|
701
|
+
*
|
|
702
|
+
* ---
|
|
703
|
+
*
|
|
704
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getDeposits)
|
|
705
|
+
* @see request {@link katanaperps.RestRequestGetDeposits RestRequestGetDeposits}
|
|
706
|
+
* @see response {@link katanaperps.RestResponseGetDeposits RestResponseGetDeposits}
|
|
707
|
+
* @see type {@link katanaperps.KatanaPerpsDeposit KatanaPerpsDeposit}
|
|
708
|
+
* @see related {@link getDeposit client.getDeposit}
|
|
709
|
+
*
|
|
710
|
+
* @category Deposits & Withdrawals
|
|
711
|
+
*/
|
|
712
|
+
async getDeposits(params) {
|
|
713
|
+
return this.get('/deposits', params);
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* A convenience method that helps capture the appropriate value for the
|
|
717
|
+
* {@link withdraw} method's {@link katanaperps.RestRequestWithdrawFundsBase.maximumGasFee maximumGasFee}
|
|
718
|
+
* parameter.
|
|
719
|
+
*
|
|
720
|
+
* - Calls `publicClient.getGasFees` and adds the defined `maximumSlippagePercent` to it.
|
|
721
|
+
* - User should then confirm the value is acceptable before calling {@link withdraw} method.
|
|
722
|
+
* - If gas were `0.05000000` and `maximumSlippagePercent` is `0.10000000` (10%) then result would be `0.05500000`
|
|
723
|
+
* - The value is represented in USD.
|
|
724
|
+
*
|
|
725
|
+
* ---
|
|
726
|
+
*
|
|
727
|
+
* @returns
|
|
728
|
+
* - A value indicating the max gas fee that should be allowed (in USD) based on the
|
|
729
|
+
* core gas fee with your `maximumSlippagePercent` added. This value should always
|
|
730
|
+
* be validated by your application before calling {@link withdraw} method with this
|
|
731
|
+
* as your {@link katanaperps.RestRequestWithdrawFundsBase.maximumGasFee maximumGasFee}
|
|
732
|
+
* parameter.
|
|
733
|
+
*
|
|
734
|
+
* ---
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* ```typescript
|
|
738
|
+
* // returns the max gas fee in USD you will accept for a withdrawal
|
|
739
|
+
* const maximumGasFee = await client.calculateWithdrawalMaximumGasFee({
|
|
740
|
+
* bridgeTarget: BridgeTarget.STARGATE_ETHEREUM,
|
|
741
|
+
* // 10% slippage alllowed (default)
|
|
742
|
+
* maximumSlippagePercent: '0.10000000'
|
|
743
|
+
* });
|
|
744
|
+
*
|
|
745
|
+
* // never pay more than $1 USD in gas fees to withdrawal
|
|
746
|
+
* if (Number(maximumGasFee) >= 1) {
|
|
747
|
+
* throw new Error('Too Much Gas cost to Withdraw! ${maximumGasFee} USD >= 1 USD!');
|
|
748
|
+
* }
|
|
749
|
+
*
|
|
750
|
+
* const withdrawal = await client.withdraw({
|
|
751
|
+
* nonce: uuidv1(),
|
|
752
|
+
* wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
|
|
753
|
+
* quantity: '100.00000000',
|
|
754
|
+
* maximumGasFee,
|
|
755
|
+
* bridgeTarget: BridgeTarget.STARGATE_ETHEREUM
|
|
756
|
+
* });
|
|
757
|
+
* ```
|
|
758
|
+
*
|
|
759
|
+
* <br />
|
|
760
|
+
*
|
|
761
|
+
* ---
|
|
762
|
+
*
|
|
763
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#calculateWithdrawalMaximumGasFee)
|
|
764
|
+
* @see related {@link withdraw client.withdraw}
|
|
765
|
+
*/
|
|
766
|
+
async calculateWithdrawalMaximumGasFee({ bridgeTarget, maximumSlippagePercent, }) {
|
|
767
|
+
const maximumSlippagePercentBN = (0, bignumber_js_1.default)(maximumSlippagePercent);
|
|
768
|
+
if (maximumSlippagePercentBN.gt(1) || maximumSlippagePercentBN.lt(0)) {
|
|
769
|
+
throw new Error(`maximumSlippagePercent must be a value between 0 and 1. Value of ${maximumSlippagePercent} was provided`);
|
|
770
|
+
}
|
|
771
|
+
const gasFees = await this.public.getGasFees();
|
|
772
|
+
const fees = gasFees.withdrawal[bridgeTarget];
|
|
773
|
+
if (!fees) {
|
|
774
|
+
// in testnet we only define katana so need this - mainnet should have all of them.
|
|
775
|
+
throw new Error(`Could not estimate withdrawal maximumGasFee for ${bridgeTarget} as the "gasFees" endpoint does not provide the gas fee for the target.`);
|
|
776
|
+
}
|
|
777
|
+
const slippage = (0, bignumber_js_1.default)(fees).multipliedBy(maximumSlippagePercent);
|
|
778
|
+
return (0, bignumber_js_1.default)(fees).plus(slippage).toFixed(8, bignumber_js_1.default.ROUND_DOWN);
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Withdraw funds from the exchange.
|
|
782
|
+
*
|
|
783
|
+
* - Unlike deposits, withdrawals are initiated via this REST API endpoint.
|
|
784
|
+
* - Once the withdrawal is validated, Katana Perps automatically dispatches the
|
|
785
|
+
* resulting transaction to send funds to the wallet.
|
|
786
|
+
*
|
|
787
|
+
* ---
|
|
788
|
+
* **Endpoint Parameters**
|
|
789
|
+
*
|
|
790
|
+
* > - **HTTP Request:** `POST /v1/withdrawals`
|
|
791
|
+
* > - **Endpoint Security:** [Trade](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
792
|
+
* > - **API Key Scope:** [Withdraw](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
793
|
+
* > - **Pagination:** `None`
|
|
794
|
+
* ---
|
|
795
|
+
*
|
|
796
|
+
* @returns
|
|
797
|
+
* - Returns an {@link katanaperps.KatanaPerpsWithdrawal KatanaPerpsWithdrawal} object providing the details of the
|
|
798
|
+
* withdrawal.
|
|
799
|
+
*
|
|
800
|
+
* ---
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* ```typescript
|
|
804
|
+
* // returns the max gas fee in USD you will accept for a withdrawal
|
|
805
|
+
* const maximumGasFee = await client.calculateWithdrawalMaximumGasFee({
|
|
806
|
+
* bridgeTarget: BridgeTarget.STARGATE_ETHEREUM,
|
|
807
|
+
* // 10% slippage alllowed (default)
|
|
808
|
+
* maximumSlippagePercent: '0.10000000'
|
|
809
|
+
* });
|
|
810
|
+
*
|
|
811
|
+
* // never pay more than $1 USD in gas fees to withdrawal
|
|
812
|
+
* if (Number(maximumGasFee) >= 1) {
|
|
813
|
+
* throw new Error('Too Much Gas cost to Withdraw! ${maximumGasFee} USD >= 1 USD!');
|
|
814
|
+
* }
|
|
815
|
+
*
|
|
816
|
+
* const withdrawal = await client.withdraw({
|
|
817
|
+
* nonce: uuidv1(),
|
|
818
|
+
* wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
|
|
819
|
+
* quantity: '100.00000000',
|
|
820
|
+
* maximumGasFee,
|
|
821
|
+
* bridgeTarget: BridgeTarget.STARGATE_ETHEREUM
|
|
822
|
+
* });
|
|
823
|
+
* ```
|
|
824
|
+
*
|
|
825
|
+
* <br />
|
|
826
|
+
*
|
|
827
|
+
* ---
|
|
828
|
+
*
|
|
829
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#withdraw)
|
|
830
|
+
* @see request {@link katanaperps.RestRequestWithdrawFunds RestRequestWithdrawFunds}
|
|
831
|
+
* @see response {@link katanaperps.RestResponseWithdrawFunds RestResponseWithdrawFunds}
|
|
832
|
+
* @see type {@link katanaperps.KatanaPerpsWithdrawal KatanaPerpsWithdrawal}
|
|
833
|
+
* @see related {@link calculateWithdrawalMaximumGasFee}
|
|
834
|
+
*
|
|
835
|
+
* @category Deposits & Withdrawals
|
|
836
|
+
*/
|
|
837
|
+
async withdraw($params, signer = this.#signer) {
|
|
838
|
+
ensureSigner(signer);
|
|
839
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
840
|
+
let params;
|
|
841
|
+
if ($params.bridgeTarget) {
|
|
842
|
+
const { bridgeTarget, ...rest } = $params;
|
|
843
|
+
params = {
|
|
844
|
+
...rest,
|
|
845
|
+
...getWithdrawalRequestBridgeAdapterParametersForTarget(),
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
else {
|
|
849
|
+
params = $params;
|
|
850
|
+
}
|
|
851
|
+
return this.post('/withdrawals', {
|
|
852
|
+
parameters: params,
|
|
853
|
+
signature: await signer(...(0, _signatures_1.getWithdrawalSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Returns information about a single withdrawal matching the request.
|
|
858
|
+
*
|
|
859
|
+
* ---
|
|
860
|
+
* **Endpoint Parameters**
|
|
861
|
+
*
|
|
862
|
+
* > - **HTTP Request:** `GET /v1/withdrawals`
|
|
863
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
864
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
865
|
+
* > - **Pagination:** `None`
|
|
866
|
+
* ---
|
|
867
|
+
*
|
|
868
|
+
* @returns
|
|
869
|
+
* - Returns an {@link katanaperps.KatanaPerpsWithdrawal KatanaPerpsWithdrawal} object matching your request.
|
|
870
|
+
*
|
|
871
|
+
* ---
|
|
872
|
+
*
|
|
873
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getWithdrawal)
|
|
874
|
+
* @see request {@link katanaperps.RestRequestGetWithdrawal RestRequestGetWithdrawal}
|
|
875
|
+
* @see response {@link katanaperps.RestResponseGetWithdrawal RestResponseGetWithdrawal}
|
|
876
|
+
* @see type {@link katanaperps.KatanaPerpsWithdrawal KatanaPerpsWithdrawal}
|
|
877
|
+
* @see related {@link getWithdrawals client.getWithdrawals}
|
|
878
|
+
*
|
|
879
|
+
* @category Deposits & Withdrawals
|
|
880
|
+
*/
|
|
881
|
+
async getWithdrawal(params) {
|
|
882
|
+
return this.get('/withdrawals', params);
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Returns information about withdrawals to a wallet.
|
|
886
|
+
*
|
|
887
|
+
* ---
|
|
888
|
+
* **Endpoint Parameters**
|
|
889
|
+
*
|
|
890
|
+
* > - **HTTP Request:** `GET /v1/withdrawals`
|
|
891
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
892
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
893
|
+
* > - **Pagination:**
|
|
894
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.start start},
|
|
895
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.end end},
|
|
896
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.limit limit},
|
|
897
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.fromId fromId}
|
|
898
|
+
* ---
|
|
899
|
+
*
|
|
900
|
+
* @returns
|
|
901
|
+
* - Returns an array of {@link katanaperps.KatanaPerpsWithdrawal KatanaPerpsWithdrawal} objects matching your request.
|
|
902
|
+
*
|
|
903
|
+
* ---
|
|
904
|
+
*
|
|
905
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getWithdrawals)
|
|
906
|
+
* @see request {@link katanaperps.RestRequestGetWithdrawals RestRequestGetWithdrawals}
|
|
907
|
+
* @see response {@link katanaperps.RestResponseGetWithdrawals RestResponseGetWithdrawals}
|
|
908
|
+
* @see type {@link katanaperps.KatanaPerpsWithdrawal KatanaPerpsWithdrawal}
|
|
909
|
+
* @see related {@link getWithdrawal client.getWithdrawal}
|
|
910
|
+
*
|
|
911
|
+
* @category Deposits & Withdrawals
|
|
912
|
+
*/
|
|
913
|
+
async getWithdrawals(params) {
|
|
914
|
+
return this.get('/withdrawals', params);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Get Funding Payments for wallet matching {@link katanaperps.KatanaPerpsFundingPayment KatanaPerpsFundingPayment}
|
|
918
|
+
*
|
|
919
|
+
* ---
|
|
920
|
+
* **Endpoint Parameters**
|
|
921
|
+
*
|
|
922
|
+
* > - **HTTP Request:** `GET /v1/fundingPayments`
|
|
923
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
924
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
925
|
+
* > - **Pagination:**
|
|
926
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.start start},
|
|
927
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.end end},
|
|
928
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.limit limit}
|
|
929
|
+
* ---
|
|
930
|
+
*
|
|
931
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getFundingPayments)
|
|
932
|
+
* @see request {@link katanaperps.RestRequestGetFundingPayments RestRequestGetFundingPayments}
|
|
933
|
+
* @see response {@link katanaperps.RestResponseGetFundingPayments RestResponseGetFundingPayments}
|
|
934
|
+
* @see type {@link katanaperps.KatanaPerpsFundingPayment KatanaPerpsFundingPayment}
|
|
935
|
+
*
|
|
936
|
+
* @category Fills & Historical
|
|
937
|
+
*/
|
|
938
|
+
async getFundingPayments(params) {
|
|
939
|
+
return this.get('/fundingPayments', params);
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Override minimum Initial Margin Fraction for wallet for a market
|
|
943
|
+
*
|
|
944
|
+
* ---
|
|
945
|
+
* **Endpoint Parameters**
|
|
946
|
+
*
|
|
947
|
+
* > - **HTTP Request:** `POST /v1/initialMarginFractionOverride`
|
|
948
|
+
* > - **Endpoint Security:** [Trade](https://api-docs-v1-perps.katana.network/#endpointSecurityTrade)
|
|
949
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
950
|
+
* > - **Pagination:**
|
|
951
|
+
* ---
|
|
952
|
+
*
|
|
953
|
+
* @returns
|
|
954
|
+
* - Returns an {@link katanaperps.KatanaPerpsInitialMarginFractionOverride KatanaPerpsInitialMarginFractionOverride}
|
|
955
|
+
* object providing the details of the new setting.
|
|
956
|
+
|
|
957
|
+
*
|
|
958
|
+
* @category Wallets & Positions
|
|
959
|
+
*/
|
|
960
|
+
async setInitialMarginFractionOverride(params, signer = this.#signer) {
|
|
961
|
+
ensureSigner(signer);
|
|
962
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
963
|
+
return this.post('/initialMarginFractionOverride', {
|
|
964
|
+
parameters: params,
|
|
965
|
+
signature: await signer(...(0, _signatures_1.getInitialMarginFractionOverrideSettingsSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Get Initial Margin Fraction overrides for wallet for a market or all markets
|
|
970
|
+
*
|
|
971
|
+
* ---
|
|
972
|
+
* **Endpoint Parameters**
|
|
973
|
+
*
|
|
974
|
+
* > - **HTTP Request:** `GET /v1/initialMarginFractionOverride`
|
|
975
|
+
* > - **Endpoint Security:** [Trade](https://api-docs-v1-perps.katana.network/#endpointSecurityTrade)
|
|
976
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
977
|
+
* > - **Pagination:**
|
|
978
|
+
* ---
|
|
979
|
+
*
|
|
980
|
+
* @returns
|
|
981
|
+
* - Returns an {@link katanaperps.KatanaPerpsInitialMarginFractionOverride KatanaPerpsInitialMarginFractionOverride}
|
|
982
|
+
* object providing the details of the setting.
|
|
983
|
+
|
|
984
|
+
*
|
|
985
|
+
* @category Wallets & Positions
|
|
986
|
+
*/
|
|
987
|
+
async getInitialMarginFractionOverride(params) {
|
|
988
|
+
return this.get('/initialMarginFractionOverride', params);
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Get Historical PnL for the wallet / market matching {@link katanaperps.KatanaPerpsHistoricalProfitLoss KatanaPerpsHistoricalProfitLoss}
|
|
992
|
+
*
|
|
993
|
+
* ---
|
|
994
|
+
* **Endpoint Parameters**
|
|
995
|
+
*
|
|
996
|
+
* > - **HTTP Request:** `GET /v1/historicalPnL`
|
|
997
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
998
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
999
|
+
* > - **Pagination:**
|
|
1000
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.start start},
|
|
1001
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.end end},
|
|
1002
|
+
* > {@link katanaperps.RestRequestPaginationWithFromId.limit limit}
|
|
1003
|
+
* ---
|
|
1004
|
+
*
|
|
1005
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getHistoricalPnL)
|
|
1006
|
+
* @see request {@link katanaperps.RestRequestGetHistoricalPnL RestRequestGetHistoricalPnL}
|
|
1007
|
+
* @see response {@link katanaperps.RestResponseGetHistoricalPnL RestResponseGetHistoricalPnL}
|
|
1008
|
+
* @see type {@link katanaperps.KatanaPerpsHistoricalProfitLoss KatanaPerpsHistoricalProfitLoss}
|
|
1009
|
+
*
|
|
1010
|
+
* @category Fills & Historical
|
|
1011
|
+
*/
|
|
1012
|
+
async getHistoricalPnL(params) {
|
|
1013
|
+
return this.get('/historicalPnL', params);
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Returns a single-use authentication token as a string for access
|
|
1017
|
+
* to {@link katanaperps.SubscriptionNameAuthenticated authenticated subscriptions}
|
|
1018
|
+
* in the WebSocket API.
|
|
1019
|
+
*
|
|
1020
|
+
* ---
|
|
1021
|
+
* **Endpoint Parameters**
|
|
1022
|
+
*
|
|
1023
|
+
* > - **HTTP Request:** `GET /v1/wsToken`
|
|
1024
|
+
* > - **Endpoint Security:** [User Data](https://api-docs-v1-perps.katana.network/#endpointSecurityUserData)
|
|
1025
|
+
* > - **API Key Scope:** [Read](https://api-docs-v1-perps.katana.network/#api-keys)
|
|
1026
|
+
* > - **Pagination:** `None`
|
|
1027
|
+
* ---
|
|
1028
|
+
*
|
|
1029
|
+
* @returns
|
|
1030
|
+
* - Returns the {@link katanaperps.KatanaPerpsWebSocketToken.token KatanaPerpsWebSocketToken.token} string
|
|
1031
|
+
* directly which you can use to authenticate with the WebSocket server.
|
|
1032
|
+
*
|
|
1033
|
+
* ---
|
|
1034
|
+
*
|
|
1035
|
+
* @see typedoc [Reference Documentation](https://sdk-js-docs-v1-perps.katana.network/classes/RestAuthenticatedClient.html#getWsToken)
|
|
1036
|
+
* @see request {@link katanaperps.RestRequestGetAuthenticationToken RestRequestGetAuthenticationToken}
|
|
1037
|
+
* @see response {@link katanaperps.RestResponseGetAuthenticationToken RestResponseGetAuthenticationToken}
|
|
1038
|
+
*
|
|
1039
|
+
* @category WebSocket
|
|
1040
|
+
*/
|
|
1041
|
+
async getWsToken(params) {
|
|
1042
|
+
if (!params.nonce || !params.wallet) {
|
|
1043
|
+
throw new Error('Invalid request, nonce and wallet are required');
|
|
1044
|
+
}
|
|
1045
|
+
return (await this.get('/wsToken', params)).token;
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* - All requests within the internal symbol are undocumented internal methods which may change or be removed without notice.
|
|
1049
|
+
* - API handling of the parameters used within these methods is likely to change without notice without changes to the SDK to match.
|
|
1050
|
+
* - These methods or parameters may require additional permissions to use and result in errors or blocking of your request if used.
|
|
1051
|
+
* - If you need to use these methods for your use case, please contact support to discuss your requirements before using them.
|
|
1052
|
+
*
|
|
1053
|
+
* @internal
|
|
1054
|
+
*/
|
|
1055
|
+
[_utils_1.INTERNAL_SYMBOL] = Object.freeze({
|
|
1056
|
+
/**
|
|
1057
|
+
* Requires the public IDs (`orderIds`) of the stop loss orders' parent
|
|
1058
|
+
* orders. Do not provide the public IDs of the stop loss orders themselves.
|
|
1059
|
+
*/
|
|
1060
|
+
cancelConditionalStopLossOrders: async (params, signer = this.#signer) => {
|
|
1061
|
+
return this.makeCancelOrdersRequest('/internal/orders/conditionalStopLossOrders', params, signer);
|
|
1062
|
+
},
|
|
1063
|
+
/**
|
|
1064
|
+
* Requires the public IDs (`orderIds`) of the take profit orders' parent
|
|
1065
|
+
* orders. Do not provide the public IDs of the take profit orders themselves.
|
|
1066
|
+
*/
|
|
1067
|
+
cancelConditionalTakeProfitOrders: async (params, signer = this.#signer) => {
|
|
1068
|
+
return this.makeCancelOrdersRequest('/internal/orders/conditionalTakeProfitOrders', params, signer);
|
|
1069
|
+
},
|
|
1070
|
+
getFundingPayments: async (...[params, ...args]) => {
|
|
1071
|
+
const result = await this.getFundingPayments({
|
|
1072
|
+
...params,
|
|
1073
|
+
page: Math.max(typeof params.page === 'number' ? params.page : 1, 1),
|
|
1074
|
+
}, ...args);
|
|
1075
|
+
return result;
|
|
1076
|
+
},
|
|
1077
|
+
getXChallenge: async (params) => {
|
|
1078
|
+
const result = await this.get('/internal/vaults/xchallenge', params);
|
|
1079
|
+
return result;
|
|
1080
|
+
},
|
|
1081
|
+
placeConditionalTpSlOrder: async (takeProfitOrStopLossOrder, conditionalParentOrderId, signer = this.#signer) => {
|
|
1082
|
+
ensureSigner(signer);
|
|
1083
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
1084
|
+
return this.post('/internal/orders/conditionalTpSlOrders', {
|
|
1085
|
+
order: {
|
|
1086
|
+
parameters: takeProfitOrStopLossOrder,
|
|
1087
|
+
signature: await signer(...(0, _signatures_1.getOrderSignatureTypedData)(takeProfitOrStopLossOrder, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
1088
|
+
},
|
|
1089
|
+
conditionalParentOrderPublicId: conditionalParentOrderId,
|
|
1090
|
+
});
|
|
1091
|
+
},
|
|
1092
|
+
placeOrderWithConditionalTpSlOrders: async (params, signer = this.#signer) => {
|
|
1093
|
+
ensureSigner(signer);
|
|
1094
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
1095
|
+
const signOrder = (order) => signer(...(0, _signatures_1.getOrderSignatureTypedData)(order, exchangeContractAddress, chainId, this.#config.sandbox));
|
|
1096
|
+
return this.post('/internal/orders/orderWithConditionalTpSlOrders', {
|
|
1097
|
+
order: {
|
|
1098
|
+
parameters: params.order,
|
|
1099
|
+
signature: await signOrder(params.order),
|
|
1100
|
+
},
|
|
1101
|
+
conditionalTakeProfitOrder: params.conditionalTakeProfitOrder ?
|
|
1102
|
+
{
|
|
1103
|
+
parameters: params.conditionalTakeProfitOrder,
|
|
1104
|
+
signature: await signOrder(params.conditionalTakeProfitOrder),
|
|
1105
|
+
}
|
|
1106
|
+
: undefined,
|
|
1107
|
+
conditionalStopLossOrder: params.conditionalStopLossOrder ?
|
|
1108
|
+
{
|
|
1109
|
+
parameters: params.conditionalStopLossOrder,
|
|
1110
|
+
signature: await signOrder(params.conditionalStopLossOrder),
|
|
1111
|
+
}
|
|
1112
|
+
: undefined,
|
|
1113
|
+
});
|
|
1114
|
+
},
|
|
1115
|
+
setVaultDetails: async (params, signer = this.#signer) => {
|
|
1116
|
+
ensureSigner(signer);
|
|
1117
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
1118
|
+
return this.post('/internal/vaults/details', {
|
|
1119
|
+
parameters: params,
|
|
1120
|
+
signature: await signer(...(0, _signatures_1.getSetVaultDetailsSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
1121
|
+
});
|
|
1122
|
+
},
|
|
1123
|
+
removeVaultXConnection: async (params, signer = this.#signer) => {
|
|
1124
|
+
ensureSigner(signer);
|
|
1125
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
1126
|
+
await this.delete('/internal/vaults/xconnection', {
|
|
1127
|
+
parameters: params,
|
|
1128
|
+
signature: await signer(...(0, _signatures_1.getRemoveVaultXConnectionSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
1129
|
+
});
|
|
1130
|
+
},
|
|
1131
|
+
setVaultXConnection: async (params, signer = this.#signer) => {
|
|
1132
|
+
ensureSigner(signer);
|
|
1133
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
1134
|
+
await this.post('/internal/vaults/xconnection', {
|
|
1135
|
+
parameters: params,
|
|
1136
|
+
signature: await signer(...(0, _signatures_1.getSetVaultXConnectionSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
1137
|
+
});
|
|
1138
|
+
},
|
|
1139
|
+
withdrawFromManagedAccountByQuantity: async ($params, signer = this.#signer) => {
|
|
1140
|
+
ensureSigner(signer);
|
|
1141
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
1142
|
+
let params;
|
|
1143
|
+
if ($params.bridgeTarget) {
|
|
1144
|
+
const { bridgeTarget, ...rest } = $params;
|
|
1145
|
+
params = {
|
|
1146
|
+
...rest,
|
|
1147
|
+
...getWithdrawalRequestBridgeAdapterParametersForTarget(),
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
else {
|
|
1151
|
+
params = $params;
|
|
1152
|
+
}
|
|
1153
|
+
return this.post('/internal/vaults/withdrawByQuantity', {
|
|
1154
|
+
parameters: params,
|
|
1155
|
+
signature: await signer(...(0, _signatures_1.getWithdrawalFromManagedAccountByQuantitySignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
1156
|
+
});
|
|
1157
|
+
},
|
|
1158
|
+
withdrawFromManagedAccountByShares: async ($params, signer = this.#signer) => {
|
|
1159
|
+
ensureSigner(signer);
|
|
1160
|
+
const { chainId, exchangeContractAddress } = await this.getContractAndChainId();
|
|
1161
|
+
let params;
|
|
1162
|
+
if ($params.bridgeTarget) {
|
|
1163
|
+
const { bridgeTarget, ...rest } = $params;
|
|
1164
|
+
params = {
|
|
1165
|
+
...rest,
|
|
1166
|
+
...getWithdrawalRequestBridgeAdapterParametersForTarget(),
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
else {
|
|
1170
|
+
params = $params;
|
|
1171
|
+
}
|
|
1172
|
+
return this.post('/internal/vaults/withdrawByShares', {
|
|
1173
|
+
parameters: params,
|
|
1174
|
+
signature: await signer(...(0, _signatures_1.getWithdrawalFromManagedAccountBySharesSignatureTypedData)(params, exchangeContractAddress, chainId, this.#config.sandbox)),
|
|
1175
|
+
});
|
|
1176
|
+
},
|
|
1177
|
+
});
|
|
1178
|
+
// Internal methods exposed for advanced usage
|
|
1179
|
+
async getContractAndChainId() {
|
|
1180
|
+
let { chainId, exchangeContractAddress } = this.#config;
|
|
1181
|
+
if (!chainId || !exchangeContractAddress) {
|
|
1182
|
+
if (!this.#exchange) {
|
|
1183
|
+
this.#exchange = await this.public.getExchange();
|
|
1184
|
+
}
|
|
1185
|
+
if (this.#exchange.chainId && this.#exchange.exchangeContractAddress) {
|
|
1186
|
+
this.#config.chainId ??= this.#exchange.chainId;
|
|
1187
|
+
chainId ??= this.#config.chainId;
|
|
1188
|
+
this.#config.exchangeContractAddress ??=
|
|
1189
|
+
this.#exchange.exchangeContractAddress;
|
|
1190
|
+
exchangeContractAddress ??= this.#config.exchangeContractAddress;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
if (!chainId || !exchangeContractAddress) {
|
|
1194
|
+
throw new Error(`Could not determine chainId (${typeof chainId}) or exchangeContractAddress (${typeof exchangeContractAddress})`);
|
|
1195
|
+
}
|
|
1196
|
+
return {
|
|
1197
|
+
chainId,
|
|
1198
|
+
exchangeContractAddress,
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* - Internal Use and may change or break without notice
|
|
1203
|
+
*
|
|
1204
|
+
* @internal
|
|
1205
|
+
* @hidden
|
|
1206
|
+
*/
|
|
1207
|
+
async get(endpoint, params = undefined, axiosConfig = {}) {
|
|
1208
|
+
return (await this.request(endpoint, {
|
|
1209
|
+
...axiosConfig,
|
|
1210
|
+
method: 'GET',
|
|
1211
|
+
params: (0, _utils_1.sanitizeSearchParams)(params),
|
|
1212
|
+
})).data;
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* - Internal Use and may change or break without notice
|
|
1216
|
+
*
|
|
1217
|
+
* @internal
|
|
1218
|
+
* @hidden
|
|
1219
|
+
*/
|
|
1220
|
+
async post(endpoint, data = {}, axiosConfig = {}) {
|
|
1221
|
+
return (await this.request(endpoint, {
|
|
1222
|
+
...axiosConfig,
|
|
1223
|
+
method: 'POST',
|
|
1224
|
+
data,
|
|
1225
|
+
})).data;
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* - Internal Use and may change or break without notice
|
|
1229
|
+
*
|
|
1230
|
+
* @internal
|
|
1231
|
+
* @hidden
|
|
1232
|
+
*/
|
|
1233
|
+
async delete(endpoint, data = {}, axiosConfig = {}) {
|
|
1234
|
+
return (await this.request(endpoint, {
|
|
1235
|
+
...axiosConfig,
|
|
1236
|
+
method: 'DELETE',
|
|
1237
|
+
data,
|
|
1238
|
+
})).data;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* - Internal Use and may change or break without notice
|
|
1242
|
+
*
|
|
1243
|
+
* @internal
|
|
1244
|
+
* @hidden
|
|
1245
|
+
*/
|
|
1246
|
+
async put(endpoint, data = {}, axiosConfig = {}) {
|
|
1247
|
+
return (await this.request(endpoint, {
|
|
1248
|
+
...axiosConfig,
|
|
1249
|
+
method: 'PUT',
|
|
1250
|
+
data,
|
|
1251
|
+
})).data;
|
|
1252
|
+
}
|
|
1253
|
+
/**
|
|
1254
|
+
* - Internal Use and may change or break without notice
|
|
1255
|
+
*
|
|
1256
|
+
* @internal
|
|
1257
|
+
* @hidden
|
|
1258
|
+
*/
|
|
1259
|
+
async patch(endpoint, data = {}, axiosConfig = {}) {
|
|
1260
|
+
return (await this.request(endpoint, {
|
|
1261
|
+
...axiosConfig,
|
|
1262
|
+
method: 'PATCH',
|
|
1263
|
+
data,
|
|
1264
|
+
})).data;
|
|
1265
|
+
}
|
|
1266
|
+
/**
|
|
1267
|
+
* - Internal Use and may change or break without notice
|
|
1268
|
+
*
|
|
1269
|
+
* @internal
|
|
1270
|
+
* @hidden
|
|
1271
|
+
*/
|
|
1272
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1273
|
+
request(endpoint, config, createHmacSignatureHeader = this.#config.autoCreateHmacHeader) {
|
|
1274
|
+
const request = {
|
|
1275
|
+
...config,
|
|
1276
|
+
headers: config.headers ?? {},
|
|
1277
|
+
url: endpoint,
|
|
1278
|
+
};
|
|
1279
|
+
if (createHmacSignatureHeader) {
|
|
1280
|
+
const paramsSerialized = config.method === 'GET' ?
|
|
1281
|
+
new URLSearchParams(config.params ?? {}).toString()
|
|
1282
|
+
: JSON.stringify(config.data);
|
|
1283
|
+
Object.assign(request.headers, (0, _utils_1.createHmacRestRequestSignatureHeader)(paramsSerialized, this.#apiSecret));
|
|
1284
|
+
}
|
|
1285
|
+
return this.axios(request);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
exports.RestAuthenticatedClient = RestAuthenticatedClient;
|
|
1289
|
+
/**
|
|
1290
|
+
* @internal
|
|
1291
|
+
*
|
|
1292
|
+
* Ensures that {@link signer} is provided either by constructor definition
|
|
1293
|
+
* or manually dependent on the use-case.
|
|
1294
|
+
*
|
|
1295
|
+
* - SDK use case by end-user should always be provided via constructor
|
|
1296
|
+
* definition so the manual define case is for internal purposes only.
|
|
1297
|
+
*/
|
|
1298
|
+
function ensureSigner(signer) {
|
|
1299
|
+
if (!signer) {
|
|
1300
|
+
throw new Error('A "signer" function is required but was not provided during RestAuthenticatedClient constructor or when calling the method');
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* @internal
|
|
1305
|
+
*/
|
|
1306
|
+
function getWithdrawalRequestBridgeAdapterParametersForTarget() {
|
|
1307
|
+
return {
|
|
1308
|
+
bridgeAdapterAddress: ethers_1.ethers.ZeroAddress,
|
|
1309
|
+
bridgeAdapterPayload: '0x',
|
|
1310
|
+
};
|
|
1311
|
+
}
|