White-Label Partners
BrokerTool ⇐ WriteAccessHandler
WriteAccessHandler
Functions for white-label partners to determine fees, deposit lots, and sign-up traders. This class requires a private key and executes smart-contract interactions that require gas-payments.
Kind: global class
Extends: WriteAccessHandler
BrokerTool ⇐
WriteAccessHandler
new BrokerTool(config, privateKey, signer)
.getBrokerInducedFee(poolSymbolName) ⇒
number
.getFeeForBrokerDesignation(poolSymbolName, [lots]) ⇒
number
.getFeeForBrokerVolume(poolSymbolName) ⇒
number
.getFeeForBrokerStake([brokerAddr]) ⇒
number
.determineExchangeFee(order, traderAddr) ⇒
number
.getCurrentBrokerVolume(poolSymbolName) ⇒
number
.getLotSize(poolSymbolName) ⇒
number
.getBrokerDesignation(poolSymbolName) ⇒
number
.depositBrokerLots(poolSymbolName, lots) ⇒
ContractTransaction
.signOrder(order, traderAddr) ⇒
Order
.signSCOrder(scOrder, traderAddr) ⇒
string
.transferOwnership(poolSymbolName, newAddress) ⇒
ContractTransaction
new BrokerTool(config, privateKey, signer)
Constructor
Param | Type | Description |
---|---|---|
config |
| Configuration object, see PerpetualDataHandler. readSDKConfig. |
privateKey |
| Private key of a white-label partner. |
signer |
| Signer (ignored if a private key is provided) |
Example
brokerTool.getBrokerInducedFee(poolSymbolName) ⇒ number
number
Determine the exchange fee based on lots, traded volume, and D8X balance of this white-label partner. This is the final exchange fee that this white-label partner can offer to traders that trade through him.
Kind: instance method of BrokerTool
Returns: number
-
Exchange fee for this white-label partner, in decimals (i.e. 0.1% is 0.001)
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
Example
brokerTool.getFeeForBrokerDesignation(poolSymbolName, [lots]) ⇒ number
number
Determine the exchange fee based on lots purchased by this white-label partner. The final exchange fee that this white-label partner can offer to traders that trade through him is equal to maximum(brokerTool.getFeeForBrokerDesignation(poolSymbolName), brokerTool.getFeeForBrokerVolume(poolSymbolName), brokerTool.getFeeForBrokerStake())
Kind: instance method of BrokerTool
Returns: number
-
Fee based solely on this white-label partner's designation, in decimals (i.e. 0.1% is 0.001).
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
[lots] |
| Optional, designation to use if different from this white-label partner's. |
Example
brokerTool.getFeeForBrokerVolume(poolSymbolName) ⇒ number
number
Determine the exchange fee based on volume traded under this white-label partner. The final exchange fee that this white-label partner can offer to traders that trade through him is equal to maximum(brokerTool.getFeeForBrokerDesignation(poolSymbolName), brokerTool.getFeeForBrokerVolume(poolSymbolName), brokerTool.getFeeForBrokerStake())
Kind: instance method of BrokerTool
Returns: number
-
Fee based solely on a white-label partner's traded volume in the corresponding pool, in decimals (i.e. 0.1% is 0.001).
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
Example
brokerTool.getFeeForBrokerStake([brokerAddr]) ⇒ number
number
Determine the exchange fee based on the current D8X balance in a white-label partner's wallet. The final exchange fee that this white-label partner can offer to traders that trade through him is equal to maximum(brokerTool.getFeeForBrokerDesignation(symbol, lots), brokerTool.getFeeForBrokerVolume(symbol), brokerTool.getFeeForBrokerStake)
Kind: instance method of BrokerTool
Returns: number
-
Fee based solely on a white-label partner's D8X balance, in decimals (i.e. 0.1% is 0.001).
Param | Type | Description |
---|---|---|
[brokerAddr] |
| Address of the white-label partner in question, if different from the one calling this function. |
Example
brokerTool.determineExchangeFee(order, traderAddr) ⇒ number
number
Determine exchange fee based on an order and a trader. This is the fee charged by the exchange only, excluding the white-label partner fee, and it takes into account whether the order given here has been signed by a white-label partner or not. Use this, for instance, to verify that the fee to be charged for a given order is as expected, before and after signing it with brokerTool.signOrder. This fee is equal or lower than the white-label partner induced fee, provided the order is properly signed.
Kind: instance method of BrokerTool
Returns: number
-
Fee in decimals (i.e. 0.1% is 0.001).
Param | Type | Description |
---|---|---|
order |
| Order structure. As a minimum the structure needs to specify symbol, side, type and quantity. |
traderAddr |
| Address of the trader for whom to determine the fee. |
Example
brokerTool.getCurrentBrokerVolume(poolSymbolName) ⇒ number
number
Exponentially weighted EMA of the total trading volume of all trades performed under this white-label partner. The weights are chosen so that in average this coincides with the 30 day volume.
Kind: instance method of BrokerTool
Returns: number
-
Current trading volume for this white-label partner, in USD.
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
Example
brokerTool.getLotSize(poolSymbolName) ⇒ number
number
Total amount of collateral currency a white-label partner has to deposit into the default fund to purchase one lot. This is equivalent to the price of a lot expressed in a given pool's currency (e.g. MATIC, USDC, etc).
Kind: instance method of BrokerTool
Returns: number
-
White-label partner lot size in a given pool's currency, e.g. in MATIC for poolSymbolName MATIC.
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
Example
brokerTool.getBrokerDesignation(poolSymbolName) ⇒ number
number
Provides information on how many lots a white-label partner purchased for a given pool. This is relevant to determine the white-label partner's fee tier.
Kind: instance method of BrokerTool
Returns: number
-
Number of lots purchased by this white-label partner.
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
Example
brokerTool.depositBrokerLots(poolSymbolName, lots) ⇒ ContractTransaction
ContractTransaction
Deposit lots to the default fund of a given pool.
Kind: instance method of BrokerTool
Returns: ContractTransaction
-
ContractTransaction object.
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
lots |
| Number of lots to deposit into this pool. |
Example
brokerTool.signOrder(order, traderAddr) ⇒ Order
Order
Adds this white-label partner's signature to a user-friendly order. An order signed by a white-label partner is considered to be routed through this white-label partner and benefits from the white-label partner's fee conditions.
Kind: instance method of BrokerTool
Returns: Order
-
An order signed by this white-label partner, which can be submitted directly with AccountTrade.order.
Param | Type | Description |
---|---|---|
order |
| Order to sign. It must contain valid white-label partner fee, white-label partner address, and order deadline. |
traderAddr |
| Address of trader submitting the order. |
Example
brokerTool.signSCOrder(scOrder, traderAddr) ⇒ string
string
Generates a white-label partner's signature of a smart-contract ready order. An order signed by a white-label partner is considered to be routed through this white-label partner and benefits from the white-label partner's fee conditions.
Kind: instance method of BrokerTool
Returns: string
-
Signature of order.
Param | Type | Description |
---|---|---|
scOrder |
| Order to sign. It must contain valid white-label partner fee, white-label partner address, and order deadline. |
traderAddr |
| Address of trader submitting the order. |
Example
brokerTool.transferOwnership(poolSymbolName, newAddress) ⇒ ContractTransaction
ContractTransaction
Transfer ownership of a white-label partner's status to a new wallet. This function transfers the values related to (i) trading volume and (ii) deposited lots to newAddress. The white-label partner needs in addition to manually transfer his D8X holdings to newAddress. Until this transfer is completed, the white-label partner will not have his current designation reflected at newAddress.
Kind: instance method of BrokerTool
Returns: ContractTransaction
-
ethers transaction object
Param | Type | Description |
---|---|---|
poolSymbolName |
| Pool symbol name (e.g. MATIC, USDC, etc). |
newAddress |
| The address this white-label partner wants to use from now on. |
Example