-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
202 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[ | ||
{ | ||
"inputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "asset", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "feeValue", | ||
"type": "uint256" | ||
}, | ||
{ | ||
"internalType": "uint8", | ||
"name": "feeDecimals", | ||
"type": "uint8" | ||
}, | ||
{ | ||
"internalType": "address", | ||
"name": "owner", | ||
"type": "address" | ||
} | ||
], | ||
"name": "buildFeePool", | ||
"outputs": [ | ||
{ | ||
"internalType": "contract IFeePool", | ||
"name": "", | ||
"type": "address" | ||
} | ||
], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
pragma solidity 0.6.12; | ||
|
||
import "./FeePool.sol"; | ||
import "../interfaces/IFeePool.sol"; | ||
import "../interfaces/IFeePoolBuilder.sol"; | ||
|
||
/** | ||
* @title FeePoolBuilder | ||
* @author Pods Finance | ||
* @notice Builds FeePool | ||
*/ | ||
contract FeePoolBuilder is IFeePoolBuilder { | ||
/** | ||
* @notice creates a new FeePool Contract | ||
* @param asset The token in which the fees are collected | ||
* @param feeValue The base value of fees | ||
* @param feeDecimals Amount of decimals of feeValue | ||
* @param owner Owner of the FeePool | ||
* @return feePool | ||
*/ | ||
function buildFeePool( | ||
address asset, | ||
uint256 feeValue, | ||
uint8 feeDecimals, | ||
address owner | ||
) external override returns (IFeePool) { | ||
FeePool feePool = new FeePool(asset, feeValue, feeDecimals); | ||
feePool.transferOwnership(owner); | ||
return feePool; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: agpl-3.0 | ||
|
||
pragma solidity 0.6.12; | ||
|
||
import "./IFeePool.sol"; | ||
|
||
interface IFeePoolBuilder { | ||
function buildFeePool( | ||
address asset, | ||
uint256 feeValue, | ||
uint8 feeDecimals, | ||
address owner | ||
) external returns (IFeePool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const { expect } = require('chai') | ||
const { ethers } = require('hardhat') | ||
const { toBigNumber } = require('../../utils/utils') | ||
|
||
describe('FeePoolBuilder', () => { | ||
let FeePoolBuilder, MintableERC20 | ||
let feePoolBuilder, usdc | ||
let deployer, owner | ||
const initialFee = toBigNumber(3) | ||
const initialDecimals = toBigNumber(3) | ||
|
||
before(async () => { | ||
;[deployer, owner] = await ethers.getSigners() | ||
;[FeePoolBuilder, MintableERC20] = await Promise.all([ | ||
ethers.getContractFactory('FeePoolBuilder'), | ||
ethers.getContractFactory('MintableERC20') | ||
]) | ||
|
||
usdc = await MintableERC20.deploy('USDC Token', 'USDC', 6) | ||
}) | ||
|
||
beforeEach(async () => { | ||
feePoolBuilder = await FeePoolBuilder.deploy() | ||
}) | ||
|
||
it('should create a new FeePool correctly and not revert', async () => { | ||
// Calculates address | ||
const deterministicFeePoolAddress = await feePoolBuilder.callStatic.buildFeePool( | ||
usdc.address, | ||
initialFee, | ||
initialDecimals, | ||
owner.address | ||
) | ||
|
||
// Executes the transaction | ||
const tx = feePoolBuilder.buildFeePool(usdc.address, initialFee, initialDecimals, owner.address) | ||
await expect(tx).to.not.be.reverted | ||
|
||
const feePool = await ethers.getContractAt('FeePool', deterministicFeePoolAddress) | ||
expect(await feePool.owner()).to.be.equal(owner.address) | ||
expect(await feePool.feeToken()).to.be.equal(usdc.address) | ||
expect(await feePool.feeValue()).to.be.equal(initialFee) | ||
expect(await feePool.feeDecimals()).to.be.equal(initialDecimals) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters