Giter Site home page Giter Site logo

curve-contract's People

Contributors

acryptosx avatar agureevroman avatar fubuloubu avatar iamdefinitelyahuman avatar jameslefrere avatar michwill avatar pengiundev avatar samwerner avatar skellet0r 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  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

curve-contract's Issues

Update to latest Brownie and other packages

Overview

There are vulnerable packages in the pip dependencies that are defined by requirements.txt
It should contain:

  • cytools>=0.12.3
  • click>=8.1.3
  • pathspec>=0.12.1
  • black>=24.2.0
  • attrs>=23.2.0
  • vyper>=0.3.10rc4 # not directly required, pinned by Snyk to avoid a vulnerability
  • eth-brownie>=1.20.2
  • brownie-token-tester>=0.1.0
  • flake8>=3.8.4
  • isort>=5.7.0

Since curve deals with a lot of money, there should be a focus on fixing known vulnerabilities quickly.
Static code analysis scanners like snyk.io should be used for this purpose.

0x57b583b32b249da49d9e91f7f4f300113187e762

Environment information

  • curve-contract branch/commit: master/latest
  • brownie Version: x.x.x
  • ganache-cli Version: x.x.x
  • OS: osx/linux/win

What was wrong?

Please include information like:

  • what you are trying to accomplish
  • which command(s) you ran
  • the code that caused the failure (see this link for help with formatting code)
  • full output of the error you received

How can it be fixed?

Fill this in if you know how the bug could be fixed.

Unable to Deploy LiquidityGaugeV3 To Development Nework

Environment information

  • curve-contract branch/commit: master:bb0bbf77 (latest)
  • brownie Version: 1.19.1
  • ganache-cli Version: 6.12.2
  • OS: OSX Monterey v12.6

What was wrong?

I am attempting to deploy a pool to my local Gananche development network. I am able to follow the instructions for deploy.py file by specifying which pool I am trying to deploy and providing the correct Account info for my local development network.

I am able to deploy all other contracts, except for LiquidityGaugeV3, which fails with a revert error:

> brownie run deploy.py --network development

# Inputs:
# token: 0x06E727325DcB9eeDC94506F99C0aD2df283b4952
# MINTER: 0x7aD04ce3E9Be5718a6af1e8dD6B2Cf46485430A1
# GAUGE_OWNER: 0x523a0E9cBCeA169C286Bc43B06A640C706D08117
# tx_params output (truncated gas strategy) : {'from': <Account '0xfC5B6585411EF391cD5c2223C11D74d5b15351D5'>, 'required_confs': 1}

# fails at this line, which I moved to the last line in the deploy script to isolate the error:
LiquidityGaugeV3.deploy(token, MINTER, GAUGE_OWNER, _tx_params())

LiquidityGaugeV3
<brownie.network.contract.ContractContainer object at 0x7fd35e4a53d0>
Transaction sent: 0x3d76629f9549fdf72064c39e4fddf509ae9083105f4b761ec05c7a7181796784
  Gas price: 0.0 gwei   Gas limit: 10000000000000   Nonce: 42
  LiquidityGaugeV3.constructor confirmed (reverted)   Block: 43   Gas used: 1067909 (0.00%)

  File "brownie/_cli/run.py", line 55, in main
    _include_frame=True,
  File "brownie/project/scripts.py", line 110, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File "./scripts/deploy.py", line 131, in main
    LiquidityGaugeV3.deploy(token, MINTER, GAUGE_OWNER, _tx_params())
  File "brownie/network/contract.py", line 560, in __call__
    publish_source=publish_source,
  File "brownie/network/account.py", line 550, in deploy
    receipt._raise_if_reverted(exc)
  File "brownie/network/transaction.py", line 447, in _raise_if_reverted
    source=source, revert_msg=self._revert_msg, dev_revert_msg=self._dev_revert_msg
VirtualMachineError: revert

How can it be fixed?

I pulled the Curve-Dao-Contracts and noticed quite a lot of progress was made on the LiquidityGauge versions, perhaps this is being worked on currently? Not sure if I need to deploy the Curve-DAO-Contracts onto the same development network to test the pool.

Thank you in advance for the advice, apologies if redundant question or known issue.

Twap contract not deployed?

Environment information

  • curve-contract branch/commit: master/latest
  • brownie Version: x.x.x
  • ganache-cli Version: x.x.x
  • OS: osx/linux/win

What was wrong?

Please include information like:

  • what you are trying to accomplish
  • which command(s) you ran
  • the code that caused the failure (see this link for help with formatting code)
  • full output of the error you received

How can it be fixed?

Fill this in if you know how the bug could be fixed.

Standardize the pool templates

Overview

Standardize the pool templates.

Specification

  • Templates should use the same variable names
  • The ordering of events / interfaces / functions should be consistent
  • Comments and natspec should be consistent
  • Dev revert strings should be applied to all reverts, with consistent messages

Some thoughts on variable naming:

  • calldata variables should begin with _ to denote they are immutable.
  • memory variables to avoid repeated SLOADs should use the same name as their storage counterpart.
  • ensure comments

`brownie test`: "import file mismatch"

Environment information

  • curve-contract branch/commit: master/latest
  • brownie Version: 1.14.5
  • ganache-cli Version: 6.12.2
  • OS: linux

What was wrong?

Please include information like:

  • what you are trying to accomplish: run tests
  • which command(s) you ran: brownie test
  • the code that caused the failure:
    /tests/pools/common/unitary/test_exchange_reverts.py
    /tests/pools/eth/test_exchange_reverts.py
  • output:
    (curve-venv) $brownie test
    Brownie v1.14.5 - Python development framework for Ethereum

Compiling contracts...
Solc version: 0.5.17
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
Generating build data...

  • AaveLendingPoolMock
  • IERC20
  • aToken
  • ATokenMock
  • IERC20
  • SafeMath

================================================================================================================================== test session starts ===================================================================================================================================
platform linux -- Python 3.9.5, pytest-6.0.1, py-1.10.0, pluggy-0.13.1
rootdir: /home/e/r/[removed]/curve-venv/curve-contract
plugins: eth-brownie-1.14.5, xdist-1.34.0, forked-1.3.0, hypothesis-5.41.3, web3-5.11.1
collected 14564 items / 2 errors / 14562 selected

Launching 'ganache-cli --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie --defaultBalanceEther 10000'...

========================================================================================================================================= ERRORS =========================================================================================================================================
_______________________________________________________________________________________________________________ ERROR collecting tests/pools/eth/test_exchange_reverts.py ________________________________________________________________________________________________________________
import file mismatch:
imported module 'test_exchange_reverts' has this file attribute:
/home/e/r/[removed]/curve-venv/curve-contract/tests/pools/common/unitary/test_exchange_reverts.py
which is not the same as the test file we want to collect:
/home/e/r/[removed]/curve-venv/curve-contract/tests/pools/eth/test_exchange_reverts.py
HINT: remove pycache / .pyc files and/or use a unique basename for your test file modules
__________________________________________________________________________________________________ ERROR collecting tests/zaps/meta/integration/test_remove_liquidity_imbalance_zap.py ___________________________________________________________________________________________________
import file mismatch:
imported module 'test_remove_liquidity_imbalance_zap' has this file attribute:
/home/e/r/[removed]/curve-venv/curve-contract/tests/zaps/common/test_remove_liquidity_imbalance_zap.py
which is not the same as the test file we want to collect:
/home/e/r/[removed]/curve-venv/curve-contract/tests/zaps/meta/integration/test_remove_liquidity_imbalance_zap.py
HINT: remove pycache / .pyc files and/or use a unique basename for your test file modules

How can it be fixed?

No idea.

I'm using a venv, as instructed.

Note that I'm using Python 3.9.5 and you currently require 3.6 to 3.8, but this doesn't seem like a Python issue.

Test files not unique in brownie v1.14.5

What was wrong?

When runningbrownie test I get the following output:

Brownie v1.14.5 - Python development framework for Ethereum

================================================ test session starts ================================================
platform darwin -- Python 3.8.17, pytest-6.0.1, py-1.10.0, pluggy-0.13.1
rootdir: /Users/chris/github.com/curve-contract
plugins: eth-brownie-1.14.5, hypothesis-5.41.3, xdist-1.34.0, web3-5.11.1, forked-1.3.0
collected 14564 items / 2 errors / 14562 selected

