Skip to content

Implement swap intent for pumpx #3354

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

Merged
merged 37 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0c7aacf
Add a required `usd_worth` field to the PumpxConfig and
silva-fj Apr 9, 2025
469e206
updating types
silva-fj Apr 9, 2025
0c95790
adding validation on submit_swap_order
silva-fj Apr 9, 2025
38a1174
adding workspace dependencies
silva-fj Apr 9, 2025
c80efa7
feat(cross-chain): add PumpxApi & StorageDB to executor
silva-fj Apr 9, 2025
7f762e2
initial work for pumpx swap (market orders)
silva-fj Apr 9, 2025
9c7df75
Merge branch 'dev' into p-1427-implement-cross-chain-swap-intent-for-…
silva-fj Apr 9, 2025
ad69a29
fix(cross-chain): move create_cross_order inside if block
silva-fj Apr 9, 2025
aa1dc41
fixing TODO's
silva-fj Apr 9, 2025
a6fe75e
removing TODO
silva-fj Apr 9, 2025
044d61d
removing comments
silva-fj Apr 9, 2025
74364f7
small cleanup
silva-fj Apr 9, 2025
7feb39a
updating pumpx api types
silva-fj Apr 9, 2025
8aef09f
setting up limit orders
silva-fj Apr 9, 2025
22a32ec
removing warning
silva-fj Apr 9, 2025
ece144b
adding codec to cross-chain executor
silva-fj Apr 10, 2025
da1e0d5
feat(intent): add return data support in executors
silva-fj Apr 10, 2025
c72fb2a
adding support for submit_swap_order responses (from pumpx api)
silva-fj Apr 10, 2025
0c9e2f5
feat(omni-executor): implement intent ID for PumpX swaps
silva-fj Apr 10, 2025
03f498f
don't check OmniAccount storage
silva-fj Apr 10, 2025
040db51
fixing pumpx types
silva-fj Apr 10, 2025
04bf656
feat(pumpx): change SwapOrder amount from u64 to string
silva-fj Apr 10, 2025
96a1b5b
fixing native-task-handler
silva-fj Apr 10, 2025
6be1b85
fixing errors
silva-fj Apr 10, 2025
7907054
commenting out rest of locking mechanism
silva-fj Apr 10, 2025
fd5884a
fix(cross-chain): refactor PumpX cross-order creation
silva-fj Apr 10, 2025
38703e1
refactor(pumpx): restructure swap order response
silva-fj Apr 10, 2025
65b1f94
Merge branch 'dev' into p-1427-implement-cross-chain-swap-intent-for-…
silva-fj Apr 10, 2025
653da90
feat: implement tx signing for pumpx swaps
silva-fj Apr 10, 2025
bf6ff87
setting correct pumpx wallet address
silva-fj Apr 10, 2025
abe6324
updating parentchain api-interface
silva-fj Apr 10, 2025
eb658fc
make sure signature has hex prefix
silva-fj Apr 10, 2025
9c1aa52
Merge branch 'dev' into p-1427-implement-cross-chain-swap-intent-for-…
silva-fj Apr 10, 2025
3a153b0
Merge branch 'dev' into p-1427-implement-cross-chain-swap-intent-for-…
silva-fj Apr 10, 2025
ba157da
feat(cross-chain): change CrossOrderInfo to a vector
silva-fj Apr 10, 2025
40a3a64
fixing TODOs, using real wallet address
silva-fj Apr 10, 2025
a849594
Merge remote-tracking branch 'origin/dev' into p-1427-implement-cross…
silva-fj Apr 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/primitives/core/src/omni/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ pub enum ChainAsset {
Ethereum(u32, EthereumToken), // with chain id
Solana(SolanaToken),
}

impl ChainAsset {
pub fn is_same_chain(&self, other: &Self) -> bool {
match (self, other) {
(ChainAsset::Ethereum(id1, _), ChainAsset::Ethereum(id2, _)) => id1 == id2,
(ChainAsset::Solana(_), ChainAsset::Solana(_)) => true,
_ => false,
}
}
}
4 changes: 3 additions & 1 deletion common/primitives/core/src/omni/intent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use sp_runtime::traits::ConstU32;
pub type CallEthereumInputLen = ConstU32<{ 10 * 1024 }>;
pub type RemarkLen = ConstU32<{ u32::max_value() }>;
pub type IntentStringLen = ConstU32<128>;
pub type AmountLen = ConstU32<32>;

pub type IntentId = u32;

Expand Down Expand Up @@ -67,7 +68,7 @@ pub enum HeimaMultiAddress {
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)]
pub struct SwapOrder {
pub from_asset: ChainAsset,
pub from_amount: u64,
pub from_amount: BoundedVec<u8, AmountLen>,
pub to_asset: ChainAsset,
pub to_address: Option<HeimaMultiAddress>,
}
Expand Down Expand Up @@ -105,6 +106,7 @@ pub struct PumpxConfig {
// below is only relevant to limit order, thus `Option<>`
pub token_cap: Option<BoundedVec<u8, IntentStringLen>>,
pub price_usd: Option<BoundedVec<u8, IntentStringLen>>,
pub usd_worth: BoundedVec<u8, IntentStringLen>,
pub trailing_percent: Option<u32>,
}

Expand Down
4 changes: 4 additions & 0 deletions tee-worker/omni-executor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tee-worker/omni-executor/executor-core/src/intent_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait IntentExecutor: Send {
account_id: &AccountId,
intent_id: IntentId,
intent: Intent,
) -> Result<(), ()>;
) -> Result<Option<Vec<u8>>, ()>;
Copy link
Member

Choose a reason for hiding this comment

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

Can this be generic ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean like a trait object?

}

pub struct MockedIntentExecutor {
Expand All @@ -50,7 +50,7 @@ impl IntentExecutor for MockedIntentExecutor {
_account_id: &AccountId,
_intent_id: IntentId,
_intent: Intent,
) -> Result<(), ()> {
self.sender.send(()).map_err(|_| ())
) -> Result<Option<Vec<u8>>, ()> {
self.sender.send(()).map(|_| None).map_err(|_| ())
}
}
8 changes: 5 additions & 3 deletions tee-worker/omni-executor/executor-worker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,18 @@ async fn main() -> Result<(), ()> {
rpc_endpoint_registry.insert(Chain::Ethereum(97), bsc_testnet_url.to_owned());
}

let pumpx_api_base_url = std::env::var("OE_PUMPX_API_BASE_URL").ok();
let pumpx_api = Arc::new(PumpxApi::new(pumpx_api_base_url));

let cross_chain_intent_executor = CrossChainIntentExecutor::new(
parentchain_rpc_client_factory.clone(),
tx_signer.clone(),
rpc_endpoint_registry,
pumpx_signer_client.clone(),
pumpx_api.clone(),
storage_db.clone(),
)?;

let pumpx_api_base_url = std::env::var("OE_PUMPX_API_BASE_URL").ok();
let pumpx_api = Arc::new(PumpxApi::new(pumpx_api_base_url));

let intent_id_store: Arc<Box<dyn IntentIdStore>> =
Arc::new(Box::new(StorageDbIntentIdStore::new(storage_db.clone())));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ edition.workspace = true

[dependencies]
async-trait = { workspace = true }
hex = { workspace = true }
log = { workspace = true }
parity-scale-codec = { workspace = true }

# Local dependencies
executor-core = { workspace = true }
executor-primitives = { workspace = true }
executor-storage = { workspace = true }
heima-authentication = { workspace = true }
intent-asset-lock = { workspace = true }
intent-token-query = { workspace = true }
parentchain-api-interface = { workspace = true }
Expand Down
Loading
Loading