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
13 changes: 12 additions & 1 deletion integration-test/test/pegin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,20 @@ describe('Flyover pegin process should', () => {
if (provider?.providerType === 'pegin' || provider?.providerType === 'both') {
expect(provider?.pegin).not.toBeUndefined()
expect(provider?.pegin.fee).not.toBeUndefined()
expect(provider?.pegin.feePercentage).not.toBeUndefined()
expect(provider?.pegin.fixedFee).not.toBeUndefined()
expect(provider?.pegin.maxTransactionValue).not.toBeUndefined()
expect(provider?.pegin.minTransactionValue).not.toBeUndefined()
expect(provider?.pegin.fixedFee).toBe(provider?.pegin.fee)
}
if (provider?.providerType === 'pegout' || provider?.providerType === 'both') {
expect(provider?.pegout).not.toBeUndefined()
expect(provider?.pegout.fee).not.toBeUndefined()
expect(provider?.pegout.feePercentage).not.toBeUndefined()
expect(provider?.pegout.fixedFee).not.toBeUndefined()
expect(provider?.pegout.maxTransactionValue).not.toBeUndefined()
expect(provider?.pegout.minTransactionValue).not.toBeUndefined()
expect(provider?.pegout.fixedFee).toBe(provider?.pegout.fee)
}
})

