(Legacy) Integrate X Swap Contract
XY Finance deploys smart contracts of Swapper (X Swap) on most mainstream chains and benefits all types of users in terms of secure cross-chain swaps.
yBridge has been updated to version v3, and this v2 documentation is currently only for reference purposes. If you need to integrate with our new contracts, please refer to Integrate YBridge Contract to get the latest information.
XSwapper
Code
To enable ease of access to the content of the smart contracts (its code, data, status, etc.) and ascertain how they work and how they are programmed on the network, here we give you (users and institutions alike) the APIs and custom-fit UIs to suit your needs and provide you with a sense of security.
The link XSwapper.sol
below offers a collection of our code and functions. The smart contract accounts, deployed to the network, will interact with you when you submit transactions that execute functions that are defined on the smart contracts per se. Just like a regular, typical contract, our smart contracts define rules and will automatically implement them via the code.
Events
System Setting Related Events
StartSwapIdSet
This will be emitted when the starting swap ID is set.
FeeStructureSet
This will be emitted when the fee structure of a certain liquidity pool token on a certain chain is set
YPoolVaultSet
This will be emitted when a Y Pool (liquidity pool) is set.
AggregatorAdaptorSet
This will be emitted when an aggregator adaptor is set.
SwapValidatorXYChainSet
This will be emitted when the validator address (on settlement chain) is set.
AcceptSwapRequestSet
This will be emitted when the acceptSwapRequest is set. If true, XSwapper accepts swap request.
X Swap Related Events
SwapRequested
This will be emitted whenever a cross-chain swap request is initiated.
CloseSwapCompleted
This will be emitted by the time all a cross-chain swap request is processed at the target chain so as to keep a record of the request.
SwappedForUser
This will be emitted also by the time all a cross-chain swap request is processed at the target chain. However, this event records more information of the swap details than the CloseSwapCompleted
event.
SwapCompleted
This will be emitted when a cross-chain swap request is completed at the source chain. That is, the asset is settled and claimed back to the liquidity pool.
State-Changing Functions
swap
Initiate a cross-chain request and execute source chain side swap.
The aggregatorAdaptor
is to adapt to the DEX aggregator involved in the aggregatorData
.
The swapDesc
contains the information of the source chain side swap.
The aggregatorData
is generated by server containing source chain part of best routing path.
The toChainDesc
would be emitted in event to record target chain swap path and slippage. Note that the slippage would be seen as BP (1223 slippage equals to 12.23%).
swapWithReferrer
Initiate a cross-chain request and execute source chain side swap and leave a record of the referrer. Please contact us for more information about referral program.
singleChainSwap
Execute a single-chain swap.
The aggregator
is the DEX aggregator involved in the aggregatorData
.
The swapDesc
contains the information of the source chain side swap.
The aggregatorData
is generated by server containing source chain part of best routing path.
singleChainSwapWithReferrer
Execute a single-chain swap and leave a record of the referrer. Please contact us for more information about referral program.
View Functions
getSwapRequest
Get a certain swap request information by swap ID
getFeeStructure
Get the fee setting of a certain liquidity pool token of a certain chain.
For example, if you are using Ethereum
, you can get the fee setting of USDT
pool of Ethereum
by invoking
getFeeStructure(1, "0xdAC17F958D2ee523a2206206994597C13D831ec7")
;
you can also get the fee setting of USDT
pool of Polygon
by invoking
getFeeStructure(137, "0xdAC17F958D2ee523a2206206994597C13D831ec7")
.
This way you can figure out the fee setting when you try to bridge from Ethereum
to Polygon
via USDT
pool.
getEverClosed
Check whether a swap request is closed (processed) on target chain by the swap ID on the source chain and the source chain ID.
getTokenBalance
Get balance of an account of a token.
Last updated
Was this helpful?