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

Increase decay precision #454

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions apps/web/configs/subgraph.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"VERSION_TESTNET": "0.0.2",
"VERSION_PROD": "0.0.3"
"VERSION_TESTNET": "0.0.5",
"VERSION_PROD": "0.0.5"
}
8 changes: 4 additions & 4 deletions apps/web/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { formatUnits } from "viem";

export const INPUT_MIN_VALUE = 0.000000000001;
export const MAX_RATIO_CONSTANT = 0.77645;
export const CV_PERCENTAGE_SCALE = 10 ** 4;
export const CV_PERCENTAGE_SCALE_DECIMALS = 4;
export const CV_PERCENTAGE_SCALE = 10 ** CV_PERCENTAGE_SCALE_DECIMALS;

export const UI_PERCENTAGE_FORMAT = 10 ** 2; // 100% = 1
export const UI_PERCENTAGE_FORMAT_DECIMALS = 2;
export const UI_PERCENTAGE_FORMAT = 10 ** UI_PERCENTAGE_FORMAT_DECIMALS; // 100% = 1

export const SCALE_PRECISION = CV_PERCENTAGE_SCALE * UI_PERCENTAGE_FORMAT; // 1% = 10.000
export const SCALE_PRECISION_DECIMALS =
CV_PERCENTAGE_SCALE_DECIMALS + UI_PERCENTAGE_FORMAT_DECIMALS; // 6 decimals

export const CV_SCALE_PRECISION = 10 ** 7;
export const CV_SCALE_PRECISION_DECIMALS = 7;
export const CV_SCALE_PRECISION_DECIMALS = 14;
export const CV_SCALE_PRECISION = 10 ** CV_SCALE_PRECISION_DECIMALS;
export const ETH_DECIMALS = 18;

