Skip to content

Commit

Permalink
chore: fix vault_swap_request
Browse files Browse the repository at this point in the history
  • Loading branch information
albert-llimos committed Nov 8, 2024
1 parent c607c8e commit fab6ad1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
9 changes: 6 additions & 3 deletions engine/src/witness/arb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ struct ArbCallBuilder {}

use cf_chains::{address::EncodedAddress, CcmDepositMetadata, ChannelRefundParameters};
use cf_primitives::{
Asset, AssetAmount, BasisPoints, Beneficiaries, DcaParameters, TransactionHash,
AccountId, Affiliates, Asset, AssetAmount, BasisPoints, Beneficiary, DcaParameters,
TransactionHash,
};

impl super::evm::vault::IngressCallBuilder for ArbCallBuilder {
Expand All @@ -190,7 +191,8 @@ impl super::evm::vault::IngressCallBuilder for ArbCallBuilder {
destination_address: EncodedAddress,
deposit_metadata: Option<CcmDepositMetadata>,
tx_hash: TransactionHash,
_broker_fees: Beneficiaries<ShortId>,
_broker_fees: Beneficiary<AccountId>,
_affiliate_fees: Affiliates<ShortId>,
refund_params: Option<ChannelRefundParameters>,
dca_params: Option<DcaParameters>,
// This is only to be checked in the pre-witnessed version
Expand All @@ -205,8 +207,9 @@ impl super::evm::vault::IngressCallBuilder for ArbCallBuilder {
deposit_metadata,
tx_hash,
deposit_details: Box::new(DepositDetails { tx_hashes: Some(vec![tx_hash.into()]) }),
// Defaulting to no broker fees until PRO-1743 is completed.
// TODO: To update after PRO-1751 for both broker_fees and affiliate_fees
broker_fees: Default::default(),
// affiliate_fees: Default::default(),
boost_fee: boost_fee.unwrap_or_default(),
dca_params,
refund_params: refund_params.map(Box::new),
Expand Down
3 changes: 2 additions & 1 deletion engine/src/witness/common/cf_parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ pub struct VaultSwapParameters {
pub refund_params: ChannelRefundParameters,
pub dca_params: Option<DcaParameters>,
pub boost_fee: Option<BasisPoints>,
// TODO: Should we use u8 instead of BasisPoints for fees as in Bitcoin?
// TODO: Create BrokerAndFee instead so fee is also a u8?
pub broker_fees: Beneficiary<AccountId>,
// TODO: Use AffiliateAndFee in PRO-1751
pub affiliate_fees: Affiliates<ShortId>,
}

Expand Down
9 changes: 6 additions & 3 deletions engine/src/witness/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ where

use cf_chains::{address::EncodedAddress, CcmDepositMetadata, ChannelRefundParameters};
use cf_primitives::{
Asset, AssetAmount, BasisPoints, Beneficiaries, DcaParameters, TransactionHash,
AccountId, Affiliates, Asset, AssetAmount, BasisPoints, Beneficiary, DcaParameters,
TransactionHash,
};

pub struct EthCallBuilder {}
Expand All @@ -238,7 +239,8 @@ impl super::evm::vault::IngressCallBuilder for EthCallBuilder {
destination_address: EncodedAddress,
deposit_metadata: Option<CcmDepositMetadata>,
tx_hash: TransactionHash,
_broker_fees: Beneficiaries<ShortId>,
_broker_fees: Beneficiary<AccountId>,
_affiliate_fees: Affiliates<ShortId>,
refund_params: Option<ChannelRefundParameters>,
dca_params: Option<DcaParameters>,
// This is only to be checked in the pre-witnessed version
Expand All @@ -253,8 +255,9 @@ impl super::evm::vault::IngressCallBuilder for EthCallBuilder {
deposit_metadata,
tx_hash,
deposit_details: Box::new(DepositDetails { tx_hashes: Some(vec![tx_hash.into()]) }),
// Defaulting to no broker fees until PRO-1743 is completed.
// TODO: To update after PRO-1751 for both broker_fees and affiliate_fees
broker_fees: Default::default(),
// affiliate_fees: Default::default(),
boost_fee: boost_fee.unwrap_or_default(),
dca_params,
refund_params: refund_params.map(Box::new),
Expand Down
23 changes: 13 additions & 10 deletions engine/src/witness/evm/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ use cf_chains::{
evm::DepositDetails,
CcmChannelMetadata, CcmDepositMetadata, Chain, ChannelRefundParameters,
};
use cf_primitives::{Asset, BasisPoints, DcaParameters, ForeignChain};
use cf_primitives::{
AccountId, Affiliates, Asset, BasisPoints, Beneficiary, DcaParameters, ForeignChain,
};
use ethers::prelude::*;
use state_chain_runtime::{EthereumInstance, Runtime, RuntimeCall};

Expand Down Expand Up @@ -78,8 +80,8 @@ where
try_into_encoded_address(try_into_primitive(dst_chain)?, dst_address.to_vec())?,
None,
event.tx_hash.into(),
// TODO: To update after PRO-1751 for both broker_fees and affiliate_fees
Default::default(),
vault_swap_parameters.broker_fees,
vault_swap_parameters.affiliate_fees,
Some(vault_swap_parameters.refund_params),
vault_swap_parameters.dca_params,
vault_swap_parameters.boost_fee,
Expand Down Expand Up @@ -108,8 +110,8 @@ where
try_into_encoded_address(try_into_primitive(dst_chain)?, dst_address.to_vec())?,
None,
event.tx_hash.into(),
// TODO: To update after PRO-1751 for both broker_fees and affiliate_fees
Default::default(),
vault_swap_parameters.broker_fees,
vault_swap_parameters.affiliate_fees,
Some(vault_swap_parameters.refund_params),
vault_swap_parameters.dca_params,
vault_swap_parameters.boost_fee,
Expand Down Expand Up @@ -152,8 +154,8 @@ where
},
}),
event.tx_hash.into(),
// TODO: To update after PRO-1751 for both broker_fees and affiliate_fees
Default::default(),
vault_swap_parameters.broker_fees,
vault_swap_parameters.affiliate_fees,
Some(vault_swap_parameters.refund_params),
vault_swap_parameters.dca_params,
vault_swap_parameters.boost_fee,
Expand Down Expand Up @@ -199,8 +201,8 @@ where
},
}),
event.tx_hash.into(),
// TODO: To update after PRO-1751 for both broker_fees and affiliate_fees
Default::default(),
vault_swap_parameters.broker_fees,
vault_swap_parameters.affiliate_fees,
Some(vault_swap_parameters.refund_params),
vault_swap_parameters.dca_params,
vault_swap_parameters.boost_fee,
Expand Down Expand Up @@ -247,7 +249,8 @@ pub trait IngressCallBuilder {
destination_address: EncodedAddress,
deposit_metadata: Option<CcmDepositMetadata>,
tx_hash: cf_primitives::TransactionHash,
broker_fees: cf_primitives::Beneficiaries<ShortId>,
broker_fees: Beneficiary<AccountId>,
affiliate_fees: Affiliates<ShortId>,
refund_params: Option<ChannelRefundParameters>,
dca_params: Option<DcaParameters>,
boost_fee: Option<BasisPoints>,
Expand Down

0 comments on commit fab6ad1

Please sign in to comment.