Launching 'ganache-cli --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie --defaultBalanceEther 10000'...

====================================================== ERRORS =======================================================
_____________________________ ERROR collecting tests/pools/eth/test_exchange_reverts.py _____________________________
import file mismatch:
imported module 'test_exchange_reverts' has this __file__ attribute:
  /Users/chris/github.com/curve-contract/tests/pools/common/unitary/test_exchange_reverts.py
which is not the same as the test file we want to collect:
  /Users/chris/github.com/curve-contract/tests/pools/eth/test_exchange_reverts.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
________________ ERROR collecting tests/zaps/meta/integration/test_remove_liquidity_imbalance_zap.py ________________
import file mismatch:
imported module 'test_remove_liquidity_imbalance_zap' has this __file__ attribute:
  /Users/chris/github.com/curve-contract/tests/zaps/common/test_remove_liquidity_imbalance_zap.py
which is not the same as the test file we want to collect:
  /Users/chris/github.com/curve-contract/tests/zaps/meta/integration/test_remove_liquidity_imbalance_zap.py
HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules

How can it be fixed?

I fixed this by changing the names of the files to test_remove_liquidity_imbalance_common.py, test_remove_liquidity_imbalance_meta.py, etc.

Also when compiling I had this common issue with pyyaml as detailed in yaml/pyyaml#724
Which was solved with running pip install wheel pyyaml==5.4.1 cython==0.29.36 --no-build-isolation in the venv prior to installing dependencies.

Forex based currency swap

Hi Curve Project,

This is Min, a developer working in the traditional Quant / high frequency trading industry.

We just launched a new asset backed stablecoin in Hong Kong ( https://onecash.asia/), including HKD, CNH and JPY. I'm wondering if it's possible to add currency liquidity pool on curve fi

In your design, the core formula is this:
Sum (Xi * Wi ) = const.

If you use a forex rate from oracle as Wi, it will become a nice forex swap liquidity pool very naturally.

Curve events are an utter mess

Curve events are just a horrible mess without:

  • Some of the liquidity events return fixed sized arrays, meaning there is a different signature for each amount of tokens
  • RemoveLiquidityOne is missing the vital information, which coin was actually removed

So the first one, though butt-ugly, can be handled by just subscribing to all possible pool sizes. The second one can be handled as well, but even more uglier, since it requires any consumer that wishes to keep track of balances, to calculate the amount for all possible tokens to determine which one an event referred to. This of course requires to know the internal parameters of the pool, and:

  • There no pair creation or other initial event containing pool creation parameters

Sigh

Seriously, who "designed" such a mess? Given that basically every pool is incompatible in some way with the next one, to the extent that not even the pool registry is able to query a good proportion of them without reverting, how about just fixing this crap? Its not like ABI compatibility is an issue here...

0xbdfa4f4492dd7b7cf211209c4791af8d52bf5c50

Environment information

  • curve-contract branch/commit: master/latest
  • brownie Version: x.x.x
  • ganache-cli Version: x.x.x
  • OS: osx/linux/win

What was wrong?

Please include information like:

  • what you are trying to accomplish
  • which command(s) you ran
  • the code that caused the failure (see this link for help with formatting code)
  • full output of the error you received

How can it be fixed?

Fill this in if you know how the bug could be fixed.

Have you all made a subgraph?

I'm interested in writing a subgraph and was wondering if:

  1. Your team has already written a subgraph
  2. There's deployed test network contracts, preferably with volume.

Thanks!

I cannot AddLiquidity in the StableSwap3Pool.vy Smart Contract through a middle Operator Solidity Smart Contract.

https://github.com/curvefi/curve-contract/blob/master/contracts/pools/3pool/StableSwap3Pool.vy

Hello, I have a Unit Test which is Testing this Soldity Smart Contract Implementation:

ICurveFiPool.sol :

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.9;

interface ICurveFiPool {
    function get_virtual_price() external returns (uint256 out);

    function add_liquidity(uint256[3] memory amounts, uint256 min_mint_amount) external;

    function get_dy(
        int128 i,
        int128 j,
        uint256 dx
    ) external returns (uint256 out);

    function get_dy_underlying(
        int128 i,
        int128 j,
        uint256 dx
    ) external returns (uint256 out);

    function exchange(
        int128 i,
        int128 j,
        uint256 dx,
        uint256 min_dy
    ) external;

    function exchange(
        int128 i,
        int128 j,
        uint256 dx,
        uint256 min_dy,
        uint256 deadline
    ) external;

    function exchange_underlying(
        int128 i,
        int128 j,
        uint256 dx,
        uint256 min_dy
    ) external;

    function exchange_underlying(
        int128 i,
        int128 j,
        uint256 dx,
        uint256 min_dy,
        uint256 deadline
    ) external;

    function remove_liquidity(uint256 _amount, uint256[] calldata min_amounts) external;

    function remove_liquidity_imbalance(uint256[2] calldata amounts, uint256 deadline) external;

    function commit_new_parameters(
        int128 amplification,
        int128 new_fee,
        int128 new_admin_fee
    ) external;

    function apply_new_parameters() external;

    function revert_new_parameters() external;

    function commit_transfer_ownership(address _owner) external;

    function apply_transfer_ownership() external;

    function revert_transfer_ownership() external;

    function withdraw_admin_fees() external;

    function coins(uint256 arg0) external returns (address out);

    function underlying_coins(int128 arg0) external returns (address out);

    function balances(int128 arg0) external returns (uint256 out);

    function A() external returns (int128 out);

    function fee() external returns (int128 out);

    function admin_fee() external returns (int128 out);

    function owner() external returns (address out);

    function admin_actions_deadline() external returns (uint256 out);

    function transfer_ownership_deadline() external returns (uint256 out);

    function future_A() external returns (int128 out);

    function future_fee() external returns (int128 out);

    function future_admin_fee() external returns (int128 out);

    function future_owner() external returns (address out);
}

CurveFiOperator.sol :

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.9;

import "./ICurveFiPool.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/*
 * - CurveFi Pool Smart Contract Address: 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7
 * - Underlaying Tokens Available in the CurveFiYPool(https://etherscan.io/address/0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7#readContract#F8):
 * Index 0: DAI - 0x6B175474E89094C44Da98b954EedeAC495271d0F
 * Index 1: USDC - 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
 * Index 2: USDT - 0xdAC17F958D2ee523a2206206994597C13D831ec7
 * Liquidity Pool Token: 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490
 */

//-Addresses Source: https://curve.readthedocs.io/ref-addresses.html#base-pools

contract CurveFiOperator {
    event Received(address sender, uint256 value);

    function getLPTokens(address lpTokenAddress) public returns (uint256) {
        return ICurveFiPoolToken(lpTokenAddress).balanceOf(address(this));
    }

    /// @param _amountTIndexes: List of Amounts of Different Coins to Deposit. Ex: [2 DAI, 4 USDC, 3 USDT].
    function depositLiquidityInOperator(address curveFiPool, uint256[3] memory _amountTIndexes) external {
        for (uint256 i = 0; i < 3; i++) {
            if (_amountTIndexes[i] > 0) {
                address currentCoin = ICurveFiPool(curveFiPool).coins(i);
                IERC20Modified(currentCoin).approve(address(this), _amountTIndexes[i]);
                IERC20Modified(currentCoin).transferFrom(msg.sender, address(this), _amountTIndexes[i]);
            }
        }
    }

    /// @param _amountTIndexes: List of Amounts of Different Coins to Deposit. Ex: [2 DAI, 4 USDC, 3 USDT].
    /// @param minLPTokenMintAmount: Minimum amount of L.P. Tokens to mint from the deposit.
    /// return Returns the Minimum Amount of L.P. tokens received in exchange for the deposited tokens.
    /// @dev More Info Here: https://resources.curve.fi/lp/depositing/depositing-into-the-y-pool
    function addLiquidity(
        address curveFiPool,
        uint256[3] memory _amountTIndexes,
        uint256 minLPTokenMintAmount
    ) external {
        for (uint256 i = 0; i < 3; i++) {
            if (_amountTIndexes[i] > 0) {
                address currentCoin = ICurveFiPool(curveFiPool).coins(i);
                IERC20Modified(currentCoin).approve(address(this), _amountTIndexes[i]);
                IERC20Modified(currentCoin).transferFrom(msg.sender, address(this), _amountTIndexes[i]);
            }
        }

        //-Example of the Function in the Curve S.C.s:_ def add_liquidity(amounts: uint256[N_COINS], min_mint_amount: uint256):
        ICurveFiPool(curveFiPool).add_liquidity(_amountTIndexes, minLPTokenMintAmount);
    }

 //...

    function safeTransferETH(address to, uint256 value) private {
        (bool success, ) = to.call{ value: value }(new bytes(0));
        require(success, "TransferHelper: ETH_TRANSFER_FAILED");
    }

    receive() external payable {
        emit Received(msg.sender, msg.value);
    }
}

That is Being Tested with the Hardhat MainNet Forking tool trying to Operate with THIS Vyper Smart Contract which is Deployed at THIS Address. When I try to Add Liquidity to the Protocol, basically doing the same as in THIS Recent Transaction, it fails without any message. The S.C.s is not "Paused" or Killed, the Parameters Introduced to the Function are Correct and I already reviewed all the require(...); of all the Functions that I call in THIS Vyper Smart Contract (In Vyper the are called assert, like in HERE). Also the changing or omitting the BlockNumber of the Hardhat MainNet Forking tool doesn't affects in anything.

  • The Return that I get is this one:
1) CurveFinance Pool S.Contract
      CurveFi Pool Adds Liquidity:
    Error: Transaction reverted without a reason string
     at <UnrecognizedContract>.<unknown> (0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7)
     at CurveFiOperator.addLiquidity (contracts/CurveFi/CurveFiOperator.sol:65)
     at async HardhatNode._mineBlockWithPendingTxs (node_modules\hardhat\src\internal\hardhat-network\provider\node.ts:1773:23)
     at async HardhatNode.mineBlock (node_modules\hardhat\src\internal\hardhat-network\provider\node.ts:466:16)
     at async EthModule._sendTransactionAndReturnHash (node_modules\hardhat\src\internal\hardhat-network\provider\modules\eth.ts:1504:18)
     at async HardhatNetworkProvider.request (node_modules\hardhat\src\internal\hardhat-network\provider\provider.ts:118:18)
     at async EthersProviderWrapper.send (node_modules\@nomiclabs\hardhat-ethers\src\internal\ethers-provider-wrapper.ts:13:20)
  • When
    I try to recreate that Same Transaction in Tenderly with these Parameters:
  • Caller (Whale Wallet that I impersonate for Testing): 0x935f64B44B5C48A1539C4AdA5161D27ace4205b5
  • BlockNumber: Either 15269796 or the Latest.
  • S.C. A.B.I. CurveFiOperator.json :
[
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "address",
        "name": "sender",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "value",
        "type": "uint256"
      }
    ],
    "name": "Received",
    "type": "event"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "curveFiPool",
        "type": "address"
      },
      {
        "internalType": "uint256[3]",
        "name": "_amountTIndexes",
        "type": "uint256[3]"
      },
      {
        "internalType": "uint256",
        "name": "minLPTokenMintAmount",
        "type": "uint256"
      }
    ],
    "name": "addLiquidity",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "curveFiPool",
        "type": "address"
      },
      {
        "internalType": "uint256[3]",
        "name": "_amountTIndexes",
        "type": "uint256[3]"
      }
    ],
    "name": "depositLiquidityInOperator",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "curveFiPool",
        "type": "address"
      },
      {
        "internalType": "int128",
        "name": "_tokenInIndex",
        "type": "int128"
      },
      {
        "internalType": "int128",
        "name": "_tokenOutIndex",
        "type": "int128"
      },
      {
        "internalType": "uint256",
        "name": "_amountIn",
        "type": "uint256"
      }
    ],
    "name": "exchange",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "lpTokenAddress",
        "type": "address"
      }
    ],
    "name": "getLPTokens",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "curveFiPool",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "LPtokensToBurn",
        "type": "uint256"
      },
      {
        "internalType": "uint256[]",
        "name": "_minAmountTIndexes",
        "type": "uint256[]"
      }
    ],
    "name": "removeLiquidity",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "stateMutability": "payable",
    "type": "receive"
  }
]
  • Function Call:
