krav-sdk-beta v0.2.0
Krav SDK
Hooks
- useSupportedPools - Get supported pools
- usePoolInfo - Get pool information
- useAvailableBalance - Get available token balance for trading
- useAvailableLiquidity - Get available liquidity for trading
- useOrderLimit - Get order size limit for a pool
- useOpenTrades - Get open trades
- useOpenLimitOrders - Get open limit orders
- useHistoryTrades - Get historical trades
- useCloseTrade - Close an open trade
- useClaimTrade - Claim funds from a closed trade
- useCancelLimitOrder - Cancel a limit order
- useTradeBeforeActions - Check and approve trade authorization
- useConfirmTrade - Execute a trade
- useGetBTCPrice - Get Bitcoin price from an oracle
- useUpdateTrade
useSupportedPools
This hook is used to get the supported pools. Returns an array of supported pools.
const { data: supportedPools } = useSupportedPools()
usePoolInfo
This hook is used to get information about a given pool.
const poolInfo = usePoolInfo(tradePool?.tradingT)
Parameters:
- tradingT: Trading contract address of the pool
useAvailableBalance
This hook is used to get the available balance of the trading contract for a given pool.
const availableBalance = useAvailableBalance(tradePool?.tradingT)
Parameters:
- tradingT: Trading contract address of the pool
useAvailableLiquidity
This hook is used to get the available liquidity for a given pool.
const availableLiquidity = useAvailableLiquidity(tradePool?.tradingT)
Parameters:
- tradingT: Trading contract address of the pool
useOrderLimit
This hook is used to get the order limit for a given pool.
const { data: orderLimit } = useOrderLimit(tradePool)
Parameters:
- tradePool: Pool object
useOpenTrades
This hook is used to get the open trade records for a given pool.
const { data: openTrades } = useOpenTrades(tradePool?.storageT)
Parameters:
- storageT: Storage contract address of the pool
useOpenLimitOrders
This hook is used to get the open limit orders for a given pool.
const { data: openLimitOrders } = useOpenLimitOrders(tradePool?.storageT)
Parameters:
- storageT: Storage contract address of the pool
useHistoryTrades
This hook is used to get the historical trade records for a given pool.
const { data: historyTrades } = useHistoryTrades(tradePool)
Parameters:
- tradePool: Pool object
useCloseTrade
This hook is used to close an open trade for a given pool.
const closeTrade = useCloseTrade(tradePool?.tradingT)
Parameters:
- tradingT: Trading contract address of the pool
useClaimTrade
This hook is used to claim funds from a closed trade.
const claimTrade = useClaimTrade(tradePool?.tradingT)
Parameters:
- tradingT: Trading contract address of the pool
useCancelLimitOrder
This hook is used to cancel a limit order for a given pool.
const cancelLimitOrder = useCancelLimitOrder(tradePool?.tradingT || '')
Parameters:
- tradingT: Trading contract address of the pool
useTradeBeforeActions
This hook is used to check and approve trade authorization before executing a trade.
const { check, approve } = useTradeBeforeActions(tradePool)
Parameters:
- tradePool: Pool object
useConfirmTrade
This hook is used to confirm a trade for a given pool.
const confirmTrade = useConfirmTrade(tradePool?.tradingT)
Parameters:
- tradingT: Trading contract address of the pool
useGetBTCPrice
This hook is used to get the current price of Bitcoin.
const getBTCPrice = useGetBTCPrice()
const { data: BTCPrice } = useRequest(async () => getBTCPrice(), { manual: false })
useUpdateTrade
This hook is used to get the current price of Bitcoin.
const updateTrade = useUpdateTrade(tradePool?.tradingT)