Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct distributions calculations #38

Open
wants to merge 6 commits into
base: release-1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 183 additions & 183 deletions .openzeppelin/rinkeby.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions abi/CurveFiStablecoinNoDexag.json
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,21 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "_dexagProxy",
"type": "address"
}
],
"name": "setDexagProxy",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
Expand Down
51 changes: 33 additions & 18 deletions abi/CurveFiStablecoinStrategy.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,13 @@
"inputs": [
{
"internalType": "address",
"name": "sender",
"name": "_pool",
"type": "address"
},
{
"internalType": "string",
"name": "_strategyId",
"type": "string"
}
],
"name": "initialize",
Expand All @@ -411,13 +416,8 @@
"inputs": [
{
"internalType": "address",
"name": "_pool",
"name": "sender",
"type": "address"
},
{
"internalType": "string",
"name": "_strategyId",
"type": "string"
}
],
"name": "initialize",
Expand Down Expand Up @@ -471,6 +471,21 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"internalType": "address",
"name": "_dexagProxy",
"type": "address"
}
],
"name": "setDexagProxy",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
Expand Down Expand Up @@ -520,14 +535,9 @@
"type": "address"
},
{
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
"internalType": "uint256[]",
"name": "amounts",
"type": "uint256[]"
}
],
"name": "withdraw",
Expand All @@ -545,9 +555,14 @@
"type": "address"
},
{
"internalType": "uint256[]",
"name": "amounts",
"type": "uint256[]"
"internalType": "address",
"name": "token",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "withdraw",
Expand Down
30 changes: 15 additions & 15 deletions abi/PoolToken.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,21 @@
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "distributionTotalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
Expand Down Expand Up @@ -1018,20 +1033,5 @@
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "distributionTotalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
2 changes: 1 addition & 1 deletion contracts/modules/token/DistributionToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ contract DistributionToken is ERC20, ERC20Mintable {
uint256 fromDistribution = nextDistributions[account];
if (fromDistribution >= toDistribution) return 0;
uint256 distributionAmount = calculateClaimAmount(account, toDistribution);
if (distributionAmount == 0) return 0;
nextDistributions[account] = toDistribution;
if (distributionAmount == 0) return 0;
super._transfer(address(this), account, distributionAmount);
emit DistributionsClaimed(account, distributionAmount, fromDistribution, toDistribution);
return distributionAmount;
Expand Down
5 changes: 0 additions & 5 deletions contracts/modules/token/PoolToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,4 @@ contract PoolToken is Module, ERC20, ERC20Detailed, ERC20Mintable, ERC20Burnable
function distributionBalanceOf(address account) public view returns(uint256) {
return (account == address(this))?0:super.distributionBalanceOf(account);
}

function distributionTotalSupply() public view returns(uint256) {
return super.distributionTotalSupply().sub(balanceOf(address(this)));
}

}
6 changes: 6 additions & 0 deletions contracts/modules/token/VaultPoolToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract VaultPoolToken is PoolToken, IOperableToken {
}

function increaseOnHoldValue(address _user, uint256 _amount) public onlyMinter {
_updateUserBalance(_user);
onHoldAmount[_user] = onHoldAmount[_user].add(_amount);
totalOnHold = totalOnHold.add(_amount);
}
Expand All @@ -36,6 +37,9 @@ contract VaultPoolToken is PoolToken, IOperableToken {

userBalanceChanged(_user);
}
else {
revert("Incorrect on hold amount");
}
}

