Gateway Fee Collection
How Fee Collection works on Gateway Contracts​
How Fee Collection works on Socket Gateway​
- Fees will always be deducted from the inputToken on the source chain. Fees are deducted for swap txs and bridging txs.
- Fees can now dynamically be set when calling the Quote endpoint. Two new params need to be passed when calling Quote endpoint —
feePercent
andfeeTakerAddress
- Please contact the Socket team for the
feeTakerAddress
. We’ll set this contract for you & share the address - The Fee Collection logic lies in the FeesTakerController contract. FeesTakerController is a part of the (new) SocketGateway contracts. The contract has been audited and deployed on all the supported chains.
Passing Fee Params in Quote​
- Two new query parameters have been introduced in Quote endpoint
Parameter Description feePercent The % of fee to be cut from the source input token amount NOTE : Fee Percent can be up to three decimal places and cannot be more than 5% feeTakerAddress Contact the Socket team for the feeTakerAddress value
Example Quote Request​
Quote for deducting 5% fee on swapping 0.033 ETH to USDC on Arbitrum
curl --location --request GET 'https://api.socket.tech/v2/quote?userAddress=0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53&singleTxOnly=true&bridgeWithGas=false&sort=output&isContractCall=false&fromChainId=42161&toChainId=42161&fromTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&toTokenAddress=0xff970a61a04b1ca14834a43f5de4533ebddb5cc8&fromAmount=33000000000000000&defaultSwapSlippage=0.5**&feeTakerAddress=0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53&feePercent=5**' \
--header 'API-KEY: 72a5b4b0-e727-48be-8aa1-5da9d62fe635'
Example Quote Response​
- Quote response returns
integratorFee
object will have the following parameters in the response -- Asset - The token in which the fee is being charged.
- feeTakerAddress - the address where the fee will be sent to in the transaction.
- amount - amount of fee being charged for the transaction.
"integratorFee": {
"feeTakerAddress": "0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53",
"amount": "1687843767742083",
"asset": {
"chainId": 42161,
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"symbol": "ETH",
"name": "Ethereum",
"decimals": 18,
"icon": "https://maticnetwork.github.io/polygon-token-assets/assets/eth.svg",
"logoURI": "https://maticnetwork.github.io/polygon-token-assets/assets/eth.svg",
"chainAgnosticId": null
}
}
Building the calldata
with fee params​
Using Build-Tx (POST)
- If you’re using the Build-Tx (POST) endpoint, you won’t have to make any changes
Using Build-Tx (GET)
- If you’re using the Build-Tx (GET) endpoint, you will have to pass two new query parameters in the request —
feeTakerAddress
andfeePercent
. The values for these have to be the same that were passed in Quote Passing Fee Params in Quote - Example Request
curl --location --request GET '[https://api.socket.tech/v2/build-tx?toChainId=10&recipient=0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53&bridgeWithGas=false&toAmount=31931252691373786&toTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&fromChainId=42161&fromTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&fromAmount=33756875354841653&bridgeInputTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&routePath=0-388&sender=0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53&**feePercent=5&feeTakerAddress=0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53**](https://api.socket.tech/v2/build-tx?toChainId=10&recipient=0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53&bridgeWithGas=false&toAmount=31931252691373786&toTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&fromChainId=42161&fromTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&fromAmount=33756875354841653&bridgeInputTokenAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&routePath=0-388&sender=0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53&feePercent=5&feeTakerAddress=0x0E1B5AB67aF1c99F8c7Ebc71f41f75D4D6211e53)' \
--header 'API-KEY: 72a5b4b0-e727-48be-8aa1-5da9d62fe635'
- If you’re using the Build-Tx (GET) endpoint, you will have to pass two new query parameters in the request —
Viewing Claimable Fees​
- Socket will be setting up a 0xSplits dashboard for the
feeTakerAddress
that we share - All the fees collected across chains can be viewed on this dashboard. Below is a screenshot of an example dashboard
Claiming Fees​
- Fees can be claimed from the 0xSplits dashboard as can be seen below
- You can add the
feeTakerAddress
andCHAIN_ID
in the URL below to go to the dashboard for claiming feeshttps://app.0xsplits.xyz/accounts/feeTakerAddress/?chainId=CHAIN_ID