Skip to content
Open
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
7 changes: 7 additions & 0 deletions v2/api-validator/src/client/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type { AssetReference } from './models/AssetReference';
export { BadRequestError } from './models/BadRequestError';
export type { Balances } from './models/Balances';
export type { BankAccountNumber } from './models/BankAccountNumber';
export { BasisPointsFeeAmount } from './models/BasisPointsFeeAmount';
export { Bep20Token } from './models/Bep20Token';
export { Blockchain } from './models/Blockchain';
export type { BlockchainCapabilityWithOptionalAddress } from './models/BlockchainCapabilityWithOptionalAddress';
Expand All @@ -42,6 +43,7 @@ export type { Bridge } from './models/Bridge';
export type { BridgeCapability } from './models/BridgeCapability';
export { BridgeProperties } from './models/BridgeProperties';
export type { BridgePropertiesWithPaymentInstructions } from './models/BridgePropertiesWithPaymentInstructions';
export type { BridgeReceipt } from './models/BridgeReceipt';
export { BucketAsset } from './models/BucketAsset';
export { BusinessIdentificationInfo } from './models/BusinessIdentificationInfo';
export type { Capabilities } from './models/Capabilities';
Expand Down Expand Up @@ -92,12 +94,15 @@ export type { EuropeanSEPAAddress } from './models/EuropeanSEPAAddress';
export { EuropeanSEPACapability } from './models/EuropeanSEPACapability';
export type { EuropeanSEPATransfer } from './models/EuropeanSEPATransfer';
export type { EuropeanSEPATransferDestination } from './models/EuropeanSEPATransferDestination';
export { Fee } from './models/Fee';
export type { FeeAmount } from './models/FeeAmount';
export type { FiatAddress } from './models/FiatAddress';
export type { FiatCapability } from './models/FiatCapability';
export type { FiatTransfer } from './models/FiatTransfer';
export type { FiatTransferDestination } from './models/FiatTransferDestination';
export type { FiatWithdrawal } from './models/FiatWithdrawal';
export type { FiatWithdrawalRequest } from './models/FiatWithdrawalRequest';
export { FixedFeeAmount } from './models/FixedFeeAmount';
export type { FullName } from './models/FullName';
export { GeneralError } from './models/GeneralError';
export type { Iban } from './models/Iban';
Expand Down Expand Up @@ -137,10 +142,12 @@ export type { OffRamp } from './models/OffRamp';
export type { OffRampCapability } from './models/OffRampCapability';
export { OffRampProperties } from './models/OffRampProperties';
export type { OffRampPropertiesWithPaymentInstructions } from './models/OffRampPropertiesWithPaymentInstructions';
export type { OffRampReceipt } from './models/OffRampReceipt';
export type { OnRamp } from './models/OnRamp';
export type { OnRampCapability } from './models/OnRampCapability';
export { OnRampProperties } from './models/OnRampProperties';
export type { OnRampPropertiesWithPaymentInstructions } from './models/OnRampPropertiesWithPaymentInstructions';
export type { OnRampReceipt } from './models/OnRampReceipt';
export type { Order } from './models/Order';
export type { OrderBook } from './models/OrderBook';
export type { OrderBookPairIdQueryParam } from './models/OrderBookPairIdQueryParam';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

export type BasisPointsFeeAmount = {
amountType: BasisPointsFeeAmount.amountType;
/**
* Basis points (bps) - 1 is 0.01% and 10000 is 100%
*/
amount: number;
};

export namespace BasisPointsFeeAmount {

export enum amountType {
BASIS_POINTS = 'BASIS_POINTS',
}


}

4 changes: 2 additions & 2 deletions v2/api-validator/src/client/generated/models/Bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
/* eslint-disable */

import type { BridgePropertiesWithPaymentInstructions } from './BridgePropertiesWithPaymentInstructions';
import type { BridgeReceipt } from './BridgeReceipt';
import type { CommonRamp } from './CommonRamp';
import type { PrefundedBridgeProperties } from './PrefundedBridgeProperties';
import type { PublicBlockchainTransaction } from './PublicBlockchainTransaction';

export type Bridge = (CommonRamp & (BridgePropertiesWithPaymentInstructions | PrefundedBridgeProperties) & {
receipt?: PublicBlockchainTransaction;
receipt?: BridgeReceipt;
});

12 changes: 12 additions & 0 deletions v2/api-validator/src/client/generated/models/BridgeReceipt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { PublicBlockchainTransaction } from './PublicBlockchainTransaction';
import type { RampFees } from './RampFees';

export type BridgeReceipt = (PublicBlockchainTransaction & {
actualFees?: RampFees;
});

