Skip to content

Commit

Permalink
DGOV mint allocated update (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: yuliu-debond <79855548+yuliu-debond@users.noreply.github.com>
  • Loading branch information
drikssy and yuliu-debond committed Oct 12, 2022
1 parent 9eb3a57 commit 282cde5
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 69 deletions.
42 changes: 14 additions & 28 deletions contracts/DBIT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,32 @@ contract DBIT is DebondToken {
address bankAddress,
address airdropAddress
)
DebondToken(
"DBIT",
"DBIT",
airdropAddress,
bankAddress,
executableAddress,
500_000 ether,
1000 // rate on 10000 (10%)
)
DebondToken(
"DBIT",
"DBIT",
airdropAddress,
bankAddress,
executableAddress,
500_000 ether,
1000 // rate on 10000 (10%)
)
{}

function mintCollateralisedSupply(address _to, uint256 _amount)
external
onlyBank
external
onlyBank
{
_mintCollateralisedSupply(_to, _amount);
}

function mintAllocatedSupply(address _to, uint256 _amount)
external
onlyExecutable
{
require(
_amount <
(totalSupply() * _maxAllocationPercentage) /
10000 -
_allocatedSupply,
"limit exceeds"
);
_mintAllocatedSupply(_to, _amount);
}

function totalSupply() public view override(DebondToken) returns (uint256) {
return super.totalSupply();
}

function transfer(address _to, uint256 _amount)
public
override(DebondToken)
returns (bool)
public
override(DebondToken)
returns (bool)
{
return super.transfer(_to, _amount);
}
Expand Down
67 changes: 28 additions & 39 deletions contracts/DGOV.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ contract DGOV is IDGOV, DebondToken {
address bankAddress,
address airdropAddress
)
DebondToken(
"DGOV",
"DGOV",
airdropAddress,
bankAddress,
executableAddress,
250_000 ether,
1000 // rate on 10000 (10%)
)
DebondToken(
"DGOV",
"DGOV",
airdropAddress,
bankAddress,
executableAddress,
250_000 ether,
1000 // rate on 10000 (10%)
)
{
_maximumSupply = 1_000_000 ether;
}
Expand All @@ -48,64 +48,53 @@ contract DGOV is IDGOV, DebondToken {

function getMaxCollateralisedSupply() external view returns (uint256) {
return (_maximumSupply -
(_maxAirdropSupply +
((_maximumSupply * _maxAllocationPercentage) / 10000)));
(_maxAirdropSupply +
((_maximumSupply * _maxAllocationPercentage) / 10000)));
}

function setMaxSupply(uint256 max_supply)
external
onlyExecutable
returns (bool)
external
onlyExecutable
returns (bool)
{
require(
max_supply >
_maxAirdropSupply + _allocatedSupply + _collateralisedSupply,
_maxAirdropSupply + _allocatedSupply + _collateralisedSupply,
"Max Supply cannot be less than max estimated supply"
);
_maximumSupply = max_supply;
return true;
}

function mintAllocatedSupply(address _to, uint256 _amount)
external
onlyExecutable
{
require(
_amount <= getMaxAllocatedSupply() - _allocatedSupply,
"limit exceeds"
);
_mintAllocatedSupply(_to, _amount);
}

function mintCollateralisedSupply(address _to, uint256 _amount)
external
onlyBank
external
onlyBank
{
require(
_amount <=
_maximumSupply -
(_maxAirdropSupply +
getMaxAllocatedSupply() +
_collateralisedSupply),
_maximumSupply -
(_maxAirdropSupply +
getMaxAllocatedSupply() +
_collateralisedSupply),
"exceeds limit"
);

_mintCollateralisedSupply(_to, _amount);
}

function totalSupply()
public
view
override(DebondToken, IDebondToken)
returns (uint256)
public
view
override(DebondToken, IDebondToken)
returns (uint256)
{
return super.totalSupply();
}

function transfer(address _to, uint256 _amount)
public
override(DebondToken, IDebondToken)
returns (bool)
public
override(DebondToken, IDebondToken)
returns (bool)
{
return super.transfer(_to, _amount);
}
Expand Down
14 changes: 14 additions & 0 deletions contracts/DebondToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ abstract contract DebondToken is IDebondToken, ERC20, ExecutableOwnable {
// as the airdroped supply is minted it will be seperate from the each investors lockedBalance.
}

function mintAllocatedSupply(address _to, uint256 _amount)
external
onlyExecutable
{
require(
_amount <
(totalSupply() * _maxAllocationPercentage) /
10000 -
_allocatedSupply,
"limit exceeds"
);
_mintAllocatedSupply(_to, _amount);
}

function getCollateralisedBalance(address _of) external view returns (uint256)
{
return _collateralisedBalance[_of];
Expand Down
4 changes: 2 additions & 2 deletions test/DGOV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ contract("DGOV Token", async (accounts: any) => {
});

it('Mint Allocated Supply Check', async () => {
await dgovObj.mintAllocatedSupply(user2, 100000, { from: governanceAddress });
await dgovObj.mintAllocatedSupply(user2, 60000, { from: governanceAddress });
expect(web3.utils.toNumber(await dgovObj.balanceOf(user2))).to.equal(web3.utils.toNumber(await dgovObj.getTotalAllocatedSupply()));
});

Expand All @@ -60,4 +60,4 @@ contract("DGOV Token", async (accounts: any) => {
expect(web3.utils.toNumber(await dgovObj.getMaxAllocatedSupply())).to.equal(200000);
expect(web3.utils.toNumber(await dgovObj.getMaxCollateralisedSupply())).to.equal(1550000);
});
})
})

0 comments on commit 282cde5

Please sign in to comment.