@giveth/commons-abc-contracts
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -5,10 +5,15 @@ const ReserveTokenMock = artifacts.require("ERC20Mintable"); | ||
const reserveRatio = 142857; // kappa ~ 6 | ||
const theta = 350000; // 35% in ppm | ||
const p0 = 1; | ||
const initialRaise = 300000; | ||
const friction = 20000; // 2% in ppm | ||
const gasPrice = 15000000000; // 15gwei | ||
// Curve parameters: | ||
const reserveRatio = 142857; // Kappa (~ 6) | ||
const theta = 350000; // 35% in ppm | ||
const p0 = 1; // Price of internal token in external tokens. | ||
const initialRaise = 300000; // Raise amount in external tokens. | ||
const friction = 20000; // 2% in ppm | ||
const gasPrice = 15000000000; // 15 gwei | ||
const duration = 3024000000000000; // ~5 weeks. | ||
const minExternalContibution = 100000; | ||
module.exports = async function(deployer, networks, accounts) { | ||
@@ -22,11 +27,14 @@ await deployer.deploy(FundingPoolMock); | ||
await deployer.deploy(CommonsToken, | ||
ReserveTokenMockInstance.address, | ||
reserveRatio, | ||
gasPrice, | ||
theta, | ||
p0, | ||
initialRaise, | ||
FundingPoolMockInstance.address, | ||
friction, {gas: 10000000} | ||
); | ||
ReserveTokenMockInstance.address, // _externalToken | ||
reserveRatio, // _reserveRatio | ||
gasPrice, // _gasPrice | ||
theta, // _theta | ||
p0, // _p0 | ||
initialRaise, // _initialRaise | ||
FundingPoolMockInstance.address, // _fundingPool | ||
friction, // _friction | ||
duration, // _duration | ||
minExternalContibution, // _minExternalContribution | ||
{ gas: 10000000 } | ||
); | ||
}; |
{ | ||
"name": "@giveth/commons-abc-contracts", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"devDependencies": { | ||
@@ -21,9 +21,10 @@ "chai": "^4.2.0", | ||
"start": "concurrently 'npm:ganache' 'npm:deploy'", | ||
"ganache": "mkdir -p .chain && ganache-cli -p 8545 -d --gasLimit 7000000000000 --gasPrice 1 --acctKeys ./.chain/ganache-accounts.json -m 'ivory sibling about kiwi grant sunset beauty solar cup fame south girl'", | ||
"deploy": "wait-on tcp:8545 && truffle migrate --compile-all --reset --network development", | ||
"compile": "truffle compile", | ||
"test": "wait-on tcp:8545 && truffle test", | ||
"ganache": "mkdir -p .chain && ./node_modules/.bin/ganache-cli -p 8545 -d -i 5777 --gasLimit 7000000000000 --gasPrice 1 --acctKeys ./.chain/ganache-accounts.json -m 'ivory sibling about kiwi grant sunset beauty solar cup fame south girl'", | ||
"deploy": "wait-on tcp:8545 && ./node_modules/.bin/truffle migrate --compile-all --reset --network development", | ||
"compile": "./node_modules/.bin/truffle compile", | ||
"test": "wait-on tcp:8545 && ./node_modules/.bin/truffle test", | ||
"lint": "solhint --max-warnings 0 \"contracts/**/*.sol\"", | ||
"ci": "concurrently 'npm:ganache' 'npm:test'" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
@@ -1,8 +0,197 @@ | ||
// const CommonsToken = artifact.require("CommonsToken"); | ||
const { BN, constants, expectEvent, shouldFail } = require('openzeppelin-test-helpers'); | ||
contract("CommonsToken", accounts => { | ||
it("some test case", async () => { | ||
const CommonsToken = artifacts.require("CommonsToken.sol"); | ||
const FundingPoolMock = artifacts.require("FundingPoolMock.sol"); | ||
const ReserveTokenMock = artifacts.require("./contracts/vendor/ERC20/ERC20Mintable.sol"); | ||
const DENOMINATOR_PPM = 1000000; | ||
contract("CommonsToken", ([reserveTokenMinter, contractCreator, hatcherOne, hatcherTwo, lateInvestor]) => { | ||
const reserveRatio = 142857; // kappa ~ 6 | ||
const theta = 350000; // 35% in ppm | ||
const p0 = 1; | ||
const initialRaise = 300000; | ||
const friction = 20000; // 2% in ppm | ||
const gasPrice = 15000000000; // 15gwei | ||
const duration = 604800; // 1 week in seconds | ||
const minimalContribution = 100 // in xDai | ||
beforeEach(async function() { | ||
this.fundingPool = await FundingPoolMock.new(); | ||
this.reserveToken = await ReserveTokenMock.new(reserveTokenMinter); | ||
this.commonsToken = await CommonsToken.new( | ||
this.reserveToken.address, | ||
reserveRatio, | ||
gasPrice, | ||
theta, | ||
p0, | ||
initialRaise, | ||
this.fundingPool.address, | ||
friction, | ||
duration, | ||
minimalContribution, | ||
{ gas: 10000000 } | ||
); | ||
await this.reserveToken.mint(hatcherOne, 1000000); | ||
await this.reserveToken.mint(hatcherTwo, 1000000); | ||
}) | ||
describe('hatchContribute', function () { | ||
describe('When we are in the hatch phase', function() { | ||
describe("When we are within the duration deadline", function() { | ||
describe('When the contribution does not reach the initialRaise', function() { | ||
const amountToFundExtern = 200; | ||
describe("When there is sufficient contribution", function() { | ||
describe('When the commonToken can pull the external token', function() { | ||
beforeEach(async function() { | ||
// problem. The msg.sender is the smart contract. | ||
await this.reserveToken.approve(this.commonsToken.address, amountToFundExtern, {from: hatcherOne}); | ||
await this.commonsToken.hatchContribute(amountToFundExtern, {from: hatcherOne}); | ||
}) | ||
it("Should have increased the total amount raised", async function() { | ||
let raisedExternal = await this.commonsToken.raisedExternal() | ||
assert.equal(raisedExternal, amountToFundExtern); | ||
}) | ||
it("Should have allocated the external tokens to the bonding curve", async function() { | ||
let externalTokensOwned = await this.reserveToken.balanceOf(this.commonsToken.address); | ||
assert.equal(externalTokensOwned, amountToFundExtern); | ||
}) | ||
it("Should have set the initial external contributions for the hatcher", async function() { | ||
let initialContributions = await this.commonsToken.initialContributions(hatcherOne); | ||
let paidExternal = initialContributions.paidExternal; | ||
assert.equal(paidExternal, amountToFundExtern); | ||
}) | ||
it("Should have set the locked internal tokens for the hatcher", async function() { | ||
let initialContributions = await this.commonsToken.initialContributions(hatcherOne); | ||
let lockedInternal = initialContributions.lockedInternal; | ||
assert.equal(lockedInternal, amountToFundExtern * p0); | ||
}) | ||
}) | ||
describe("When the commonToken cannot pull the reserve token", async function() { | ||
it('reverts', async function() { | ||
await shouldFail.reverting(this.commonsToken.hatchContribute(amountToFundExtern, {from: hatcherOne})) | ||
}) | ||
}) | ||
}) | ||
describe("When there is no sufficient contribution", function() { | ||
const amountToFundExtern = 1 | ||
it('reverts', async function() { | ||
await shouldFail.reverting(this.commonsToken.hatchContribute(amountToFundExtern, {from: hatcherOne})) | ||
}) | ||
}) | ||
}) | ||
describe("When the contribution reaches the initial raise", function() { | ||
// increase raised | ||
// pull reservetoken from the contributer to our account | ||
// set the initialContributions for the hatcher | ||
// mint bonding curve tokens to the bondingcurve contract | ||
}) | ||
describe("When the contribution reaches over the initial raise", function() { | ||
const amountToFundExtern = 400000; | ||
beforeEach(async function() { | ||
await this.reserveToken.approve(this.commonsToken.address, amountToFundExtern, {from: hatcherOne}); | ||
await this.commonsToken.hatchContribute(amountToFundExtern, {from: hatcherOne}); | ||
}) | ||
it("Should have increased the total amount raised", async function() { | ||
let raisedExternal = await this.commonsToken.raisedExternal() | ||
assert.equal(raisedExternal, initialRaise); | ||
}) | ||
it("Should have allocated the external tokens to the bonding curve", async function() { | ||
let externalTokensOwned = await this.reserveToken.balanceOf(this.commonsToken.address); | ||
assert.equal(externalTokensOwned, initialRaise); | ||
}) | ||
it("Should have set the initial external contributions for the hatcher", async function() { | ||
let initialContributions = await this.commonsToken.initialContributions(hatcherOne); | ||
let paidExternal = initialContributions.paidExternal; | ||
assert.equal(paidExternal, initialRaise); | ||
}) | ||
it("Should have minted the correct amount to the fundingPool", async function() { | ||
let internalTokensInFundingPool = await this.commonsToken.balanceOf(this.fundingPool.address) | ||
assert.equal(internalTokensInFundingPool, (initialRaise / p0 ) * (theta / DENOMINATOR_PPM)); | ||
}) | ||
it("Should have minted the correct amount to the reserve", async function() { | ||
let internalTokensReserve = await this.commonsToken.balanceOf(this.commonsToken.address); | ||
assert.equal(internalTokensInFundingPool, (initialRaise / p0 ) * (1 - (theta / DENOMINATOR_PPM))); | ||
}) | ||
it("Should have ended the hatching phase", async function() { | ||
let isHatched = await this.isHatched(); | ||
assert.isTrue(isHatched); | ||
}) | ||
}) | ||
}) | ||
describe("When we are outside the duration deadline", function() { | ||
// do something with the time | ||
}) | ||
}) | ||
describe("When we are not in the hatch phase", function() { | ||
const amountToFundExtern = 400000; | ||
beforeEach(async function() { | ||
// problem. The msg.sender is the smart contract. | ||
await this.reserveToken.approve(this.commonsToken.address, amountToFundExtern, {from: hatcherOne}); | ||
await this.commonsToken.hatchContribute(amountToFundExtern, {from: hatcherOne}); | ||
}) | ||
it('reverts', async function() { | ||
await shouldFail.reverting(this.commonsToken.hatchContribute(amountToFundExtern, {from: hatcherOne})) | ||
}) | ||
}) | ||
}); | ||
}); | ||
describe("fundsAllocated", function() { | ||
describe("When the sender is the fundingPool", function() { | ||
describe("When we have not yet allocated all the initial funds", function() { | ||
describe("When we don't allocate all the initial funds", function() { | ||
//totalUnlocked increases to less than 100% | ||
}) | ||
describe("When we allocate all the initial funds", function() { | ||
//totalUnlocked 100% | ||
}) | ||
describe("When we allocate more than the initial funds", function() { | ||
//totalUnlocked 100% | ||
}) | ||
}) | ||
}) | ||
describe("When the sender is not the fundingPool", function() { | ||
//reverts | ||
}) | ||
}) | ||
describe("burn", function() { | ||
describe("When we are not in the hatching phase", function() { | ||
describe("When the callee has enough internal tokens", function() { | ||
// burn tokens | ||
// transfer 1-friction to the callee in external token to the callee | ||
// transfer fridction to the funding pool | ||
}) | ||
describe("When the callee has not enough internal tokens", function() { | ||
//revert | ||
}) | ||
}) | ||
describe("When we are in the hatchin phase", function() { | ||
//reverts | ||
}) | ||
}) | ||
describe("mint", function() { | ||
describe("when we are not in the hatching phase", function() { | ||
}) | ||
describe("When we are in the hatching phase", function() { | ||
}) | ||
}) | ||
}) | ||
// scenarios | ||
@@ -9,0 +198,0 @@ // 1. Init |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
347721
279
26
1