2 changes: 1 addition & 1 deletion v2/api-validator/src/client/generated/models/CommonRamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type CommonRamp = {
updatedAt: string;
status: RampStatus;
amount: PositiveAmount;
fees?: RampFees;
estimatedFees?: RampFees;
executionDetails?: OrderQuote;
/**
* Ramp expiration time.
Expand Down
34 changes: 34 additions & 0 deletions v2/api-validator/src/client/generated/models/Fee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { AssetReference } from './AssetReference';
import type { FeeAmount } from './FeeAmount';

export type Fee = {
/**
* Specifies the category of fee applied to the transaction. - ORDER - Fee charged by the platform for executing the trade. - NETWORK - Blockchain network fee paid to validators/miners. - SPREAD - Implicit cost built into the price difference between quotes. - REBATE - Negative fee returned to the user as a reward or incentive.
*
*/
feeType: Fee.feeType;
feeAsset: AssetReference;
fee: FeeAmount;
};

export namespace Fee {

/**
* Specifies the category of fee applied to the transaction. - ORDER - Fee charged by the platform for executing the trade. - NETWORK - Blockchain network fee paid to validators/miners. - SPREAD - Implicit cost built into the price difference between quotes. - REBATE - Negative fee returned to the user as a reward or incentive.
*
*/
export enum feeType {
ORDER = 'ORDER',
NETWORK = 'NETWORK',
SPREAD = 'SPREAD',
REBATE = 'REBATE',
}


}

10 changes: 10 additions & 0 deletions v2/api-validator/src/client/generated/models/FeeAmount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { BasisPointsFeeAmount } from './BasisPointsFeeAmount';
import type { FixedFeeAmount } from './FixedFeeAmount';

export type FeeAmount = (FixedFeeAmount | BasisPointsFeeAmount);

21 changes: 21 additions & 0 deletions v2/api-validator/src/client/generated/models/FixedFeeAmount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { PositiveAmount } from './PositiveAmount';

export type FixedFeeAmount = {
amountType: FixedFeeAmount.amountType;
amount: PositiveAmount;
};

export namespace FixedFeeAmount {

export enum amountType {
FIXED = 'FIXED',
}


}

4 changes: 2 additions & 2 deletions v2/api-validator/src/client/generated/models/OffRamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import type { CommonRamp } from './CommonRamp';
import type { OffRampPropertiesWithPaymentInstructions } from './OffRampPropertiesWithPaymentInstructions';
import type { OffRampReceipt } from './OffRampReceipt';
import type { PrefundedOffRampProperties } from './PrefundedOffRampProperties';
import type { RampFiatTransfer } from './RampFiatTransfer';

export type OffRamp = (CommonRamp & (OffRampPropertiesWithPaymentInstructions | PrefundedOffRampProperties) & {
receipt?: RampFiatTransfer;
receipt?: OffRampReceipt;
});

12 changes: 12 additions & 0 deletions v2/api-validator/src/client/generated/models/OffRampReceipt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { RampFees } from './RampFees';
import type { RampFiatTransfer } from './RampFiatTransfer';

export type OffRampReceipt = (RampFiatTransfer & {
actualFees?: RampFees;
});

4 changes: 2 additions & 2 deletions v2/api-validator/src/client/generated/models/OnRamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import type { CommonRamp } from './CommonRamp';
import type { OnRampPropertiesWithPaymentInstructions } from './OnRampPropertiesWithPaymentInstructions';
import type { OnRampReceipt } from './OnRampReceipt';
import type { PrefundedOnRampProperties } from './PrefundedOnRampProperties';
import type { PublicBlockchainTransaction } from './PublicBlockchainTransaction';

export type OnRamp = (CommonRamp & (OnRampPropertiesWithPaymentInstructions | PrefundedOnRampProperties) & {
receipt?: PublicBlockchainTransaction;
receipt?: OnRampReceipt;
});

12 changes: 12 additions & 0 deletions v2/api-validator/src/client/generated/models/OnRampReceipt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */

import type { PublicBlockchainTransaction } from './PublicBlockchainTransaction';
import type { RampFees } from './RampFees';

export type OnRampReceipt = (PublicBlockchainTransaction & {
actualFees?: RampFees;
});

