Comments (13)
@wysenynja I figured it out.
https://github.com/Uniswap/contracts-vyper/blob/master/contracts/uniswap_exchange.vy#L65
First liquidity provider needs to add at least 1000000000 wei to the contract.
from v1-contracts.
New test:
it("... should add some TutorialToken to the Uniswap pool", async () => {
await UniswapExchange.deployed();
await UniswapFactory.deployed();
const uniswapFactoryInstance = await IUniswapFactory.at(UniswapFactory.address);
const tutorialTokenInstance = await TutorialToken.deployed();
const tutorialTokenUniswapAddress = await uniswapFactoryInstance.getExchange(TutorialToken.address);
await tutorialTokenInstance.approve(tutorialTokenUniswapAddress, 1500000000);
const tutorialTokenUniswapInstance = await IUniswapExchange.at(tutorialTokenUniswapAddress);
const balanceETH = web3.utils.toBN(await web3.eth.getBalance(accounts[0]));
assert(balanceETH.gt(1500000000));
const balanceTT = await tutorialTokenInstance.balanceOf(accounts[0]);
assert.isAtLeast(balanceTT.toNumber(), 1500000000);
const current_block = await web3.eth.getBlock(await web3.eth.getBlockNumber());
await tutorialTokenUniswapInstance.addLiquidity(1000000000, 1000000000, current_block.timestamp + 300, {value: 1000000000});
});
Sweet success:
Contract: uniswap_factory
✓ ... should be initializable through the interface (356200 gas)
✓ ... should have a pool for TutorialToken (250727 gas)
✓ ... should add some TutorialToken to the Uniswap pool (155332 gas)
from v1-contracts.
Thanks a lot @wysenynja @haydenadams , this saved my day!
from v1-contracts.
If I try to truffle debug $tx
, I get an error. Probably because the uniswap truffle artifacts only have the bytecode and nothing else in them.
Gathering transaction data...
TypeError: Cannot read property 'id' of undefined
at newScope.variables.concat.filter.variable (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-debugger/dist/debugger.js:1738:1)
at Array.filter (<anonymous>)
at map (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-debugger/dist/debugger.js:1735:1)
at Array.map (<anonymous>)
at data.info.scopes._ (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-debugger/dist/debugger.js:1720:125)
at /usr/src/app/node_modules/truffle/build/webpack:/~/reselect/lib/index.js:76:1
at /usr/src/app/node_modules/truffle/build/webpack:/~/reselect/lib/index.js:36:1
at /usr/src/app/node_modules/truffle/build/webpack:/~/reselect/lib/index.js:90:1
at Function._ (/usr/src/app/node_modules/truffle/build/webpack:/~/reselect/lib/index.js:36:1)
at args (/usr/src/app/node_modules/truffle/build/webpack:/~/reselect-tree/index.js:209:1)
at /usr/src/app/node_modules/truffle/build/webpack:/~/reselect/lib/index.js:86:1
at Function._ (/usr/src/app/node_modules/truffle/build/webpack:/~/reselect/lib/index.js:36:1)
at args (/usr/src/app/node_modules/truffle/build/webpack:/~/reselect-tree/index.js:209:1)
at /usr/src/app/node_modules/truffle/build/webpack:/~/reselect/lib/index.js:86:1
at /usr/src/app/node_modules/truffle/build/webpack:/~/reselect/lib/index.js:36:1
at runSelectEffect (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:723:1)
at runEffect (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1191:1)
at digestEffect (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1258:1)
at next (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1148:1)
at currCb (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1238:1)
at checkEnd (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/chunk-585b854f.js:154:1)
at chCbAtKey (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/chunk-585b854f.js:170:1)
at Object.currCb [as cont] (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1238:1)
at end (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1001:1)
at Object.task.cont (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:829:1)
at next (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1157:1)
at Object.currCb [as cont] (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1238:1)
at end (/usr/src/app/node_modules/truffle/build/webpack:/~/@redux-saga/core/dist/redux-saga-core.esm.js:1001:1)
The above error occurred in task session.saga
Tasks cancelled due to error:
controller.saga
data.saga
evm.saga
solidity.saga
trace.saga
web3.saga
from v1-contracts.
What happens if you set minLiquidity to 1?
Also if your eth balance and token balance are both 1000, maybe send less than 1000 (like 500 of each).
Also the abi is likely giving you issues b/c of vyper unit types that solidity doesnt have.
from v1-contracts.
from v1-contracts.
Your deploy order seems to be good.
The JUMP error is a Vyper bug. Basically Uniswap uses Vypers create_with_code_of()
which was created before the REVERT opcode was added. It sets up a new contract with a delegatecall pattern to a library contract.
Unfortunately when REVERT was added, create_with_code_of()
fell through the cracks so if a call fails on a proxy delegatecall contract created with this function, it throws by doing an invalid jump.
But yeah something is causing the addLiquidity function to fail.
Try calling tutorialTokenUniswapInstance.factoryAddress()
and tutorialTokenUniswapInstance.tokenAddress()
and make sure it outputs the expected addresses.
Do you have any tests for the tutorial token to make sure thats working?
from v1-contracts.
I do call factoryAddress
and tokenAddress
in the should have a pool for TutorialToken
test and it passes.
from v1-contracts.
from v1-contracts.
This is my TutorialToken.sol. It is pretty simple so I doubt I've added any bugs here.
pragma solidity 0.5.4;
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
contract TutorialToken is ERC20 {
string public name = "TutorialToken";
string public symbol = "TT";
uint8 public decimals = 18;
uint public INITIAL_SUPPLY = 1000000000000;
constructor() public {
_mint(msg.sender, INITIAL_SUPPLY);
}
}
from v1-contracts.
from v1-contracts.
Fo sho lmk if there are still issues
from v1-contracts.
@haydenadams any reason why 1000000000 wei was chosen? Out of pure curiosity :)
from v1-contracts.
Related Issues (20)
- contracts-vyper instruction HOT 1
- getTokenToTokenPrice HOT 2
- Tokens that do no return bools do not work HOT 1
- vNext Feature Request: Moving Average Price Feed Data HOT 3
- Unknown list type HOT 1
- Market limit orders for Uniswap HOT 7
- How important is the `min_liquidity` argument when adding liquidity
- UIP 1: Optional Permissioned Liquidity Pools HOT 2
- Add support for EIP1155
- ERC-777 token support HOT 2
- Doesn’t woks with ᴇʀᴄ20 tokens which always returns nothing. HOT 1
- What will happen in case of REVERT inside DELEGATE_CALL? HOT 4
- Support for latest Vyper compiler HOT 4
- End to End encryption of Uniswap to prevent front running HOT 3
- Bytecode: deployedBytecode or constructor?
- ABI removeLiquidity return values name collision
- Can't compile contracts on master branch, are other branch contracts okay to test on local testnet? HOT 1
- Add ERC-20 compatibility check when creating a new exchange HOT 1
- Missing ETH after failed attempt to add additional funds to UBT/ETH Liquidity pool HOT 2
- 如何将一个地址中的代币转移到另外一个地址中?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v1-contracts.