Swap tokens

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
'''swap tokens''' is a command that allows you to swap tokens using a decentralized exchange.
+
'''swap tokens''' is a command that allows you to swap one token for another using a decentralized exchange.
  
By utilizing this command, you can swap a token ("Token In ID") for another token ("Token Out ID") on a given decentralized exchange ("Exchange").
+
This command is beneficial for users who wish to exchange one type of token for another via protocols like Uniswap, PancakeSwap, etc.
  
 
== Parameters ==
 
== Parameters ==
 +
 +
'''Exchange:''' The decentralized exchange where the tokens will be swapped.
  
'''Exchange:''' The decentralized exchange on which you want to conduct the token swap. The available exchanges will be dependent on the "SwapNames" list set in your environment.
+
'''Token In ID''': The token you wish to exchange/sell.
  
'''Token In ID:''' The token which you want to swap from. The available tokens will depend on the "CoinNames" list set in your environment.
+
'''Token Out ID''': The token you wish to get/buy.
  
'''Token Out ID:''' The desired token which you want to acquire from the swap. The available tokens will depend on the "CoinNames" list set in your environment.
+
'''Amount:''' The quantity of the 'Token In ID' you wish to swap.
  
'''Amount:''' The amount of the "Token In ID" that you want to swap.
+
'''Transaction Info Variable:''' (Advanced, Optional) This variable is used to retrieve the transaction information after the execution. The default value for this variable is '#txinfo'.
 
+
'''Transaction Info Variable:''' (optional) The variable which stores the transaction information after the swap occurs. Default is '#txinfo'.
+
  
 
== Example ==
 
== Example ==
 +
 
<pre>
 
<pre>
swap tokens("PancakeSwap", "BUSD", "BNB", "500", '#transaction details')
+
config defi wallet("your private key")
alert(#transaction details)
+
swap tokens("PancakeSwap","BTC","ETH","0.01","#txOutput")
 +
log object(#txOutput)
 
</pre>
 
</pre>
  
This script conducts a swap operation on PancakeSwap, swapping 500 BUSD for BNB. The details of the transaction are then alerted to the user.  
+
Please replace "your private key" with your actual DeFi wallet's private key.
 +
 
 +
Be mindful when you are handling your private key. It's a sensitive piece of data that allows full control over your funds in your DeFi wallet. Therefore, never share this key publicly or with anyone.
 +
 
 +
This code snippet would swap 0.01 BTC for ETH on PancakeSwap and log the transaction details.
  
Remember, all transactions on blockchain are irreversible, so always double-check before executing a script. The token names and values you replace in the script should match exactly with the actual tokens that exist on the specified blockchain and your wallet's holdings.
+
Note: Always ensure you have enough balance and correct token ID before moving forward with the swap, because once the transaction is confirmed, it cannot be reversed. Also, consider blockchain network fees while estimating your transaction.

Revision as of 20:03, 4 July 2023

swap tokens is a command that allows you to swap one token for another using a decentralized exchange.

This command is beneficial for users who wish to exchange one type of token for another via protocols like Uniswap, PancakeSwap, etc.

Parameters

Exchange: The decentralized exchange where the tokens will be swapped.

Token In ID: The token you wish to exchange/sell.

Token Out ID: The token you wish to get/buy.

Amount: The quantity of the 'Token In ID' you wish to swap.

Transaction Info Variable: (Advanced, Optional) This variable is used to retrieve the transaction information after the execution. The default value for this variable is '#txinfo'.

Example

config defi wallet("your private key")
swap tokens("PancakeSwap","BTC","ETH","0.01","#txOutput")
log object(#txOutput)

Please replace "your private key" with your actual DeFi wallet's private key.

Be mindful when you are handling your private key. It's a sensitive piece of data that allows full control over your funds in your DeFi wallet. Therefore, never share this key publicly or with anyone.

This code snippet would swap 0.01 BTC for ETH on PancakeSwap and log the transaction details.

Note: Always ensure you have enough balance and correct token ID before moving forward with the swap, because once the transaction is confirmed, it cannot be reversed. Also, consider blockchain network fees while estimating your transaction.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox