From 5237a5fd313d7ccafed87c1ecccb45cb0eed2abe Mon Sep 17 00:00:00 2001 From: Forrest Norwood Date: Tue, 11 Jul 2023 14:47:13 -0500 Subject: [PATCH 1/2] remove feebps and add protocolfee func --- .../rubicon-market/contract-overview.en.mdx | 8 +- .../rubicon-market/contract-overview.mdx | 21 +++-- pages/protocol/rubicon-market/fees.en.mdx | 10 +-- pages/protocol/rubicon-market/fees.mdx | 77 +++++++++++++++---- 4 files changed, 85 insertions(+), 31 deletions(-) diff --git a/pages/protocol/rubicon-market/contract-overview.en.mdx b/pages/protocol/rubicon-market/contract-overview.en.mdx index fe1a014..4d8de11 100644 --- a/pages/protocol/rubicon-market/contract-overview.en.mdx +++ b/pages/protocol/rubicon-market/contract-overview.en.mdx @@ -223,10 +223,10 @@ Returns the number of offers in the order book for a specified pair. ### getFeeBPS() ```solidity copy -function getFeeBPS() - public - view - returns (uint256) + function protocolFee() + public + view + returns (uint256) ``` Returns the current protocol fee. diff --git a/pages/protocol/rubicon-market/contract-overview.mdx b/pages/protocol/rubicon-market/contract-overview.mdx index 181f719..b2ffcd5 100644 --- a/pages/protocol/rubicon-market/contract-overview.mdx +++ b/pages/protocol/rubicon-market/contract-overview.mdx @@ -259,16 +259,25 @@ function getOfferCount(ERC20 sell_gem, ERC20 buy_gem) Returns the number of offers in the order book for a specified pair. -### getFeeBPS() - +```solidity copy + function protocolFee() + public + view + returns (uint256) ``` -function getFeeBPS() - public - view + +Returns the current protocol fee. + +### makerFee() + +```solidity copy +function makerFee() + public + view returns (uint256) ``` -Returns the protocol fee, in basis points. +Returns the current maker fee. ## Key Events diff --git a/pages/protocol/rubicon-market/fees.en.mdx b/pages/protocol/rubicon-market/fees.en.mdx index fbae368..6053bfb 100644 --- a/pages/protocol/rubicon-market/fees.en.mdx +++ b/pages/protocol/rubicon-market/fees.en.mdx @@ -26,13 +26,13 @@ The **Total Taker Fee** is equal to the sum of the **Protocol Fee** and the **Ma ### Querying the Fees -Use these view functions to query the fee values. **Please note that "getFeeBPS" is a semantic misnomer and the integer value it returns is a pip, 1 / 100,000, and represents the input to the protocol fee**. This is maintained for backward compatibility and will be fixed in future updates. +Use these view functions to query the fee values. ```solidity copy -function getFeeBPS() - public - view - returns (uint256) + function protocolFee() + public + view + returns (uint256) ``` Returns the current protocol fee. diff --git a/pages/protocol/rubicon-market/fees.mdx b/pages/protocol/rubicon-market/fees.mdx index d3a1f17..6053bfb 100644 --- a/pages/protocol/rubicon-market/fees.mdx +++ b/pages/protocol/rubicon-market/fees.mdx @@ -1,41 +1,86 @@ --- title: Fees pageTitle: Fees -description: Fees on the Rubicon protocol +description: Fees on Rubicon --- -# Fees +# Rubicon Market -The Rubicon protocol has a maker-taker fee model, charging trades that "take" liquidity from the order book and paying a rebate to orders that "make" liquidity on the order book. The taker fee is paid in the ERC-20 token that is sent to the contract, and the maker fee is paid to the owner address of the filled order(s). +## Fees -## Fee Schedule +import { Callout } from "/components/Callout"; -| Name | Amount | Description | -| -------------- | ------ | ------------------------------------------------------------- | -| Taker | 0.04% | Paid by trades that "take" liquidity from the order book | -| Maker | 0.038% | Paid by the taker to the "maker", the owner address of the filled offer(s) | + + Paid by takers (buyers) to the protocol. Paid in the token sent from the taker to the contract. + + + + Paid by the taker to the maker (seller), the address that owns the filled offer during a buy. + + +The **Total Taker Fee** is equal to the sum of the **Protocol Fee** and the **Maker Rebate**. All market fees (rebates) are paid in the token the buyer is paying to fill an offer. + + + Total fee paid by trades that "take" liquidity from the order book (a buy). Paid in the token sent to the contract from the taker. + ### Querying the Fees -At a technical level, the taker fee is equal to the sum of the protocol fee and the maker fee. +Use these view functions to query the fee values. -```solidity -function getFeeBPS() - public - view - returns (uint256) +```solidity copy + function protocolFee() + public + view + returns (uint256) ``` Returns the current protocol fee. -```solidity +```solidity copy function makerFee() public view returns (uint256) ``` -Returns the current maker fee (rebate). +Returns the current maker fee. + +### Calculating Fees for a Trade + +Use `getBuyAmountWithFee()` or `getPayAmountWithFee()` to calculate the total amount to send to the contract for a given trade, including fees. + +```solidity copy + function getBuyAmountWithFee( + IERC20 buy_gem, + IERC20 pay_gem, + uint256 pay_amt + ) external view returns (uint256 buy_amt, uint256 approvalAmount) { + uint modifiedAmount = calculateFees(pay_amt, false); + buy_amt = (getBuyAmount(buy_gem, pay_gem, modifiedAmount)); + + approvalAmount = pay_amt; + return (buy_amt, approvalAmount); + } +``` + +Returns `buy_amt`, the amount of `buy_gem` tokens to send to the contract to receive the `pay_amt` amount of the `pay_gem` token. Also returns `approvalAmount`, the amount of `pay_gem` tokens to approve for the interaction, accounting for fees. + +```solidity copy + function getPayAmountWithFee( + IERC20 pay_gem, + IERC20 buy_gem, + uint256 buy_amt + ) public view returns (uint256 pay_amt, uint256 approvalAmount) { + pay_amt = (getPayAmount(pay_gem, buy_gem, buy_amt)); + uint modifiedAmount = calculateFees(pay_amt, true); + + approvalAmount = modifiedAmount; + return (pay_amt, approvalAmount); + } +``` + +Returns `pay_amt`, the amount of `pay_gem` tokens to send to the contract to receive the `buy_amt` amount of the `buy_gem` token. Also returns `approvalAmount`, the amount of `buy_gem` tokens to approve for the interaction, accounting for fees. ## Network Fees From c24c28bcfc8d603efb1c9426d68fe066eb7454e0 Mon Sep 17 00:00:00 2001 From: Forrest Norwood Date: Tue, 11 Jul 2023 16:04:29 -0500 Subject: [PATCH 2/2] language for return value precision --- pages/protocol/rubicon-market/contract-overview.en.mdx | 6 +++--- pages/protocol/rubicon-market/contract-overview.mdx | 6 ++++-- pages/protocol/rubicon-market/fees.en.mdx | 4 ++-- pages/protocol/rubicon-market/fees.mdx | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pages/protocol/rubicon-market/contract-overview.en.mdx b/pages/protocol/rubicon-market/contract-overview.en.mdx index 4d8de11..620a763 100644 --- a/pages/protocol/rubicon-market/contract-overview.en.mdx +++ b/pages/protocol/rubicon-market/contract-overview.en.mdx @@ -220,7 +220,7 @@ function getOfferCount(ERC20 sell_gem, ERC20 buy_gem) Returns the number of offers in the order book for a specified pair. -### getFeeBPS() +### protocolFee() ```solidity copy function protocolFee() @@ -229,7 +229,7 @@ Returns the number of offers in the order book for a specified pair. returns (uint256) ``` -Returns the current protocol fee. +Returns the current protocol fee. Return value is an integer at this precision (1 / 100,000 or 0.001%). ### makerFee() @@ -240,7 +240,7 @@ function makerFee() returns (uint256) ``` -Returns the current maker fee. +Returns the current maker fee. Return value is an integer at this precision (1 / 100,000 or 0.001%). ## Events diff --git a/pages/protocol/rubicon-market/contract-overview.mdx b/pages/protocol/rubicon-market/contract-overview.mdx index b2ffcd5..479f596 100644 --- a/pages/protocol/rubicon-market/contract-overview.mdx +++ b/pages/protocol/rubicon-market/contract-overview.mdx @@ -259,6 +259,8 @@ function getOfferCount(ERC20 sell_gem, ERC20 buy_gem) Returns the number of offers in the order book for a specified pair. +### protocolFee() + ```solidity copy function protocolFee() public @@ -266,7 +268,7 @@ Returns the number of offers in the order book for a specified pair. returns (uint256) ``` -Returns the current protocol fee. +Returns the current protocol fee. Return value is an integer at this precision (1 / 100,000 or 0.001%). ### makerFee() @@ -277,7 +279,7 @@ function makerFee() returns (uint256) ``` -Returns the current maker fee. +Returns the current maker fee. Return value is an integer at this precision (1 / 100,000 or 0.001%). ## Key Events diff --git a/pages/protocol/rubicon-market/fees.en.mdx b/pages/protocol/rubicon-market/fees.en.mdx index 6053bfb..ada82ed 100644 --- a/pages/protocol/rubicon-market/fees.en.mdx +++ b/pages/protocol/rubicon-market/fees.en.mdx @@ -35,7 +35,7 @@ Use these view functions to query the fee values. returns (uint256) ``` -Returns the current protocol fee. +Returns the current protocol fee. Return value is an integer at this precision (1 / 100,000 or 0.001%). ```solidity copy function makerFee() @@ -44,7 +44,7 @@ function makerFee() returns (uint256) ``` -Returns the current maker fee. +Returns the current maker fee. Return value is an integer at this precision (1 / 100,000 or 0.001%). ### Calculating Fees for a Trade diff --git a/pages/protocol/rubicon-market/fees.mdx b/pages/protocol/rubicon-market/fees.mdx index 6053bfb..ada82ed 100644 --- a/pages/protocol/rubicon-market/fees.mdx +++ b/pages/protocol/rubicon-market/fees.mdx @@ -35,7 +35,7 @@ Use these view functions to query the fee values. returns (uint256) ``` -Returns the current protocol fee. +Returns the current protocol fee. Return value is an integer at this precision (1 / 100,000 or 0.001%). ```solidity copy function makerFee() @@ -44,7 +44,7 @@ function makerFee() returns (uint256) ``` -Returns the current maker fee. +Returns the current maker fee. Return value is an integer at this precision (1 / 100,000 or 0.001%). ### Calculating Fees for a Trade