Skip to content

Commit

Permalink
forwarder trigger voter distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
belbix committed Nov 4, 2023
1 parent 6371716 commit 9b97f8e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion contracts/infrastructure/ForwarderV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/IVoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions contracts/test/MockVoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ contract MockVoter is IVoter {
// noop
}

function distributeAll() external override {
// noop
}

function voting(uint id) external {
mockVotes[id]++;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/ve/TetuVoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/addresses/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/addresses/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion test/ve/VeTetuTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
}


Expand Down

0 comments on commit 9b97f8e

Please sign in to comment.