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

Token spreader fixes #913

Merged
merged 9 commits into from
Jun 28, 2022
Merged
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
6 changes: 4 additions & 2 deletions examples/beginner-examples/token-spreader/.env.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
GOERLI_URL=

PRIVATE_KEY=
MNEMONIC=

ETHERSCAN_API_KEY=
ETHERSCAN_API_KEY=

TOKENSPREADER_ADDRESS=
675 changes: 633 additions & 42 deletions examples/beginner-examples/token-spreader/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const gorliHostAddress = "0x22ff293e14F1EC3A09B137e9e06084AFd63adDF9";
const gorliFDAIXAddress = "0xF2d68898557cCb2Cf4C10c3Ef2B034b2a69DAD00";
const goerliHostAddress = "0x22ff293e14F1EC3A09B137e9e06084AFd63adDF9";
const goerliFDAIXAddress = "0xF2d68898557cCb2Cf4C10c3Ef2B034b2a69DAD00";

module.exports = [
gorliHostAddress,
gorliFDAIXAddress
goerliHostAddress,
goerliFDAIXAddress
];

// npx hardhat verify --network goerli --constructor-args arguments-tokenspreader.js [contractaddress]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
IInstantDistributionAgreementV1
} from "@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/IInstantDistributionAgreementV1.sol";

import {IDAv1Library} from "@superfluid-finance/ethereum-contracts/contracts/apps/IDAv1Library.sol";
import { IDAv1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/IDAv1Library.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

Expand All @@ -30,7 +30,7 @@ contract TokenSpreader {
) {

// Ensure _spreaderToken is indeed a super token
require(address(_host) == _spreaderToken.getHost(),"!superToken");
require(address(_host) == _spreaderToken.getHost(),"!superToken");


spreaderToken = _spreaderToken;
Expand Down Expand Up @@ -60,7 +60,7 @@ contract TokenSpreader {

(uint256 actualDistributionAmount,) = idaV1.ida.calculateDistribution(
spreaderToken,
address(this),
address(this),
INDEX_ID,
spreaderTokenBalance
);
Expand All @@ -73,12 +73,12 @@ contract TokenSpreader {
/// @param subscriber subscriber address whose units are to be incremented
function gainShare(address subscriber) public {

// Get current units msg.sender holds
// Get current units subscriber holds
(,,uint256 currentUnitsHeld,) = idaV1.getSubscription(
spreaderToken,
address(this),
INDEX_ID,
subscriber
spreaderToken,
address(this),
INDEX_ID,
subscriber
);

// Update to current amount + 1
Expand All @@ -95,12 +95,12 @@ contract TokenSpreader {
/// @param subscriber subscriber address whose units are to be decremented
function loseShare(address subscriber) public {

// Get current units msg.sender holds
// Get current units subscriber holds
(,,uint256 currentUnitsHeld,) = idaV1.getSubscription(
spreaderToken,
address(this),
INDEX_ID,
subscriber
spreaderToken,
address(this),
INDEX_ID,
subscriber
);

// Update to current amount - 1 (reverts if currentUnitsHeld - 1 < 0, so basically if currentUnitsHeld = 0)
Expand All @@ -126,4 +126,4 @@ contract TokenSpreader {

}

}
}
7 changes: 5 additions & 2 deletions examples/beginner-examples/token-spreader/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ module.exports = {
networks: {
goerli: {
url: process.env.GOERLI_URL || "",
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
accounts: {
mnemonic: process.env.MNEMONIC || "",
initialIndex: 0,
count: 10,
}
},
},
gasReporter: {
Expand Down
Loading