Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staking mutliplier fix #96

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,240 changes: 3,240 additions & 0 deletions Bonding.txt

Large diffs are not rendered by default.

1,675 changes: 1,675 additions & 0 deletions V1.sol

Large diffs are not rendered by default.

2,570 changes: 2,570 additions & 0 deletions V2.sol

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions allResults.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions allResults5million.json

Large diffs are not rendered by default.

1,778 changes: 458 additions & 1,320 deletions bonding_transactions.json

Large diffs are not rendered by default.

229 changes: 229 additions & 0 deletions bondingv2_migration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
[
{
"address": "0xefc0e701a824943b469a694ac564aa1eff7ab7dd",
"deposits": [
{
"hash": "0xb543c6bba4159b2c73754b1477eeda44ee0527960a58fe3f4cb89d09c4ecda77",
"lpsAmount": "20351824946109000000000",
"weeks": "208",
"bondingShareId": "32",
"bondingShareAmount": "1",
"withdraw": null
},
{
"hash": "0x881768c7e1cde1b9d0b443b5df70f7210a32f8606a520d8ef1915d4dc002f45b",
"lpsAmount": "20351824946109000000000",
"weeks": "208",
"bondingShareId": "33",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "40703649892217999999999",
"weeks": "208"
}
},
{
"address": "0xdec08cb92a506b88411da9ba290f3694be223c26",
"deposits": [
{
"hash": "0xc27f060479efedf997b42c1e336057534084db4935a2aed86266aae35980773e",
"lpsAmount": "0",
"weeks": "208",
"bondingShareId": "34",
"bondingShareAmount": "1",
"withdraw": null
},
{
"hash": "0x17cf0466439a165353dc977f62806b7036df6dd8dc6e1c8f2938c42f70005f91",
"lpsAmount": "7043472587335639038593",
"weeks": "4",
"bondingShareId": "37",
"bondingShareAmount": "1",
"withdraw": null
},
{
"hash": "0x4b5b40e4edf92f7692e88e226e0e84f556fc31aecbc6758ee5b87afd22b49c38",
"lpsAmount": "2399959119875157837134",
"weeks": "208",
"bondingShareId": "42",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "9443431707210796875726",
"weeks": "55"
}
},
{
"address": "0x004b709f7ca60e1f1618d5f7a1cf8ae46e0b88d8",
"deposits": [
{
"hash": "0x0e485f5e2b21f4cba90a255dab0b2f9c1930691a664c51d392da2609e216ac60",
"lpsAmount": "14974287434728263478134",
"weeks": "16",
"bondingShareId": "36",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "14974287434728263478133",
"weeks": "16"
}
},
{
"address": "0x0709e442a5469b88bb090dd285b1b3a63fb0c226",
"deposits": [
{
"hash": "0xa72273151c6f957e2c9a703a91f685458271078663603d6f8cdb3b8e7a83533a",
"lpsAmount": "18354645016127011508507",
"weeks": "208",
"bondingShareId": "38",
"bondingShareAmount": "1",
"withdraw": null
},
{
"hash": "0x3a1439bc2037cf22b52c7019df06b9f1f702e95253623df868e3b0beb1954737",
"lpsAmount": "2019728956757894302720",
"weeks": "208",
"bondingShareId": "44",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "20374373972884905811226",
"weeks": "208"
}
},
{
"address": "0x7af2fbb8940617743b6b168d7b494fa2aec0ed3d",
"deposits": [
{
"hash": "0x70c73d77bec3430de45daff56e550eb67c3668866963528a95df33a9e4ac3588",
"lpsAmount": "746979676349068349574",
"weeks": "4",
"bondingShareId": "39",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "746979676349068349573",
"weeks": "4"
}
},
{
"address": "0x64dff05df95f9f7060e13cc1a2c78a9bfd3a608e",
"deposits": [
{
"hash": "0x62712b707e22b6ae1e95bfed477992143197703db4841547f71e189a80b821e1",
"lpsAmount": "747459000000000000000",
"weeks": "2",
"bondingShareId": "40",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "747458999999999999999",
"weeks": "2"
}
},
{
"address": "0x2b0bdf08039640cec28f4ba3c5f1d4153e2aad0d",
"deposits": [
{
"hash": "0x3e0c1ddad08c001bcb5ff103bf0891660714d7918a86f83eca958f1e4202048b",
"lpsAmount": "1492562873018786396661",
"weeks": "4",
"bondingShareId": "41",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "1492562873018786396660",
"weeks": "4"
}
},
{
"address": "0xeeac255b45a57595080820c17f40fbd8bbc6b993",
"deposits": [
{
"hash": "0x66103d40db66ca7a7b456423a0bce2c431ff48b357601f575d779d6331ebadce",
"lpsAmount": "0",
"weeks": "208",
"bondingShareId": "43",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "-1",
"weeks": "1"
}
},
{
"address": "0x0709b103d46d71458a71e5d81230dd688809a53d",
"deposits": [
{
"hash": "0x2ab2f637ade0e58b5177f8b9aa20a9df7d140513be3257a337251f21bfad7ac0",
"lpsAmount": "310353",
"weeks": "1",
"bondingShareId": "45",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "310352",
"weeks": "1"
}
},
{
"address": "0x2582a712c2c2e9fbd9f5b081be4b4f699d2489b5",
"deposits": [
{
"hash": "0x7886939653d56e62487cb3d60f8b7bd0237b8bf132b239a87773664d97513faf",
"lpsAmount": "10000000000000000000",
"weeks": "4",
"bondingShareId": "46",
"bondingShareAmount": "1",
"withdraw": null
},
{
"hash": "0x95ed34ec2ad7f89e2abca33f9569e4aa3c2a7e176b9345ee61e0e85c36bc8afc",
"lpsAmount": "10200000000000000000",
"weeks": "1",
"bondingShareId": "47",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "20199999999999999999",
"weeks": "2"
}
},
{
"address": "0xf6501068a54f3eab46c1f145cb9d3fb91658b220",
"deposits": [
{
"hash": "0x6fca3b959f0b207db2bb16303624de3e26073ad32597c43aedb6d82462e652d6",
"lpsAmount": "858932507320256038784",
"weeks": "12",
"bondingShareId": "48",
"bondingShareAmount": "1",
"withdraw": null
}
],
"migration": {
"lpsAmount": "858932507320256038783",
"weeks": "12"
}
}
]
67 changes: 67 additions & 0 deletions contracts/BondingDebt.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

import "./interfaces/IERC20Ubiquity.sol";
import "./UbiquityAlgorithmicDollarManager.sol";

// Allows to claim UBQ missing compensation till 6th May 2024 for Bond holders affected with wrong staking multiplier
// Full explanation https://github.com/ubiquity/ubiquity-dollar/issues/752#issuecomment-2095837822

contract BondingDebt {
mapping(address => bool) public isUserClaimed;

// Ubiquity Manager
UbiquityAlgorithmicDollarManager public manager;

// ----------- Modifiers -----------
modifier onlyTokenManager() {
require(
manager.hasRole(manager.UBQ_TOKEN_MANAGER_ROLE(), msg.sender),
"BondingDebt: not UBQ manager"
);
_;
}

constructor(address _manager) {
manager = UbiquityAlgorithmicDollarManager(_manager);
}

function claim(address toClaim) external onlyTokenManager {
require(!isUserClaimed[toClaim], "Already claimed");

address governanceToken = 0x4e38D89362f7e5db0096CE44ebD021c3962aA9a0;
address treasuryAddress = 0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd;

// Bond 1
if (toClaim == address(0x89eae71B865A2A39cBa62060aB1b40bbFFaE5b0D)) {
IERC20Ubiquity(governanceToken).mint(toClaim, 35704952407232639376);
IERC20Ubiquity(governanceToken).mint(treasuryAddress, 7140990481446527875);

Check failure on line 38 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace treasuryAddress,·7140990481446527875 with ⏎················treasuryAddress,⏎················7140990481446527875⏎············

Check failure on line 38 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace treasuryAddress,·7140990481446527875 with ⏎················treasuryAddress,⏎················7140990481446527875⏎············
}

// Bond 2
if (toClaim == address(0x4007CE2083c7F3E18097aeB3A39bb8eC149a341d)) {
IERC20Ubiquity(governanceToken).mint(toClaim, 2630501621780289065714618);

Check failure on line 43 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace toClaim,·2630501621780289065714618 with ⏎················toClaim,⏎················2630501621780289065714618⏎············

Check failure on line 43 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace toClaim,·2630501621780289065714618 with ⏎················toClaim,⏎················2630501621780289065714618⏎············
IERC20Ubiquity(governanceToken).mint(treasuryAddress, 526100324356057813142923);

Check failure on line 44 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace treasuryAddress,·526100324356057813142923 with ⏎················treasuryAddress,⏎················526100324356057813142923⏎············

Check failure on line 44 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace treasuryAddress,·526100324356057813142923 with ⏎················treasuryAddress,⏎················526100324356057813142923⏎············
}

// Bond 3
if (toClaim == address(0x7c76f4DB70b7E2177de10DE3e2f668daDcd11108)) {
IERC20Ubiquity(governanceToken).mint(toClaim, 1577484595484460523315806);

Check failure on line 49 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace toClaim,·1577484595484460523315806 with ⏎················toClaim,⏎················1577484595484460523315806⏎············

Check failure on line 49 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace toClaim,·1577484595484460523315806 with ⏎················toClaim,⏎················1577484595484460523315806⏎············
IERC20Ubiquity(governanceToken).mint(treasuryAddress, 315496919096892104663161);

Check failure on line 50 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace treasuryAddress,·315496919096892104663161 with ⏎················treasuryAddress,⏎················315496919096892104663161⏎············

Check failure on line 50 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace treasuryAddress,·315496919096892104663161 with ⏎················treasuryAddress,⏎················315496919096892104663161⏎············
}

// Bond 5
if (toClaim == address(0xa53A6fE2d8Ad977aD926C485343Ba39f32D3A3F6)) {
IERC20Ubiquity(governanceToken).mint(toClaim, 329713782662103366904643);

Check failure on line 55 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace toClaim,·329713782662103366904643 with ⏎················toClaim,⏎················329713782662103366904643⏎············

Check failure on line 55 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace toClaim,·329713782662103366904643 with ⏎················toClaim,⏎················329713782662103366904643⏎············
IERC20Ubiquity(governanceToken).mint(treasuryAddress, 65942756532420673380928);

Check failure on line 56 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace treasuryAddress,·65942756532420673380928 with ⏎················treasuryAddress,⏎················65942756532420673380928⏎············

Check failure on line 56 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace treasuryAddress,·65942756532420673380928 with ⏎················treasuryAddress,⏎················65942756532420673380928⏎············
}

// Bond 6
if (toClaim == address(0xCEFD0E73cC48B0b9d4C8683E52B7d7396600AbB2)) {
IERC20Ubiquity(governanceToken).mint(toClaim, 317041833739125580390236);

Check failure on line 61 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace toClaim,·317041833739125580390236 with ⏎················toClaim,⏎················317041833739125580390236⏎············

Check failure on line 61 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace toClaim,·317041833739125580390236 with ⏎················toClaim,⏎················317041833739125580390236⏎············
IERC20Ubiquity(governanceToken).mint(treasuryAddress, 63408366747825116078047);

Check failure on line 62 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (14.16.x, ubuntu-latest)

Replace treasuryAddress,·63408366747825116078047 with ⏎················treasuryAddress,⏎················63408366747825116078047⏎············

Check failure on line 62 in contracts/BondingDebt.sol

View workflow job for this annotation

GitHub Actions / lint-and-test (15.x, ubuntu-latest)

Replace treasuryAddress,·63408366747825116078047 with ⏎················treasuryAddress,⏎················63408366747825116078047⏎············
}

isUserClaimed[toClaim] = true;
}
}
10 changes: 9 additions & 1 deletion deploy/V2Test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,15 @@ const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const ubiquityGovernance: UbiquityGovernance = ubqFactory.attach(
ubqGovAdr
) as UbiquityGovernance;

deployments.log("idsAfter:", idsAfter[0].toNumber());
let bond = await bondingShareV2.getBond(idsAfter[0]);
deployments.log(`bond id:${idsAfter[0].toNumber()}
minter:${bond.minter}
lpAmount:${ethers.utils.formatEther(bond.lpAmount)}
lpFirstDeposited:${ethers.utils.formatEther(bond.lpFirstDeposited)}
endBlock:${bond.endBlock.toNumber()}
tx:${tx.blockNumber ? tx.blockNumber.toString() : ""}
`);
deployments.log(
`UbiquityAlgorithmicDollarManager deployed at:`,
manager.address
Expand Down
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const config: HardhatUserConfig = {
url: `https://eth-mainnet.alchemyapi.io/v2/${
process.env.ALCHEMY_API_KEY || ""
}`,
blockNumber: 13252206,
blockNumber: 19810615,
},
accounts,
hardfork: "london",
Expand All @@ -118,7 +118,7 @@ const config: HardhatUserConfig = {
url: `https://eth-mainnet.alchemyapi.io/v2/${
process.env.ALCHEMY_API_KEY || ""
}`,
blockNumber: 13252206,
blockNumber: 19810615,
},
accounts,
hardfork: "london",
Expand Down
46 changes: 46 additions & 0 deletions masterchef_transactions.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions multiplier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pprint import pprint
import math

def main():
for d in range(1, 208):

pprint(1 + 0.001 * math.sqrt(d**3) )

if __name__ == '__main__':
main()
Loading
Loading