function onHoldBalanceOf(address _user) public view returns (uint256) {
Expand All @@ -50,6 +54,8 @@ contract VaultPoolToken is PoolToken, IOperableToken {
}

function distributionBalanceOf(address account) public view returns(uint256) {
if (account == address(this)) return 0;

if (balanceOf(account).add(toBeMinted) <= onHoldAmount[account])
return 0;
return balanceOf(account).add(toBeMinted).sub(onHoldAmount[account]);
Expand Down
8 changes: 4 additions & 4 deletions deployment_rinkeby.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
* RewardVestingModule `0x214eAB7667848ec753A50Bf98416a8E12D3516f2`
* RewardDistributionModule `0x586C698698f316D9f10332A4300859DD8A82B130`

* VaultSavingsModule `0x172cd550d0E08AcB67f6C4712bC9F78a99FCa83D`
* VaultProtocol Curve `0xF0b0d7078bE36a05864Cc9af8EeC9C8232177ec2`
* CurveFiStablecoinStrategy `0xa79Fc0367e7aA6CeE680284d7e78bA872205b073`
* PoolToken for CurveFiStablecoinStrategy `0xb33b69481544573F2f7032a9613b15f998525f5c`
* VaultSavingsModule `0xA0ce47C8072C0eAA5d0E343b7aE533e0E377c0F7`
* VaultProtocol Curve `0x181A9a2bC318F1748437089c1Fc7543e449B99B4`
* CurveFiStablecoinStrategy `0x6cd11F017015475Ff08f3e547a45f99AE15081c9`
* PoolToken for CurveFiStablecoinStrategy `0x6D205cf0d2A71F687AE727c17768703a9c7A7ADD`

#### Protocols
##### Curve.Fi Y [(y)DAI, (y)USDC, (y)USDT, (y)TUSD] - YFI
Expand Down
15 changes: 9 additions & 6 deletions scripts/deploy_rinkeby_vault.bat
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ rem ==== Akropolis ====
SET MODULE_POOL=0x6CEEd89849f5890392D7c2Ecb429888e2123E99b
SET MODULE_ACCESS=0xbFC891b6c83b36aFC9493957065D304661c4189A

SET MODULE_VAULT_SAVINGS=0x172cd550d0E08AcB67f6C4712bC9F78a99FCa83D
SET VAULT_PROTOCOL_CURVE=0xF0b0d7078bE36a05864Cc9af8EeC9C8232177ec2
SET STRATEGY_CURVE=0xa79Fc0367e7aA6CeE680284d7e78bA872205b073
SET POOL_TOKEN_VAULT_CURVE=0xb33b69481544573F2f7032a9613b15f998525f5c
SET MODULE_VAULT_SAVINGS=0xA0ce47C8072C0eAA5d0E343b7aE533e0E377c0F7
SET VAULT_PROTOCOL_CURVE=0x181A9a2bC318F1748437089c1Fc7543e449B99B4
SET STRATEGY_CURVE=0x6cd11F017015475Ff08f3e547a45f99AE15081c9
SET POOL_TOKEN_VAULT_CURVE=0x6D205cf0d2A71F687AE727c17768703a9c7A7ADD

rem ==== Roles ====
SET VAULT_OPERATOR=0x5D507818B52A891fe296463adC01EeD9C51e218b
SET VAULT_OPERATOR_01=0x5D507818B52A891fe296463adC01EeD9C51e218b
SET VAULT_OPERATOR_02=0x98f0D2dDB5262202E95666e646775FcC773B8C02


rem === GOTO REQUESTED OP===
Expand Down Expand Up @@ -66,7 +67,9 @@ call npx oz send-tx --to %MODULE_VAULT_SAVINGS% --network rinkeby --method setVa
goto :done

:setupOperator
call npx oz send-tx --to %MODULE_VAULT_SAVINGS% --network rinkeby --method addVaultOperator --args %VAULT_OPERATOR%
call npx oz send-tx --to %MODULE_VAULT_SAVINGS% --network rinkeby --method addVaultOperator --args %VAULT_OPERATOR_01%
call npx oz send-tx --to %MODULE_VAULT_SAVINGS% --network rinkeby --method addVaultOperator --args %VAULT_OPERATOR_02%
call npx oz send-tx --to %POOL_TOKEN_VAULT_CURVE% --network rinkeby --method addMinter --args %VAULT_OPERATOR_02%
rem call npx oz send-tx --to %STRATEGY_CURVE% --network rinkeby --method addDefiOperator --args %VAULT_OPERATOR%
goto :done

Expand Down
Loading