Skip to content

Commit

Permalink
refine by PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alex0207s committed Aug 19, 2024
1 parent 428b52e commit 1e397fb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/GenericSwap.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

GenericSwap is a general token swapping contract designed to integrate with various strategy executors (e.g. the `SmartOrderSwap` contract). The GenericSwap contract is responsible for ensuring a result of a swap is match the order. However, the actual swap is executed by a strategy executor. This design allows fulfilling an order with any combination of swapping protocols. Also, by adjusting payload in our off-chain system, it may support new protocol without upgrading contracts.

## Gas Saving Technical
## Gas Saving Technique

GenericSwap retains 1 wei of the maker token at the end of each swap transaction. This practice avoids repeatedly clearing the token balance to zero, as the EVM charges different gas fees for various storage states. By preventing frequent resets to zero, this approach effectively reduces gas consumption.

Expand Down
10 changes: 5 additions & 5 deletions doc/RFQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ The RFQ (Request For Quote) contract facilitates the settlement of trades betwee

The maker of an RFQ offer can specify certain options using a `uint256` field in the offer, referred to as option flags:

- `FLG_ALLOW_CONTRACT_SENDER` : Determines whether the RFQ offer can be filled by a contract.
- `FLG_ALLOW_PARTIAL_FILL` : Whether a RFQ offer can be filled partially or not (but once).
- `FLG_MAKER_RECEIVES_WETH` : Specifies whether a market maker is willing to receive WETH from a RFQ offer.
- `FLG_ALLOW_CONTRACT_SENDER` : Determines whether an RFQ offer can be filled by a contract. This flag is intended to prevent arbitrageurs from using contracts to execute flash loans to arbitrage RFQ orders.
- `FLG_ALLOW_PARTIAL_FILL: Determines whether an RFQ offer can be partially filled. However, each RFQ order can only be filled once, regardless of whether it's fully or partially filled.
- `FLG_MAKER_RECEIVES_WETH` : Specifies whether a market maker wants the RFQ contract to wrap the ETH he received into WETH for him.

## Relayer

The RFQ contract allows for trade submissions by a relayer with user's signatures. To prevent replay attacks, the hash of the relayed trade is recorded.

## Fee

A portion of the maker's asset in the order will be deducted as a protocol fee. This fee is transferred to the feeCollector during settlement.
A portion of the maker's asset in the order will be deducted as a protocol fee. This fee is transferred to the `feeCollector` during settlement.

The fee factor is composed of two parts:

1. Protocol Fee
2. Gas Fee

If a relayer submits the trade on-chain, the gas fee will be adjusted according to the on-chain conditions at the time of the transaction.
If a trade is submitted by a relayer, the relayer will adjust the gas fee according to the on-chain conditions at the time of the transaction.
6 changes: 3 additions & 3 deletions doc/SmartOrderStrategy.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SmartOrderStrategy

SmartOrderStrategy is a strategy executor of a generic swap. It is designed to be called by the `GenericSwap contract` and performs swaps according to the provided payload. This contract should not hold any significant token balance or require token approvals, as it can execute arbitrary calls. Additionally, the `executeStrategy` function is restricted to being called only by the GenericSwap contract.
`SmartOrderStrategy` is a strategy executor of a generic swap. It is designed to be called by the `GenericSwap` contract and performs swaps according to the provided payload. This contract should not hold any significant token balance or require token approvals, as it can execute arbitrary calls. Additionally, the `executeStrategy` function is restricted to being called only by the `GenericSwap` contract.

## Gas Saving Technical
## Gas Saving Technique

SmartOrderStrategy retains 1 wei of the maker token at the end of each swap transaction. This practice avoids repeatedly clearing the token balance to zero, as the EVM charges different gas fees for various storage states. By preventing frequent resets to zero, this approach effectively reduces gas consumption.
`SmartOrderStrategy` retains 1 wei of the maker token at the end of each swap transaction. This practice avoids repeatedly clearing the token balance to zero, as the EVM charges different gas fees for various storage states. By preventing frequent resets to zero, this approach effectively reduces gas consumption.
2 changes: 1 addition & 1 deletion doc/TokenCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`TokenCollector` is an abstract contract designed to handle various token collection mechanisms. It supports different methods of token transfer, allowing flexibility in interacting with Tokenlon and other token standards.

When interacting with Tokenlon, users can select one of the supported approval schemes and provide the corresponding parameters in the data field (encoded in bytes). The first byte of this data indicates the type of the scheme, followed by the encoded data specific to that type.
When interacting with Tokenlon, users can select one of the supported approval schemes and provide the corresponding parameters in the data field (encoded as type `bytes`). The first byte of this data indicates the type of the scheme, followed by the encoded data specific to that type.

```
// ***********************************
Expand Down

0 comments on commit 1e397fb

Please sign in to comment.