-
Notifications
You must be signed in to change notification settings - Fork 115
feat(trading-proto-upgrade): fees fixes among other things #2109
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
base: dev
Are you sure you want to change the base?
Changes from 22 commits
13a798e
9a7d81b
a844f62
151f5a8
9f722fb
ef28a6c
0bd984a
ad21f4e
ff05d06
c20bac2
2ff43ad
7a92123
225b776
b221def
481ba3e
e0f649c
d1f2d1b
d90ad0e
0a4248c
3bd51d1
f4d18d6
d18bf96
4848cb0
b6ee698
4f5a04a
130fc88
ec3ffe3
9cb9818
c86bade
a2e4bfa
c383862
a08a981
ba0037f
c970e25
0ea4f0c
db11ed9
28fc442
638d90e
12e1b66
bc32198
241af5a
100951b
1e63689
03afb72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1236,6 +1236,8 @@ pub struct SendTakerFundingArgs<'a> { | |
| pub maker_pub: &'a [u8], | ||
| /// DEX fee | ||
| pub dex_fee: &'a DexFee, | ||
| /// The extra fee added to the trading volume to cover the taker payment transaction fees | ||
| pub taker_payment_fee: BigDecimal, | ||
| /// Additional reward for maker (premium) | ||
| pub premium_amount: BigDecimal, | ||
| /// Actual volume of taker's payment | ||
|
|
@@ -1257,7 +1259,7 @@ pub struct RefundFundingSecretArgs<'a, Coin: ParseCoinAssocTypes + ?Sized> { | |
| } | ||
|
|
||
| /// Helper struct wrapping arguments for [TakerCoinSwapOpsV2::gen_taker_funding_spend_preimage] | ||
| pub struct GenTakerFundingSpendArgs<'a, Coin: ParseCoinAssocTypes + ?Sized> { | ||
| pub struct GenTakerPaymentPreimageArgs<'a, Coin: ParseCoinAssocTypes + ?Sized> { | ||
| /// Taker payment transaction serialized to raw bytes | ||
| pub funding_tx: &'a Coin::Tx, | ||
| /// Maker's pubkey | ||
|
|
@@ -1272,6 +1274,8 @@ pub struct GenTakerFundingSpendArgs<'a, Coin: ParseCoinAssocTypes + ?Sized> { | |
| pub taker_payment_time_lock: u64, | ||
| /// The hash of the secret generated by maker | ||
| pub maker_secret_hash: &'a [u8], | ||
| /// The extra fee added to the trading volume to cover the taker payment transaction fees | ||
| pub taker_payment_fee: BigDecimal, | ||
shamardy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /// Helper struct wrapping arguments for [TakerCoinSwapOpsV2::validate_taker_funding] | ||
|
|
@@ -1286,6 +1290,8 @@ pub struct ValidateTakerFundingArgs<'a, Coin: ParseCoinAssocTypes + ?Sized> { | |
| pub other_pub: &'a Coin::Pubkey, | ||
| /// DEX fee amount | ||
| pub dex_fee: &'a DexFee, | ||
| /// The extra fee added to the trading volume to cover the taker payment transaction fees | ||
| pub taker_payment_fee: BigDecimal, | ||
shamardy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// Additional reward for maker (premium) | ||
| pub premium_amount: BigDecimal, | ||
| /// Actual volume of taker's payment | ||
|
|
@@ -1394,6 +1400,8 @@ impl From<UtxoRpcError> for ValidateSwapV2TxError { | |
| /// Enum covering error cases that can happen during taker funding spend preimage validation. | ||
| #[derive(Debug, Display, EnumFromStringify)] | ||
| pub enum ValidateTakerFundingSpendPreimageError { | ||
| /// Error during conversion of BigDecimal amount to coin's specific monetary units (satoshis, wei, etc.). | ||
| NumConversion(String), | ||
| /// Funding tx has no outputs | ||
| FundingTxNoOutputs, | ||
| /// Actual preimage fee is either too high or too small | ||
|
|
@@ -1414,6 +1422,10 @@ pub enum ValidateTakerFundingSpendPreimageError { | |
| Rpc(String), | ||
| } | ||
|
|
||
| impl From<NumConversError> for ValidateTakerFundingSpendPreimageError { | ||
| fn from(err: NumConversError) -> Self { ValidateTakerFundingSpendPreimageError::NumConversion(err.to_string()) } | ||
| } | ||
|
|
||
| impl From<TxGenError> for ValidateTakerFundingSpendPreimageError { | ||
| fn from(err: TxGenError) -> Self { ValidateTakerFundingSpendPreimageError::TxGenError(format!("{:?}", err)) } | ||
| } | ||
|
|
@@ -1644,6 +1656,12 @@ pub trait MakerCoinSwapOpsV2: ParseCoinAssocTypes + Send + Sync + 'static { | |
|
|
||
| /// Spend maker payment transaction | ||
| async fn spend_maker_payment_v2(&self, args: SpendMakerPaymentArgs<'_, Self>) -> Result<Self::Tx, TransactionErr>; | ||
|
|
||
| /// Get the fee to be paid for the processing of the maker payment transaction. | ||
| async fn get_maker_payment_fee(&self, stage: &FeeApproxStage) -> TradePreimageResult<TradeFee>; | ||
|
|
||
| /// Get the fee to be paid for the processing of the maker payment spend transaction aka the claimation transaction. | ||
shamardy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| async fn get_maker_payment_spend_fee(&self, stage: &FeeApproxStage) -> TradePreimageResult<TradeFee>; | ||
|
||
| } | ||
|
|
||
| #[async_trait] | ||
|
|
@@ -1786,24 +1804,24 @@ pub trait TakerCoinSwapOpsV2: ParseCoinAssocTypes + Send + Sync + 'static { | |
| ) -> Result<Option<FundingTxSpend<Self>>, SearchForFundingSpendErr>; | ||
|
|
||
| /// Generates and signs a preimage spending funding tx to the combined taker payment | ||
| async fn gen_taker_funding_spend_preimage( | ||
| async fn gen_taker_payment_preimage( | ||
| &self, | ||
| args: &GenTakerFundingSpendArgs<'_, Self>, | ||
| args: &GenTakerPaymentPreimageArgs<'_, Self>, | ||
| swap_unique_data: &[u8], | ||
| ) -> GenPreimageResult<Self>; | ||
|
|
||
| /// Validates taker funding spend preimage generated and signed by maker | ||
| async fn validate_taker_funding_spend_preimage( | ||
| async fn validate_taker_payment_preimage( | ||
| &self, | ||
| gen_args: &GenTakerFundingSpendArgs<'_, Self>, | ||
| gen_args: &GenTakerPaymentPreimageArgs<'_, Self>, | ||
| preimage: &TxPreimageWithSig<Self>, | ||
| ) -> ValidateTakerFundingSpendPreimageResult; | ||
|
|
||
| /// Generates and signs a preimage spending funding tx to the combined taker payment | ||
| async fn sign_and_send_taker_funding_spend( | ||
| async fn sign_and_send_taker_payment( | ||
| &self, | ||
| preimage: &TxPreimageWithSig<Self>, | ||
| args: &GenTakerFundingSpendArgs<'_, Self>, | ||
| args: &GenTakerPaymentPreimageArgs<'_, Self>, | ||
| swap_unique_data: &[u8], | ||
| ) -> Result<Self::Tx, TransactionErr>; | ||
|
|
||
|
|
@@ -1844,6 +1862,25 @@ pub trait TakerCoinSwapOpsV2: ParseCoinAssocTypes + Send + Sync + 'static { | |
|
|
||
| /// Derives an HTLC key-pair and returns a public key corresponding to that key. | ||
| fn derive_htlc_pubkey_v2(&self, swap_unique_data: &[u8]) -> Self::Pubkey; | ||
|
|
||
| /// Get the fee to be paid for the processing of the funding transaction. | ||
| /// Txs in success case (no refund) go as follows: | ||
| /// Chain A: funding -> taker payment -> taker payment spend (aka preimage) (to the maker & dex) | ||
| /// Chain B: maker payment -> maker payment spend (aka claimation) (to the taker) | ||
| async fn get_funding_fee(&self, stage: &FeeApproxStage) -> TradePreimageResult<TradeFee>; | ||
|
|
||
| /// Get the fee to be paid for the processing of the funding-spend transaction aka taker payment transaction. | ||
| /// | ||
| /// Don't use this method, use [TakerCoinSwapOpsV2::get_taker_payment_fee] instead. | ||
| async fn get_funding_spend_fee(&self, stage: &FeeApproxStage) -> TradePreimageResult<TradeFee> { | ||
| self.get_taker_payment_fee(stage).await | ||
| } | ||
|
|
||
| /// Get the fee to be paid for the processing of the taker payment transaction. | ||
| async fn get_taker_payment_fee(&self, stage: &FeeApproxStage) -> TradePreimageResult<TradeFee>; | ||
shamardy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// Get the fee to be paid for the processing of the taker payment spend transaction aka the preimage transaction. | ||
| async fn get_taker_payment_spend_fee(&self, stage: &FeeApproxStage) -> TradePreimageResult<TradeFee>; | ||
| } | ||
|
|
||
| /// Operations that coins have independently from the MarketMaker. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.