Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

support option #11

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

support option #11

wants to merge 9 commits into from

Conversation

AaronZgl
Copy link
Contributor

No description provided.

@xdefilab
Copy link
Collaborator

@AaronZgl 这个有冲突了

@xdefilab
Copy link
Collaborator

TODO:

  1. 在XPool加一个池类型字段,区分 现货、期权
  2. 在XPool,对于池类型是期权的,进行poolExpiryBlockHeight、 getSwapFee() 等操作;池类型是现货的话,保持现有逻辑不变。
  3. 在XSwapProxyV1.sol,保持现货池接口不变,对于期权池,单加新的接口(比如create)

@xdefilab
Copy link
Collaborator

xdefilab commented Jan 22, 2021

TODO:

  1. gas优化:swapExactAmountIn 和 swapExactAmountOut函数内,可以只查一次swap fee,之后的代码不必再调用查询接口;其它参数(如果有),同理;
  2. XConfig 已经没有 getFarmCreator(),用 isFarmPool() 判断是否为Farm池
  3. XPool setPoolType() 和 setExpery() 接口,都应该加finalized判断;所以createOptionPool() 对 _create()的封装将无效,因为_create会调用pool.finalize()在前,setPoolType和setExpery在后
  4. poolType在XPool构造函数显性初始化为0 (虽然隐形默认也是0)

Copy link

@spirinvladimir spirinvladimir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary sqrt

Comment on lines +12 to +15
uint256 feeRate = sqrt(expiryBlockHeight - blockNumber);
uint256 actFee = base * 5 / feeRate;
uint256 swapFee = minFee >= actFee ? minFee : actFee;
return swapFee;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3/1000 > 5/sqrt(x) there x is more then 2778889. Because sqrt is increasing function. As swapFee will be always minFee then calculation sqrt unnecessary.
So according to current code calSwapFee always return base * 3 / 1000.

denorms[2] = 25 * (10 ** 17);
denorms[3] = 25 * (10 ** 17);

// check pool exist

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// check pool exist
// check pool not exist

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants