Skip to content

Commit

Permalink
Fix: Initialize vault in contract
Browse files Browse the repository at this point in the history
  • Loading branch information
sembrestels committed Oct 14, 2023
1 parent 1eb20cf commit 2018b2c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion pkg/abc-template/contracts/AbcTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ contract AbcTemplate is AbcBaseTemplate, TokenCache {
uint256 initialBalance
) = _unwrapAbcSettings(_abcSettings);

Vault reserve = Vault(_installNonDefaultApp(_dao, VAULT_APP_ID, new bytes(0)));
Vault reserve =
Vault(_installNonDefaultApp(_dao, VAULT_APP_ID, abi.encodeWithSelector(Vault(0).initialize.selector)));
IAugmentedBondingCurve abc = _installAbcApp(_dao, _tokenManager, reserve, _agent, entryTribute, exitTribute);
_configureAbcApp(_acl, abc, collateralToken, reserveRatio);
if (initialBalance > 0) {
Expand Down
1 change: 1 addition & 0 deletions pkg/abc-template/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require("@nomicfoundation/hardhat-ethers");
require("@nomicfoundation/hardhat-verify");
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
Expand Down
14 changes: 12 additions & 2 deletions pkg/abc-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
"dependencies": {
"@aragon/os": "^4.4.0",
"@aragon/templates-shared": "^1.0.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.4",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^1.1.1",
"@typechain/ethers-v6": "^0.4.0",
"@typechain/hardhat": "^8.0.0",
"@types/mocha": ">=9.1.0",
"chai": "^4.3.10",
"ethers": "^6.7.1",
"hardhat": "^2.18.0"
"ethers": "^6.4.0",
"hardhat": "^2.18.0",
"hardhat-gas-reporter": "^1.0.8",
"solidity-coverage": "^0.8.1",
"ts-node": ">=8.0.0",
"typechain": "^8.2.0"
}
}
19 changes: 13 additions & 6 deletions pkg/abc-template/test/AbcTemplate.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// const { expect } = require("chai");
const { ethers } = require("hardhat");
const { ethers, network } = require("hardhat");

// Optimism:
const daoFactory = "0x0a42106615233D0E6F9811d0cBb7ddC83170Fe5E"
Expand All @@ -16,6 +15,13 @@ describe("AbcTemplate contract", function () {
it("Deployment should work", async function () {
const [owner] = await ethers.getSigners();

const daiHolder = '0x2de373887b9742162c9a5885ddb5debea8e4486d'
await network.provider.request({
method: "hardhat_impersonateAccount",
params: [daiHolder],
});
const signer = await ethers.getSigner(daiHolder);

const abcTemplate = await ethers.deployContract("AbcTemplate", [
daoFactory,
_ens,
Expand All @@ -24,18 +30,19 @@ describe("AbcTemplate contract", function () {
_formula
]);

const reserveToken = new ethers.Contract(_reserveToken, ["function approve(address spender, uint256 value) public returns (bool)"], owner);
const reserveToken = new ethers.Contract(_reserveToken, ["function approve(address spender, uint256 value) public returns (bool)"], signer);

await reserveToken.approve(await abcTemplate.getAddress(), wad(3));
await reserveToken.approve(await abcTemplate.getAddress(), wad(3n * 10n ** 18n));

await abcTemplate.newTokenAndInstance(
await abcTemplate.connect(signer).newTokenAndInstance(
"Token Name",
"TKN",
"daoname",
[owner.address],
[wad(1)],
[pct(50), pct(15), 7 * 24 * 60 * 60],
[pct(1), pct(2), _reserveToken, 20e4, wad(3)]
[pct(1), pct(2), _reserveToken, 20e4, wad(3n * 10n ** 18n)],
{ from : daiHolder }
);

});
Expand Down

0 comments on commit 2018b2c

Please sign in to comment.