-
Notifications
You must be signed in to change notification settings - Fork 760
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
Dispatchable Call for Swapping Treasury Asset #2939
base: master
Are you sure you want to change the base?
Conversation
...s/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs
Outdated
Show resolved
Hide resolved
match ensure_signed(origin.clone()) { | ||
Err(e) if T::SpendOrigin::ensure_origin(origin).is_err() => Err(e), | ||
_ => Ok(()), | ||
}?; |
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.
nit: This could be a separate function.
Is the reason we try the check for SpendOrigin
because the call coming from the XCM in the test is not actually a signed origin, but an XCM origin?
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.
Yes.
Might be any pallets origin, not only XCM.
...s/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/treasury.rs
Outdated
Show resolved
Hide resolved
EnsureSignedBy< | ||
impls::MemberByLocation< | ||
xcm_config::RelayTreasuryVoice, | ||
xcm_config::LocationToAccountId, | ||
AccountId, | ||
>, | ||
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.
XCM Transact instruction to swap treasury funds received with SovereignAccount
origin kind, because swap
calls must be signed by AccountId
. The swap calls are not executed with Transact
instruction, but scheduled with the schedule
call, which is permissioned with this ScheduleOrigin
type. This is why we need to EnsureSignedBy
here.
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.
Alternatively same can be achieved if a call requiring an account will be wrapped with a call like dispatch_as_account
: #4197
@@ -13,7 +13,8 @@ | |||
// See the License for the specific language governing permissions and | |||
// limitations under the License. | |||
|
|||
use crate::*; | |||
// use crate::*; |
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.
// use crate::*; |
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, my previous comments are all addressed 👍
Presenting a dispatchable call executed in the integration test environment, where the treasury's native asset is swapped for another asset on Asset Hub through the asset conversion pallet instance.
The swaps can be split into multiple swaps with retries to implement the DCA model.
The purpose of this PR is to explore and demonstrate the potential for swapping and diversifying treasury assets.