mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
fix formating on connectors/curve.sol;
adding @openzeppelin/test-helpers, ganache-cli; fixing test/CurveProtocol.js to pass; added truffle network for tenderly proxy; added .nvmrc to set to node v12 as ganache-cli requires;
This commit is contained in:
parent
076a836c03
commit
bce54aba13
|
@ -73,7 +73,6 @@ contract CurveHelpers is Stores, DSMath {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
contract CurveProtocol is CurveHelpers {
|
||||
|
||||
event LogSell(
|
||||
|
|
1669
package-lock.json
generated
1669
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -5,10 +5,11 @@
|
|||
"main": "truffle-config.js",
|
||||
"directories": {},
|
||||
"scripts": {
|
||||
"test": "npm run ganache sleep 5 && truffle test && npm run stop",
|
||||
"test": "truffle test",
|
||||
"coverage": "./node_modules/.bin/solidity-coverage",
|
||||
"solium": "solium -d contracts/",
|
||||
"build-contracts": "sol-merger \"./contracts/connectors/mock.sol\" ./contracts/build"
|
||||
"build-contracts": "sol-merger \"./contracts/connectors/mock.sol\" ./contracts/build",
|
||||
"ganache": "ganache-cli --deterministic --unlock 0x9eb7f2591ed42dee9315b6e2aaf21ba85ea69f8c -f https://mainnet.infura.io/v3/<Your Key>"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -35,6 +36,8 @@
|
|||
"truffle-verify": "^1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openzeppelin/test-helpers": "^0.5.6",
|
||||
"ganache-cli": "^6.10.0-beta.2",
|
||||
"sol-merger": "^2.0.1",
|
||||
"solidity-coverage": "0.5.11",
|
||||
"solium": "1.2.3"
|
||||
|
|
|
@ -2,7 +2,7 @@ const CurveProtocol = artifacts.require('CurveProtocol')
|
|||
const daiABI = require('./abi/dai');
|
||||
const erc20 = require('./abi/erc20')
|
||||
const swap_abi = require('./abi/swap')
|
||||
const { ether, balance } = require('openzeppelin-test-helpers');
|
||||
const { ether, balance } = require('@openzeppelin/test-helpers');
|
||||
|
||||
const BN = require('bn.js')
|
||||
|
||||
|
@ -24,22 +24,20 @@ const swapContract = new web3.eth.Contract(swap_abi, swap)
|
|||
const swapToken = '0xC25a3A3b969415c80451098fa907EC722572917F'
|
||||
const tokenContract = new web3.eth.Contract(erc20, swapToken)
|
||||
|
||||
|
||||
|
||||
contract('Curve Protocol', async accounts => {
|
||||
|
||||
|
||||
it('should send ether to the DAI address', async () => {
|
||||
it('should send ether to the user address', async () => {
|
||||
let account = accounts[0]
|
||||
let contract = await CurveProtocol.deployed()
|
||||
const ethBalanceBefore = await balance.current(userAddress);
|
||||
// Send 0.1 eth to userAddress to have gas to send an ERC20 tx.
|
||||
await web3.eth.sendTransaction({
|
||||
from: accounts[0],
|
||||
to: userAddress,
|
||||
value: ether('0.1')
|
||||
});
|
||||
const ethBalance = await balance.current(userAddress);
|
||||
expect(+ethBalance).to.be.at.least(+ether('0.1'))
|
||||
const ethBalanceAfter = await balance.current(userAddress);
|
||||
expect(+ethBalanceAfter - +ethBalanceBefore).to.equal(+ether('0.1'))
|
||||
});
|
||||
|
||||
it('should transfer DAI to CurveProtocol', async () => {
|
||||
|
@ -48,6 +46,10 @@ contract('Curve Protocol', async accounts => {
|
|||
// Get 100 DAI for first 5 accounts
|
||||
// daiAddress is passed to ganache-cli with flag `--unlock`
|
||||
// so we can use the `transfer` method
|
||||
//
|
||||
// Note: This only works as userAddress has 2546221640728945323079640 Dai,
|
||||
// should remove this dependence in the future
|
||||
const daiBalanceUser = await daiContract.methods.balanceOf(userAddress).call();
|
||||
await daiContract.methods
|
||||
.transfer(contract.address, ether('100').toString())
|
||||
.send({ from: userAddress, gasLimit: 800000 });
|
||||
|
@ -66,19 +68,23 @@ contract('Curve Protocol', async accounts => {
|
|||
expect(+daiAllowance).to.be.at.least(+ether('100'))
|
||||
});
|
||||
|
||||
/* Deprecated as CurveProtocol is not ICurve and exchange has been implemented into sell method
|
||||
it('should exchange', async () => {
|
||||
let account = accounts[0]
|
||||
let contract = await CurveProtocol.deployed()
|
||||
|
||||
// Get 100 DAI for first 5 accounts
|
||||
console.log('before');
|
||||
let get_dy = await contract.get_dy.call(0, 1, ether('1').toString())
|
||||
console.log('after');
|
||||
let min_dy = +get_dy * 0.99
|
||||
let receipt = await contract.exchange(0, 1, ether('1').toString(), 1, { from: account })
|
||||
let buyAmount = receipt.logs[0].args.buyAmount.toString()
|
||||
expect(+buyAmount).to.be.at.least(min_dy);
|
||||
|
||||
});
|
||||
*/
|
||||
|
||||
/* Deprecated as CurveProtocol is not ICurve and calc_token_amount has been implemented into withdraw method
|
||||
it('should add liquidity', async () => {
|
||||
let account = accounts[0]
|
||||
let contract = await CurveProtocol.deployed()
|
||||
|
@ -119,4 +125,5 @@ contract('Curve Protocol', async accounts => {
|
|||
console.log(+daiBalance, +daiBalanceAfter, +withdrawnAmount)
|
||||
//expect(BN(daiBalance)).to.be.a.bignumber.equal(BN(daiBalanceAfter).sub(withdrawnAmount));
|
||||
})
|
||||
*/
|
||||
});
|
|
@ -54,6 +54,12 @@ module.exports = {
|
|||
port: 8545, // Standard Ethereum port (default: none)
|
||||
network_id: "*", // Any network (default: none)
|
||||
},
|
||||
// Tenderly Proxy
|
||||
proxy: {
|
||||
host: "127.0.0.1", // Localhost (default: none)
|
||||
port: 9545, // Standard Ethereum port (default: none)
|
||||
network_id: "*", // Any network (default: none)
|
||||
},
|
||||
|
||||
// Another network with more advanced options...
|
||||
// advanced: {
|
||||
|
@ -108,7 +114,7 @@ module.exports = {
|
|||
// Configure your compilers
|
||||
compilers: {
|
||||
solc: {
|
||||
version: "v0.6.0", // Fetch exact version from solc-bin (default: truffle's version)
|
||||
version: "v0.6.2", // Fetch exact version from solc-bin (default: truffle's version)
|
||||
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
|
||||
// settings: { // See the solidity docs for advice about optimization and evmVersion
|
||||
// optimizer: {
|
||||
|
|
Loading…
Reference in New Issue
Block a user