Profit-Sharing Instructions
To reward the providers of transaction volume, the API users can adjust the address for transaction fee collection and fee percentage. The provider will be rewarded with the corresponding fee after the user makes a transaction using the widgets launched by the provider.
Description
feeRate
: API user's fee rate; the feeRate
set by the API user is calculated separately from the fee charged by DODO, the fee’s unit is in 1e18, i.e. if the feeRate
is set to 1500000000000000, the actual fee rate is 1500000000000000 / 10^18 = 0.0015 = 0.15%. rebateTo:
the wallet address that will receive the transaction fee incentives⚠️Note: If you want to use the profit-sharing mode, these two sets of codes are mandatory for widgets. If the codes are not processed, feeRate defaults to 0, and the default API user will not collect any transaction fee.
import { SwapWidget } from '@dodoex/widgets';
function App() {
return (
<SwapWidget
feeRate={1500000000000000}
rebateTo='0x2Ba1633338dDD2Ab37fbc95ea615BA98f0445380'
// ...otherPrpos
/>
)
}
/**
* main.js
* InitializeSwapWidget
*/
'use strict';
import { InitSwapWidget } from '@dodoex/widgets';
function initDodoWidget() {
InitSwapWidget({
feeRate: 1500000000000000,
rebateTo: '0x2Ba1633338dDD2Ab37fbc95ea615BA98f0445380',
// ...otherPrpos
});
}
initDodoWidget();
function _routeWithdraw(
address toToken,
uint256 receiveAmount,
bytes memory feeData,
uint256 minReturnAmount
) internal {
(address broker, uint256 brokerFeeRate) = abi.decode(feeData, (address, uint256));
uint256 routeFee = DecimalMath.mulFloor(receiveAmount, routeFeeRate);
IERC20(toToken).universalTransfer(payable(routeFeeReceiver), routeFee);
uint256 brokerFee = DecimalMath.mulFloor(receiveAmount, brokerFeeRate);
IERC20(toToken).universalTransfer(payable(broker), brokerFee);
receiveAmount = receiveAmount - routeFee - brokerFee;
require(receiveAmount >= minReturnAmount, "DODORouteProxy: Return amount is not enough");
if (toToken == _ETH_ADDRESS_) {
IWETH(_WETH_).withdraw(receiveAmount);
payable(msg.sender).transfer(receiveAmount);
} else {
IERC20(toToken).universalTransfer(payable(msg.sender), receiveAmount);
}
}
As demonstrated, to get accurate routing quotes, the toAmount displayed to users has already deducted the transaction fee.
According to the above contract, the toAmount (i.e. DODO in the sample image) in the quotation stage is the number of Token after the feeRate of the API user is deducted.

Basic Fee: Fee from the service provider (DODO); Additional Fee: Additional fee from the widget user (feeRate);

Last modified 9mo ago