From 68cac470cfa30cca3eb243816c82a180d72bd180 Mon Sep 17 00:00:00 2001 From: Tomer Vilensky Date: Wed, 15 Jul 2020 17:15:30 +0300 Subject: [PATCH] Fees endpoints --- src/fireblocks-sdk.ts | 18 +++++++++++++++++- src/types.ts | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index 32e1b30f..df75170b 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -21,7 +21,9 @@ import { TransferTicketResponse, TermResponse, ExecuteTermArgs, - CreateTransferTicketResponse + CreateTransferTicketResponse, + EstimateTransactionFeeResponse, + EstimateFeeResponse } from "./types"; export * from "./types"; @@ -440,6 +442,20 @@ export class FireblocksSDK { return await this.apiClient.issuePostRequest("/v1/transactions", options); } + /** + * Estimates the fee for a transaction request + */ + public async estimateFeeForTransaction(options: TransactionArguments): Promise { + return await this.apiClient.issuePostRequest("/v1/transactions/estimate_fee", options); + } + + /** + * Gets the estimated fees for an asset + */ + public async getFeeForAsset(asset: string): Promise { + return await this.apiClient.issueGetRequest(`/v1/estimate_network_fee?assetId=${asset}`); + } + /** * Creates a new transfer ticket */ diff --git a/src/types.ts b/src/types.ts index 986ef802..57e37f37 100644 --- a/src/types.ts +++ b/src/types.ts @@ -47,6 +47,31 @@ export interface CreateTransactionResponse { status: string; } +export interface EstimateFeeResponse { + low: EstimatedFee; + medium: EstimatedFee; + high: EstimatedFee; +} + +export interface EstimateTransactionFeeResponse { + low: EstimatedTransactionFee; + medium: EstimatedTransactionFee; + high: EstimatedTransactionFee; +} + +export interface EstimatedFee { + networkFee?: string; + gasPrice?: string; + feePerByte?: string; +} + +export interface EstimatedTransactionFee { + networkFee?: string; + gasPrice?: string; + gasLimit?: string; + feePerByte?: string; +} + export interface TransferPeerPath { type: PeerType; id: string;