1 change: 1 addition & 0 deletions v2/api-validator/src/client/generated/models/Quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type Quote = {
* Conversion fee in basis points. The amounts are expected to include the fee.
*/
conversionFeeBps: number;
conversionFeeAsset?: AssetReference;
status: QuoteStatus;
/**
* Quote creation time.
Expand Down
15 changes: 2 additions & 13 deletions v2/api-validator/src/client/generated/models/RampFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
/* tslint:disable */
/* eslint-disable */

/**
* Fees associated with the ramp transfer.
*/
export type RampFees = {
/**
* Fees charged from the sub-account in basis points.
*/
subAccount?: number;
/**
* Fees charged by the provider for the ramp service in basis points.
*/
provider?: number;
};
import type { Fee } from './Fee';

export type RampFees = Array<Fee>;
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class LiquidityController {
fromAsset,
toAsset,
conversionFeeBps: 1,
conversionFeeAsset: fromAsset,
createdAt: new Date(Date.now()).toISOString(),
expiresAt: new Date(Date.now() + QUOTE_EXPIRATION_IN_MS).toISOString(),
id: randomUUID(),
Expand Down
45 changes: 39 additions & 6 deletions v2/api-validator/src/server/controllers/ramps-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class RampsController {
}

const knownAssetIds = AssetsController.getAllAdditionalAssets().map((a) => a.id);
injectKnownAssetIdsToRampsAssetObjects(knownAssetIds, this.rampsRepository);
injectKnownAssetIdsToRamps(knownAssetIds, this.rampsRepository);
}

private loadRampMethods() {
Expand All @@ -75,7 +75,7 @@ export class RampsController {
this.rampMethodRepository.create(capability);
}
const knownAssetIds = AssetsController.getAllAdditionalAssets().map((a) => a.id);
injectKnownAssetIdsToRampsAssetObjects(knownAssetIds, this.rampMethodRepository);
injectKnownAssetIdsToRampsMethods(knownAssetIds, this.rampMethodRepository);
}

private static generateRampMethods() {
Expand Down Expand Up @@ -143,7 +143,7 @@ export class RampsController {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { idempotencyKey, ...rampProps } = ramp;
let paymentInstructions;

let status = RampStatus.PENDING;
if (
ramp.type === OffRampProperties.type.OFF_RAMP ||
ramp.type === BridgeProperties.type.BRIDGE
Expand All @@ -154,6 +154,7 @@ export class RampsController {
};
} else if ('type' in ramp.from && ramp.from.type === 'Prefunded') {
paymentInstructions = undefined;
status = RampStatus.PROCESSING;
} else if (ramp.type === OnRampProperties.type.ON_RAMP) {
const transferMethod = getTransferMethod((ramp.from as FiatCapability)?.transferMethod);
paymentInstructions = {
Expand All @@ -170,7 +171,7 @@ export class RampsController {
...(paymentInstructions && { paymentInstructions }),
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
status: RampStatus.PENDING,
status,
fees: {},
expiresAt: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000).toISOString(), // 3 days from now
};
Expand Down Expand Up @@ -202,9 +203,9 @@ function getTransferMethod(transferMethod: FiatCapability['transferMethod']): Fi
}
}

function injectKnownAssetIdsToRampsAssetObjects(
function injectKnownAssetIdsToRampsMethods(
knownAssetIds: string[],
repository: Repository<Ramp> | Repository<RampMethod>
repository: Repository<RampMethod>
) {
for (const { id } of repository.list()) {
const ramp = repository.find(id);
Expand All @@ -221,3 +222,35 @@ function injectKnownAssetIdsToRampsAssetObjects(
}
}
}

function injectKnownAssetIdsToRamps(knownAssetIds: string[], repository: Repository<Ramp>) {
for (const { id } of repository.list()) {
const ramp = repository.find(id);
if (!ramp) {
throw new Error('Not possible!');
}

if ('assetId' in ramp.from.asset) {
ramp.from.asset.assetId = JSONSchemaFaker.random.pick(knownAssetIds);
}
if ('assetId' in ramp.to.asset) {
ramp.to.asset.assetId = JSONSchemaFaker.random.pick(knownAssetIds);
}

if (ramp.estimatedFees) {
for (const fee of ramp.estimatedFees) {
if ('assetId' in fee.feeAsset) {
fee.feeAsset.assetId = JSONSchemaFaker.random.pick(knownAssetIds);
}
}
}

if (ramp.receipt?.actualFees) {
for (const fee of ramp.receipt.actualFees) {
if ('assetId' in fee.feeAsset) {
fee.feeAsset.assetId = JSONSchemaFaker.random.pick(knownAssetIds);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Liquidity Controller', () => {
toAmount: defaultAmount,
fromAsset: defaultAssetReference,
toAsset: defaultAssetReference,
conversionFeeAsset: defaultAssetReference,
conversionFeeBps: 1,
createdAt: new Date(Date.now()).toISOString(),
expiresAt: new Date(Date.now() + 1000).toISOString(),
Expand Down
Loading