curvefi / curve-contract Goto Github PK
View Code? Open in Web Editor NEWVyper contracts used in Curve.fi exchange pools.
Home Page: https://www.curve.fi/
License: Other
Vyper contracts used in Curve.fi exchange pools.
Home Page: https://www.curve.fi/
License: Other
There are vulnerable packages in the pip dependencies that are defined by requirements.txt
It should contain:
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.
curve-contract
branch/commit: master/latestbrownie
Version: x.x.xganache-cli
Version: x.x.xPlease include information like:
Fill this in if you know how the bug could be fixed.
curve-contract
branch/commit: master:bb0bbf77 (latest)brownie
Version: 1.19.1ganache-cli
Version: 6.12.2I 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
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.
curve-contract
branch/commit: master/latestbrownie
Version: x.x.xganache-cli
Version: x.x.xPlease include information like:
Fill this in if you know how the bug could be fixed.
Standardize the pool templates.
Some thoughts on variable naming:
_
to denote they are immutable.SLOAD
s should use the same name as their storage counterpart.curve-contract
branch/commit: master/latestbrownie
Version: 1.14.5ganache-cli
Version: 6.12.2Please include information like:
brownie test
Compiling contracts...
Solc version: 0.5.17
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
Generating build data...
================================================================================================================================== 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
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.
User is required to approve the token contract, before redeeming LP. This is an extra friction which can be removed.
I think it should be changed to
Ann: uint256 = amp * (N_COINS ** N_COINS)
The "A*n**n" variable is essential to solve the stableswap algorithm.
curve-contract/vyper/stableswap.vy
Line 102 in 8c338d1
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
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.
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 just a horrible mess without:
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:
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...
curve-contract
branch/commit: master/latestbrownie
Version: x.x.xganache-cli
Version: x.x.xPlease include information like:
Fill this in if you know how the bug could be fixed.
I'm interested in writing a subgraph and was wondering if:
Thanks!
While not being a high severity issue, it is possible (in infinite number of transactions) to facilitate zero-fee trades.
There is a more proper way to implement asymmetric deposits and withdrawals so that they are exactly equivalent to trades
People see that they'll spend $1.5 on gas when it turns out to be 10 cents in reality
https://github.com/curvefi/curve-contract/blob/master/contracts/pools/3pool/StableSwap3Pool.vy
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.
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)
0x935f64B44B5C48A1539C4AdA5161D27ace4205b5
15269796
or the Latest.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"
}
]
addLiquidity(0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7,
[90000000000000000000,
100000000,
95000000],
1000000000000000000)
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?:
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?
curve-contract/tests/pools/common/unitary/test_claim_fees.py
Lines 19 to 27 in b0bbf77
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.
While being a low-severity issue, it's better to assert that allowance is zero before setting a new allowance. Liquidity token (cDAIUSDC) is affected by that. That's important in case LP token starts being used massively as an interest-accruing token of its own.
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.
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
Hello from Trezor,
I want you to know that we have released Connect v9. It is now GA. https://www.npmjs.com/package/@trezor/connect
Provide a simple overview of what you wish to see added. Please include:
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.
Include links to any open issues that must be resolved before this feature can be implemented.
https://etherscan.io/address/0x66442B0C5260B92cAa9c234ECf2408CBf6b19a6f#code
This is the implementation contract for factory tricrypto pools. e.g., https://curve.fi/#/ethereum/pools/factory-tricrypto-0/deposit
Thank you
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:
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.
curve-contract/contracts/pools/3pool/StableSwap3Pool.vy
Lines 177 to 181 in b0bbf77
curve-contract/contracts/pools/3pool/StableSwap3Pool.vy
Lines 195 to 218 in b0bbf77
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]
" ... multiplied by n * (n - 1)" should be "... multiplied by n ** (n - 1)"
\Hello there
why i cant make unstaking or withdraw and the site become freez?
here is my address
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.
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.
No known open issues that must be resolved before this feature can be implemented.
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]
Should make the same logic of computing _dy value in both functions.
I need to get this ball rolling with them.
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)
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.
curve-contract
branch/commit: master/latestbrownie
Version: v1.12.0I'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
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.
I want to try this dApp from Argent which supports WalletConnect
Please do not open an issue to request support. This repository's issues are reserved for feature requests and bug reports.
If you have a question about Curve or require technical support:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.