This shows you the differences between two versions of the page.
fob:laboratoare:08 [2022/12/14 20:43] costin.carabas |
fob:laboratoare:08 [2022/12/15 18:28] (current) costin.carabas |
||
---|---|---|---|
Line 6: | Line 6: | ||
Tasks for this practical session: | Tasks for this practical session: | ||
+ | - Create tokens: First Token, Second Token, LiquidityPool Token (see previous labs) | ||
- Build SC (see previous labs) | - Build SC (see previous labs) | ||
- Deploy SC (see previous labs) | - Deploy SC (see previous labs) | ||
- | - Create tokens: First Token, Second Token, LiquidityPool Token (see previous labs) | ||
- Set Roles of deployed SC: setTransferExecGasLimit, setLpTokenIdentifier, setSpecialRoleToken | - Set Roles of deployed SC: setTransferExecGasLimit, setLpTokenIdentifier, setSpecialRoleToken | ||
- Add Liquidity | - Add Liquidity | ||
Line 55: | Line 55: | ||
=== Add and Remove Liquidity === | === Add and Remove Liquidity === | ||
+ | |||
+ | <note warning>To add liquidity to the Pair SC you have to send two tokens. Please use [[https://docs.elrond.com/sdk-and-tools/erdpy/smart-contract-interactions/#multi-esdt-transfer|Multi ESDT Transfer]] documentation.</note> | ||
Now that the Pair SC is configured, you can call [[https://github.com/systems-cs-pub-ro/Foundation-Of-Blockchains/blob/5634f03ce56ba191a0e6685f6b5e675f02c9431f/labs/lab07/lab07/src/lib.rs#L88|addLiquidity]] and [[https://github.com/systems-cs-pub-ro/Foundation-Of-Blockchains/blob/5634f03ce56ba191a0e6685f6b5e675f02c9431f/labs/lab07/lab07/src/lib.rs#L190|removeLiquidity]]. | Now that the Pair SC is configured, you can call [[https://github.com/systems-cs-pub-ro/Foundation-Of-Blockchains/blob/5634f03ce56ba191a0e6685f6b5e675f02c9431f/labs/lab07/lab07/src/lib.rs#L88|addLiquidity]] and [[https://github.com/systems-cs-pub-ro/Foundation-Of-Blockchains/blob/5634f03ce56ba191a0e6685f6b5e675f02c9431f/labs/lab07/lab07/src/lib.rs#L190|removeLiquidity]]. | ||
<note important>Check the transactions. What tokens were sent/received?</note> | <note important>Check the transactions. What tokens were sent/received?</note> | ||
+ | |||
+ | The transactions should follow the order: | ||
+ | <code> | ||
+ | MultiESDTNFTTransfer@Contract_address_in_hex@02@Token1Identifier_in_hex@Token1Nonce_in_hex@Token1Value_in_hex@Token2Identifier_in_hex@Token2Nonce_in_hex@Token2Value_in_hex@myEndpoint_in_hex@parameters | ||
+ | </code> | ||
=== Swaps === | === Swaps === | ||
Line 63: | Line 70: | ||
Now with the SC configured and having liquidity, you can perform swaps using [[https://github.com/systems-cs-pub-ro/Foundation-Of-Blockchains/blob/5634f03ce56ba191a0e6685f6b5e675f02c9431f/labs/lab07/lab07/src/lib.rs#L351|swap_tokens_fixed_input]] and [[https://github.com/systems-cs-pub-ro/Foundation-Of-Blockchains/blob/5634f03ce56ba191a0e6685f6b5e675f02c9431f/labs/lab07/lab07/src/lib.rs#L438|swap_tokens_fixed_output]]. Remember the difference from last lab? | Now with the SC configured and having liquidity, you can perform swaps using [[https://github.com/systems-cs-pub-ro/Foundation-Of-Blockchains/blob/5634f03ce56ba191a0e6685f6b5e675f02c9431f/labs/lab07/lab07/src/lib.rs#L351|swap_tokens_fixed_input]] and [[https://github.com/systems-cs-pub-ro/Foundation-Of-Blockchains/blob/5634f03ce56ba191a0e6685f6b5e675f02c9431f/labs/lab07/lab07/src/lib.rs#L438|swap_tokens_fixed_output]]. Remember the difference from last lab? | ||
<note important>What happens with the ratio Token1/Token2?</note> | <note important>What happens with the ratio Token1/Token2?</note> | ||
- | |||
=== Bonus === | === Bonus === | ||
This Pair SC has a vulnerability. Can you find it? | This Pair SC has a vulnerability. Can you find it? |