Code Monkey home page Code Monkey logo

bsc-alpaca-contract's People

Contributors

abc-alpaca avatar abraham-alpaca avatar alpaca-cappuccino avatar alpanaca avatar blackalpacaa avatar blueanalpaca avatar endriu00 avatar festusmaria avatar grandpas01 avatar jakeal-papaca avatar jr-alpaca avatar mgjoo avatar ricardo-alpaca avatar sora-alpaca avatar spicysquid168 avatar sundayalpaca avatar wow-alpaca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bsc-alpaca-contract's Issues

Trading Fee Discrepancy Between Alpaca And PancakeSwapV2

In the Alpaca Finance Protocol, a number of situations require the real-time swap of one token to another. For example, the StrategyAddBaseTokenOnly strategy takes only the base token and converts some portion of it to quote token so that their ratio matches the current swap price in the PancakeSwapV2 pool. Note that in PancakeSwapV2, if you make a token swap or trade on the exchange, you will need to pay a 0.25% trading fee, which is broken down into three parts. The first part of 0.17% is returned to liquidity pools in the form of a fee reward for liquidity providers while the second part of 0.03% is sent to the PancakeSwap Treasury, third part of 0.05% is used to CAKE buyback and burn.

To elaborate, i show below the getAmountOut() routine inside the the PancakeLibraryV2. For comparison, i also show the getMktSellAmount() routine in PancakeswapV2Worker. It is interesting to note that PancakeswapV2Worker has implicitly assumed the trading fee is 0.2%, instead of 0.25%. The difference in the built-in trading fee may skew the optimal allocation of assets in the developed strategies, including StrategyAddBaseTokenOnly and StrategyAddTwoSidesOptimal. It also affects the helper contract, i,e., ibTokenRouter.

PancakeLibraryV2.sol:

  // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
  function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
    require(amountIn > 0, "PancakeLibrary: INSUFFICIENT_INPUT_AMOUNT");
    require(reserveIn > 0 && reserveOut > 0, "PancakeLibrary: INSUFFICIENT_LIQUIDITY");
    uint amountInWithFee = amountIn.mul(9975);
    uint numerator = amountInWithFee.mul(reserveOut);
    uint denominator = reserveIn.mul(10000).add(amountInWithFee);
    amountOut = numerator / denominator;
  }
PancakeswapV2Worker.sol:

  /// @dev Return maximum output given the input amount and the status of Uniswap reserves.
  /// @param aIn The amount of asset to market sell.
  /// @param rIn the amount of asset in reserve for input.
  /// @param rOut The amount of asset in reserve for output.
  function getMktSellAmount(uint256 aIn, uint256 rIn, uint256 rOut) public view returns (uint256) {
    if (aIn == 0) return 0;
    require(rIn > 0 && rOut > 0, "PancakeswapWorker::getMktSellAmount:: bad reserve values");
    /// if fee is not set, 
    /// revert to V1 fee first as this can implied that migrationLp hasn't bee executed
    uint256 _fee = fee;
    uint256 _feeDenom = feeDenom;
    if (_fee == 0) _fee = 998;
    if (_feeDenom == 0) _feeDenom = 1000;
    uint256 aInWithFee = aIn.mul(_fee);
    uint256 numerator = aInWithFee.mul(rOut);
    uint256 denominator = rIn.mul(_feeDenom).add(aInWithFee);
    return numerator / denominator;
  }

Recommendation: Make the built-in trading fee in Alpaca consistent with the actual trading fee in PancakeSwapV2.

Missing members in the typechain

I have difficulties running the tests.

  • I installed node artefacts using npm install
  • I provided one arbitrary privateKey in hardhat.config.ts:22
  • I ran npx hardhat test

This resulted in the errors below:

test/CakeMaxiWorker.test.ts:9:3 - error TS2724: '"../typechain"' has no exported member named 'PancakeFactory'. Did you mean 'IPancakeFactory'?
test/CakeMaxiWorker.test.ts:10:3 - error TS2724: '"../typechain"' has no exported member named 'PancakeFactoryfactory'. Did you mean 'IPancakeFactoryfactory'?

Are there classes missing or did I do somenthing wrong?
Can anyone publish how to setup this project in order to run the tests?

yarn build error TS18003

my dev version:
node: v14.0.0
yarn: v1.22.18
npm: v6.14.4
But when I run yarn in the project path,an error occurred :

yarn install v1.22.18
[1/5] πŸ”  Validating package.json...
[2/5] πŸ”  Resolving packages...
success Already up-to-date.
$ yarn build
yarn run v1.22.18
$ yarn run build:cjs
$ tsc -p tsconfig.cjs.json
error TS18003: No inputs were found in config file '/Users/nateyang/Documents/GitHub/bsc-alpaca-contract/tsconfig.cjs.json'. Specified 'include' paths were '["./typechain/**/*.ts"]' and 'exclude' paths were '["node_modules","build","cache","artifacts"]'.

Question - Address to Position Numbers

Knowing the wallet address, which contract do I call to get a list of my vault position numbers?
I've ask the same question in another issue, but it seem a bit inappropriate there.

Frontend Open-sourced?

Is your Frontend Webpage open-sourced?
If so, where does its code locate?
If not, can you open it please?
I am a leveraged farmer on your platform trying to write a programme to tract the safety buffers of my vaults. Then I guessed your frontend would be the perfect place to start.

Typo

In deploy/exec/dex/deploy/token-liq-pool.ts there is a typo.
In line 152 it should be liquidity, but there is a typo.

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.