Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion integration-test/test/pegin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assertTruthy, ethers, BlockchainReadOnlyConnection } from '@rsksmart/br
import { integrationTestConfig } from '../config'
import { fakeTokenResolver, getUtxosFromMempoolSpace } from './common/utils'
import { Transaction, payments, networks } from 'bitcoinjs-lib'
import { TEST_CONTRACT_ABI } from './common/constants'
import { EXTENDED_TIMEOUT, TEST_CONTRACT_ABI } from './common/constants'

describe('Flyover pegin process should', () => {
let flyover: Flyover
Expand Down Expand Up @@ -190,6 +190,20 @@ describe('Flyover pegin process should', () => {
expect(result).toBe('')
})

test('get recommended value for quote total', async () => {
const result = await flyover.estimateRecommendedPegin(
FlyoverUtils.getQuoteTotal(quote),
{
data: quote.quote.data,
destinationAddress: quote.quote.contractAddr
}
);
expect(result.estimatedCallFee.toString()).toEqual(quote.quote.callFee.toString());
expect(result.estimatedGasFee.toString()).toEqual(quote.quote.gasFee.toString());
expect(result.estimatedProductFee.toString()).toEqual(quote.quote.productFeeAmount.toString());
expect(result.recommendedQuoteValue.toString()).toEqual(quote.quote.value.toString());
}, EXTENDED_TIMEOUT)

test('get a smart contract interaction quote', async () => {
const smartContractData = new ethers.utils.Interface(TEST_CONTRACT_ABI)
.encodeFunctionData('save', [integrationTestConfig.rskAddress])
Expand Down
11 changes: 11 additions & 0 deletions integration-test/test/pegout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ describe('Flyover pegout process should', () => {
expect(creationData.feeRate).not.toBeUndefined()
}, EXTENDED_TIMEOUT)

test('get recommended value for quote total', async () => {
const result = await flyover.estimateRecommendedPegout(
FlyoverUtils.getQuoteTotal(selectedQuote),
{ destinationAddressType: 'p2pkh' }
);
expect(result.estimatedCallFee.toString()).toEqual(selectedQuote.quote.callFee.toString());
expect(result.estimatedGasFee.toString()).toEqual(selectedQuote.quote.gasFee.toString());
expect(result.estimatedProductFee.toString()).toEqual(selectedQuote.quote.productFeeAmount.toString());
expect(result.recommendedQuoteValue.toString()).toEqual(selectedQuote.quote.value.toString());
}, EXTENDED_TIMEOUT)

test.skip('[DISABLED: until we have a way to force a quote expiration] execute refungPegout to get back amount', async () => {
const txHash = await flyover.refundPegout(selectedQuote)
expect([null, undefined, '']).not.toContain(txHash)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rsksmart/flyover-sdk",
"version": "1.7.0",
"version": "1.8.0",
"description": "SDK that simplifies interaction between Flyover's Liquidity Provider Server and client applications",
"main": "lib/index.js",
"private": false,
Expand Down
33 changes: 33 additions & 0 deletions src/api/bindings/PeginRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
PeginConfigurationRequest,
PeginQuoteRequest,
PeginQuoteStatusDTO,
RecommendedOperationDTO,
} from "./data-contracts";

export namespace Pegin {
Expand Down Expand Up @@ -119,6 +120,38 @@ export namespace Pegin {

export const PostGetQuotePath = "/pegin/getQuote";

/**
* @description Returns the recommended quote value to create a quote whose total payment is the input amount
* @name RecommendedList
* @summary Recommended pegin
* @request GET:/pegin/recommended
*/
export namespace RecommendedList {
export type RequestParams = {};
export type RequestQuery = {
/**
* Amount in wei expected to use as total payment for the quote
* @format string
*/
amount: string;
/**
* Destination address for the pegin. Is optional, but if provided, it will increase the estimation accuracy.
* @format string
*/
destination_address?: string;
/**
* Hex-encoded data payload to include in the pegin transaction. Is optional, but if provided, it will increase the estimation accuracy.
* @format string
*/
data?: string;
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = RecommendedOperationDTO;
}

export const RecommendedListPath = "/pegin/recommended";

/**
* @description Returns the status of an accepted pegin quote
* @name StatusList
Expand Down
28 changes: 28 additions & 0 deletions src/api/bindings/PegoutRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
PegoutConfigurationRequest,
PegoutQuoteRequest,
PegoutQuoteStatusDTO,
RecommendedOperationDTO,
} from "./data-contracts";

export namespace Pegout {
Expand Down Expand Up @@ -119,6 +120,33 @@ export namespace Pegout {

export const PostGetQuotesPath = "/pegout/getQuotes";

/**
* @description Returns the recommended quote value to create a quote whose total payment is the input amount
* @name RecommendedList
* @summary Recommended pegout
* @request GET:/pegout/recommended
*/
export namespace RecommendedList {
export type RequestParams = {};
export type RequestQuery = {
/**
* Amount in wei expected to use as total payment for the quote
* @format string
*/
amount: string;
/**
* Destination address type for the pegout. Is optional, but if provided, it will increase the estimation accuracy. Must be one of: p2pkh, p2sh, p2wpkh, p2wsh, p2tr
* @format string
*/
destination_type?: string;
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = RecommendedOperationDTO;
}

export const RecommendedListPath = "/pegout/recommended";

/**
* @description Returns the status of an accepted pegout quote
* @name StatusList
Expand Down
180 changes: 180 additions & 0 deletions src/api/bindings/ReportsRoute.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/* eslint-disable */
/* tslint:disable */
/*
* ---------------------------------------------------------------
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
* ## ##
* ## AUTHOR: acacode ##
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
* ---------------------------------------------------------------
*/

import { GetTransactionsResponse, SummaryResultDTO } from "./data-contracts";

export namespace Reports {
/**
* @description Get the asset information for the LPS.
* @name AssetsList
* @summary Get asset Reports
* @request GET:/reports/assets
*/
export namespace AssetsList {
export type RequestParams = {};
export type RequestQuery = {};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = void;
}

export const AssetsListPath = "/reports/assets";

/**
* @description Get the last pegins on the API. Included in the management API.
* @name PeginList
* @summary Get Pegin Reports
* @request GET:/reports/pegin
*/
export namespace PeginList {
export type RequestParams = {};
export type RequestQuery = {
/**
* Start date for the report. Supports YYYY-MM-DD (expands to full day) or ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ)
* @format string
*/
startDate: string;
/**
* End date for the report. Supports YYYY-MM-DD (expands to end of day) or ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ)
* @format string
*/
endDate: string;
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = void;
}

export const PeginListPath = "/reports/pegin";

/**
* @description Get the last pegouts on the API. Included in the management API.
* @name PegoutList
* @summary Get Pegout Reports
* @request GET:/reports/pegout
*/
export namespace PegoutList {
export type RequestParams = {};
export type RequestQuery = {
/**
* Start date for the report. Supports YYYY-MM-DD (expands to full day) or ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ)
* @format string
*/
startDate: string;
/**
* End date for the report. Supports YYYY-MM-DD (expands to end of day) or ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ)
* @format string
*/
endDate: string;
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = void;
}

export const PegoutListPath = "/reports/pegout";

/**
* @description Get the revenue for the specified period.
* @name RevenueList
* @summary Get revenue Reports
* @request GET:/reports/revenue
*/
export namespace RevenueList {
export type RequestParams = {};
export type RequestQuery = {
/**
* Start date for the report. Supports YYYY-MM-DD (expands to full day) or ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ)
* @format string
*/
startDate: string;
/**
* End date for the report. Supports YYYY-MM-DD (expands to end of day) or ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ)
* @format string
*/
endDate: string;
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = void;
}

export const RevenueListPath = "/reports/revenue";

/**
* @description Returns financial data for a given period
* @name SummariesList
* @summary Summaries
* @request GET:/reports/summaries
*/
export namespace SummariesList {
export type RequestParams = {};
export type RequestQuery = {
/**
* Start date in YYYY-MM-DD format
* @format string
*/
startDate: string;
/**
* End date in YYYY-MM-DD format
* @format string
*/
endDate: string;
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = SummaryResultDTO;
}

export const SummariesListPath = "/reports/summaries";

/**
* @description Get a paginated list of individual transactions of a specific type processed by the liquidity provider within a specified time period
* @name TransactionsList
* @summary Get Transaction Reports
* @request GET:/reports/transactions
*/
export namespace TransactionsList {
export type RequestParams = {};
export type RequestQuery = {
/**
* Transaction type filter: 'pegin' or 'pegout'
* @format string
*/
type: string;
/**
* Start date for the report. Supports YYYY-MM-DD (expands to full day) or ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ)
* @format string
*/
startDate?: string;
/**
* End date for the report. Supports YYYY-MM-DD (expands to end of day) or ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ)
* @format string
*/
endDate?: string;
/**
* Page number to retrieve (1-indexed, default: 1)
* @format int64
*/
page?: number;
/**
* Number of transactions per page (max: 100, default: 10)
* @format int64
*/
perPage?: number;
};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = GetTransactionsResponse;
}

export const TransactionsListPath = "/reports/transactions";
}
Loading