Skip to content
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

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

ronaldsg20
Copy link
Member

	I've defined the PeginQUote class in order to assing all the required
	behavior to each specific quote object

		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)
Copy link
Contributor

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()),
Copy link
Collaborator

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.

Copy link
Member Author

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
Copy link
Collaborator

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) {
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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'),
Copy link
Collaborator

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
Copy link

Copy link
Collaborator

@alexjavabraz alexjavabraz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@annipi annipi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

@leoiovlabs leoiovlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ronaldsg20 ronaldsg20 merged commit 234fddd into feature/2.3 Oct 21, 2024
3 checks passed
@ronaldsg20 ronaldsg20 deleted the refactor/full-calculation branch October 21, 2024 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants