-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: add/update contract swaps parameters #5343
Conversation
That makes sense to me. Especially when we implement the changes in CCM swaps, regular swaps and CCM swaps will be almost identical for the majority of the swap flow. So I'd be in favor of doing it if the breaking change is not annoying to handle on upgrade. |
@@ -1147,76 +1132,30 @@ pub mod pallet { | |||
#[pallet::weight(T::WeightInfo::contract_ccm_swap_request())] | |||
pub fn contract_ccm_swap_request( |
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.
Yeah let's just merge these. They can only be called via witnessing so for backwards-compatibility / to avoid migration headaches, we could keep and deprecate the old ones and add a new one. Then we can remove the new one at a later release.
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.
Haven't we already broken compatibility by adding new parameters?
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.
As discussed - I guess we did 😅
But given that we are now aware of this, let's avoid breaking - it's easy to do.
This is/was to communicate (visibly) that something went wrong, without returning an error, because returning an error in the extrinsic rolls back the state, and we don't want to do that in a witnessed transaction. If anything, we should emit a failure event for the address decoding too. A cleaner approach might be to create an Error enum and return that from process_contract_swap_request (then we can write the code a bit more concisely/idiomatically), and log that error in an event, say |
@@ -1139,6 +1141,7 @@ pub mod pallet { | |||
deposit_metadata: CcmDepositMetadata, | |||
tx_hash: TransactionHash, | |||
deposit_details: Box<<T::TargetChain as Chain>::DepositDetails>, | |||
broker_fees: Beneficiaries<T::AccountId>, |
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.
As discussed in the ticket below, and more particularly on the comment, we'll need to pass the accounts and commission/fees for both the broker and the affiliates. Do we use this parameter for both (e.g. first account is the broker) or we separate them?
This also runs into what I recently discussed with @dandanlen on whether we should make passing the brokerId mandatory for Vault swaps.
https://linear.app/chainflip/issue/PRO-1743/support-for-brokeraffiliate-fees-via-vault-swaps
https://linear.app/chainflip/issue/PRO-1743/support-for-brokeraffiliate-fees-via-vault-swaps#comment-338490a3
I'm not sure there is an easy answer for whether it should be mandatory but it can make sense to separate them here just for flexibility in the future. That's either by having two separate parameters or by this broker_fees
having two separate parameters.
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 think this approach is fine for now - we don't need to worry too much about breaking changes here because it only really affects us (it's a witnessed call), and isn't something that is exposed externally.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5343 +/- ##
======================================
- Coverage 71% 71% -0%
======================================
Files 495 495
Lines 86335 86286 -49
Branches 86335 86286 -49
======================================
- Hits 61623 61509 -114
- Misses 21951 22009 +58
- Partials 2761 2768 +7 ☔ View full report in Codecov by Sentry. |
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 👌
Sorry that commit should be |
d41959d
to
2ff3128
Compare
…waps-close-accounts * origin/main: (44 commits) fix: expire all previous epochs (#5279) feat: add/update contract swaps parameters (#5343) chore: add address to solana logging (#5353) fix: ignore dust underflows in order fills rpc (#5352) chore: consistent naming prewitnessed (#5351) feat: engine-runner verifies gpg signature of old dylib when downloaded (#5339) feat: tainted transaction reporting (#5310) bug: change_utxo not always present (#5340) feat: structured error return types for rpcs (#5346) chore: unify dependencies to root cargo.toml (#5333) feat: Submit a slot number alongside nonce (#5297) chore: use node version from `.nvmrc` 📌 (#5336) chore: add engine account_info logging (#5347) chore: replace manual scale encoding for ts-scale (#5335) chore: more consistent params in Broker API (#5342) feat: broker can encode btc smart contract call (#5329) chore: localnet recreate script can use defaults (#5338) feat: witnessing btc smart contract swaps (#5331) feat: Solana CCM fallback (#5316) fix: scale types for pending ceremonies (#5286) ... # Conflicts: # Cargo.lock # state-chain/chains/src/sol/api.rs # state-chain/pallets/cf-broadcast/src/migrations.rs # state-chain/pallets/cf-environment/Cargo.toml
Pull Request
Closes: PRO-1731, PRO-1732
Added missing parameters (FoK, DCA, Boost) to contract swap extrinsics (
contract_swap_request
andcontract_ccm_swap_request
); these parameters are now passed into the swapping pallet and will be used if provided. (fyi @albert-llimos)Made some parameters more consistent (and to make sure we don't have to assert/convert when passing them further):
from
type changedAsset
->TargetChainAsset<T, I>
deposit_amount
type changedAssetAmount
-><T::TargetChain as Chain>::ChainAmount
Contract swaps now validate DCA/FoK parameters and enforce minimum deposit amount
Most code in both extrinsics is the same, so I factored it out into
process_contract_swap_request
BREAKING CHANGES (fyi @acdibble)
DepositIgnored
event:deposit_address
is now optional; this to be able to ignore deposits made directly into our valut.CcmFailed
was emitted on invalid destination address in case ccm parameters were provided. I made it more consistent with non-ccm contract swaps where we just log a warning, which also made the code simpler. (CcmFailed
is still emitted when a deposit/swap fails for ccm-sepcific reason.) As such, I also removed theCcmFailReason::InvalidDestinationAddress
variant.Discussion:
contract_swap_request
) that supports both CCM and non-CCM by acception an optional ccm_deposit_metadata parameter?CcmFailed
seems odd. We don't really have any other events for when other parameters are invalid. Is it used anywhere? Can we simplify code by removing it and replacing it with a warning (like we do for other parameters).