addLiquidity(0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7,
[90000000000000000000,
100000000,
95000000],
1000000000000000000)
  • Or also:
addLiquidity(0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7,
[0000000000000000000,
100000000,
0000000],
96000000000000000000)
  • And the OutPut is: invalid opcode: opcode 0xa7 not defined

  • Do you have any idea of why is this happening?:

Some doubts on StableSwapIB (Curve IronBank Pool)

From the code:

PRECISION_MUL: constant(uint256[N_COINS]) = [1, 1000000000000, 1000000000000]

In any other pool, this array of values reflects 10 ** (18 - coin.decimals) for each coin in the pool.

The decimals value of each one of the coins in this pool (iDAI, iUSDC, iUSDT) is set to 8.

This means that the array above would typically be initialized as:

PRECISION_MUL: constant(uint256[N_COINS]) = [10000000000, 10000000000, 10000000000]

What is the reason behind this notable difference between the IB pool and all other pools in this repository?

What are these tests for ?

for i in (sending, receiving):
if wrapped_coins[i] == ETH_ADDRESS:
admin_fee = swap.balance() - swap.balances(i)
assert admin_fee + swap.balances(i) == swap.balance()
else:
admin_fee = wrapped_coins[i].balanceOf(swap) - swap.balances(i)
assert admin_fee + swap.balances(i) == wrapped_coins[i].balanceOf(swap)
assert admin_fee > 0

