Readonly publicWhen creating an authenticated client, a katanaperps.RestPublicClient RestPublicClient is automatically created and can be used based on the config given for this client.
import { RestAuthenticatedClient } from '@katanaperps/katana-perps-sdk';
// Edit the values before for your environment
const client = new RestAuthenticatedClient({
sandbox: true,
apiKey: '1f7c4f52-4af7-4e1b-aa94-94fac8d931aa',
apiSecret: 'axuh3ywgg854aq7m73oy6gnnpj5ar9a67szuw5lclbz77zqu0j',
walletPrivateKey: '0x...'
});
const wallets = await client.getWallets();
client katanaperps.RestPublicClient RestPublicClient
The RestAuthenticatedClient is used to make authenticated requests to the Katana Perps API. It includes methods that make requests on behalf of a specific wallet such as creating and cancelling orders.
true in order to point to the Katana Perps Sandbox API.import { RestAuthenticatedClient } from '@katanaperps/katana-perps-sdk';
// Edit the values before for your environment
const client = new RestAuthenticatedClient({
sandbox: true,
apiKey: '1f7c4f52-4af7-4e1b-aa94-94fac8d931aa',
apiSecret: 'axuh3ywgg854aq7m73oy6gnnpj5ar9a67szuw5lclbz77zqu0j',
walletPrivateKey: '0x...'
});
const wallets = await client.getWallets();
Returns information about deposits made by a wallet.
Endpoint Parameters
Returns information about deposits made by a wallet.
Endpoint Parameters
- HTTP Request:
GET /v1/deposits- Endpoint Security: User Data
- API Key Scope: Read
- Pagination: katanaperps.RestRequestPaginationWithFromId.start start, katanaperps.RestRequestPaginationWithFromId.end end, katanaperps.RestRequestPaginationWithFromId.limit limit, katanaperps.RestRequestPaginationWithFromId.fromId fromId
Withdraw funds from the exchange.
Endpoint Parameters
// returns the max gas fee in USD you will accept for a withdrawal
const maximumGasFee = await client.calculateWithdrawalMaximumGasFee({
bridgeTarget: BridgeTarget.STARGATE_ETHEREUM,
// 10% slippage alllowed (default)
maximumSlippagePercent: '0.10000000'
});
// never pay more than $1 USD in gas fees to withdrawal
if (Number(maximumGasFee) >= 1) {
throw new Error('Too Much Gas cost to Withdraw! ${maximumGasFee} USD >= 1 USD!');
}
const withdrawal = await client.withdraw({
nonce: uuidv1(),
wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
quantity: '100.00000000',
maximumGasFee,
bridgeTarget: BridgeTarget.STARGATE_ETHEREUM
});
Transfer collateral to another wallet without leaving the exchange.
Endpoint Parameters
const transfer = await client.transfer({
nonce: uuidv1(),
wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
targetWallet: '0x8bC1a9B2b6b1a17c8574c9E3fC5A2c2b1DfF9D1e',
quantity: '100.00000000',
maximumGasFee: '0.00000000',
});
Returns information about a single withdrawal matching the request.
Endpoint Parameters
Returns information about withdrawals to a wallet.
Endpoint Parameters
- HTTP Request:
GET /v1/withdrawals- Endpoint Security: User Data
- API Key Scope: Read
- Pagination: katanaperps.RestRequestPaginationWithFromId.start start, katanaperps.RestRequestPaginationWithFromId.end end, katanaperps.RestRequestPaginationWithFromId.limit limit, katanaperps.RestRequestPaginationWithFromId.fromId fromId
Get a single fill from the API by your requests katanaperps.RestRequestGetFill.fillId fillId parameter.
Endpoint Parameters
Get an array of KatanaPerpsFill objects matching your request parameters.
Endpoint Parameters
- HTTP Request:
GET /v1/fills- Endpoint Security: User Data
- API Key Scope: Read
- Pagination: katanaperps.RestRequestPaginationWithFromId.start start, katanaperps.RestRequestPaginationWithFromId.end end, katanaperps.RestRequestPaginationWithFromId.limit limit, katanaperps.RestRequestPaginationWithFromId.fromId fromId
Get Funding Payments for wallet matching katanaperps.KatanaPerpsFundingPayment KatanaPerpsFundingPayment
Endpoint Parameters
Get Historical PnL for the wallet / market matching katanaperps.KatanaPerpsHistoricalProfitLoss KatanaPerpsHistoricalProfitLoss
Endpoint Parameters
Create and submit an order to the matching engine.
Endpoint Parameters
import { OrderType, OrderSide } from '@katanaperps/katana-perps-sdk';
try {
const order = await client.createOrder({
// always use the enum and define it first so that
// the type of this params object change to the
// appropriate interface with completion hints in IDE!
type: OrderType.market,
// this object is now narrowed to
// interface: RestRequestOrderTypeMarket
side: OrderSide.buy,
nonce: uuidv1(),
wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
market: 'ETH-USD',
quantity: '10.00000000'
});
} catch(e) {
// order placement failed with an unexpected error
// you may use isAxiosError(e) for stronger typing here if desired
if (e.response?.data?.code === 'INSUFFICIENT_FUNDS') {
// handle insufficient funds errors
console.log('Insufficient funds to create order');
}
}
Cancel multiple matching orders using one of the following methods:
Endpoint Parameters
const allOrders = client.cancelOrders({
nonce: uuidv1(),
wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
});
const ordersForMarket = client.cancelOrders({
nonce: uuidv1(),
wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
market: 'ETH-USD'
});
Returns an order matching your katanaperps.RestRequestGetOrder.orderId orderId request parameter.
client:.Endpoint Parameters
Returns information about open and past orders.
Endpoint Parameters
- HTTP Request:
GET /v1/orders- Endpoint Security: User Data
- API Key Scope: Read
- Pagination: katanaperps.RestRequestPaginationWithFromId.start start, katanaperps.RestRequestPaginationWithFromId.end end, katanaperps.RestRequestPaginationWithFromId.limit limit, katanaperps.RestRequestPaginationWithFromId.fromId fromId
Endpoint Parameters
This method has two overloads to provide type-safe responses:
The Get Epoch endpoint provides detailed information about epoch configuration as well as wallet epoch performance.
When providing a wallet address, the resulting response will be katanaperps.MarketMakerRewardsEpochDetailedWithWallet MarketMakerRewardsEpochDetailedWithWallet
When not providing a katanaperps.RestRequestGetMarketMakerRewardsEpochWithWallet.wallet wallet, the resulting response will be katanaperps.MarketMakerRewardsEpochDetailedWithoutWallet MarketMakerRewardsEpochDetailedWithoutWallet
The Get Epochs endpoint provides a list of the defined market maker rewards epochs.
Endpoint Parameters
Returns information about a payout program and the requested wallets earned/paid amounts for the program.
distribute
function of the escrow contract.0Endpoint Parameters
import { PayoutProgram } from '@katanaperps/katana-perps-sdk';
// create client
await client.authorizePayout({
wallet: '0x...',
nonce: uuidv1(),
// use the PayoutProgram enum for inline auto completion
program: PayoutProgram.tradingRewardsV2
});
Returns information about a payout program and the requested wallets earned/paid amounts for the program.
Endpoint Parameters
import { PayoutProgram } from '@katanaperps/katana-perps-sdk';
// create client
await client.getPayouts({
wallet: '0x...',
nonce: uuidv1(),
// use the PayoutProgram enum for inline auto completion
program: PayoutProgram.tradingRewardsV2
});
Associates a wallet with an API account, allowing access to private data such as fills. Associating a wallet with an API account is often the first step in interacting with private read endpoints.
Endpoint Parameters
Optional referralCode: stringconst wallet = await client.associateWallet({
nonce: uuidv1(),
wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
});
Returns information about the wallets associated with the API account.
Endpoint Parameters
Returns all wallet addresses associated with the API key used to make the request, sorted alphabetically.
Endpoint Parameters
Returns delegated keys authorized for the requested wallet.
Endpoint Parameters
Authorizes a delegated public key for API trading on behalf of the custody wallet (signed).
Endpoint Parameters
Optional name on the request is a client label and must be 64 characters or fewer when provided.
Revokes a previously authorized delegated key (signed).
Endpoint Parameters
Get Positions
Endpoint Parameters
Override minimum Initial Margin Fraction for wallet for a market
Endpoint Parameters
Get Initial Margin Fraction overrides for wallet for a market or all markets
Endpoint Parameters
Returns a single-use authentication token as a string for access to katanaperps.SubscriptionNameAuthenticated authenticated subscriptions in the WebSocket API.
Endpoint Parameters
A convenience method that helps capture the appropriate value for the withdraw method's katanaperps.RestRequestWithdrawFundsBase.maximumGasFee maximumGasFee parameter.
publicClient.getGasFees and adds the defined maximumSlippagePercent to it.0.05000000 and maximumSlippagePercent is 0.10000000 (10%) then result would be 0.05500000The bridge target for the withdrawal of funds.
enum BridgeTarget
Maximum slippage percent in pips percent format (ex 0.10000000 for 10%)
// 10%
'0.10000000'
maximumSlippagePercent added. This value should always
be validated by your application before calling withdraw method with this
as your katanaperps.RestRequestWithdrawFundsBase.maximumGasFee maximumGasFee
parameter.// returns the max gas fee in USD you will accept for a withdrawal
const maximumGasFee = await client.calculateWithdrawalMaximumGasFee({
bridgeTarget: BridgeTarget.STARGATE_ETHEREUM,
// 10% slippage alllowed (default)
maximumSlippagePercent: '0.10000000'
});
// never pay more than $1 USD in gas fees to withdrawal
if (Number(maximumGasFee) >= 1) {
throw new Error('Too Much Gas cost to Withdraw! ${maximumGasFee} USD >= 1 USD!');
}
const withdrawal = await client.withdraw({
nonce: uuidv1(),
wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
quantity: '100.00000000',
maximumGasFee,
bridgeTarget: BridgeTarget.STARGATE_ETHEREUM
});
The RestAuthenticatedClient is used to make authenticated requests to the Katana Perps API. It includes methods that make requests on behalf of a specific wallet such as creating and cancelling orders.
truein order to point to the Katana Perps Sandbox API.Example
See