Skip to content

Commit

Permalink
Removes 1K reward (#328)
Browse files Browse the repository at this point in the history
* Removes 1K reward

* Update KintoWalletFactoryTest to check zero balance and claimed rewards after account creation

* Remove newUserClaim function and related tests, add NEW_USER_REWARD_END_TIMESTAMP for reward period control.

* Update fund-faucets limits and amounts, adjust reward end timestamp, add placeholder function in RewardsDistributor, and temporary call in KintoWalletFactory.

* Upgrade RewardsDistributor to V8, update contract addresses, and modify migration script for new implementation deployment.

---------

Co-authored-by: Igor Yalovoy <[email protected]>
  • Loading branch information
rrecuero and ylv-io authored Dec 14, 2024
1 parent edaa9a0 commit a655118
Show file tree
Hide file tree
Showing 11 changed files with 308 additions and 80 deletions.
149 changes: 149 additions & 0 deletions broadcast/112-upgrade_distr.s.sol/7887/run-1734134256.json

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions broadcast/112-upgrade_distr.s.sol/7887/run-latest.json

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions broadcast/fund-faucets.s.sol/7887/run-1734040112.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"transactions": [
{
"hash": "0xbe47b43594af3097b4d55fcede2891ad1b82978596e32e97606de953e25064d1",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x8a4720488ca32f1223ccfe5a087e250fe3bc5d75",
"function": "sendMoneyToAccount(address)",
"arguments": [
"0x0719D47A213149E2Ef8d3f5afDaDA8a8E22dfc03"
],
"transaction": {
"from": "0x660ad4b5a74130a4796b4d54bc6750ae93c86e6c",
"to": "0x8a4720488ca32f1223ccfe5a087e250fe3bc5d75",
"value": "0x3782dace9d90000",
"input": "0x08aae1630000000000000000000000000719d47a213149e2ef8d3f5afdada8a8e22dfc03",
"nonce": "0x4b8ab",
"chainId": "0x1ecf"
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"status": "0x1",
"cumulativeGasUsed": "0x1536c",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"transactionHash": "0xbe47b43594af3097b4d55fcede2891ad1b82978596e32e97606de953e25064d1",
"transactionIndex": "0x1",
"blockHash": "0x4299dd7fab26d12bd0b7baf7789e0791005079a3a1f1e8b206b6f9586771819f",
"blockNumber": "0x9e35e",
"gasUsed": "0x1536c",
"effectiveGasPrice": "0x5f5e100",
"from": "0x660ad4b5a74130a4796b4d54bc6750ae93c86e6c",
"to": "0x8a4720488ca32f1223ccfe5a087e250fe3bc5d75",
"contractAddress": null,
"gasUsedForL1": "0x4dcd",
"l1BlockNumber": "0x1465f9d"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1734040112,
"chain": 7887,
"commit": "cfac64e"
}
50 changes: 50 additions & 0 deletions broadcast/fund-faucets.s.sol/7887/run-latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"transactions": [
{
"hash": "0xbe47b43594af3097b4d55fcede2891ad1b82978596e32e97606de953e25064d1",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x8a4720488ca32f1223ccfe5a087e250fe3bc5d75",
"function": "sendMoneyToAccount(address)",
"arguments": [
"0x0719D47A213149E2Ef8d3f5afDaDA8a8E22dfc03"
],
"transaction": {
"from": "0x660ad4b5a74130a4796b4d54bc6750ae93c86e6c",
"to": "0x8a4720488ca32f1223ccfe5a087e250fe3bc5d75",
"value": "0x3782dace9d90000",
"input": "0x08aae1630000000000000000000000000719d47a213149e2ef8d3f5afdada8a8e22dfc03",
"nonce": "0x4b8ab",
"chainId": "0x1ecf"
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"status": "0x1",
"cumulativeGasUsed": "0x1536c",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"transactionHash": "0xbe47b43594af3097b4d55fcede2891ad1b82978596e32e97606de953e25064d1",
"transactionIndex": "0x1",
"blockHash": "0x4299dd7fab26d12bd0b7baf7789e0791005079a3a1f1e8b206b6f9586771819f",
"blockNumber": "0x9e35e",
"gasUsed": "0x1536c",
"effectiveGasPrice": "0x5f5e100",
"from": "0x660ad4b5a74130a4796b4d54bc6750ae93c86e6c",
"to": "0x8a4720488ca32f1223ccfe5a087e250fe3bc5d75",
"contractAddress": null,
"gasUsedForL1": "0x4dcd",
"l1BlockNumber": "0x1465f9d"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1734040112,
"chain": 7887,
"commit": "cfac64e"
}
4 changes: 2 additions & 2 deletions script/actions/fund-faucets.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ contract FundFaucetsScript is MigrationHelper {

address[3] memory apps = [KINTO_CORE, DINARI, SOCKET_DL];
string[3] memory appNames = ["KINTO_CORE", "DINARI", "SOCKET_DL"];
uint56[3] memory appLimits = [0.02 ether, 0.02 ether, 0.02 ether];
uint56[3] memory appAmounts = [0.01 ether, 0.01 ether, 0.01 ether];
uint56[3] memory appLimits = [0.05 ether, 0.05 ether, 0.05 ether];
uint64[3] memory appAmounts = [0.2 ether, 0.2 ether, 0.2 ether];

SponsorPaymaster paymaster = SponsorPaymaster(_getChainDeployment("SponsorPaymaster"));
for (uint256 index = 0; index < apps.length; index++) {
Expand Down
4 changes: 2 additions & 2 deletions script/migrations/112-upgrade_distr.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ contract UpgradeDistributorScript is MigrationHelper {
)
);

address impl = _deployImplementationAndUpgrade("RewardsDistributor", "V7", bytecode);
address impl = _deployImplementationAndUpgrade("RewardsDistributor", "V8", bytecode);

RewardsDistributor distr = RewardsDistributor(_getChainDeployment("RewardsDistributor"));

assertEq(address(distr.KINTO()), 0x010700808D59d2bb92257fCafACfe8e5bFF7aB87);
assertEq(distr.startTime(), LIQUIDITY_MINING_START_DATE);
assertEq(distr.walletFactory(), _getChainDeployment("KintoWalletFactory"));

saveContractAddress("RewardsDistributorV7-impl", impl);
saveContractAddress("RewardsDistributorV8-impl", impl);
}
}
22 changes: 7 additions & 15 deletions src/liquidity-mining/RewardsDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ contract RewardsDistributor is Initializable, UUPSUpgradeable, ReentrancyGuardUp
/// @notice New user rewards timestmap
uint256 public constant NEW_USER_REWARD_TIMESTAMP = 1729785402;

/// @notice New user rewards end timestmap
uint256 public constant NEW_USER_REWARD_END_TIMESTAMP = 1734133547;

/* ============ State Variables ============ */

/// @notice The root of the merkle tree for Kinto token distribition.
Expand Down Expand Up @@ -269,21 +272,9 @@ contract RewardsDistributor is Initializable, UUPSUpgradeable, ReentrancyGuardUp
}

/**
* @notice Allows a new user to claim the new user reward.
* @param wallet The address of the wallet to claim the reward for.
* @notice Does nothing. Remove upon the upgrade of KintoWalletFactory
*/
function newUserClaim(address wallet) external nonReentrant {
if (msg.sender != walletFactory) {
revert OnlyWalletFactory(msg.sender);
}
if (_claimedByUser[wallet] > 0) {
revert AlreadyClaimed(wallet);
}
_claimedByUser[wallet] += NEW_USER_REWARD;
totalClaimed += NEW_USER_REWARD;
KINTO.safeTransfer(wallet, NEW_USER_REWARD);
emit NewUserReward(wallet, NEW_USER_REWARD);
}
function newUserClaim(address) external {}

/**
* @notice Updates the root of the Merkle tree.
Expand Down Expand Up @@ -386,7 +377,8 @@ contract RewardsDistributor is Initializable, UUPSUpgradeable, ReentrancyGuardUp
*/
function claimedByUser(address wallet) public view returns (uint256) {
uint256 claimed = _claimedByUser[wallet];
if (IKintoWalletFactory(walletFactory).getWalletTimestamp(wallet) >= NEW_USER_REWARD_TIMESTAMP) {
uint256 walletTs = IKintoWalletFactory(walletFactory).getWalletTimestamp(wallet);
if (walletTs >= NEW_USER_REWARD_TIMESTAMP && walletTs < NEW_USER_REWARD_END_TIMESTAMP) {
// Offset K bonus for new users after the launch of the rewards program
return claimed >= NEW_USER_REWARD ? claimed - NEW_USER_REWARD : claimed;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/KintoWalletFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ contract KintoWalletFactory is Initializable, UUPSUpgradeable, OwnableUpgradeabl

walletTs[address(ret)] = block.timestamp;
totalWallets++;
// Claim new user rewards
// TODO: Remove upon next upgrade. This call does nothing.
rewardsDistributor.newUserClaim(address(ret));
emit KintoWalletFactoryCreation(address(ret), owner, factoryWalletVersion);
}
Expand Down
3 changes: 2 additions & 1 deletion test/artifacts/7887/addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,5 +245,6 @@
"KintoAppRegistryV22": "0xb9cE6BC89b79c713f34fd15D82a70900fEFD0de1",
"KintoIDV9-impl": "0x7CFe474936fA50181ae7c2C43EeB8806e25bc983",
"SponsorPaymasterV15-impl": "0x2A10b80bE8Ee546C52Fde9b58d65D089C6B929BB",
"KintoIDV10-impl": "0xaa0726829d41E3C70B84Bc5390cce82afC56871A"
"KintoIDV10-impl": "0xaa0726829d41E3C70B84Bc5390cce82afC56871A",
"RewardsDistributorV8-impl": "0xF3D955B4cF3489A37027f0F3484E87328dBdBB39"
}
6 changes: 3 additions & 3 deletions test/unit/KintoWalletFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ contract KintoWalletFactoryTest is SharedSetup {
_kintoWallet = _walletFactory.createAccount(_owner, _owner, 0);

assertEq(_kintoWallet.owners(0), _owner);
assertEq(_bridgedKinto.balanceOf(address(_kintoWallet)), 1e18);
assertEq(_rewardsDistributor.claimedByUser(address(_kintoWallet)), 1e18);
assertEq(_bridgedKinto.balanceOf(address(_kintoWallet)), 0);
assertEq(_rewardsDistributor.claimedByUser(address(_kintoWallet)), 0);
}

function testCreateAccount_WhenAfterNewRewards() public {
Expand All @@ -82,7 +82,7 @@ contract KintoWalletFactoryTest is SharedSetup {
_kintoWallet = _walletFactory.createAccount(_owner, _owner, 0);

assertEq(_kintoWallet.owners(0), _owner);
assertEq(_bridgedKinto.balanceOf(address(_kintoWallet)), 1e18);
assertEq(_bridgedKinto.balanceOf(address(_kintoWallet)), 0);
assertEq(_rewardsDistributor.claimedByUser(address(_kintoWallet)), 0);
}

Expand Down
14 changes: 0 additions & 14 deletions test/unit/liquidity-mining/RewardsDistributor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -383,18 +383,4 @@ contract RewardsDistributorTest is SharedSetup {
38978619272429166666666
); // 39k for a 30 days in 11'th quarter
}

function testNewUserClaim_RevertWhen_NotFactory() public {
vm.expectRevert(abi.encodeWithSelector(RewardsDistributor.OnlyWalletFactory.selector, address(this)));
distributor.newUserClaim(address(_kintoWallet));
}

function testNewUserClaim_RevertWhen_AlreadyClaimed() public {
vm.prank(address(_owner));
_kintoWallet = _walletFactory.createAccount(_owner, _owner, 0);

vm.expectRevert(abi.encodeWithSelector(RewardsDistributor.AlreadyClaimed.selector, address(_kintoWallet)));
vm.prank(address(_walletFactory));
_rewardsDistributor.newUserClaim(address(_kintoWallet));
}
}

0 comments on commit a655118

Please sign in to comment.