Skip to content

[Python SDK] <how to swap tokens in one wallet?> #104

Closed Answered by danijelTxFusion
ManutdGTA asked this question in SDKs
Discussion options

You must be logged in to vote

Atomic swap provides token swap within a single account.

orderA = await wallet.get_order('USDT', 'ETH', Fraction(1500, 1), RatioType.token, Decimal('10.0'))
orderB = await wallet.get_order('ETH', 'USDT', Fraction(1, 1200), RatioType.token, Decimal('0.007'))

swap = await wallet.swap((orderA, orderB), 'ETH')

Pay attention to following limitations (docs):

  • orders have matching tokens: if orderA specifies tokenA -> tokenB, then orderB should specify tokenB -> tokenA
  • ratios in orders are compatible: 1/orderB.ratio <= orderA.amount/orderB.amount <= orderA.ratio
  • if orders have recipients, their accounts already exist in zkSync

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ManutdGTA
Comment options

Answer selected by uF4No

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
SDKs
Labels
sdk Questions for the SDKs zksync-lite Discussions related to zkSync Lite (v1.0)
7 participants