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. This action is typically carried out by enterprise users involved in trading or managing diversified portfolios on decentralized exchanges.
+
'''swap tokens''' is a command that allows you to swap tokens 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").
  
 
== Parameters ==
 
== Parameters ==
  
'''Exchange:''' The decentralized exchange platform on which the token swap will be executed. You can select a specific exchange from the dropdown menu.
+
'''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 identifier for the token you want to swap from. You can either select a token from the dropdown menu or enter its contract address.
+
'''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 identifier for the token you want to swap to. You can either select a token from the dropdown menu or enter its contract address.
+
'''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' that you wish to swap.
+
'''Amount:''' The amount of the "Token In ID" that you want to swap.
  
'''Transaction Info Variable:''' (Optional) The name of a variable you can use to store the transaction information associated with the token swap. If not specified, the default value '#txinfo' is used.
+
'''Transaction Info Variable:''' (optional) The variable which stores the transaction information after the swap occurs. Default is '#txinfo'.
  
 
== Example ==
 
== Example ==
 
 
<pre>
 
<pre>
ui console view
+
swap tokens("PancakeSwap", "BUSD", "BNB", "500", '#transaction details')
config defi wallet("your private key here")
+
alert(#transaction details)
swap tokens("PancakeSwap","0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c","0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82","10")
+
log("Transaction Info: {#txinfo}")
+
 
</pre>
 
</pre>
  
Note that you should replace "your private key here" with your actual private key. Private keys are sensitive information that should be handled with ultimate care.
+
This script conducts a swap operation on PancakeSwap, swapping 500 BUSD for BNB. The details of the transaction are then alerted to the user.  
 
+
The output of this script will be the transaction info of the token swap action. For example, it could include details like the transaction hash, the number of gas used, the time at which the transaction was included in a block, etc.
+
  
The actual output might look something like:
+
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.
<blockquote>
+
Transaction Info: {"blockHash":"0x1f51bbceec31819c5ab9a17a73e6cf9a1f412ac85a34005d6ca522a34450dc53","blockNumber":11061824,"contractAddress":null,"cumulativeGasUsed":1690539,"from":"0xe3f3589c4943f8c8a3b2b4c5b5a837c215ba3a8b","gasUsed":21706,"logsBloom":"0x04000000000000040040000000000000000000000000..."}
+
</blockquote>
+

Revision as of 19:07, 4 July 2023

swap tokens is a command that allows you to swap tokens 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").

Parameters

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 which you want to swap from. The available tokens will depend on the "CoinNames" list set in your environment.

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 amount of the "Token In ID" that you want to swap.

Transaction Info Variable: (optional) The variable which stores the transaction information after the swap occurs. Default is '#txinfo'.

Example

swap tokens("PancakeSwap", "BUSD", "BNB", "500", '#transaction details')
alert(#transaction details)

This script conducts a swap operation on PancakeSwap, swapping 500 BUSD for BNB. The details of the transaction are then alerted to the user.

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.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox