XY Finance
Search…
⌃K

X Swap Widget

X Swap Widget is easy to embed into your apps and sites alike, helping engage and retain your users.
XY Finance team has been wracking our brains just to come up with a powerful engagement tool to help strengthen your user retention, making them want to come back more for a satisfying user experience that this widget provides for your website and reducing friction by letting them fast-forward into your app's/site's key functionality. Note that this X Swap Widget will be constantly renewed as we're also gathering more resources and collecting feedback from users along the way. The "Get Started" section below gives a step-by-step walkthrough as to how you're supposed to do to complete the embedding process and personalize your web/app experience, making transactions on your protocol way easier and interfaces look gracefully effortless! The "Configuration" section, however, categorizes the elements (keys) in the code, providing a clearer picture with regard to the website embedded.

Get Started

Step 1. Paste this code as high in the <head> of the page as possible
<script defer type="text/javascript" src="https://widget.xy.finance/js/bundle.min.js"></script>
Step 2. Paste this <div> tag to the place where you need Widget to display in body
<div id="xy-finance-widget-root"></div>
Step 3. Paste this <script> to the bottom of body
<script defer>
// set default config
let config = {
fromTokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
sourceChainId: '1',
toTokenAddress: '0x77777777772cf0455fB38eE0e75f38034dFa50DE',
targetChainId: '1',
amount: 1,
slippage: '1',
orientation: 'portrait',
theme: 'dark',
lockmode: 'none',
pagecolor: null
}
// use widget
xyFinaceWidget.init(config);
</script>

Configuration

Key
Type
Default
Note
fromTokenAddress
String
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
sourceChainId
String
'1'
toTokenAddress
String
'0x77777777772cf0455fB38eE0e75f38034dFa50DE'
targetChainId
String
'1'
amount
Number
1
slippage
String
'1'
If the difference between the estimated quote and execution price exceeds the rate(default rate 1%),the tx will be revoked.
orientation
portrait | landscape
portrait
For now, only support 'portrait'
theme
dark | light
dark
lockmode
none or both or fromToken or toToken
none
Disable user select Token
pagecolor
String or null
null
Only use HexColor without #
The "sourceChainId" and "targetChainId" in the configuration can be found in the page below.
Theme : Dark
Theme : Light