Giter Club home page Giter Club logo

xdefi-base's People

Contributors

aaronzgl avatar islishude avatar jingleizhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xdefi-base's Issues

简化Single Swap(XMath)

在前端约束情况下单次Swap涉及一个简化判断:wO/wI是否为1或2或1/2或其他浮点数

1: 跳过计算(重要紧急)
2: 裸乘(重要)
0.5: 引导用户反向裸乘(重要)
其他: 其他

建议:
64-73 原始

public pure returns (uint256 tokenAmountOut) {
uint256 weightRatio = tokenWeightIn.bdiv(tokenWeightOut);
uint256 adjustedIn = BONE.bsub(swapFee);
adjustedIn = tokenAmountIn.bmul(adjustedIn);
uint256 y = tokenBalanceIn.bdiv(tokenBalanceIn.badd(adjustedIn));
uint256 foo = y.bpow(weightRatio);
uint256 bar = BONE.bsub(foo);
tokenAmountOut = tokenBalanceOut.bmul(bar);
return tokenAmountOut;
}

修改

public pure returns (uint256 tokenAmountOut) {
if (tokenWeightIn==tokenWightOut){
uint256 weightRatio = 1;
}else if (tokenWeightIn>>1==tokenWightOut){
uint256 weightRatio = 2;
} else{
uint256 weightRatio = tokenWeightIn.bdiv(tokenWeightOut);
}
uint256 adjustedIn = BONE.bsub(swapFee);
adjustedIn = tokenAmountIn.bmul(adjustedIn);
uint256 y = tokenBalanceIn.bdiv(tokenBalanceIn.badd(adjustedIn));
if (tokenWeightIn==tokenWightOut){
uint256 foo = y;
}else if (tokenWeightIn>>1==tokenWightOut){
uint256 foo = y.bmul(y);
} else{
uint256 foo = y.bpow(weightRatio);
}
uint256 bar = BONE.bsub(foo);
tokenAmountOut = tokenBalanceOut.bmul(bar);
return tokenAmountOut;
}

92-101行

原始

public pure returns (uint256 tokenAmountIn) {
uint256 weightRatio = tokenWeightOut.bdiv(tokenWeightIn);
uint256 diff = tokenBalanceOut.bsub(tokenAmountOut);
uint256 y = tokenBalanceOut.bdiv(diff);
uint256 foo = y.bpow(weightRatio);
foo = foo.bsub(BONE);
tokenAmountIn = BONE.bsub(swapFee);
tokenAmountIn = tokenBalanceIn.bmul(foo).bdiv(tokenAmountIn);
return tokenAmountIn;
}
修改

public pure returns (uint256 tokenAmountIn) {
if (tokenWeightOut==tokenWeightIn){
uint256 weightRatio = 1;
}else if (tokenWeightOut>>1==tokenWeightIn){
uint256 weightRatio = 2;
} else{
uint256 weightRatio = tokenWeightOut.bdiv(tokenWeightIn);
}
uint256 diff = tokenBalanceOut.bsub(tokenAmountOut);
uint256 y = tokenBalanceOut.bdiv(diff);
if (tokenWeightOut==tokenWeightIn){
uint256 foo = y;
}else if (tokenWeightOut>>1==tokenWeightIn){
uint256 foo = y.bmul(y);
} else{
uint256 foo = y.bpow(weightRatio);
}
foo = foo.bsub(BONE);
tokenAmountIn = BONE.bsub(swapFee);
tokenAmountIn = tokenBalanceIn.bmul(foo).bdiv(tokenAmountIn);
return tokenAmountIn;
}

Error in SWAP. BigNumber Error in Metamask

Hello.

I got a metamask error during the next swap in the network test. Do you need such information or is it a metamask problem? (I made screenshots and wrote down the error codes)

`Детали ошибки
Сообщение: new BigNumber() not a base 16 number: undefined

Код: BigNumber Error

Стек:
BigNumber Error: new BigNumber() not a base 16 number: undefined
at $ (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui.js:43:44267)
at w (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui.js:43:49784)
at new H (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui.js:43:41731)
at E (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui.js:152:619624)
at S (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui.js:152:620308)
at Function.mapToProps (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui.js:152:227614)
at n (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:93:20755)
at Function.n.mapToProps (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:93:20891)
at n (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:93:20755)
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:93:19596
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:93:12990
at Object.useMemo (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:63534)
at useMemo (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:136:5250)
at _ (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:93:12934)
at ca (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:59367)
at Ga (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:67589)
at Va (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:67408)
at Ua (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:67127)
at jl (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:107861)
at bu (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:90053)
at pu (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:89978)
at iu (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:87326)
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:45768
at r.unstable_runWithPriority (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:172:3472)
at Vo (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:45477)
at Yo (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:45713)
at Ko (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:45648)
at le (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:114525)
at Er (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-libs.js:75:29321)
at HTMLDocument.c (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/initSentry.js:1:10461)`

1
2
3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.