Skip to content

Commit

Permalink
Store Quote data of the Pegin and Pegout for flyover
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldsg20 committed Nov 18, 2024
1 parent 75886fe commit 21f484d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/models/flyover-status.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { QuoteDbModel } from './quote-db.model';
import {SearchableModel} from './rsk/searchable-model';

export class FlyoverStatusModel implements SearchableModel {
Expand All @@ -10,6 +11,7 @@ export class FlyoverStatusModel implements SearchableModel {
senderAddress: string;
recipientAddress: string;
quoteHash: string;
quote: QuoteDbModel;

getId() {
return this.txHash;
Expand Down
1 change: 1 addition & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ export * from './register-payload.model';
export * from './features.model';
export * from './pegout-status.model';
export * from './register-flyover-call.model';
export * from './quote-db.model';
40 changes: 40 additions & 0 deletions src/models/quote-db.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export interface BaseQuoteDbModel {
agreementTimestamp: number;
gasFeeOnWei: bigint;
nonce: bigint;
penaltyFeeOnWei: bigint;
btcRefundAddress: string;
lbcAddress: string;
lpBtcAddress: string;
rskRefundAddress: string;
liquidityProviderRskAddress: string;
}

export interface PeginQuoteDbModel extends BaseQuoteDbModel {
callFeeOnSatoshi: bigint;
callOnRegister: boolean;
confirmations: number;
contractAddr: string;
data: string;
fedBTCAddr: string;
gasLimit: number;
lpCallTime: number;
productFeeAmountOnSatoshi: bigint;
timeForDepositInSeconds: number;
valueOnSatoshi: bigint;
}

export interface PegoutQuoteDbModel extends BaseQuoteDbModel {
callFeeOnWei: bigint;
depositAddr: string;
depositConfirmations: number;
depositDateLimit: number;
expireBlocks: number;
expireDate: number;
productFeeAmountOnWei: bigint;
transferConfirmations: number;
transferTime: number;
valueOnWei: bigint;
}

export type QuoteDbModel = PeginQuoteDbModel | PegoutQuoteDbModel;
3 changes: 2 additions & 1 deletion src/services/flyover.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mongoose from 'mongoose';
import mongoose, { Schema } from 'mongoose';
import {RegisterPayload} from '../models';
import {FlyoverStatusModel} from '../models/flyover-status.model';
import {MongoDbDataService} from './mongodb-data.service';
Expand All @@ -17,6 +17,7 @@ const FlyoverStatusSchema = new mongoose.Schema({
senderAddress: {type: String, required: true},
recipientAddress: {type: String, required: true},
quoteHash: {type: String, required: true},
quote: Schema.Types.Mixed,
});

const FlyoverStatusConnector = mongoose.model<FlyoverStatusMongoModel>('FlyoverStatuses', FlyoverStatusSchema);
Expand Down

0 comments on commit 21f484d

Please sign in to comment.