Expand Down Expand Up @@ -100,10 +106,11 @@ describe('Flyover pegin process should', () => {
test('get status of the accepted quote', async () => {
const quoteHash = quote.quoteHash
assertTruthy(quoteHash)
const { detail, status } = await flyover.getPeginStatus(quoteHash)
const { detail, status, creationData } = await flyover.getPeginStatus(quoteHash)

expect(detail).not.toBeUndefined()
expect(status).not.toBeUndefined()
expect(creationData).not.toBeUndefined()

expect(detail.agreementTimestamp).not.toBeUndefined()
expect(detail.btcRefundAddr).not.toBeUndefined()
Expand Down Expand Up @@ -134,6 +141,10 @@ describe('Flyover pegin process should', () => {
expect(status.signature).not.toBeUndefined()
expect(status.state).not.toBeUndefined()
expect(status.userBtcTxHash).not.toBeUndefined()

expect(creationData.fixedFee).not.toBeUndefined()
expect(creationData.gasPrice).not.toBeUndefined()
expect(creationData.feePercentage).not.toBeUndefined()
})

test('validate the PegIn deposit transaction', async () => {
Expand Down
14 changes: 13 additions & 1 deletion integration-test/test/pegout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ describe('Flyover pegout process should', () => {
if (provider?.providerType === 'pegin' || provider?.providerType === 'both') {
expect(provider?.pegin).not.toBeUndefined()
expect(provider?.pegin.fee).not.toBeUndefined()
expect(provider?.pegin.feePercentage).not.toBeUndefined()
expect(provider?.pegin.fixedFee).not.toBeUndefined()
expect(provider?.pegin.maxTransactionValue).not.toBeUndefined()
expect(provider?.pegin.minTransactionValue).not.toBeUndefined()
expect(provider?.pegin.fixedFee).toBe(provider?.pegin.fee)
}
if (provider?.providerType === 'pegout' || provider?.providerType === 'both') {
expect(provider?.pegout).not.toBeUndefined()
expect(provider?.pegout.fee).not.toBeUndefined()
expect(provider?.pegout.feePercentage).not.toBeUndefined()
expect(provider?.pegout.fixedFee).not.toBeUndefined()
expect(provider?.pegout.maxTransactionValue).not.toBeUndefined()
expect(provider?.pegout.minTransactionValue).not.toBeUndefined()
expect(provider?.pegout.fixedFee).toBe(provider?.pegout.fee)
}
})

Expand Down Expand Up @@ -120,10 +126,11 @@ describe('Flyover pegout process should', () => {
}, EXTENDED_TIMEOUT)

test('get status of the accepted quote', async () => {
const { detail, status } = await flyover.getPegoutStatus(selectedQuote.quoteHash)
const { detail, status, creationData } = await flyover.getPegoutStatus(selectedQuote.quoteHash)

expect(detail).not.toBeUndefined()
expect(status).not.toBeUndefined()
expect(creationData).not.toBeUndefined()

expect(detail.agreementTimestamp).not.toBeUndefined()
expect(detail.btcRefundAddress).not.toBeUndefined()
Expand Down Expand Up @@ -154,6 +161,11 @@ describe('Flyover pegout process should', () => {
expect(status.signature).not.toBeUndefined()
expect(status.state).not.toBeUndefined()
expect(status.userRskTxHash).not.toBeUndefined()

expect(creationData.fixedFee).not.toBeUndefined()
expect(creationData.gasPrice).not.toBeUndefined()
expect(creationData.feePercentage).not.toBeUndefined()
expect(creationData.feeRate).not.toBeUndefined()
}, EXTENDED_TIMEOUT)

test.skip('[DISABLED: until we have a way to force a quote expiration] execute refungPegout to get back amount', async () => {
Expand Down
30 changes: 30 additions & 0 deletions src/api/bindings/VersionRoute.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable */
/* tslint:disable */
/*
* ---------------------------------------------------------------
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
* ## ##
* ## AUTHOR: acacode ##
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
* ---------------------------------------------------------------
*/

import { ServerInfoDTO } from "./data-contracts";

export namespace Version {
/**
* @description Returns the server version and revision
* @name VersionList
* @summary Get server version
* @request GET:/version
*/
export namespace VersionList {
export type RequestParams = {};
export type RequestQuery = {};
export type RequestBody = never;
export type RequestHeaders = {};
export type ResponseBody = ServerInfoDTO;
}

export const VersionListPath = "/version";
}
62 changes: 56 additions & 6 deletions src/api/bindings/data-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export interface AvailableLiquidityDTO {
*/
peginLiquidityAmount: bigint;
/**
* Available liquidity for PegOut operations in satoshi
* @example "500000000"
* Available liquidity for PegOut operations in wei
* @example "5000000000000000000"
*/
pegoutLiquidityAmount: bigint;
}
Expand Down Expand Up @@ -208,8 +208,9 @@ export const LiquidityProviderRequiredFields: string[] = [
];

export interface PeginConfigurationDTO {
callFee?: bigint;
callTime?: number;
feePercentage?: number;
fixedFee?: bigint;
maxValue?: bigint;
minValue?: bigint;
penaltyFee?: bigint;
Expand All @@ -220,6 +221,17 @@ export interface PeginConfigurationRequest {
configuration?: PeginConfigurationDTO;
}

export interface PeginCreationDataDTO {
/** The percentage fee used to compute the call fee */
feePercentage: number;
/** The fixed fee used to compute the call fee */
fixedFee: bigint;
/** The gas price used to compute the gas fee */
gasPrice: bigint;
}

export const PeginCreationDataDtoRequiredFields: string[] = ["gasPrice", "feePercentage", "fixedFee"];

export interface PeginQuoteDTO {
/** The timestamp of the agreement */
agreementTimestamp: number;
Expand Down Expand Up @@ -317,19 +329,22 @@ export const PeginQuoteRequestRequiredFields: string[] = [
];

export interface PeginQuoteStatusDTO {
/** Values used to compute some fields of the quote */
creationData: PeginCreationDataDTO;
/** Agreed specification of the quote */
detail: PeginQuoteDTO;
/** Current status of the quote */
status: RetainedPeginQuoteDTO;
}

export const PeginQuoteStatusDtoRequiredFields: string[] = ["detail", "status"];
export const PeginQuoteStatusDtoRequiredFields: string[] = ["detail", "status", "creationData"];

export interface PegoutConfigurationDTO {
bridgeTransactionMin?: string;
callFee?: bigint;
expireBlocks?: number;
expireTime?: number;
feePercentage?: number;
fixedFee?: bigint;
maxValue?: bigint;
minValue?: bigint;
penaltyFee?: bigint;
Expand All @@ -340,6 +355,19 @@ export interface PegoutConfigurationRequest {
configuration?: PegoutConfigurationDTO;
}

export interface PegoutCreationDataDTO {
/** The percentage fee used to compute the call fee */
feePercentage: number;
/** The fee rate used to compute the gas fee */
feeRate: number;
/** The fixed fee used to compute the call fee */
fixedFee: bigint;
/** The gas price used to compute the gas fee */
gasPrice: bigint;
}

export const PegoutCreationDataDtoRequiredFields: string[] = ["gasPrice", "feePercentage", "fixedFee", "feeRate"];

export interface PegoutQuoteDTO {
agreementTimestamp: number;
btcRefundAddress: string;
Expand Down Expand Up @@ -404,23 +432,30 @@ export interface PegoutQuoteRequest {
export const PegoutQuoteRequestRequiredFields: string[] = ["to", "valueToTransfer", "rskRefundAddress"];

export interface PegoutQuoteStatusDTO {
/** Values used to compute some fields of the quote */
creationData: PegoutCreationDataDTO;
/** Agreed specification of the quote */
detail: PegoutQuoteDTO;
/** Current status of the quote */
status: RetainedPegoutQuoteDTO;
}

export const PegoutQuoteStatusDtoRequiredFields: string[] = ["detail", "status"];
export const PegoutQuoteStatusDtoRequiredFields: string[] = ["detail", "status", "creationData"];

export interface ProviderDetail {
/** @deprecated */
fee: bigint;
feePercentage: number;
fixedFee: bigint;
maxTransactionValue: bigint;
minTransactionValue: bigint;
requiredConfirmations: number;
}

export const ProviderDetailRequiredFields: string[] = [
"fee",
"fixedFee",
"feePercentage",
"minTransactionValue",
"maxTransactionValue",
"requiredConfirmations",
Expand Down Expand Up @@ -518,6 +553,21 @@ export const RetainedPegoutQuoteDtoRequiredFields: string[] = [
"bridgeRefundTxHash",
];

export interface ServerInfoDTO {
/**
* Version commit hash
* @example "b7bf393a2b1cedde8ee15b00780f44e6e5d2ba9d"
*/
revision: string;
/**
* Server version tag
* @example "v1.0.0"
*/
version: string;
}

export const ServerInfoDtoRequiredFields: string[] = ["version", "revision"];

export interface Services {
btc?: string;
db?: string;
Expand Down
5 changes: 4 additions & 1 deletion src/api/templates/data-contracts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ const CONTENT_FIELD_REGEX = /^[a-zA-Z][a-zA-Z0-9]*\??: [A-Za-z0-9]+,/

const isBigIntField = name => {
name = name.toLowerCase();
return name.includes('fee') ||
const isDecimalField = name.includes('percentage') || name.includes('rate');
const isAmountField = name.includes('fee') ||
name.includes('value') ||
name.includes('amount') ||
name.includes('cost') ||
name.includes('price') ||
/^nonce:*/.test(name)
return isAmountField && !isDecimalField;
}

const parseFieldToBigint = line => {
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/acceptPegoutQuote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ const providerMock: LiquidityProvider = {
minTransactionValue: BigInt(1),
maxTransactionValue: BigInt(100),
fee: BigInt(1),
fixedFee: BigInt(3),
feePercentage: 1.25,
requiredConfirmations: 5
},
pegout: {
minTransactionValue: BigInt(1),
maxTransactionValue: BigInt(100),
fee: BigInt(1),
fixedFee: BigInt(3),
feePercentage: 1.25,
requiredConfirmations: 5
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/acceptQuote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ const providerMock: LiquidityProvider = {
minTransactionValue: BigInt(1),
maxTransactionValue: BigInt(100),
fee: BigInt(1),
fixedFee: BigInt(3),
feePercentage: 1.25,
requiredConfirmations: 5
},
pegout: {
minTransactionValue: BigInt(1),
maxTransactionValue: BigInt(100),
fee: BigInt(1),
fixedFee: BigInt(3),
feePercentage: 1.25,
requiredConfirmations: 5
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/flyover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@ const providerMock: LiquidityProvider = {
minTransactionValue: BigInt(1),
maxTransactionValue: BigInt(100),
fee: BigInt(1),
fixedFee: BigInt(3),
feePercentage: 1.25,
requiredConfirmations: 5
},
pegout: {
minTransactionValue: BigInt(1),
maxTransactionValue: BigInt(100),
fee: BigInt(1),
fixedFee: BigInt(3),
feePercentage: 1.25,
requiredConfirmations: 5
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/getAvailableLiquidity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ const providerMock: LiquidityProvider = {
minTransactionValue: BigInt(1),
maxTransactionValue: BigInt(100),
fee: BigInt(1),
fixedFee: BigInt(3),
feePercentage: 1.25,
requiredConfirmations: 5
},
pegout: {
minTransactionValue: BigInt(1),
maxTransactionValue: BigInt(100),
fee: BigInt(1),
fixedFee: BigInt(3),
feePercentage: 1.25,
requiredConfirmations: 5
}
}
Expand Down
Loading
Loading