-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: PeginQuote class definition #849
Conversation
ronaldsg20
commented
Oct 11, 2024
I've defined the PeginQUote class in order to assing all the required behavior to each specific quote object
const amountToTransfer = computed(() => (flyover.value | ||
? selectedQuote.value.quote.value.plus(getProviderFee()) | ||
? selectedQuote.value.quote.value.plus(selectedQuote.value.providerFee) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to use totalValueToTransfer
here too.
.plus(safeFee.value)); | ||
|
||
const flyoverPeginSummary = computed((): NormalizedSummary => ({ | ||
amountFromString: selectedQuote.value.quote.value.toBTCTrimmedString(), | ||
amountReceivedString: selectedQuote.value.quote.value.toBTCTrimmedString(), | ||
fee: Number(flyoverTotalFee.value), | ||
fee: Number(flyoverTotalFee.value.toBTCTrimmedString()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flyoverTotalFee needs to be on selectedQuote object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming the quote is not responsable of the networkFee calculation, here we called safeFee
and its outside of the Quote
.plus(selectedQuote.value.quote.callFee) | ||
.plus(SatoshiBig.fromWeiBig(selectedQuote.value.quote.gasFee)); | ||
} | ||
|
||
const amountToTransfer = computed(() => (flyover.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this calculation needs to be internally on the PeginQuote object
@@ -144,16 +144,11 @@ export default defineComponent({ | |||
const selectedAccountBalance = useGetter<SatoshiBig>('pegInTx', constants.PEGIN_TX_GET_SELECTED_BALANCE); | |||
|
|||
const enoughAmountFlyover = computed(() => { | |||
const quote = selectedQuote.value?.quote; | |||
if (!quote) { | |||
if (!selectedQuote.value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a function like isValid internally on selecterQuote
object, verifying if value is not empty or 0 or null.
.plus(quote.productFeeAmount) | ||
.plus(quote.callFee) | ||
.plus(SatoshiBig.fromWeiBig(quote.gasFee)) | ||
const fullAmount: SatoshiBig = selectedQuote.value.totalValueToTransfer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert selectedFee on selectedQuote
object, and then call getFullAmount from selectedQuote
object
amountToTransfer: () => quote.value?.value | ||
.plus(quoteFee.value).plus(selectedFee.value) ?? new SatoshiBig('0', 'btc'), | ||
estimatedTime: () => blockConfirmationsToTimeString(computedQuote.value?.quote.confirmations ?? 0, 'btc'), | ||
amountToTransfer: () => computedQuote.value?.totalValueToTransfer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the same function mentioned above getFullAmount
providerFee: () => quoteFee.value, | ||
valueToReceive: () => quote.value?.value ?? new SatoshiBig('0', 'btc'), | ||
valueToReceive: () => computedQuote.value?.quote.value ?? new SatoshiBig('0', 'btc'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use the same function mentioned above isValid
I've added 2 methods in order to calculate the full tx amounts using the external Network fee value
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM