From 9b97f8e7fe3f15e6bb805017e894ed771391ca6a Mon Sep 17 00:00:00 2001 From: belbix <7453635@gmail.com> Date: Sat, 4 Nov 2023 22:39:49 +0300 Subject: [PATCH] forwarder trigger voter distribution --- contracts/infrastructure/ForwarderV3.sol | 3 ++- contracts/interfaces/IVoter.sol | 2 ++ contracts/test/MockVoter.sol | 4 ++++ contracts/ve/TetuVoter.sol | 2 +- scripts/addresses/base.ts | 2 +- scripts/addresses/polygon.ts | 2 +- test/ve/VeTetuTest.ts | 5 ++++- 7 files changed, 15 insertions(+), 5 deletions(-) diff --git a/contracts/infrastructure/ForwarderV3.sol b/contracts/infrastructure/ForwarderV3.sol index ff09146..c22a096 100644 --- a/contracts/infrastructure/ForwarderV3.sol +++ b/contracts/infrastructure/ForwarderV3.sol @@ -24,7 +24,7 @@ contract ForwarderV3 is ReentrancyGuard, ControllableV3, IForwarder { // CONSTANTS // ************************************************************* /// @dev Version of this contract. Adjust manually on each code modification. - string public constant FORWARDER_VERSION = "3.0.0"; + string public constant FORWARDER_VERSION = "3.0.1"; /// @dev Denominator for different ratios. It is default for the whole platform. uint public constant RATIO_DENOMINATOR = 100_000; /// @dev If slippage not defined for concrete token will be used 5% tolerance. @@ -288,6 +288,7 @@ contract ForwarderV3 is ReentrancyGuard, ControllableV3, IForwarder { address voter = controller_.voter(); IERC20(_tetu).safeApprove(voter, toGauges); IVoter(voter).notifyRewardAmount(toGauges); + IVoter(voter).distributeAll(); } if (toBribes != 0) { diff --git a/contracts/interfaces/IVoter.sol b/contracts/interfaces/IVoter.sol index bdb6571..d1d7335 100644 --- a/contracts/interfaces/IVoter.sol +++ b/contracts/interfaces/IVoter.sol @@ -14,6 +14,8 @@ interface IVoter is IVeVotable { function distribute(address stakingToken) external; + function distributeAll() external; + function notifyRewardAmount(uint amount) external; function votedVaultsLength(uint veId) external view returns (uint); diff --git a/contracts/test/MockVoter.sol b/contracts/test/MockVoter.sol index 1215f5c..64ee00b 100644 --- a/contracts/test/MockVoter.sol +++ b/contracts/test/MockVoter.sol @@ -35,6 +35,10 @@ contract MockVoter is IVoter { // noop } + function distributeAll() external override { + // noop + } + function voting(uint id) external { mockVotes[id]++; } diff --git a/contracts/ve/TetuVoter.sol b/contracts/ve/TetuVoter.sol index 2cdcadc..476fdb1 100644 --- a/contracts/ve/TetuVoter.sol +++ b/contracts/ve/TetuVoter.sol @@ -368,7 +368,7 @@ contract TetuVoter is ReentrancyGuard, ControllableV3, IVoter { } /// @dev Distribute rewards to all valid vaults. - function distributeAll() external { + function distributeAll() external override { uint length = validVaultsLength(); IController c = IController(controller()); for (uint x; x < length; x++) { diff --git a/scripts/addresses/base.ts b/scripts/addresses/base.ts index 24ec9bb..51d62e1 100644 --- a/scripts/addresses/base.ts +++ b/scripts/addresses/base.ts @@ -11,7 +11,7 @@ export class BaseAddresses { "0x5E42c17CAEab64527D9d80d506a3FE01179afa02", // tetu "0x255707B70BF90aa112006E1b07B9AeA6De021424", // controller "0xb8bA82F19A9Be6CbF6DAF9BF4FBCC5bDfCF8bEe6", // ve - "0x875976AeF383Fe4135B93C3989671056c4dEcDFF", // veDist + "0xA2c5911b6EcB4Da440C93F8b7dAa90c68F53E26a", // veDist old 0x875976AeF383Fe4135B93C3989671056c4dEcDFF "0xD8a4054d63fCb0030BC73E2323344Ae59A19E92b", // gauge "0x0B62ad43837A69Ad60289EEea7C6e907e759F6E8", // bribe "0xFC9b894D0b4a34AB41278Df5F2aBEEb5de95c9e4", // tetuVoter diff --git a/scripts/addresses/polygon.ts b/scripts/addresses/polygon.ts index c8befbb..98740c6 100644 --- a/scripts/addresses/polygon.ts +++ b/scripts/addresses/polygon.ts @@ -37,7 +37,7 @@ export class PolygonAddresses { public static PERF_FEE_TREASURY = "0x9Cc199D4353b5FB3e6C8EEBC99f5139e0d8eA06b".toLowerCase(); public static TETU_BRIDGED_PROCESSING = "0x1950a09fc28Dd3C36CaC89485357844Af0739C07".toLowerCase(); public static REWARDS_REDIRECTOR = "0xA9947d0815d6EA3077805E2112FB19572DD4dc9E".toLowerCase(); - public static BRIBE_DISTRIBUTION = "0x3220Fa5BD9Be44C2A7BbB137dA6E5Cd3b6bf7124".toLowerCase(); + public static BRIBE_DISTRIBUTION = "0x5947868a6842e69Cacad068AbF6481e1F522063E".toLowerCase(); // old 0x3220Fa5BD9Be44C2A7BbB137dA6E5Cd3b6bf7124 // PROTOCOL ADRS public static DEPOSIT_HELPER_V2 = "0xab2422A4d8Ac985AE98F5Da3713988b420f24165".toLowerCase(); diff --git a/test/ve/VeTetuTest.ts b/test/ve/VeTetuTest.ts index 94f68b8..9f44a40 100644 --- a/test/ve/VeTetuTest.ts +++ b/test/ve/VeTetuTest.ts @@ -870,6 +870,9 @@ describe("veTETU tests", function () { it("always max lock test", async function () { await expect(ve.setAlwaysMaxLock(1, false)).revertedWith('WRONG_INPUT'); + // align lock time + // await TimeUtils.advanceBlocksOnTs(60 * 60 * 24) + // await ve.increaseUnlockTime(1, MAX_LOCK); const endOld = (await ve.lockedEnd(1)).toNumber() const balOld = +formatUnits(await ve.balanceOfNFT(1)) @@ -960,7 +963,7 @@ describe("veTETU tests", function () { async function maxLockTime(ve: VeTetu) { const now = (await ve.blockTimestamp()).toNumber() - return Math.round((now + MAX_LOCK) / WEEK) * WEEK; + return Math.floor((now) / WEEK) * WEEK + MAX_LOCK; }