In simpler terms :

admin_fee = A - B

and the test is :

admin_fee + B == A

Whatever swap.balance() and swap.balances(i) returns, the result will always be true.

Spend limit permission not recognized

It seems that the spending allowance is not recognized if it's already done before starting the exchange.

This is what I did:
I wanted to exchange aUSDT for aUSDC.
When I clicked "Sell" button, metamask asked me to approve spend limit. I edited the amount to a 1% more than I wanted to exchange. At the next step I saw a fee of 50usd, so I cancelled the trade, but the spending allowance is already confirmed.
Now, if I try to start again the process, it asks again for the spending limit aproval, even though it's already approved.

brownie_hooks.py documentation

Good morning, folks. I'm experimenting with curvefi and yearn finance brownie projects. I noticed that the brownie mix used by either team relies on 'brownie_hooks.py' at the project root. I'm not able to find any documentation so was hoping you could provide any insight you have on it. Many thanks

0xbdfa4f4492dd7b7cf211209c4791af8d52bf5c50

Overview

Provide a simple overview of what you wish to see added. Please include:

  • What you are trying to do
  • Why the current functionality is inadequate to address your goal

Specification

Describe the syntax and semantics of how you would like to see this feature implemented. The more detailed the better!

Please understand that Curve is an active project. Contracts are already deployed to the Ethereum mainnet and integrated throughout the ecosystem. Adding or modifying functionality can have wide-ranging consequences, and so cannot be done without thorough consideration and testing.

Dependencies

Include links to any open issues that must be resolved before this feature can be implemented.

For mr. @iamdefinitelyahuman. Please, I need your help.

Hello, @iamdefinitelyahuman.

First of all, I want to apologize for posting this here. I know that Github issues are not intended for technical support and honestly tried to get some guidance in Telegram and Discord. I've also read all the documentation, whitepapers at Curve.fi, all history of the messages in Discord's #dev channel as well as tons of other documentation.

I'm trying to understand the specifics of the 3pool contract, and struggling to do so. I'm doing so with one very specific goal โ€” to deeply understand how APRs are calculated for Curve pools. I need your help to understand the following:

RATES: constant(uint256[N_COINS]) = [1000000000000000000, 1000000000000000000000000000000, 1000000000000000000000000000000]

What the RATES constant stands for?
I originally thought that it is about the precision of the specific token, but found that USDT and USDC have 6 decimals while this array contains much higher values 10^30.