export function convertSecondsToReadableTime(totalSeconds: number): {
Expand Down
2,400 changes: 2,400 additions & 0 deletions broadcast/DeployCVMultiChain.s.sol/421614/run-1728003045.json

Large diffs are not rendered by default.

664 changes: 664 additions & 0 deletions broadcast/DeployCVMultiChain.s.sol/421614/run-1728318600.json

Large diffs are not rendered by default.

2,403 changes: 2,403 additions & 0 deletions broadcast/DeployCVMultiChain.s.sol/421614/run-1728318879.json

Large diffs are not rendered by default.

2,403 changes: 2,403 additions & 0 deletions broadcast/DeployCVMultiChain.s.sol/421614/run-1728320757.json

Large diffs are not rendered by default.

1,890 changes: 945 additions & 945 deletions broadcast/DeployCVMultiChain.s.sol/421614/run-latest.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pkg/contracts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ deploy-testnet-multi-arb:
--rpc-url $(RPC_URL_ARB_TESTNET) \
--sig "run(string)" 'arbsepolia' \
--account pkGarden \
--etherscan-api-key $(ARBISCAN_API_KEY) \
--ffi \
--chain-id 421614 \
--broadcast \
--chain-id 421614 \
--legacy \
--via-ir \
--verify \
-vvvvv

upgrade-testnet-multi-arb:
Expand Down
13 changes: 13 additions & 0 deletions pkg/contracts/config/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,38 @@
"PROXIES": {
"REGISTRY_FACTORY": "0x7a603877488db46c0f6b40c2c770becfd7a65593",
"REGISTRY_COMMUNITIES": [
"0x20731544b8c29c17c42a1cb1278371af5c08142f",
"0x4d434729b80c95b0454a77fc152464b2f196abf0",
"0xf17e005599813f626ff6b4ff8189105b1306af94",
"0xf6d60f30eed6e3ec588242cff30d9c8f596370cb",
"0xffa2e39cce305c82ffa70f7da0333e5f172be5f6"
],
"CV_STRATEGIES": [
"0x17769fb86708abf03d7083ea7dc6b01976a91c47",
"0x271c5834f61901623c00ca274dc0911131e3865d",
"0x2a309fc9b3d3031826fae08254c3eb3fb3e136a9",
"0x2b7e64cf97cb0ad9f074e941f29e99899cad6f00",
"0x39db23696c0ad7a4afc5db891154a426193d3046",
"0x45cbefe5f9f0df5f76c8bdd07003724ec100497f",
"0x5ba5c0d3908c12773adf3a8c2aa504339b537011",
"0x5d63ec43e1ac82d0bb4434f2d2202eec7bb05d69",
"0x6500599270e13fbed12c1de58904e0358937a66c",
"0x768a7ce48322a6360db94a4c3eae3e50babb032c",
"0x769e1039322c9516581849485f9780390c2fac9c",
"0x7932c33f0a0dd335aecbe83a3d88b2435543a0fb",
"0x7cebd57140c10e81fb283fb3dee28f98a6a1f3e7",
"0x84b9c9d4f40e3c05278b6f688c5c78c89c7c95a8",
"0x876e104878b6dfdda13d717b5c9aec91439bc45b",
"0xa999227ef53b685cd0a91ca2301e550e6373d03c",
"0xb4a340406311a6baf6d0ca84059ca69bb3b02a07",
"0xb9540d3e9dff4de30ae19a96c604d261d3919a21",
"0xbd7474ca99a439d2926526a0168e3e948d2987c6",
"0xbf647db7c6bbacaab6a1e956f97c1c4df5ca0d3e",
"0xc0410861dbae69dbe94ab2db56ef988625dcd322",
"0xc5ae99a250617a875abc9bbb485dfde746cf3ba9",
"0xd76cd68881ad9c95000ad0a8d2f332374e91d23b",
"0xdc3a597e60297bf51627918019ba7252b844970c",
"0xdd02fe21984aef0d8d3fa46d545b2dece39749b4",
"0xe0eb96a8c31d95ccca8f7fa52ee38d0d42b4167b",
"0xe57e7f0707bdb9c826a7c6da352dfb2be1275c21"
]
Expand Down
2 changes: 1 addition & 1 deletion pkg/contracts/out/Allo.sol/Allo.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/CVStrategyV0_0.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/IPointStrategy.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CVStrategyV0_0.sol/StrategyStruct.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/CollateralVault.sol/CollateralVault.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ERC20.sol/ERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ERC20/IERC20.sol/IERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/FAllo.sol/FAllo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/GV2ERC20.sol/GV2ERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IArbitrator.sol/IArbitrator.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20.sol/IERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20Metadata.sol/IERC20Metadata.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/IERC20Permit.sol/IERC20Permit.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ISafe.sol/Enum.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ISafe.sol/ISafe.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/ISafe.sol/SafeProxyFactory.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/MockERC20.sol/MockERC20.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/PassportScorer.sol/PassportScorer.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/Registry.sol/Registry.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/contracts/out/RegistrySetup.sol/RegistrySetup.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pkg/contracts/out/RegistrySetup.sol/RegistrySetupFull.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/SafeArbitrator.sol/SafeArbitrator.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/contracts/out/SafeERC20.sol/SafeERC20.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pkg/contracts/src/CVStrategy/CVStrategyV0_0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ contract CVStrategyV0_0 is BaseStrategyUpgradeable, IArbitrable, IPointStrategy,

// Constants for fixed numbers
string public constant VERSION = "0.0";
uint256 public constant D = 10000000; //10**7
// uint256 public constant D = 10000000; //10**7
uint256 public constant D = 100000000000000; //10**14
uint256 internal constant TWO_128 = 0x100000000000000000000000000000000; // 2**128
uint256 internal constant TWO_127 = 0x80000000000000000000000000000000; // 2**127
uint256 internal constant TWO_64 = 0x10000000000000000; // 2**64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ contract RegistryCommunityV0_0 is ProxyOwnableUpgrader, ReentrancyGuardUpgradeab
function activateMemberInStrategy(address _member, address _strategy) public virtual {
onlyRegistryMemberAddress(_member);
onlyStrategyEnabled(_strategy);
onlyStrategyAddress(msg.sender, _strategy);
_revertZeroAddress(_strategy);

if (memberActivatedInStrategies[_member][_strategy]) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/contracts/test/CVStrategyHelpersV0_0.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract CVStrategyHelpersV0_0 is Native, Accounts {

uint256 internal constant TWO_127 = 2 ** 127;
uint256 internal constant TWO_128 = 2 ** 128;
uint256 internal constant D = 10 ** 7;
uint256 internal constant D = 10 ** 14;

// function poolProfile_id1(RegistryCommunityV0_0 registryCommunity) public virtual returns (bytes32) {
function poolProfile_id1(IRegistry registry, address pool_admin, address[] memory pool_managers)
Expand All @@ -45,7 +45,7 @@ contract CVStrategyHelpersV0_0 is Native, Accounts {
StrategyStruct.ArbitrableConfig memory arbitrableConfig
) public pure returns (StrategyStruct.InitializeParams memory params) {
// IAllo allo = IAllo(ALLO_PROXY_ADDRESS);
params.cvParams.decay = _etherToFloat(0.9999799 ether); // alpha = decay
params.cvParams.decay = _etherToFloat(0.99997999999999 ether); // alpha = decay
params.cvParams.maxRatio = _etherToFloat(0.2 ether); // beta = maxRatio
params.cvParams.weight = _etherToFloat(0.001 ether); // RHO = p = weight
params.cvParams.minThresholdPoints = 0.2 ether; // 20%
Expand Down Expand Up @@ -127,7 +127,7 @@ contract CVStrategyHelpersV0_0 is Native, Accounts {
}

function _etherToFloat(uint256 _amount) internal pure returns (uint256) {
return _amount / 10 ** 11;
return _amount / 10 ** 4;
}

function _mul(uint256 _a, uint256 _b) internal pure returns (uint256 _result) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/contracts/test/CVStrategyTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ contract CVStrategyTest is Test, AlloSetup, RegistrySetupFull, CVStrategyHelpers

uint256 cv_amount = cv.calculateConviction(10, 0, AMOUNT_STAKED);
console.log("cv_amount: %s", cv_amount);
uint256 cv_cmp = _calculateConviction(10, 0, AMOUNT_STAKED, 0.9 ether / 10 ** 11);
uint256 cv_cmp = _calculateConviction(10, 0, AMOUNT_STAKED, 0.9 ether / 10 ** 4);
console.log("cv_cmp: %s", cv_cmp);
assertEq(cv_amount, cv_cmp);
}
Expand Down Expand Up @@ -982,7 +982,7 @@ contract CVStrategyTest is Test, AlloSetup, RegistrySetupFull, CVStrategyHelpers
// assertEq(cv.getMaxConviction(cv.getProposalStakedAmount(proposalId)), 57806809642175848314931, "maxCVStaked");

uint256 rollTo100 =
calculateBlocksTo100(ABDKMath64x64.divu(9999999, 1e7), ABDKMath64x64.divu(cv.getDecay(), 1e7));
calculateBlocksTo100(ABDKMath64x64.divu(9999999, 1e7), ABDKMath64x64.divu(cv.getDecay(), 1e14));
vm.roll(rollTo100 * 2);

console.log("after block.number", block.number);
Expand Down Expand Up @@ -1090,7 +1090,7 @@ contract CVStrategyTest is Test, AlloSetup, RegistrySetupFull, CVStrategyHelpers
// assertEq(cv.getMaxConviction(cv.getProposalStakedAmount(proposalId)), 57806809642175848314931, "maxCVStaked");

uint256 rollTo100 =
calculateBlocksTo100(ABDKMath64x64.divu(9999999, 1e7), ABDKMath64x64.divu(cv.getDecay(), 1e7));
calculateBlocksTo100(ABDKMath64x64.divu(9999999, 1e7), ABDKMath64x64.divu(cv.getDecay(), 1e14));
vm.roll(rollTo100 * 2);

console.log("after block.number", block.number);
Expand Down Expand Up @@ -1268,7 +1268,7 @@ contract CVStrategyTest is Test, AlloSetup, RegistrySetupFull, CVStrategyHelpers
}

uint256 rollTo100 =
calculateBlocksTo100(ABDKMath64x64.divu(9999999, 1e7), ABDKMath64x64.divu(cv.getDecay(), 1e7));
calculateBlocksTo100(ABDKMath64x64.divu(9999999, 1e7), ABDKMath64x64.divu(cv.getDecay(), 1e14));

vm.roll(rollTo100 * 2);
console.log("after block.number", block.number);
Expand Down Expand Up @@ -1394,7 +1394,7 @@ contract CVStrategyTest is Test, AlloSetup, RegistrySetupFull, CVStrategyHelpers
}

uint256 rollTo100 =
calculateBlocksTo100(ABDKMath64x64.divu(9999999, 1e7), ABDKMath64x64.divu(cv.getDecay(), 1e7));
calculateBlocksTo100(ABDKMath64x64.divu(9999999, 1e7), ABDKMath64x64.divu(cv.getDecay(), 1e14));
vm.roll(rollTo100 * 2);
console.log("after block.number", block.number);
console.log("Conviction After: %s", cv.updateProposalConviction(proposalId));
Expand Down
8 changes: 4 additions & 4 deletions pkg/subgraph/config/arbsepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"dataSources": [
{
"name": "RegistryFactoryV0_0",
"startBlock": 77903587,
"address": "0x7a603877488db46c0f6b40c2c770becfd7a65593",
"startBlock": 86667952,
"address": "0x571ef6c6ee1b6ac29f47e086b14945e4ec05e366",
"customTemplate": "registryFactory"
},
{
"name": "PassportScorer",
"startBlock": 77903587,
"address": "0xf0988f8c1c2fb62ea746b86c1ce70636fa4a49ff",
"startBlock": 86667952,
"address": "0x792c923f677d03a56ff8978c6e6c6e6e9ec3076e",
"customTemplate": "passportScorer"
}
]
Expand Down
4 changes: 2 additions & 2 deletions pkg/subgraph/src/scripts/last-addr.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const viemChains = require("viem/chains");
const localhostLatest = require("../../../../broadcast/DeployCV.s.sol/1337/run-latest.json");
// const localhostLatest = require("../../../../broadcast/DeployCV.s.sol/1337/run-latest.json");
const arbitrumSepoliaLatest = require("../../../../broadcast/DeployCVMultiChain.s.sol/421614/run-latest.json");
// const optimismSepoliaLatest = require("../../../../broadcast/DeployCVMultiChain.s.sol/11155420/run-latest.json");
const sepoliaLatest = require("../../../../broadcast/DeployCVMultiChain.s.sol/11155111/run-latest.json");
Expand All @@ -13,7 +13,7 @@ const { fromHex } = require("viem");
const chainArg = process.argv[process.argv.length - 1];

const jsons = {
[viemChains.localhost.id]: localhostLatest,
// [viemChains.localhost.id]: localhostLatest,
[viemChains.arbitrumSepolia.id]: arbitrumSepoliaLatest,
// [viemChains.optimismSepolia.id]: optimismSepoliaLatest,
[viemChains.sepolia.id]: sepoliaLatest,
Expand Down
1 change: 1 addition & 0 deletions pkg/subgraph/src/scripts/list-proxies.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ async function extractProxies(chainId) {
}
}`;

console.debug("Querying subgraph...", subgraphEndpoint);
const response = await fetch(subgraphEndpoint, {
method: "POST",
headers: {
Expand Down
8 changes: 4 additions & 4 deletions pkg/subgraph/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ dataSources:
type: Int
data: 421614
source:
address: "0x7a603877488db46c0f6b40c2c770becfd7a65593"
address: "0x571ef6c6ee1b6ac29f47e086b14945e4ec05e366"
abi: RegistryFactoryV0_0
startBlock: 77903587
startBlock: 86667952
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand Down Expand Up @@ -46,9 +46,9 @@ dataSources:
type: Int
data: 421614
source:
address: "0xf0988f8c1c2fb62ea746b86c1ce70636fa4a49ff"
address: "0x792c923f677d03a56ff8978c6e6c6e6e9ec3076e"
abi: PassportScorer
startBlock: 77903587
startBlock: 86667952
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand Down
Loading