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

🥶 Rename trustToken to asset in distributor #1264

Merged
merged 3 commits into from
May 24, 2024
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
2 changes: 1 addition & 1 deletion contracts/truefi/TrueFarm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ contract TrueFarm is ITrueFarm, Initializable {
) public initializer {
stakingToken = _stakingToken;
trueDistributor = _trueDistributor;
trustToken = _trueDistributor.trustToken();
trustToken = _trueDistributor.asset();
name = _name;
require(trueDistributor.farm() == address(this), "TrueFarm: Distributor farm is not set");
}
Expand Down
12 changes: 6 additions & 6 deletions contracts/truefi/distributors/LinearTrueDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract LinearTrueDistributor is ITrueDistributor, Ownable {
// REMOVAL OR REORDER OF VARIABLES WILL RESULT
// ========= IN STORAGE CORRUPTION ===========

IERC20 public override trustToken;
IERC20 public override asset;
uint256 public distributionStart;
uint256 public duration;
uint256 public totalAmount;
Expand Down Expand Up @@ -67,20 +67,20 @@ contract LinearTrueDistributor is ITrueDistributor, Ownable {
* @param _distributionStart Start time for distribution
* @param _duration Length of distribution
* @param _amount Amount to distribute
* @param _trustToken TRU address
* @param _asset TRU address
*/
function initialize(
uint256 _distributionStart,
uint256 _duration,
uint256 _amount,
IERC20 _trustToken
IERC20 _asset
) public initializer {
Ownable.initialize();
distributionStart = _distributionStart;
lastDistribution = _distributionStart;
duration = _duration;
totalAmount = _amount;
trustToken = _trustToken;
asset = _asset;
}

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ contract LinearTrueDistributor is ITrueDistributor, Ownable {
// transfer tokens & update state
lastDistribution = block.timestamp;
distributed = distributed.add(amount);
trustToken.safeTransfer(farm, amount);
asset.safeTransfer(farm, amount);

emit Distributed(amount);
}
Expand Down Expand Up @@ -141,7 +141,7 @@ contract LinearTrueDistributor is ITrueDistributor, Ownable {
distribute();
distributed = 0;
totalAmount = 0;
trustToken.safeTransfer(msg.sender, trustToken.balanceOf(address(this)));
asset.safeTransfer(msg.sender, asset.balanceOf(address(this)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/truefi/interface/ITrueDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.6.10;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface ITrueDistributor {
function trustToken() external view returns (IERC20);
function asset() external view returns (IERC20);

function farm() external view returns (address);

Expand Down
2 changes: 1 addition & 1 deletion contracts/truefi2/TrueMultiFarm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ contract TrueMultiFarm is ITrueMultiFarm, UpgradeableClaimable {
function initialize(ITrueDistributor _trueDistributor, IStkTruToken _stkTru) public initializer {
UpgradeableClaimable.initialize(msg.sender);
trueDistributor = _trueDistributor;
tru = _trueDistributor.trustToken();
tru = _trueDistributor.asset();
stkTru = _stkTru;
require(trueDistributor.farm() == address(this), "TrueMultiFarm: Distributor farm is not set");
}
Expand Down
5 changes: 3 additions & 2 deletions test/integration/truefi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ describe('TrueFi', () => {
})

it('LinearDistributor', async () => {
await upgradeSuite(TEST_STATE_BLOCK_NUMBER, LinearTrueDistributor__factory, '0xfB8d918428373f766B352564b70d1DcC1e3b6383', [
'trustToken',
const contract = await upgradeSuite(TEST_STATE_BLOCK_NUMBER, LinearTrueDistributor__factory, '0xfB8d918428373f766B352564b70d1DcC1e3b6383', [
// 'trustToken', renamed to `asset`
'distributionStart',
'duration',
'totalAmount',
'lastDistribution',
'distributed',
'farm',
])
expect(await contract.asset()).to.eq('0x4C19596f5aAfF459fA38B0f7eD92F11AE6543784')
})

it('RatingAgencyV2Distributor', async () => {
Expand Down
Loading