def _xp() -> uint256[N_COINS]:
result: uint256[N_COINS] = RATES
for i in range(N_COINS):
result[i] = result[i] * self.balances[i] / LENDING_PRECISION
return result

What the _xp() function does?
My guess was that it returns the DAI, USDC, USDT balances normalized with a Lending precision. If my guess is right, why do we use the Lending precision if it is not a lending pool?

def get_D(xp: uint256[N_COINS], amp: uint256) -> uint256:
S: uint256 = 0
for _x in xp:
S += _x
if S == 0:
return 0
Dprev: uint256 = 0
D: uint256 = S
Ann: uint256 = amp * N_COINS
for _i in range(255):
D_P: uint256 = D
for _x in xp:
D_P = D_P * D / (_x * N_COINS) # If division by 0, this will be borked: only withdrawal will work. And that is good
Dprev = D
D = (Ann * S + D_P * N_COINS) * D / ((Ann - 1) * D + (N_COINS + 1) * D_P)
# Equality with the precision of 1
if D > Dprev:
if D - Dprev <= 1:
break
else:
if Dprev - D <= 1:
break
return D

What the _get_D() function does?
My guess was that it is connected to the pool invariant calculation, but it is not clear to me why do we go through a loop to calculate the D? I have found some relevant information in dev documentation, but really struggling to understand the specifics of "converging solution"

Curve Bug

Hello,

I'm new to the Synthetic Network and it seems that I have an issue with some crypto that I have deposited into the Curve Pool and I can't get it to come out. I see there is a notice about a recent bug, and I have tried to do the transaction through my Mintr Console but that does seem to be working or showing any results either.

I do have a screenshot to share with you down below.

John Wann
[email protected]

Screenshot_2020-08-16 curve fi susd

Unstaking and withdraw

\Hello there
why i cant make unstaking or withdraw and the site become freez?
here is my address

Pool for gold pegged stable coins

Overview

I am trying to yield farm gold pegged coins to get exposure to the price of gold.
There is no pool to trade gold coins.

Specification

In order to trade gold coins, it would be nice to have a PAXGold / Tether Gold pool. They both track 1 ounce of gold and can be used like stable coins.

Dependencies

No known open issues that must be resolved before this feature can be implemented.

Make get_dy and exchange have a consistent logic of computing dy in sUSD pool

Overview

In sUSD pool code, get_dy() and exchange() have an inconsistent logic of computing _dy amount, thus, the returned amount in exchange() could be different from the returned value of get_dy().

In get_dy() function:

dy: uint256 = (xp[j] - y) * PRECISION / rates[j]
_fee: uint256 = self.fee * dy / FEE_DENOMINATOR
_dy: uint256 = dy - _fee

In exchange() function:

dy: uint256 = xp[j] - y
dy_fee: uint256 = dy * self.fee / FEE_DENOMINATOR
_dy: uint256 = (dy - dy_fee) * PRECISION / rates[j]

Specification

Should make the same logic of computing _dy value in both functions.

get_dy_underlying does not factor in rate of underlying token

What was wrong?

get_dy_underlying passes in an x into get_y that differs from the x that exchange_underlying passes. I believe this means get_dy_underlying will not be accurate since it doesn't factor in the rate.

Specifically in line 409 and 437 of the curve compound pool you can see what is passed in to each:

get_dy_underlying(...):
    x = xp[i] + dx * precisions[i]

...

_exchange(...)
    x = xp[i] + dx * rates[i] / PRECISION  # Note: rates[i] is defined in _current_rates as precisions[i] * cERC20().exchangeRateCurrent
...

I believe this means that get_dy_underlying does not factor in the rate of the underlying token and therefore always gives an incorrect amount of output given dx. I would have expected that line to be x = xp[i] + dx * rates[i] / PRECISION, where rates[i] comes from _stored_rates. Although the stored_rates is not the same as 'current_rates', I suspect it should be more accurate then not multiplying any rates at all?

