import { EncodeObject } from '@cosmjs/proto-signing'; import { Account, GasPrice, IndexedTx, StdFee } from '@cosmjs/stargate'; import { BroadcastTxAsyncResponse, BroadcastTxSyncResponse } from '@cosmjs/tendermint-rpc/build/tendermint37'; import { GetAuthenticatorsResponse } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/accountplus/query'; import { Order_TimeInForce } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order'; import { GovAddNewMarketParams, OrderFlags } from '../types'; import { Authenticator, AuthenticatorType, Network, OrderExecution, OrderSide, OrderTimeInForce, OrderType, SelectedGasDenom } from './constants'; import { IndexerClient } from './indexer-client'; import LocalWallet from './modules/local-wallet'; import { SubaccountInfo } from './subaccount'; import { BroadcastMode, IBuilderCodeParameters, ITwapParameters, OrderBatch } from './types'; import { ValidatorClient } from './validator-client'; export interface MarketInfo { clobPairId: number; atomicResolution: number; stepBaseQuantums: number; quantumConversionExponent: number; subticksPerTick: number; } export interface OrderBatchWithMarketId { marketId: string; clobPairId?: number; clientIds: number[]; } export type PlaceOrderPayload = { subaccountNumber: number; marketId: string; type: OrderType; side: OrderSide; price: number; size: number; clientId: number; timeInForce?: OrderTimeInForce; goodTilTimeInSeconds?: number; execution?: OrderExecution; postOnly?: boolean; reduceOnly?: boolean; triggerPrice?: number; marketInfo?: MarketInfo; currentHeight?: number; goodTilBlock?: number; twapParameters?: ITwapParameters; builderCodeParameters?: IBuilderCodeParameters; orderRouterAddress?: string; }; export type CancelRawOrderPayload = { subaccountNumber: number; clientId: number; orderFlags: OrderFlags; clobPairId: number; goodTilBlock?: number; goodTilBlockTime?: number; }; export type TransferToSubaccountPayload = { sourceSubaccountNumber: number; recipientSubaccountNumber: number; transferAmount: string; }; export declare class CompositeClient { readonly network: Network; gasDenom: SelectedGasDenom; private _indexerClient; private _validatorClient?; static connect(network: Network): Promise; private constructor(); private initialize; get indexerClient(): IndexerClient; get validatorClient(): ValidatorClient; get selectedGasDenom(): SelectedGasDenom | undefined; setSelectedGasDenom(gasDenom: SelectedGasDenom): void; populateAccountNumberCache(address: string): Promise; /** * @description Sign a list of messages with a wallet. * the calling function is responsible for creating the messages. * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The Signature. */ sign(subaccount: SubaccountInfo, messaging: () => Promise, zeroFee: boolean, gasPrice?: GasPrice, memo?: string, account?: () => Promise): Promise; /** * @description Send a list of messages with a wallet. * the calling function is responsible for creating the messages. * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The Transaction Hash. */ send(subaccount: SubaccountInfo, messaging: () => Promise, zeroFee: boolean, gasPrice?: GasPrice, memo?: string, broadcastMode?: BroadcastMode, account?: () => Promise): Promise; /** * @description Send a signed transaction. * * @param signedTransaction The signed transaction to send. * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The Transaction Hash. */ sendSignedTransaction(signedTransaction: Uint8Array): Promise; /** * @description Simulate a list of messages with a wallet. * the calling function is responsible for creating the messages. * * To send multiple messages with gas estimate: * 1. Client is responsible for creating the messages. * 2. Call simulate() to get the gas estimate. * 3. Call send() to send the messages. * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The gas estimate. */ simulate(subaccount: SubaccountInfo, messaging: () => Promise, gasPrice?: GasPrice, memo?: string, account?: () => Promise): Promise; /** * @description Calculate the goodTilBlock value for a SHORT_TERM order * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The goodTilBlock value */ private calculateGoodTilBlock; /** * @description Validate the goodTilBlock value for a SHORT_TERM order * * @param goodTilBlock Number of blocks from the current block height the order will * be valid for. * * @throws UserError if the goodTilBlock value is not valid given latest block height and * SHORT_BLOCK_WINDOW. */ private validateGoodTilBlock; /** * @description Calculate the goodTilBlockTime value for a LONG_TERM order * the calling function is responsible for creating the messages. * * @param goodTilTimeInSeconds The goodTilTimeInSeconds of the order to place. * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The goodTilBlockTime value */ private calculateGoodTilBlockTime; /** * @description Place a short term order with human readable input. * * Use human readable form of input, including price and size * The quantum and subticks are calculated and submitted * * @param subaccount The subaccount to place the order under * @param marketId The market to place the order on * @param side The side of the order to place * @param price The price of the order to place * @param size The size of the order to place * @param clientId The client id of the order to place * @param timeInForce The time in force of the order to place * @param goodTilBlock The goodTilBlock of the order to place * @param reduceOnly The reduceOnly of the order to place * @param builderCodeParameters The builder code parameters of the order to place. * @param orderRouterAddress The order router address of the order to place. * * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The transaction hash. */ placeShortTermOrder(subaccount: SubaccountInfo, marketId: string, side: OrderSide, price: number, size: number, clientId: number, goodTilBlock: number, timeInForce: Order_TimeInForce, reduceOnly: boolean, memo?: string, builderCodeParameters?: IBuilderCodeParameters, orderRouterAddress?: string): Promise; /** * @description Place an order with human readable input. * * Only MARKET and LIMIT types are supported right now * Use human readable form of input, including price and size * The quantum and subticks are calculated and submitted * * @param subaccount The subaccount to place the order on. * @param marketId The market to place the order on. * @param type The type of order to place. * @param side The side of the order to place. * @param price The price of the order to place. * @param size The size of the order to place. * @param clientId The client id of the order to place. * @param timeInForce The time in force of the order to place. * @param goodTilTimeInSeconds The goodTilTimeInSeconds of the order to place. * @param execution The execution of the order to place. * @param postOnly The postOnly of the order to place. * @param reduceOnly The reduceOnly of the order to place. * @param triggerPrice The trigger price of conditional orders. * @param marketInfo optional market information for calculating quantums and subticks. * This can be constructed from Indexer API. If set to null, additional round * trip to Indexer API will be made. * @param currentHeight Current block height. This can be obtained from ValidatorClient. * If set to null, additional round trip to ValidatorClient will be made. * @param goodTilBlock The goodTilBlock of the order to place. * @param twapParameters The twap parameters of the order to place. * @param builderCodeParameters The builder code parameters of the order to place. * @param orderRouterAddress The order router address of the order to place. * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The transaction hash. */ placeOrder(subaccount: SubaccountInfo, marketId: string, type: OrderType, side: OrderSide, price: number, size: number, clientId: number, timeInForce?: OrderTimeInForce, goodTilTimeInSeconds?: number, execution?: OrderExecution, postOnly?: boolean, reduceOnly?: boolean, triggerPrice?: number, marketInfo?: MarketInfo, currentHeight?: number, goodTilBlock?: number, memo?: string, broadcastMode?: BroadcastMode, twapParameters?: ITwapParameters, builderCodeParameters?: IBuilderCodeParameters, orderRouterAddress?: string): Promise; /** * @description Calculate and create the place order message * * Only MARKET and LIMIT types are supported right now * Use human readable form of input, including price and size * The quantum and subticks are calculated and submitted * * @param subaccount The subaccount to place the order under * @param marketId The market to place the order on * @param type The type of order to place * @param side The side of the order to place * @param price The price of the order to place * @param size The size of the order to place * @param clientId The client id of the order to place * @param timeInForce The time in force of the order to place * @param goodTilTimeInSeconds The goodTilTimeInSeconds of the order to place * @param execution The execution of the order to place * @param postOnly The postOnly of the order to place * @param reduceOnly The reduceOnly of the order to place * * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The message to be passed into the protocol */ private placeOrderMessage; private retrieveMarketInfo; /** * @description Calculate and create the short term place order message * * Use human readable form of input, including price and size * The quantum and subticks are calculated and submitted * * @param subaccount The subaccount to place the order under * @param marketId The market to place the order on * @param side The side of the order to place * @param price The price of the order to place * @param size The size of the order to place * @param clientId The client id of the order to place * @param timeInForce The time in force of the order to place * @param goodTilBlock The goodTilBlock of the order to place * @param reduceOnly The reduceOnly of the order to place * @param builderCodeParameters The builder code parameters of the order to place. * @param orderRouterAddress The order router address of the order to place. * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The message to be passed into the protocol */ private placeShortTermOrderMessage; /** * @description Cancel an order with order information from web socket or REST. * * @param subaccount The subaccount to cancel the order from * @param clientId The client id of the order to cancel * @param orderFlags The order flags of the order to cancel * @param clobPairId The clob pair id of the order to cancel * @param goodTilBlock The goodTilBlock of the order to cancel * @param goodTilBlockTime The goodTilBlockTime of the order to cancel * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The transaction hash. */ cancelRawOrder(subaccount: SubaccountInfo, clientId: number, orderFlags: OrderFlags, clobPairId: number, goodTilBlock?: number, goodTilBlockTime?: number): Promise; /** * @description Cancel an order with human readable input. * * @param subaccount The subaccount to cancel the order from * @param clientId The client id of the order to cancel * @param orderFlags The order flags of the order to cancel * @param marketId The market to cancel the order on * @param goodTilBlock The goodTilBlock of the order to cancel * @param goodTilBlockTime The goodTilBlockTime of the order to cancel * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The transaction hash. */ cancelOrder(subaccount: SubaccountInfo, clientId: number, orderFlags: OrderFlags, marketId: string, goodTilBlock?: number, goodTilTimeInSeconds?: number): Promise; /** * @description Batch cancel short term orders using marketId to clobPairId translation. * * @param subaccount The subaccount to cancel the order from * @param shortTermOrders The list of short term order batches to cancel with marketId * @param goodTilBlock The goodTilBlock of the order to cancel * @returns The transaction hash. */ batchCancelShortTermOrdersWithMarketId(subaccount: SubaccountInfo, shortTermOrders: OrderBatchWithMarketId[], goodTilBlock: number, broadcastMode?: BroadcastMode): Promise; /** * @description Batch cancel short term orders using clobPairId. * * @param subaccount The subaccount to cancel the order from * @param shortTermOrders The list of short term order batches to cancel with clobPairId * @param goodTilBlock The goodTilBlock of the order to cancel * @returns The transaction hash. */ batchCancelShortTermOrdersWithClobPairId(subaccount: SubaccountInfo, shortTermOrders: OrderBatch[], goodTilBlock: number, broadcastMode?: BroadcastMode): Promise; /** * @description Transfer from a subaccount to another subaccount * * @param subaccount The subaccount to transfer from * @param recipientAddress The recipient address * @param recipientSubaccountNumber The recipient subaccount number * @param amount The amount to transfer * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The transaction hash. */ transferToSubaccount(subaccount: SubaccountInfo, recipientAddress: string, recipientSubaccountNumber: number, amount: string, memo?: string, broadcastMode?: BroadcastMode): Promise; /** * @description Create message to transfer from a subaccount to another subaccount * * @param subaccount The subaccount to transfer from * @param recipientAddress The recipient address * @param recipientSubaccountNumber The recipient subaccount number * @param amount The amount to transfer * * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The message */ transferToSubaccountMessage(subaccount: SubaccountInfo, recipientAddress: string, recipientSubaccountNumber: number, amount: string): EncodeObject; /** * @description Deposit from wallet to subaccount * * @param subaccount The subaccount to deposit to * @param amount The amount to deposit * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The transaction hash. */ depositToSubaccount(subaccount: SubaccountInfo, amount: string, memo?: string): Promise; /** * @description Create message to deposit from wallet to subaccount * * @param subaccount The subaccount to deposit to * @param amount The amount to deposit * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The message */ depositToSubaccountMessage(subaccount: SubaccountInfo, amount: string): EncodeObject; /** * @description Withdraw from subaccount to wallet * * @param subaccount The subaccount to withdraw from * @param amount The amount to withdraw * @param recipient The recipient address, default to subaccount address * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The transaction hash */ withdrawFromSubaccount(subaccount: SubaccountInfo, amount: string, recipient?: string, memo?: string): Promise; /** * @description Create message to withdraw from subaccount to wallet * with human readable input. * * @param subaccount The subaccount to withdraw from * @param amount The amount to withdraw * @param recipient The recipient address * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The message */ withdrawFromSubaccountMessage(subaccount: SubaccountInfo, amount: string, recipient?: string): EncodeObject; /** * @description Create message to send chain token from subaccount to wallet * with human readable input. * * @param subaccount The subaccount to withdraw from * @param amount The amount to withdraw * @param recipient The recipient address * * @throws UnexpectedClientError if a malformed response is returned with no GRPC error * at any point. * @returns The message */ sendTokenMessage(wallet: LocalWallet, amount: string, recipient: string): EncodeObject; signPlaceOrder(subaccount: SubaccountInfo, marketId: string, type: OrderType, side: OrderSide, price: number, size: number, clientId: number, timeInForce: OrderTimeInForce, goodTilTimeInSeconds: number, execution: OrderExecution, postOnly: boolean, reduceOnly: boolean): Promise; signCancelOrder(subaccount: SubaccountInfo, clientId: number, orderFlags: OrderFlags, clobPairId: number, goodTilBlock: number, goodTilBlockTime: number): Promise; bulkCancelAndTransferAndPlaceStatefulOrders(subaccount: SubaccountInfo, cancelOrderPayloads: CancelRawOrderPayload[], transferToSubaccountPayload: TransferToSubaccountPayload | undefined, placeOrderPayloads: PlaceOrderPayload[], memo?: string, broadcastMode?: BroadcastMode): Promise; depositToMegavault(subaccount: SubaccountInfo, amountUsdc: number, broadcastMode?: BroadcastMode): Promise; depositToMegavaultMessage(subaccount: SubaccountInfo, amountUsdc: number): EncodeObject; withdrawFromMegavault(subaccount: SubaccountInfo, shares: number, minAmount: number, broadcastMode?: BroadcastMode): Promise; withdrawFromMegavaultMessage(subaccount: SubaccountInfo, shares: number, minAmount: number): EncodeObject; /** * @description Submit a governance proposal to add a new market. * * @param params Parameters neeeded to create a new market. * @param title Title of the gov proposal. * @param summary Summary of the gov proposal. * @param initialDepositAmount Initial deposit amount of the gov proposal. * @param proposer proposer of the gov proposal. * * @returns the transaction hash. */ submitGovAddNewMarketProposal(wallet: LocalWallet, params: GovAddNewMarketParams, title: string, summary: string, initialDepositAmount: string, memo?: string, metadata?: string, expedited?: boolean): Promise; createMarketPermissionless(subaccount: SubaccountInfo, ticker: string, broadcastMode?: BroadcastMode, gasAdjustment?: number, memo?: string): Promise; addAuthenticator(subaccount: SubaccountInfo, authenticatorType: AuthenticatorType, data: Uint8Array): Promise; removeAuthenticator(subaccount: SubaccountInfo, id: string): Promise; getAuthenticators(address: string): Promise; validateAuthenticator(authenticator: Authenticator): boolean; } //# sourceMappingURL=composite-client.d.ts.map