Sponsorship Reward
As a sponsor who gives reward
// Bribe.sol
function addReward(address token, uint week, uint amount) external {
require(week >= block.timestamp / 1 weeks, "cannot add for previous weeks");
token.safeTransferFrom(msg.sender, address(this), amount);
tokenRewardOfWeek[token][week] += amount;
emit AddReward(msg.sender, token, week, amount);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;
interface IERC20 {
function approve(address spender, uint value) external returns (bool);
}
interface IBribe {
function addReward(address token, uint week, uint amount) external;
}
contract MyBribeTest {
// The DYSON-USDC bribe contract on Polygon zkEVM.
address public constant bribe = 0xFCE34AA5fc1Ca594b12248a927e0153680Ef2A90;
address matic = 0xa2036f0538221a77A3937F1379699f44945018d0;
uint amount = 100e18; // 100 $MATIC
// 2024 3/21 0:00 timestamp = 1710979200
// 1710979200/(86400*7) = 2829
uint week = 2829
function addReward() external {
IERC20(matic).approve(bribe, amount);
IBribe(bribe).addReward(matic, week, amount);
}
}As a user who receive reward
Setup your contract
Last updated