Am I understanding this correctly? I am attempting to estimate dy given dx as accurate as possible, so If get_dy_underlying would be more accurate factoring in the stored rates, I can modify the dx I pass into the get_dy_underlying call so that it factors in stored_rates. (I.e. I will call out to the cERC20 token myself and multiple that to dx and use that new dx in my get_dy_underlying if it is more accurate)

How can it be fixed?

I believe the solution is to add x = xp[i] + dx * rates[i] / PRECISION into the get_dy_underlying to make it more representative of what exchange_underlying is doing, but I leave this up to the actual maintainers of the code to confirm this since I'm not 100% familiar with this.

Note I noticed this across all the pools that I looked at and I suspect the code was copy and pasted across each code base.

Compiler failures on 0.2.7 vyper files

Environment information

  • curve-contract branch/commit: master/latest
  • brownie Version: v1.12.0
  • OS: osx

What was wrong?

I'm simply trying to compile the contracts and run the tests, but am running into a compiler error.

Running brownie compile terminates with the following output:

Unhandled exception in 'contracts/pools/dusd/DepositDUSD.vy':
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/compile.py", line 50, in main
    proj = project.load()
  File "brownie/project/main.py", line 702, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 164, in __init__
    self.load()
  File "brownie/project/main.py", line 217, in load
    self._compile(changed, self._compiler_config, False)
  File "brownie/project/main.py", line 90, in _compile
    build_json = compiler.compile_and_format(
  File "brownie/project/compiler/__init__.py", line 140, in compile_and_format
    output_json = compile_from_input_json(input_json, silent, allow_paths)
  File "brownie/project/compiler/__init__.py", line 251, in compile_from_input_json
    return vyper.compile_from_input_json(input_json, silent, allow_paths)
  File "brownie/project/compiler/vyper.py", line 235, in compile_from_input_json
    return vyper_json.compile_json(input_json, root_path=allow_paths)
  File "vyper/cli/vyper_json.py", line 394, in compile_json
    compiler_data, warn_data = compile_from_input_dict(input_dict, exc_handler, root_path)
  File "vyper/cli/vyper_json.py", line 316, in compile_from_input_dict
    return exc_handler(contract_path, exc, "parser"), {}
  File "vyper/cli/vyper_json.py", line 102, in exc_handler_raises
    raise exception
  File "vyper/cli/vyper_json.py", line 312, in compile_from_input_dict
    interface_codes = get_interface_codes(
  File "vyper/cli/vyper_json.py", line 245, in get_interface_codes
    interface_codes = extract_file_interface_imports(code)
  File "vyper/cli/utils.py", line 20, in extract_file_interface_imports
    ast_tree = vy_ast.parse_to_ast(code)
  File "vyper/ast/utils.py", line 36, in parse_to_ast
    annotate_python_ast(py_ast, source_code, class_types, source_id, contract_name)
  File "vyper/ast/annotation.py", line 263, in annotate_python_ast
    tokens = asttokens.ASTTokens(source_code, tree=parsed_ast)
  File "asttokens/asttokens.py", line 65, in __init__
    self.mark_tokens(self._tree)
  File "asttokens/asttokens.py", line 76, in mark_tokens
    MarkTokens(self).visit_tree(root_node)
  File "asttokens/mark_tokens.py", line 49, in visit_tree
    util.visit_tree(node, self._visit_before_children, self._visit_after_children)
  File "asttokens/util.py", line 186, in visit_tree
    ret = postvisit(current, par_value, value)
  File "asttokens/mark_tokens.py", line 92, in _visit_after_children
    nfirst, nlast = self._methods.get(self, node.__class__)(node, first, last)
  File "asttokens/mark_tokens.py", line 330, in visit_keyword
    util.expect_token(name, token.NAME, node.arg)
  File "asttokens/util.py", line 56, in expect_token
    raise ValueError("Expected token %s, got %s on line %s col %s" % (

I also tried installing vyper v0.2.7, and compiling the file and got the same error:

$ vyper contracts/pools/dusd/DepositDUSD.vy
ValueError: Expected token NAME:'max_outsize', got OP:']' on line 68 col 28

How can it be fixed?

I tried changing the version comment on the file DepositDUSD.vy to 0.2.8, that seems to have worked, but other 0.2.7 files are now failing to compile.

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.