Readonly
publicWhen creating an authenticated client, a RestPublicClient is automatically created and can be used based on the config given for this client.
import { RestAuthenticatedClient } from '@idexio/idex-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 RestPublicClient
The RestAuthenticatedClient is used to make authenticated requests to the IDEX 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 IDEX Sandbox API.import { RestAuthenticatedClient } from '@idexio/idex-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
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
});
Returns information about a single withdrawal matching the request.
Endpoint Parameters
Returns information about withdrawals to a wallet.
Endpoint Parameters
Create and submit an order to the matching engine.
Endpoint Parameters
import { OrderType, OrderSide } from '@idexio/idex-sdk';
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'
});
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 orderId request parameter.
client:
.Endpoint Parameters
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 MarketMakerRewardsEpochDetailedWithWallet
When not providing a wallet, the resulting response will be 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.0
Endpoint Parameters
import { PayoutProgram } from '@idexio/idex-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 '@idexio/idex-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
const wallet = await client.associateWallet({
nonce: uuidv1(),
wallet: '0xA71C4aeeAabBBB8D2910F41C2ca3964b81F7310d',
});
Returns information about the wallets associated with the API account.
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 authenticated subscriptions in the WebSocket API.
Endpoint Parameters
A convenience method that helps capture the appropriate value for the withdraw method's maximumGasFee parameter.
publicClient.getGasFees
and adds the defined maximumSlippagePercent
to it.0.05000000
and maximumSlippagePercent
is 0.10000000
(10%) then result would be 0.05500000
The 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 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 IDEX 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 IDEX Sandbox API.Example
See