From 54155357f379540ab23bc9388144c3d6f2f0a4e1 Mon Sep 17 00:00:00 2001 From: MiksuJak Date: Wed, 22 May 2024 13:49:50 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A5=B6=20Rename=20trustToken=20to=20a?= =?UTF-8?q?sset=20in=20distributor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/truefi/TrueFarm.sol | 2 +- .../truefi/distributors/LinearTrueDistributor.sol | 12 ++++++------ contracts/truefi/interface/ITrueDistributor.sol | 2 +- contracts/truefi2/TrueMultiFarm.sol | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/truefi/TrueFarm.sol b/contracts/truefi/TrueFarm.sol index e1b694d44..3c5dd08ef 100644 --- a/contracts/truefi/TrueFarm.sol +++ b/contracts/truefi/TrueFarm.sol @@ -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"); } diff --git a/contracts/truefi/distributors/LinearTrueDistributor.sol b/contracts/truefi/distributors/LinearTrueDistributor.sol index 978bbfbd7..34cb540a7 100644 --- a/contracts/truefi/distributors/LinearTrueDistributor.sol +++ b/contracts/truefi/distributors/LinearTrueDistributor.sol @@ -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; @@ -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; } /** @@ -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); } @@ -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))); } /** diff --git a/contracts/truefi/interface/ITrueDistributor.sol b/contracts/truefi/interface/ITrueDistributor.sol index ed46c4777..d15cfb1d2 100644 --- a/contracts/truefi/interface/ITrueDistributor.sol +++ b/contracts/truefi/interface/ITrueDistributor.sol @@ -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); diff --git a/contracts/truefi2/TrueMultiFarm.sol b/contracts/truefi2/TrueMultiFarm.sol index 49c8eab91..1cf33f35a 100644 --- a/contracts/truefi2/TrueMultiFarm.sol +++ b/contracts/truefi2/TrueMultiFarm.sol @@ -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"); } From ab8f5d1682d95028ecfc2d1e956100dc4ea9d34f Mon Sep 17 00:00:00 2001 From: MiksuJak Date: Wed, 22 May 2024 14:01:31 +0200 Subject: [PATCH 2/3] Update integration test --- test/integration/truefi.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/truefi.test.ts b/test/integration/truefi.test.ts index fab0aa4ff..48862800e 100644 --- a/test/integration/truefi.test.ts +++ b/test/integration/truefi.test.ts @@ -121,7 +121,7 @@ describe('TrueFi', () => { it('LinearDistributor', async () => { await upgradeSuite(TEST_STATE_BLOCK_NUMBER, LinearTrueDistributor__factory, '0xfB8d918428373f766B352564b70d1DcC1e3b6383', [ - 'trustToken', + 'asset', 'distributionStart', 'duration', 'totalAmount', From ede92c0046f18e4b9ea5065fb553bb3fc72292cc Mon Sep 17 00:00:00 2001 From: MiksuJak Date: Thu, 23 May 2024 14:20:48 +0200 Subject: [PATCH 3/3] Update integration test --- test/integration/truefi.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/truefi.test.ts b/test/integration/truefi.test.ts index 48862800e..fabffea6c 100644 --- a/test/integration/truefi.test.ts +++ b/test/integration/truefi.test.ts @@ -120,8 +120,8 @@ describe('TrueFi', () => { }) it('LinearDistributor', async () => { - await upgradeSuite(TEST_STATE_BLOCK_NUMBER, LinearTrueDistributor__factory, '0xfB8d918428373f766B352564b70d1DcC1e3b6383', [ - 'asset', + const contract = await upgradeSuite(TEST_STATE_BLOCK_NUMBER, LinearTrueDistributor__factory, '0xfB8d918428373f766B352564b70d1DcC1e3b6383', [ + // 'trustToken', renamed to `asset` 'distributionStart', 'duration', 'totalAmount', @@ -129,6 +129,7 @@ describe('TrueFi', () => { 'distributed', 'farm', ]) + expect(await contract.asset()).to.eq('0x4C19596f5aAfF459fA38B0f7eD92F11AE6543784') }) it('RatingAgencyV2Distributor', async () => {