Swap tokens

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Parameters)
 
(3 intermediate revisions by one user not shown)
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 one token for another using a decentralized exchange.
  
 
== Parameters ==
 
== Parameters ==
 +
 +
'''Exchange:''' The decentralized exchange where the tokens will be swapped.
  
'''Exchange:''' The decentralized exchange platform on which the token swap will be executed. You can select a specific exchange from the dropdown menu.
+
'''Token In ID''': The token you wish to exchange/sell. This can be the symbol of the token or its contract address.
  
'''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 Out ID''': The token you wish to get/buy. This can be the symbol of the token or its contract address.
  
'''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.
+
'''Amount:''' The quantity of the 'Token In ID' you wish to swap.
  
'''Amount:''' The quantity of the 'Token In' that you wish to swap.
+
'''Transaction Info Variable:''' (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 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.
+
  
 
== Example ==
 
== Example ==
Line 17: Line 17:
 
<pre>
 
<pre>
 
ui console view
 
ui console view
config defi wallet("your private key here")
+
config defi wallet("your private key")
swap tokens("PancakeSwap","0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c","0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82","10")
+
swap tokens("PancakeSwap","BTC","ETH","0.01","#txinfo")
log("Transaction Info: {#txinfo}")
+
log object(#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.
+
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.
  
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.
+
This code snippet would swap 0.01 BTC for ETH on PancakeSwap and log the transaction details.
  
The actual output might look something like:  
+
Note: This assumes that you have enough of the token that you're selling for the transaction. It also assumes you have enough of the native token to pay gas fees.
<blockquote>
+
Transaction Info: {"blockHash":"0x1f51bbceec31819c5ab9a17a73e6cf9a1f412ac85a34005d6ca522a34450dc53","blockNumber":11061824,"contractAddress":null,"cumulativeGasUsed":1690539,"from":"0xe3f3589c4943f8c8a3b2b4c5b5a837c215ba3a8b","gasUsed":21706,"logsBloom":"0x04000000000000040040000000000000000000000000..."}
+
</blockquote>
+

Latest revision as of 02:05, 5 July 2023

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

[edit] Parameters

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

Token In ID: The token you wish to exchange/sell. This can be the symbol of the token or its contract address.

Token Out ID: The token you wish to get/buy. This can be the symbol of the token or its contract address.

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

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

[edit] Example

ui console view
config defi wallet("your private key")
swap tokens("PancakeSwap","BTC","ETH","0.01","#txinfo")
log object(#txinfo)

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: This assumes that you have enough of the token that you're selling for the transaction. It also assumes you have enough of the native token to pay gas fees.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox