1

I am trying to figure out the SpicySwap swap fees. Since there is no public implementation available to my knowledge, I am studying the michelson code. For example:

https://tzkt.io/KT1NN1NgmKFTW5FUWiyxVjUt3kH9bCiqgxLW/code

Surprisingly, there seem to be no math operations in this contract, which is weird because it contains a swap entrypoint. The contract storage has a contract_code big_map, which might contain something relevant. In this map, there is a "finalize" key:

https://tzkt.io/KT1NN1NgmKFTW5FUWiyxVjUt3kH9bCiqgxLW/storage/19579

I would like to check this out, but the value is in "bytes" format. How do I decode this into michelson code?

2 Answers 2

1

Those bytes unpack to a lambda. You can deserialize the bytes by running the following command:

tezos-client -E https://mainnet.visualtez.com unpack michelson data '0x<bytes>'

1
  • 1
    Thank you, this worked nicely
    – PEC
    Apr 29, 2022 at 20:00
2

I'm the creator of SpicySwap and yes if you unpack the bytes in contract_code you'll find the lambdas with actual code. Not sure how useful they will be though.

For anything math related, just look at UniswapV2 pair contract. All the mathy stuff is exactly the same, but in a Tezos contract.

For example fees:

uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));

Spicy does the same thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.