Closed kunj77 closed 5 months ago
I see you got passed the "corresponding swap output not found" :+1:. For the Fail: ...
error, the check that must pass is: offer_taken * price_num <= ask_given * price_den
. It looks like the starting balance for your swap is 150,000,000 MyUSD and you have a price of 1:1. So if you are taking all if it, you must deposit 150,000,000 of DjedMicroUSD. I'm not familiar with JavaScript (and lucid), but it doesn't seem like you are providing enough DjedMicroUSD. I don't see it among your assetsToSend
. I only see ada, the beacons, and 1,000,000 MyUSD.
it works! Thank you for your help @fallen-icarus
I am trying to execute a one way swap - however, its not letting me withdraw the offer tokens
This is the datum of my swap utxo
datum { beaconId: '47cec2a1404ed91fc31124f29db15dc1aae77e0617868bcef351b8fd', pairBeacon: 'df91e329aa5a47288aca86568d24d4c1dbd69c8483934d0795fdc2c4fd13ec2c', offerId: '91d4f382273f442f15e9da48cb23349ba275f8818e4c7ac5d1004a16', offerName: '4d79555344', offerBeacon: '461e1f087114b671d83b7b461fb93ac6c89b3ee5491deae6a91039bef997a9b6', askId: 'cd453198b8056208716e175e2638f99465712d79d1f39b34248c8bee', askName: '446a65644d6963726f555344', askBeacon: '016e1bc9aafb50bf22059a36db003e16e3e43d415cf8eae5f122d251f66ca307', swapPrice: { numerator: 150000000n, denominator: 150000000n }, prevInput: null }
and this is the datum am supplying inline while trying to execute the swap
{ beaconId: '47cec2a1404ed91fc31124f29db15dc1aae77e0617868bcef351b8fd', pairBeacon: 'df91e329aa5a47288aca86568d24d4c1dbd69c8483934d0795fdc2c4fd13ec2c', offerId: '91d4f382273f442f15e9da48cb23349ba275f8818e4c7ac5d1004a16', offerName: '4d79555344', offerBeacon: '461e1f087114b671d83b7b461fb93ac6c89b3ee5491deae6a91039bef997a9b6', askId: 'cd453198b8056208716e175e2638f99465712d79d1f39b34248c8bee', askName: '446a65644d6963726f555344', askBeacon: '016e1bc9aafb50bf22059a36db003e16e3e43d415cf8eae5f122d251f66ca307', swapPrice: { numerator: 150000000n, denominator: 150000000n }, prevInput: { transactionId: { hash: '4c37615d6110f93e64ce28b948745e712ffc836234be7ac0238874030eb0dacb' }, outputIndex: 0n } }
This is my transaction ` const assetsToSend = { lovelace: 1000000n, '47cec2a1404ed91fc31124f29db15dc1aae77e0617868bcef351b8fd016e1bc9aafb50bf22059a36db003e16e3e43d415cf8eae5f122d251f66ca307': 1n, '47cec2a1404ed91fc31124f29db15dc1aae77e0617868bcef351b8fd461e1f087114b671d83b7b461fb93ac6c89b3ee5491deae6a91039bef997a9b6': 1n, '47cec2a1404ed91fc31124f29db15dc1aae77e0617868bcef351b8fddf91e329aa5a47288aca86568d24d4c1dbd69c8483934d0795fdc2c4fd13ec2c': 1n, '91d4f382273f442f15e9da48cb23349ba275f8818e4c7ac5d1004a164d79555344': 1000000n, //withdrawing total offer tokens - 1 to the lucid.wallet.address };
const tx = lucid .newTx() .validTo(Date.now() + 200000) .collectFrom([utxo], Data.to(new Constr(2, []))) .payToContract( utxo.address, { inline: Data.to(datum, OneWaySwapDatum) }, assetsToSend );`
However, am getting error
Fail: offer_taken * price <= ask_given
it works if I setassetsToSend to the utxo.assets
so basically if I dont change any assets only then it works. But I need to withdraw the offer asset. Can you please help me understand what I am missing?