From 0a258633e84c01cee4341d5d809e016b6bb6f535 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Thu, 30 Jan 2025 15:06:45 +0000 Subject: [PATCH 01/13] setup --- .gitignore | 35 + Pipfile | 11 - README.md | 6 - abis/v3/AutoGovernanceV3.json | 1085 ++++++++++++++++++++++++++ abis/v3/ConfigBuilderV3.json | 1033 ++++++++++++++++++++++++ abis/v3/IndexFactoryV3.json | 95 +++ abis/v3/IndexTokenV3.json | 1379 +++++++++++++++++++++++++++++++++ config/init.json | 61 +- docker-compose.yml | 50 ++ dockerfile | 22 - package-lock.json | 106 ++- package.json | 10 +- schema.graphql | 20 +- src/v3/ConfigBuilder.ts | 285 +++++++ src/v3/Governance.ts | 13 + src/v3/IndexFactory.ts | 55 ++ src/v3/IndexToken.ts | 53 ++ subgraph.template.yaml | 127 ++- yarn.lock | 91 +++ 19 files changed, 4401 insertions(+), 136 deletions(-) delete mode 100644 Pipfile delete mode 100644 README.md create mode 100644 abis/v3/AutoGovernanceV3.json create mode 100644 abis/v3/ConfigBuilderV3.json create mode 100644 abis/v3/IndexFactoryV3.json create mode 100644 abis/v3/IndexTokenV3.json create mode 100644 docker-compose.yml delete mode 100644 dockerfile create mode 100644 src/v3/ConfigBuilder.ts create mode 100644 src/v3/Governance.ts create mode 100644 src/v3/IndexFactory.ts create mode 100644 src/v3/IndexToken.ts create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index 7c2d6ec..60fb59a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,38 @@ node_modules /generated subgraph.yaml /build + +# Graph CLI generated artifacts +build/ +generated/ + +# Dependency directories +node_modules/ +jspm_packages/ + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# dotenv environment variables file +.env + +# Testing +coverage +coverage.json + +# Typechain +typechain +typechain-types + +# Hardhat files +cache diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 7a9e19a..0000000 --- a/Pipfile +++ /dev/null @@ -1,11 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] - -[dev-packages] - -[requires] -python_version = "3.6" diff --git a/README.md b/README.md deleted file mode 100644 index 473abce..0000000 --- a/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# subgraph-test - -1. Install node packages -2. Generate types and classes ```npm run init``` -3. Run ```npm run prepare:``` to create a subgraph manifest specifically for the deployment chain -4. Deploy subgraph to your studio or hosted service account diff --git a/abis/v3/AutoGovernanceV3.json b/abis/v3/AutoGovernanceV3.json new file mode 100644 index 0000000..4b7e66d --- /dev/null +++ b/abis/v3/AutoGovernanceV3.json @@ -0,0 +1,1085 @@ +{ + "abi": [ + { + "type": "function", + "name": "NAME_HASH", + "inputs": [], + "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "finishMint", + "inputs": [ + { + "name": "configBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "params", + "type": "tuple", + "internalType": "struct IVault.EndRebalancingParams", + "components": [ + { + "name": "anatomyCurrencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "anatomyBalances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "newAnatomy", + "type": "tuple", + "internalType": "struct IVault.SnapshotAnatomy", + "components": [ + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "withdrawals", + "type": "tuple", + "internalType": "struct IVault.CurrencyWithdrawal", + "components": [ + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "amounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "lastKBalance", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + } + ] + } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "finishRebalancing", + "inputs": [ + { "name": "index", "type": "address", "internalType": "address" }, + { + "name": "configBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "result", + "type": "tuple", + "internalType": "struct IVault.RebalancingResult", + "components": [ + { + "name": "snapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencyIdSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "config", + "type": "tuple", + "internalType": "struct IConfigBuilder.Config", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IConfigBuilder.SharedConfig", + "components": [ + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "depositFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "redemptionFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + }, + { + "name": "currentConfig", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { "name": "payload", "type": "bytes", "internalType": "bytes" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "finishRebalancingAuto", + "inputs": [ + { "name": "index", "type": "address", "internalType": "address" }, + { + "name": "configBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "result", + "type": "tuple", + "internalType": "struct IVault.RebalancingResult", + "components": [ + { + "name": "snapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencyIdSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "config", + "type": "tuple", + "internalType": "struct IConfigBuilder.Config", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IConfigBuilder.SharedConfig", + "components": [ + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "depositFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "redemptionFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + }, + { + "name": "currentConfig", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { "name": "payload", "type": "bytes", "internalType": "bytes" }, + { + "name": "sigs", + "type": "tuple[]", + "internalType": "struct GovernanceSignatureChecker.Signature[]", + "components": [ + { "name": "r", "type": "bytes32", "internalType": "bytes32" }, + { "name": "vs", "type": "bytes32", "internalType": "bytes32" }, + { "name": "signer", "type": "address", "internalType": "address" } + ] + }, + { "name": "deadline", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "initialize", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "isAuthorized", + "inputs": [ + { "name": "selector", "type": "bytes4", "internalType": "bytes4" }, + { "name": "signer", "type": "address", "internalType": "address" } + ], + "outputs": [{ "name": "auth", "type": "bool", "internalType": "bool" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "migrateConfig", + "inputs": [ + { + "name": "newConfigBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "state", + "type": "tuple", + "internalType": "struct IConfigMigration.State", + "components": [ + { + "name": "weights", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencyIdSet", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "configHash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "currenciesHash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "resultHash", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "minSignersCount", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "nonce", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [{ "name": "", "type": "address", "internalType": "address" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "proxiableUUID", + "inputs": [], + "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "registerCurrencies", + "inputs": [ + { "name": "index", "type": "address", "internalType": "address" }, + { + "name": "configBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setAllowed", + "inputs": [ + { "name": "router", "type": "address", "internalType": "address" }, + { "name": "account", "type": "address", "internalType": "address" }, + { "name": "allowed", "type": "bool", "internalType": "bool" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setConfig", + "inputs": [ + { + "name": "configBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "baseConfig", + "type": "tuple", + "internalType": "struct IConfigBuilder.Config", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IConfigBuilder.SharedConfig", + "components": [ + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "depositFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "redemptionFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setConfigBuilder", + "inputs": [ + { "name": "target", "type": "address", "internalType": "address" }, + { "name": "router", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setEscrowDeployer", + "inputs": [ + { "name": "router", "type": "address", "internalType": "address" }, + { + "name": "escrowDeployer", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setFeePool", + "inputs": [ + { "name": "index", "type": "address", "internalType": "address" }, + { "name": "feePool", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setInitialConfig", + "inputs": [ + { "name": "index", "type": "address", "internalType": "address" }, + { + "name": "configBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "baseConfig", + "type": "tuple", + "internalType": "struct IConfigBuilder.Config", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IConfigBuilder.SharedConfig", + "components": [ + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "depositFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "redemptionFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setIsSigner", + "inputs": [ + { "name": "selectors", "type": "bytes4[]", "internalType": "bytes4[]" }, + { "name": "signer", "type": "address", "internalType": "address" }, + { "name": "value", "type": "bool", "internalType": "bool" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setMaxSlippageInBP", + "inputs": [ + { "name": "orderBook", "type": "address", "internalType": "address" }, + { + "name": "maxSlippageInBP", + "type": "uint16", + "internalType": "uint16" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setMinSignersCount", + "inputs": [ + { "name": "value", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setPriceOracle", + "inputs": [ + { "name": "orderBook", "type": "address", "internalType": "address" }, + { "name": "priceOracle", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setPriceOracleDeployer", + "inputs": [ + { + "name": "configBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "priceOracleDeployer", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setPriceSourceMapper", + "inputs": [ + { + "name": "priceOracleDeployer", + "type": "address", + "internalType": "address" + }, + { "name": "mapper", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRebalancer", + "inputs": [ + { "name": "vault", "type": "address", "internalType": "address" }, + { "name": "rebalancer", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setSequencerUptimeFeed", + "inputs": [ + { + "name": "priceOracleDeployer", + "type": "address", + "internalType": "address" + }, + { "name": "feed", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "startIndexRebalancing", + "inputs": [ + { "name": "index", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "startIndexRebalancingAuto", + "inputs": [ + { "name": "index", "type": "address", "internalType": "address" }, + { + "name": "sigs", + "type": "tuple[]", + "internalType": "struct GovernanceSignatureChecker.Signature[]", + "components": [ + { "name": "r", "type": "bytes32", "internalType": "bytes32" }, + { "name": "vs", "type": "bytes32", "internalType": "bytes32" }, + { "name": "signer", "type": "address", "internalType": "address" } + ] + }, + { "name": "deadline", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferContractOwnership", + "inputs": [ + { "name": "owned", "type": "address", "internalType": "address" }, + { "name": "newOwner", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { "name": "newOwner", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "updateConfig", + "inputs": [ + { "name": "index", "type": "address", "internalType": "address" }, + { + "name": "configBuilder", + "type": "address", + "internalType": "address" + }, + { + "name": "prevConfig", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "baseConfig", + "type": "tuple", + "internalType": "struct IConfigBuilder.Config", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IConfigBuilder.SharedConfig", + "components": [ + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "depositFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "redemptionFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "updateFundManager", + "inputs": [ + { "name": "orderBook", "type": "address", "internalType": "address" }, + { "name": "fundManager", "type": "address", "internalType": "address" }, + { "name": "isAllowed", "type": "bool", "internalType": "bool" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "upgradeTo", + "inputs": [ + { + "name": "newImplementation", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "upgradeToAndCall", + "inputs": [ + { + "name": "newImplementation", + "type": "address", + "internalType": "address" + }, + { "name": "data", "type": "bytes", "internalType": "bytes" } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "withdrawCurrency", + "inputs": [ + { "name": "router", "type": "address", "internalType": "address" }, + { "name": "currency", "type": "address", "internalType": "Currency" }, + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "amount", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "AdminChanged", + "inputs": [ + { + "name": "previousAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "newAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "BeaconUpgraded", + "inputs": [ + { + "name": "beacon", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint8", + "indexed": false, + "internalType": "uint8" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetConfigBuilder", + "inputs": [ + { + "name": "", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Upgraded", + "inputs": [ + { + "name": "implementation", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { "type": "error", "name": "Expired", "inputs": [] }, + { "type": "error", "name": "Forbidden", "inputs": [] }, + { "type": "error", "name": "InsufficientUniqueSigners", "inputs": [] }, + { "type": "error", "name": "InvalidSigner", "inputs": [] } + ] +} diff --git a/abis/v3/ConfigBuilderV3.json b/abis/v3/ConfigBuilderV3.json new file mode 100644 index 0000000..12026e7 --- /dev/null +++ b/abis/v3/ConfigBuilderV3.json @@ -0,0 +1,1033 @@ +{ + "abi": [ + { + "type": "constructor", + "inputs": [ + { "name": "_governance", "type": "address", "internalType": "address" }, + { "name": "_forwarder", "type": "address", "internalType": "address" }, + { + "name": "_priceOracleDeployer", + "type": "address", + "internalType": "address" + }, + { "name": "_index", "type": "address", "internalType": "address" }, + { + "name": "_nativeInfo", + "type": "tuple", + "internalType": "struct ConfigBuilder.NativeInfo", + "components": [ + { "name": "name", "type": "string", "internalType": "string" }, + { "name": "symbol", "type": "string", "internalType": "string" }, + { "name": "decimals", "type": "uint8", "internalType": "uint8" } + ] + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "configHash", + "inputs": [], + "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "configs", + "inputs": [ + { + "name": "config", + "type": "tuple", + "internalType": "struct IConfigBuilder.Config", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IConfigBuilder.SharedConfig", + "components": [ + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "depositFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "redemptionFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + } + ], + "outputs": [ + { + "name": "deposit", + "type": "tuple", + "internalType": "struct IIndex.DepositConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + }, + { + "name": "redemption", + "type": "tuple", + "internalType": "struct IIndex.RedemptionConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "currenciesUpdated", + "inputs": [ + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "newCurrenciesHash", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "finishMint", + "inputs": [ + { + "name": "params", + "type": "tuple", + "internalType": "struct IVault.EndRebalancingParams", + "components": [ + { + "name": "anatomyCurrencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "anatomyBalances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "newAnatomy", + "type": "tuple", + "internalType": "struct IVault.SnapshotAnatomy", + "components": [ + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "withdrawals", + "type": "tuple", + "internalType": "struct IVault.CurrencyWithdrawal", + "components": [ + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "amounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "lastKBalance", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "finishRebalancing", + "inputs": [ + { + "name": "vaultResult", + "type": "tuple", + "internalType": "struct IVault.RebalancingResult", + "components": [ + { + "name": "snapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencyIdSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "config", + "type": "tuple", + "internalType": "struct IConfigBuilder.Config", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IConfigBuilder.SharedConfig", + "components": [ + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "depositFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "redemptionFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + }, + { "name": "payload", "type": "bytes", "internalType": "bytes" } + ], + "outputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct IIndex.DepositConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + }, + { + "name": "", + "type": "tuple", + "internalType": "struct IIndex.RedemptionConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "forwarder", + "inputs": [], + "outputs": [{ "name": "", "type": "address", "internalType": "address" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getState", + "inputs": [], + "outputs": [ + { + "name": "state", + "type": "tuple", + "internalType": "struct IConfigMigration.State", + "components": [ + { + "name": "weights", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencyIdSet", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "configHash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "currenciesHash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "resultHash", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "governance", + "inputs": [], + "outputs": [{ "name": "", "type": "address", "internalType": "address" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "index", + "inputs": [], + "outputs": [{ "name": "", "type": "address", "internalType": "address" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setConfig", + "inputs": [ + { + "name": "_config", + "type": "tuple", + "internalType": "struct IConfigBuilder.Config", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IConfigBuilder.SharedConfig", + "components": [ + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "depositFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "redemptionFee", + "type": "tuple", + "internalType": "struct IConfigBuilder.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + } + ], + "outputs": [ + { + "name": "deposit", + "type": "tuple", + "internalType": "struct IIndex.DepositConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + }, + { + "name": "redemption", + "type": "tuple", + "internalType": "struct IIndex.RedemptionConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setForwarder", + "inputs": [ + { "name": "_forwarder", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setPriceOracleDeployer", + "inputs": [ + { + "name": "_priceOracleDeployer", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setState", + "inputs": [ + { + "name": "", + "type": "tuple", + "internalType": "struct IConfigMigration.State", + "components": [ + { + "name": "weights", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencyIdSet", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "configHash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "currenciesHash", + "type": "bytes32", + "internalType": "bytes32" + }, + { + "name": "resultHash", + "type": "bytes32", + "internalType": "bytes32" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "ConfigUpdated", + "inputs": [ + { + "name": "encodedConfig", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CurrenciesUpdate", + "inputs": [ + { + "name": "currenciesHash", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CurrencyRegistered", + "inputs": [ + { + "name": "currency", + "type": "address", + "indexed": false, + "internalType": "Currency" + }, + { + "name": "name", + "type": "string", + "indexed": false, + "internalType": "string" + }, + { + "name": "symbol", + "type": "string", + "indexed": false, + "internalType": "string" + }, + { + "name": "decimals", + "type": "uint8", + "indexed": false, + "internalType": "uint8" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "FinishRebalancing", + "inputs": [ + { + "name": "snapshot", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "newCurrencyIdSet", + "type": "uint256[]", + "indexed": false, + "internalType": "uint256[]" + }, + { + "name": "weights", + "type": "uint256[]", + "indexed": false, + "internalType": "uint256[]" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "FinishVaultRebalancing", + "inputs": [ + { + "name": "snapshot", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "currencyIdSet", + "type": "uint256[]", + "indexed": false, + "internalType": "uint256[]" + }, + { + "name": "currencies", + "type": "address[]", + "indexed": false, + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "indexed": false, + "internalType": "uint256[]" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ReceiveVaultResult", + "inputs": [ + { + "name": "resultHash", + "type": "bytes32", + "indexed": false, + "internalType": "bytes32" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetForwarder", + "inputs": [ + { + "name": "forwarder", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StartRebalancing", + "inputs": [], + "anonymous": false + }, + { "type": "error", "name": "ConfigHash", "inputs": [] }, + { "type": "error", "name": "Forbidden", "inputs": [] }, + { "type": "error", "name": "Invalid", "inputs": [] }, + { "type": "error", "name": "QueryFailed", "inputs": [] }, + { "type": "error", "name": "ReserveMissed", "inputs": [] }, + { "type": "error", "name": "ResultHash", "inputs": [] } + ] +} diff --git a/abis/v3/IndexFactoryV3.json b/abis/v3/IndexFactoryV3.json new file mode 100644 index 0000000..e7136fb --- /dev/null +++ b/abis/v3/IndexFactoryV3.json @@ -0,0 +1,95 @@ +{ + "abi": [ + { + "type": "function", + "name": "deploy", + "inputs": [ + { + "name": "implementation", + "type": "address", + "internalType": "address" + }, + { "name": "name", "type": "string", "internalType": "string" }, + { "name": "symbol", "type": "string", "internalType": "string" }, + { "name": "reserve", "type": "address", "internalType": "Currency" }, + { "name": "gov", "type": "address", "internalType": "address" } + ], + "outputs": [ + { "name": "index", "type": "address", "internalType": "address" } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [{ "name": "", "type": "address", "internalType": "address" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { "name": "newOwner", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "Deployed", + "inputs": [ + { + "name": "index", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "name", + "type": "string", + "indexed": false, + "internalType": "string" + }, + { + "name": "symbol", + "type": "string", + "indexed": false, + "internalType": "string" + }, + { + "name": "reserve", + "type": "address", + "indexed": false, + "internalType": "Currency" + }, + { + "name": "governance", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + } + ] +} diff --git a/abis/v3/IndexTokenV3.json b/abis/v3/IndexTokenV3.json new file mode 100644 index 0000000..2f225c7 --- /dev/null +++ b/abis/v3/IndexTokenV3.json @@ -0,0 +1,1379 @@ +{ + "abi": [ + { + "type": "constructor", + "inputs": [ + { + "name": "_maxDepositFeeInBPs", + "type": "uint16", + "internalType": "uint16" + }, + { + "name": "_maxRedemptionFeeInBPs", + "type": "uint16", + "internalType": "uint16" + }, + { + "name": "_maxAUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "nonpayable" + }, + { "type": "receive", "stateMutability": "payable" }, + { + "type": "function", + "name": "DOMAIN_SEPARATOR", + "inputs": [], + "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "accrueFee", + "inputs": [ + { "name": "recipient", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "allowance", + "inputs": [ + { "name": "", "type": "address", "internalType": "address" }, + { "name": "", "type": "address", "internalType": "address" } + ], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { "name": "spender", "type": "address", "internalType": "address" }, + { "name": "amount", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [{ "name": "", "type": "address", "internalType": "address" }], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "consume", + "inputs": [ + { "name": "currency", "type": "address", "internalType": "Currency" }, + { "name": "amount", "type": "uint256", "internalType": "uint256" }, + { "name": "target", "type": "address", "internalType": "address" }, + { "name": "data", "type": "bytes", "internalType": "bytes" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [{ "name": "", "type": "uint8", "internalType": "uint8" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "deposit", + "inputs": [ + { + "name": "params", + "type": "tuple", + "internalType": "struct IIndex.DepositParams", + "components": [ + { + "name": "config", + "type": "tuple", + "internalType": "struct IIndex.DepositConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { + "name": "BPs", + "type": "uint16", + "internalType": "uint16" + }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + }, + { + "name": "recipient", + "type": "address", + "internalType": "address" + }, + { "name": "payload", "type": "bytes", "internalType": "bytes" } + ] + }, + { "name": "cbTarget", "type": "address", "internalType": "address" }, + { "name": "cbData", "type": "bytes", "internalType": "bytes" } + ], + "outputs": [ + { "name": "shares", "type": "uint256", "internalType": "uint256" } + ], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "donate", + "inputs": [ + { "name": "currency", "type": "address", "internalType": "Currency" }, + { "name": "data", "type": "bytes", "internalType": "bytes" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "extsload", + "inputs": [ + { "name": "slot", "type": "bytes32", "internalType": "bytes32" } + ], + "outputs": [ + { "name": "value", "type": "bytes32", "internalType": "bytes32" } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "extsload", + "inputs": [ + { "name": "slots", "type": "bytes32[]", "internalType": "bytes32[]" } + ], + "outputs": [ + { "name": "", "type": "bytes32[]", "internalType": "bytes32[]" } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "fees", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "finishRebalancingPhase", + "inputs": [ + { + "name": "params", + "type": "tuple", + "internalType": "struct IVault.EndRebalancingParams", + "components": [ + { + "name": "anatomyCurrencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "anatomyBalances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "newAnatomy", + "type": "tuple", + "internalType": "struct IVault.SnapshotAnatomy", + "components": [ + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "withdrawals", + "type": "tuple", + "internalType": "struct IVault.CurrencyWithdrawal", + "components": [ + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "amounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "lastKBalance", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + } + ] + } + ], + "outputs": [ + { "name": "resultHash", "type": "bytes32", "internalType": "bytes32" } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { "name": "_name", "type": "string", "internalType": "string" }, + { "name": "_symbol", "type": "string", "internalType": "string" }, + { "name": "_reserve", "type": "address", "internalType": "Currency" }, + { "name": "_governance", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "initialize", + "inputs": [ + { "name": "_owner", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "kBalanceWads", + "inputs": [ + { "name": "", "type": "uint256", "internalType": "uint256" }, + { "name": "", "type": "address", "internalType": "address" } + ], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "kSelf", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "mint", + "inputs": [ + { + "name": "withdrawals", + "type": "tuple", + "internalType": "struct IVault.CurrencyWithdrawal", + "components": [ + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "amounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { "name": "amounts", "type": "uint256[]", "internalType": "uint256[]" }, + { "name": "recipient", "type": "address", "internalType": "address" }, + { "name": "shares", "type": "uint128", "internalType": "uint128" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [{ "name": "", "type": "string", "internalType": "string" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "nonces", + "inputs": [{ "name": "", "type": "address", "internalType": "address" }], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [{ "name": "", "type": "address", "internalType": "address" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "permit", + "inputs": [ + { "name": "owner", "type": "address", "internalType": "address" }, + { "name": "spender", "type": "address", "internalType": "address" }, + { "name": "value", "type": "uint256", "internalType": "uint256" }, + { "name": "deadline", "type": "uint256", "internalType": "uint256" }, + { "name": "v", "type": "uint8", "internalType": "uint8" }, + { "name": "r", "type": "bytes32", "internalType": "bytes32" }, + { "name": "s", "type": "bytes32", "internalType": "bytes32" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "proxiableUUID", + "inputs": [], + "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "redeem", + "inputs": [ + { + "name": "params", + "type": "tuple", + "internalType": "struct IIndex.RedemptionParams", + "components": [ + { + "name": "config", + "type": "tuple", + "internalType": "struct IIndex.RedemptionConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { + "name": "BPs", + "type": "uint16", + "internalType": "uint16" + }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + }, + { "name": "owner", "type": "address", "internalType": "address" }, + { "name": "shares", "type": "uint128", "internalType": "uint128" }, + { "name": "payload", "type": "bytes", "internalType": "bytes" } + ] + }, + { + "name": "forwardedSender", + "type": "address", + "internalType": "address" + }, + { "name": "recipient", "type": "address", "internalType": "address" } + ], + "outputs": [ + { + "name": "result", + "type": "tuple", + "internalType": "struct IIndex.RedemptionInfo", + "components": [ + { + "name": "reserveValuation", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "totalValuation", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "totalReserveShares", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "totalSupplyAfterAUMAccrual", + "type": "uint128", + "internalType": "uint128" + }, + { + "name": "totalKBeforeRedeem", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "accountBalanceSharesBeforeRedeem", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "accountReserveRedeemed", + "type": "uint96", + "internalType": "uint96" + }, + { + "name": "accountReserveSharesRedeemed", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "accountKRedeemed", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "reservePriceInQ128", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "registerCurrencies", + "inputs": [ + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + } + ], + "outputs": [ + { + "name": "currenciesHash", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "reserve", + "inputs": [], + "outputs": [ + { "name": "", "type": "address", "internalType": "Currency" } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "reserveBalance", + "inputs": [], + "outputs": [{ "name": "", "type": "uint96", "internalType": "uint96" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setConfig", + "inputs": [ + { + "name": "_prevConfig", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "_depositConfig", + "type": "tuple", + "internalType": "struct IIndex.DepositConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + } + ] + }, + { + "name": "_redemptionConfig", + "type": "tuple", + "internalType": "struct IIndex.RedemptionConfig", + "components": [ + { + "name": "shared", + "type": "tuple", + "internalType": "struct IIndex.Config", + "components": [ + { + "name": "latestSnapshot", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "AUMDilutionPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "useCustomAUMFee", + "type": "bool", + "internalType": "bool" + }, + { + "name": "staticPriceOracle", + "type": "address", + "internalType": "address" + }, + { + "name": "metadata", + "type": "address", + "internalType": "address" + }, + { + "name": "forwarder", + "type": "address", + "internalType": "address" + } + ] + }, + { + "name": "fee", + "type": "tuple", + "internalType": "struct IIndex.FeeConfig", + "components": [ + { "name": "BPs", "type": "uint16", "internalType": "uint16" }, + { + "name": "useCustomCallback", + "type": "bool", + "internalType": "bool" + } + ] + }, + { + "name": "currencies", + "type": "address[]", + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setConfigBuilder", + "inputs": [ + { + "name": "_configBuilder", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setFeePool", + "inputs": [ + { "name": "_feePool", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "setRebalancer", + "inputs": [ + { "name": "_rebalancer", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "startIndexRebalancing", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "startRebalancingPhase", + "inputs": [ + { + "name": "withdrawals", + "type": "tuple", + "internalType": "struct IVault.CurrencyWithdrawal", + "components": [ + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "amounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [{ "name": "", "type": "string", "internalType": "string" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], + "stateMutability": "view" + }, + { + "type": "function", + "name": "transfer", + "inputs": [ + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "amount", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { "name": "from", "type": "address", "internalType": "address" }, + { "name": "to", "type": "address", "internalType": "address" }, + { "name": "amount", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { "name": "newOwner", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "upgradeTo", + "inputs": [ + { + "name": "newImplementation", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "upgradeToAndCall", + "inputs": [ + { + "name": "newImplementation", + "type": "address", + "internalType": "address" + }, + { "name": "data", "type": "bytes", "internalType": "bytes" } + ], + "outputs": [], + "stateMutability": "payable" + }, + { + "type": "function", + "name": "withdraw", + "inputs": [ + { "name": "snapshot", "type": "uint256", "internalType": "uint256" }, + { "name": "kAmount", "type": "uint256", "internalType": "uint256" }, + { "name": "recipient", "type": "address", "internalType": "address" } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "event", + "name": "AdminChanged", + "inputs": [ + { + "name": "previousAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + }, + { + "name": "newAdmin", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Approval", + "inputs": [ + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "spender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "BeaconUpgraded", + "inputs": [ + { + "name": "beacon", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ConfigUpdated", + "inputs": [ + { + "name": "encodedConfig", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Consume", + "inputs": [ + { + "name": "currency", + "type": "address", + "indexed": false, + "internalType": "Currency" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Deposit", + "inputs": [ + { + "name": "sender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "reserve", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "shares", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Donate", + "inputs": [ + { + "name": "currency", + "type": "address", + "indexed": false, + "internalType": "Currency" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "FeeAccrued", + "inputs": [ + { + "name": "depositFee", + "type": "uint96", + "indexed": false, + "internalType": "uint96" + }, + { + "name": "redemptionFee", + "type": "uint96", + "indexed": false, + "internalType": "uint96" + }, + { + "name": "AUMFee", + "type": "uint96", + "indexed": false, + "internalType": "uint96" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "FeeSettled", + "inputs": [ + { + "name": "fee", + "type": "uint96", + "indexed": false, + "internalType": "uint96" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "FinishRebalancing", + "inputs": [ + { + "name": "snapshot", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "currencies", + "type": "address[]", + "indexed": false, + "internalType": "Currency[]" + }, + { + "name": "balances", + "type": "uint256[]", + "indexed": false, + "internalType": "uint256[]" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Initialized", + "inputs": [ + { + "name": "version", + "type": "uint8", + "indexed": false, + "internalType": "uint8" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SnapshotTransfer", + "inputs": [ + { + "name": "snapshot", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "StartRebalancing", + "inputs": [ + { + "name": "snapshot", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "kBalance", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "withdrawals", + "type": "tuple", + "indexed": false, + "internalType": "struct IVault.CurrencyWithdrawal", + "components": [ + { + "name": "currencyIndexSet", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "amounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Transfer", + "inputs": [ + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "value", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Upgraded", + "inputs": [ + { + "name": "implementation", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Withdraw", + "inputs": [ + { + "name": "sender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "receiver", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "owner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "shares", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "k", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "reserve", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { "type": "error", "name": "CurrenciesHashMismatch", "inputs": [] }, + { "type": "error", "name": "ERC20TransferFailed", "inputs": [] }, + { + "type": "error", + "name": "ExcessNewAnatomyCurrencyIndex", + "inputs": [ + { + "name": "currencyIndex", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { "type": "error", "name": "FeeExceedsMaxFee", "inputs": [] }, + { "type": "error", "name": "Forbidden", "inputs": [] }, + { "type": "error", "name": "HashMismatch", "inputs": [] }, + { "type": "error", "name": "IndexConfigHash", "inputs": [] }, + { "type": "error", "name": "IndexConfigMismatch", "inputs": [] }, + { "type": "error", "name": "IndexInitialConfig", "inputs": [] }, + { "type": "error", "name": "InvalidSender", "inputs": [] }, + { "type": "error", "name": "InvalidSigner", "inputs": [] }, + { "type": "error", "name": "InvalidWithdrawal", "inputs": [] }, + { "type": "error", "name": "NativeTransferFailed", "inputs": [] }, + { + "type": "error", + "name": "NewAnatomyCurrencyCountMismatch", + "inputs": [ + { + "name": "expectedCount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "NewAnatomyCurrencyIndexNotFound", + "inputs": [ + { + "name": "currencyIndex", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "NewAnatomyCurrencyIndexSetSizeMismatch", + "inputs": [ + { + "name": "expectedCount", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { + "type": "error", + "name": "NewAnatomyCurrencyMismatch", + "inputs": [ + { + "name": "expectedCurrency", + "type": "address", + "internalType": "Currency" + }, + { + "name": "expectedBalance", + "type": "uint256", + "internalType": "uint256" + } + ] + }, + { "type": "error", "name": "PermitDeadlineExpired", "inputs": [] }, + { "type": "error", "name": "Rebalancing", "inputs": [] }, + { + "type": "error", + "name": "Registered", + "inputs": [ + { "name": "currency", "type": "address", "internalType": "Currency" } + ] + }, + { "type": "error", "name": "ZeroAddressTransfer", "inputs": [] }, + { "type": "error", "name": "ZeroDeposit", "inputs": [] }, + { "type": "error", "name": "ZeroShares", "inputs": [] } + ] +} diff --git a/config/init.json b/config/init.json index 1d1d357..1ac5d04 100644 --- a/config/init.json +++ b/config/init.json @@ -1,28 +1,35 @@ { - "network": "mainnet", - "chainID": 1, - "v1": { - "indexFactory": { - "address": "0x0000000000000000000000000000000000000000", - "startBlock": 1 - } - }, - "v2": { - "indexFactory": { - "name": "IndexFactoryV2", - "address": "0x0000000000000000000000000000000000000000", - "startBlock": 1 - } - }, - "ephtr": true, - "savingsVaults": [ - { - "name": "USVVault", - "address": "0x0000000000000000000000000000000000000000", - "vaultAsset": "0x0000000000000000000000000000000000000000", - "viewAddress": "0x0000000000000000000000000000000000000000", - "chainlinkFeedRegistryAddress": "0x0000000000000000000000000000000000000000", - "startBlock": 1 - } - ] -} \ No newline at end of file + "network": "mainnet", + "chainID": 1, + "v1": { + "indexFactory": { + "address": "0x0000000000000000000000000000000000000000", + "startBlock": 1 + } + }, + "v2": { + "indexFactory": { + "name": "IndexFactoryV2", + "address": "0x0000000000000000000000000000000000000000", + "startBlock": 1 + } + }, + "v3": { + "indexFactory": { + "name": "IndexFactoryV3", + "address": "0x0000000000000000000000000000000000000000", + "startBlock": 1 + } + }, + "ephtr": true, + "savingsVaults": [ + { + "name": "USVVault", + "address": "0x0000000000000000000000000000000000000000", + "vaultAsset": "0x0000000000000000000000000000000000000000", + "viewAddress": "0x0000000000000000000000000000000000000000", + "chainlinkFeedRegistryAddress": "0x0000000000000000000000000000000000000000", + "startBlock": 1 + } + ] +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a008fc9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,50 @@ +version: "3" +services: + graph-node: + image: graphprotocol/graph-node + ports: + - "8000:8000" + - "8001:8001" + - "8020:8020" + - "8030:8030" + - "8040:8040" + depends_on: + - ipfs + - postgres + extra_hosts: + - host.docker.internal:host-gateway + environment: + postgres_host: postgres + postgres_user: graph-node + postgres_pass: let-me-in + postgres_db: graph-node + ipfs: "ipfs:5001" + ethereum: "mainnet:http://host.docker.internal:8545" + GRAPH_LOG: info + ipfs: + image: ipfs/kubo:v0.17.0 + ports: + - "5001:5001" + volumes: + - ./data/ipfs:/data/ipfs + postgres: + image: postgres:14 + ports: + - "5432:5432" + command: + [ + "postgres", + "-cshared_preload_libraries=pg_stat_statements", + "-cmax_connections=200", + ] + environment: + POSTGRES_USER: graph-node + POSTGRES_PASSWORD: let-me-in + POSTGRES_DB: graph-node + # FIXME: remove this env. var. which we shouldn't need. Introduced by + # , maybe as a + # workaround for https://github.com/docker/for-mac/issues/6270? + PGDATA: "/var/lib/postgresql/data" + POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C" + volumes: + - ./data/postgres:/var/lib/postgresql/data diff --git a/dockerfile b/dockerfile deleted file mode 100644 index 7edfd76..0000000 --- a/dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM --platform=linux/x86_64 ubuntu:22.04 - -ARG DEBIAN_FRONTEND=noninteractive - -ENV ARGS="" - -RUN apt update \ - && apt install -y sudo curl postgresql postgresql-contrib - -RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - \ - && sudo apt-get install -y nodejs - -RUN curl -OL https://github.com/LimeChain/matchstick/releases/download/0.6.0/binary-linux-22 \ - && chmod a+x binary-linux-22 - -RUN mkdir matchstick -WORKDIR /matchstick - -# Commenting out for now as it seems there's no need to copy when using bind mount -# COPY ./ . - -CMD ../binary-linux-22 ${ARGS} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8e64825..f9d3118 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,10 @@ { - "name": "subgraph-test", + "name": "base-index-test", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "subgraph-test", + "name": "base-index-test", "license": "UNLICENSED", "dependencies": { "@graphprotocol/graph-ts": "^0.35.0", @@ -15,17 +15,18 @@ } }, "node_modules/@graphprotocol/graph-ts": { - "version": "0.35.0", - "resolved": "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.35.0.tgz", - "integrity": "sha512-dM+I/e/WeBa8Q3m4ZLFfJjKBS9YwV+DLggWi8oEIGmnhPAZ298QB6H4hquvxqaOTSXJ2j9tPsw3xSmbRLwk39A==", + "version": "0.35.1", + "resolved": "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.35.1.tgz", + "integrity": "sha512-74CfuQmf7JI76/XCC34FTkMMKeaf+3Pn0FIV3m9KNeaOJ+OI3CvjMIVRhOZdKcJxsFCBGaCCl0eQjh47xTjxKA==", "dependencies": { "assemblyscript": "0.19.10" } }, - "node_modules/@graphprotocol/graph-ts/node_modules/assemblyscript": { + "node_modules/assemblyscript": { "version": "0.19.10", "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.10.tgz", "integrity": "sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg==", + "license": "Apache-2.0", "dependencies": { "binaryen": "101.0.0-nightly.20210723", "long": "^4.0.0" @@ -39,43 +40,11 @@ "url": "https://opencollective.com/assemblyscript" } }, - "node_modules/@graphprotocol/graph-ts/node_modules/binaryen": { + "node_modules/binaryen": { "version": "101.0.0-nightly.20210723", "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz", "integrity": "sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA==", - "bin": { - "wasm-opt": "bin/wasm-opt" - } - }, - "node_modules/@graphprotocol/graph-ts/node_modules/long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, - "node_modules/assemblyscript": { - "version": "0.19.23", - "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.23.tgz", - "integrity": "sha512-fwOQNZVTMga5KRsfY80g7cpOl4PsFQczMwHzdtgoqLXaYhkhavufKb0sB0l3T1DUxpAufA0KNhlbpuuhZUwxMA==", - "dev": true, - "dependencies": { - "binaryen": "102.0.0-nightly.20211028", - "long": "^5.2.0", - "source-map-support": "^0.5.20" - }, - "bin": { - "asc": "bin/asc", - "asinit": "bin/asinit" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/assemblyscript" - } - }, - "node_modules/binaryen": { - "version": "102.0.0-nightly.20211028", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-102.0.0-nightly.20211028.tgz", - "integrity": "sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w==", - "dev": true, + "license": "Apache-2.0", "bin": { "wasm-opt": "bin/wasm-opt" } @@ -84,19 +53,21 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/long": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz", - "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==", - "dev": true + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", + "license": "Apache-2.0" }, "node_modules/matchstick-as": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/matchstick-as/-/matchstick-as-0.5.0.tgz", "integrity": "sha512-4K619YDH+so129qt4RB4JCNxaFwJJYLXPc7drpG+/mIj86Cfzg6FKs/bA91cnajmS1CLHdhHl9vt6Kd6Oqvfkg==", "dev": true, + "license": "MIT", "dependencies": { "@graphprotocol/graph-ts": "^0.27.0", "assemblyscript": "^0.19.20", @@ -117,6 +88,7 @@ "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.10.tgz", "integrity": "sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg==", "dev": true, + "license": "Apache-2.0", "dependencies": { "binaryen": "101.0.0-nightly.20210723", "long": "^4.0.0" @@ -130,25 +102,48 @@ "url": "https://opencollective.com/assemblyscript" } }, - "node_modules/matchstick-as/node_modules/binaryen": { - "version": "101.0.0-nightly.20210723", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz", - "integrity": "sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA==", + "node_modules/matchstick-as/node_modules/assemblyscript": { + "version": "0.19.23", + "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.23.tgz", + "integrity": "sha512-fwOQNZVTMga5KRsfY80g7cpOl4PsFQczMwHzdtgoqLXaYhkhavufKb0sB0l3T1DUxpAufA0KNhlbpuuhZUwxMA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "binaryen": "102.0.0-nightly.20211028", + "long": "^5.2.0", + "source-map-support": "^0.5.20" + }, + "bin": { + "asc": "bin/asc", + "asinit": "bin/asinit" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/assemblyscript" + } + }, + "node_modules/matchstick-as/node_modules/assemblyscript/node_modules/binaryen": { + "version": "102.0.0-nightly.20211028", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-102.0.0-nightly.20211028.tgz", + "integrity": "sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w==", "dev": true, + "license": "Apache-2.0", "bin": { "wasm-opt": "bin/wasm-opt" } }, - "node_modules/matchstick-as/node_modules/long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", - "dev": true + "node_modules/matchstick-as/node_modules/assemblyscript/node_modules/long": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.4.tgz", + "integrity": "sha512-qtzLbJE8hq7VabR3mISmVGtoXP8KGc2Z/AT8OuqlYD7JTR3oqrgwdjnk07wpj1twXxYmgDXgoKVWUG/fReSzHg==", + "dev": true, + "license": "Apache-2.0" }, "node_modules/mustache": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "license": "MIT", "bin": { "mustache": "bin/mustache" } @@ -158,6 +153,7 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } @@ -167,6 +163,7 @@ "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, + "license": "MIT", "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -177,6 +174,7 @@ "resolved": "https://registry.npmjs.org/wabt/-/wabt-1.0.24.tgz", "integrity": "sha512-8l7sIOd3i5GWfTWciPL0+ff/FK/deVK2Q6FN+MPz4vfUcD78i2M/49XJTwF6aml91uIiuXJEsLKWMB2cw/mtKg==", "dev": true, + "license": "Apache-2.0", "bin": { "wasm-decompile": "bin/wasm-decompile", "wasm-interp": "bin/wasm-interp", diff --git a/package.json b/package.json index 16a2d92..f8d20e4 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { - "name": "subgraph-test", + "name": "base-index-test", "license": "UNLICENSED", "scripts": { "codegen": "graph codegen", "build": "graph build", - "deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ subgraph-test", - "create-local": "graph create --node http://localhost:8020/ subgraph-test", - "remove-local": "graph remove --node http://localhost:8020/ subgraph-test", - "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 subgraph-test", + "deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ base-index-test", + "create-local": "graph create --node http://localhost:8020/ base-index-test", + "remove-local": "graph remove --node http://localhost:8020/ base-index-test", + "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 base-index-test", "test": "graph test", "prepare:mainnet": "npm run clean && npx mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml", "prepare:avalanche": "npm run clean && npx mustache config/avalanche.json subgraph.template.yaml > subgraph.yaml", diff --git a/schema.graphql b/schema.graphql index a6cd8b7..4a45075 100644 --- a/schema.graphql +++ b/schema.graphql @@ -12,21 +12,21 @@ type Index @entity { aumFee: BigDecimal! k: BigInt isRebalancing: Boolean - anatomy: Anatomy @derivedFrom(field:"index") - lzConfig: LZConfig @derivedFrom(field:"index") - config : Config @derivedFrom(field:"index") + anatomy: Anatomy @derivedFrom(field: "index") + lzConfig: LZConfig @derivedFrom(field: "index") + config: Config @derivedFrom(field: "index") totalFees: BigDecimal totalSupply: BigDecimal! holders: BigInt! assets: [ChainIDToAssetMapping!]! - history: [HistoricalIndexBalance!]! @derivedFrom(field:"index") + history: [HistoricalIndexBalance!]! @derivedFrom(field: "index") } "Entry point for all information related to accounts" type Account @entity { id: Bytes! - indices: [IndexAccount!]! @derivedFrom(field:"account") - history: [HistoricalAccountBalance!]! @derivedFrom(field:"account") + indices: [IndexAccount!]! @derivedFrom(field: "account") + history: [HistoricalAccountBalance!]! @derivedFrom(field: "account") } type IndexAsset @entity { @@ -60,7 +60,7 @@ type HistoricalIndexBalance @entity { type HistoricalAccountBalance @entity { id: String! timestamp: BigInt! - index: Bytes! + index: Bytes! account: Account! balance: BigDecimal! } @@ -73,7 +73,7 @@ type HistoricalIndexAsset @entity { chainID: BigInt! timestamp: BigInt! balance: BigDecimal! - weight:BigInt + weight: BigInt } type HistoricalPrice @entity { @@ -115,7 +115,7 @@ type Config @entity { type LZConfig @entity { id: Bytes! index: Index! - eIds:BigInt! + eIds: BigInt! minGas: [BigInt!]! } @@ -131,4 +131,4 @@ type CurrencySet @entity { index: Bytes! chainIndex: BigInt! sets: [BigInt!]! -} \ No newline at end of file +} diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts new file mode 100644 index 0000000..c4174af --- /dev/null +++ b/src/v3/ConfigBuilder.ts @@ -0,0 +1,285 @@ +import { Bytes, BigInt, Address, ethereum, dataSource, BigDecimal, log, ByteArray, TypedMap, DataSourceContext } from "@graphprotocol/graph-ts"; +import { createOrLoadAnatomyEntity, createOrLoadChainIDToAssetMappingEntity, createOrLoadConfigEntity, createOrLoadCurrencySetEntity, createOrLoadHistoricalIndexAssetEntity, createOrLoadHistoricalIndexBalanceEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity, loadChainIDToAssetMappingEntity, loadIndexAssetEntity } from "../EntityCreation"; +import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishVaultRebalancing as FinishVaultRebalancingEvent, RegisterChain as RegisterChainEvent, FinishRebalancing as FinishRebalancingEvent, StartRebalancing as StartRebalancingEvent } from "../../generated/templates/ConfigBuilderV3/ConfigBuilderV3" +import { convertAUMFeeRate } from "../v1/FeePool"; +import { CurrencySet, HistoricalIndexAsset } from "../../generated/schema"; +import { Messenger } from "../../generated/templates"; + +export function handleConfigUpdate(event: ConfigUpdatedEvent): void { + let indexAddress = dataSource.context().getBytes('indexAddress') + let indexEntity = createOrLoadIndexEntity(indexAddress) + let configEntity = createOrLoadConfigEntity(indexAddress) + let decoded = ethereum.decode('((uint256,bool,address),(uint16,bool),(uint16,bool))', event.params.param0)!.toTuple() + configEntity.AUMDilutionPerSecond = decoded[0].toTuple()[0].toBigInt() + configEntity.useCustomAUMFee = decoded[0].toTuple()[1].toBoolean() + configEntity.metadata = decoded[0].toTuple()[2].toAddress() + configEntity.depositFeeInBP = decoded[1].toTuple()[0].toBigInt() + configEntity.depositCustomCallback = decoded[1].toTuple()[1].toBoolean() + configEntity.redemptionFeeInBP = decoded[2].toTuple()[0].toBigInt() + configEntity.redemptionCustomCallback = decoded[2].toTuple()[1].toBoolean() + let aumFee = decoded[0].toTuple()[0].toBigInt() + let scalar = new BigDecimal(BigInt.fromI32(10000)) + let mintingFee = new BigDecimal(decoded[1].toTuple()[0].toBigInt()).div(scalar) + let redemptionFee = new BigDecimal(decoded[2].toTuple()[0].toBigInt()).div(scalar) + indexEntity.mintingFee = mintingFee + indexEntity.redemptionFee = redemptionFee + indexEntity.save() + configEntity.save() + convertAUMFeeRate(indexAddress, aumFee) +} + +export function handleStartRebalancing(event: StartRebalancingEvent): void { + let indexAddress = dataSource.context().getBytes('indexAddress') + let indexEntity = createOrLoadIndexEntity(indexAddress) + indexEntity.isRebalancing = true + indexEntity.save() +} + +export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { + let indexAddress = dataSource.context().getBytes('indexAddress') + log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), event.params.chainId.toString()]) + let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, event.params.currency, event.params.chainId) + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, event.params.chainId) + indexAssetEntity.name = event.params.name + indexAssetEntity.symbol = event.params.symbol + indexAssetEntity.decimals = event.params.decimals + indexAssetEntity.currencyID = chainIDToAssetMappingEntity.registeredAssets + + chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(BigInt.fromI32(1)) + + chainIDToAssetMappingEntity.save() + indexAssetEntity.save() +} + +export function handleFinishChainRebalancing(event: FinishVaultRebalancingEvent): void { + let indexAddress = dataSource.context().getBytes('indexAddress') + let reserveAsset = dataSource.context().getBytes('reserveAsset') + let indexEntity = createOrLoadIndexEntity(indexAddress) + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, event.params.chainId) + chainIDToAssetMappingEntity.latestSnapshot = event.params.snapshot + if (event.params.currencies.length == 0) { + for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { + let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[i]) + indexAssetEntity.balance = BigDecimal.zero() + indexAssetEntity.weight = BigInt.zero() + indexAssetEntity.save() + } + let emptyAssetArray: string[] = [] + if (event.params.chainId == indexEntity.chainID) { + emptyAssetArray.push(createOrLoadIndexAssetEntity(indexAddress, reserveAsset, indexEntity.chainID).id) + } + chainIDToAssetMappingEntity.assets = emptyAssetArray + chainIDToAssetMappingEntity.save() + + if (event.params.chainId != indexEntity.chainID) { + let indexAssets = indexEntity.assets + let idx = indexAssets.indexOf(chainIDToAssetMappingEntity.id) + indexAssets.splice(idx, 1) + indexEntity.assets = indexAssets + indexEntity.save() + } + + } else { + let chainIDAssetArray: string[] = [] + let reserveAssetEntity = createOrLoadIndexAssetEntity(indexAddress, reserveAsset, indexEntity.chainID) + if (event.params.chainId == indexEntity.chainID) { + reserveAssetEntity.balance = BigDecimal.zero() + reserveAssetEntity.save() + chainIDAssetArray.push(reserveAssetEntity.id) + } + for (let i = 0; i < event.params.currencies.length; i++) { + let balance = new BigDecimal(event.params.currencies[i].rightShift(160)) + let asset = event.params.currencies[i].bitAnd(BigInt.fromI32(2).pow(160).minus(BigInt.fromI32(1))).toHex() + log.debug("{}", [asset]) + let assetConverted: Bytes + log.debug("{} length = {}", [asset, asset.length.toString()]) + if (asset.length == 3) { + assetConverted = Address.fromString("0x0000000000000000000000000000000000000000") + } + else { + assetConverted = Address.fromHexString('0x'.concat("0".repeat(42 - asset.length)).concat(asset.slice(2))) + } + log.debug("decoded asset = {}, decoded balance {}, chainID {}", [assetConverted.toHexString(), balance.toString(), event.params.chainId.toString()]) + let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, assetConverted, event.params.chainId) + let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(indexAssetEntity.decimals))) + indexAssetEntity.balance = balance.div(scalar) + indexAssetEntity.save() + if (indexAssetEntity.id != reserveAssetEntity.id) { + chainIDAssetArray.push(indexAssetEntity.id) + } + + } + for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { + let id = chainIDToAssetMappingEntity.assets[i] + if (!chainIDAssetArray.includes(id)) { + let indexAssetEntity = loadIndexAssetEntity(id) + indexAssetEntity.balance = BigDecimal.zero() + indexAssetEntity.weight = BigInt.zero() + indexAssetEntity.save() + } + } + chainIDToAssetMappingEntity.assets = chainIDAssetArray + + + if (!indexEntity.assets.includes(chainIDToAssetMappingEntity.id)) { + let indexAssetArray = indexEntity.assets + indexAssetArray.push(chainIDToAssetMappingEntity.id) + indexEntity.assets = indexAssetArray + indexEntity.save() + } + } + chainIDToAssetMappingEntity.save() + indexEntity.k = BigInt.fromI32(1).times(BigInt.fromI32(10).pow(18)) + indexEntity.save() + saveHistoricalData(indexAddress, event.block.timestamp) +} + +export function handleRegisterChain(event: RegisterChainEvent): void { + let indexAddress = dataSource.context().getBytes('indexAddress') + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, event.params.chainId) + chainIDToAssetMappingEntity.chainIndex = event.params.chainIndex + chainIDToAssetMappingEntity.latestSnapshot = BigInt.zero() + chainIDToAssetMappingEntity.registeredAssets = BigInt.zero() + chainIDToAssetMappingEntity.save() + +} + +export function saveHistoricalData(index: Bytes, timestamp: BigInt): void { + let indexEntity = createOrLoadIndexEntity(index) + let historicalIndexBalanceEntity = createOrLoadHistoricalIndexBalanceEntity(index, timestamp) + historicalIndexBalanceEntity.totalSupply = indexEntity.totalSupply + let historicalIndexAssetArray: string[] = [] + for (let i = 0; i < indexEntity.assets.length; i++) { + let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[i]) + let chainID = chainIDToAssetMappingEntity.chainID + for (let y = 0; y < chainIDToAssetMappingEntity.assets.length; y++) { + let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[y]) + let historicalIndexAssetEntity = createOrLoadHistoricalIndexAssetEntity(index, indexAssetEntity.asset, chainID, timestamp) + historicalIndexAssetEntity.balance = indexAssetEntity.balance + if (indexAssetEntity.weight) { + historicalIndexAssetEntity.weight = indexAssetEntity.weight + } + historicalIndexAssetEntity.save() + historicalIndexAssetArray.push(historicalIndexAssetEntity.id) + } + } + historicalIndexBalanceEntity.assets = historicalIndexAssetArray + historicalIndexBalanceEntity.save() +} + +export function handleFinishRebalancing(event: FinishRebalancingEvent): void { + log.debug("weights {}", [event.params.weights.toString()]) + let indexAddress = dataSource.context().getBytes('indexAddress') + let indexEntity = createOrLoadIndexEntity(indexAddress) + let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) + let anatomyArray: string[] = [] + let chainIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newAnatomy.chainIdSet)) + log.debug(" chain index array {}", [chainIndexArray.toString()]) + let count = 0 + for (let i = 0; i < chainIndexArray.length; i++) { + let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, chainIndexArray[i]) + currencySetEntity.sets = event.params.newAnatomy.currencyIdSets[i] + currencySetEntity.save() + anatomyArray.push(currencySetEntity.id) + + let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newAnatomy.currencyIdSets[i])) + log.debug("Currency index array output {} for chain index {}", [currencyIndexArray.toString(), chainIndexArray[i].toString()]) + for (let y = 0; y < indexEntity.assets.length; y++) { + let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) + let chainIndex = chainIDToAssetMappingEntity.chainIndex + if (chainIndex && chainIndex == chainIndexArray[i]) { + while (currencyIndexArray.length > 0) { + for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { + let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) + let currencyID = indexAssetEntity.currencyID + if (currencyIndexArray.length == 0) { + break + } + if (currencyID && currencyID == currencyIndexArray[0]) { + indexAssetEntity.weight = event.params.weights[count] + currencyIndexArray.splice(0, 1) + indexAssetEntity.save() + count++ + log.debug("currency array length {}", [currencyIndexArray.length.toString()]) + log.debug("count {}", [count.toString()]) + } + } + } + break + } + } + } + indexEntity.isRebalancing = false + anatomyEntity.chainIdSet = event.params.newAnatomy.chainIdSet + anatomyEntity.currencyIdSets = anatomyArray + anatomyEntity.save() + indexEntity.save() +} + +export function convertBitSetToIDs(array: BigInt[]): BigInt[] { + let IDArray: BigInt[] = [] + for (let i = 0; i < array.length; i++) { + if (array[i] == BigInt.fromI32(1)) { + IDArray.push(BigInt.fromI32(i)) + } + } + return IDArray +} + +export function convertBigIntsToBitArray(array: BigInt[]): BigInt[] { + let expandedBitArray: BigInt[] = [] + for (let i = 0; i < array.length; i++) { + let bitArray: BigInt[] = [] + let chainBitSet = array[i] + while (chainBitSet > BigInt.zero()) { + bitArray.push(chainBitSet.bitAnd(BigInt.fromI32(1))) + chainBitSet = chainBitSet.rightShift(1) + } + expandedBitArray = expandedBitArray.concat(bitArray) + } + return expandedBitArray +} + + + +export function selectNativeAsset(chainID: BigInt): Array | null { + let chainIDMap = new TypedMap>() + chainIDMap.set(BigInt.fromI32(43114), ["Avalanche", "AVAX", "18"]) + chainIDMap.set(BigInt.fromI32(43113), ["Avalanche", "AVAX", "18"]) + chainIDMap.set(BigInt.fromI32(80001), ["Matic", "MATIC", "18"]) + chainIDMap.set(BigInt.fromI32(137), ["Matic", "MATIC", "18"]) + chainIDMap.set(BigInt.fromI32(97), ["Binance Coin", "BNB", "18"]) + chainIDMap.set(BigInt.fromI32(56), ["Binance Coin", "BNB", "18"]) + chainIDMap.set(BigInt.fromI32(1), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(42161), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(10), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(8453), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(100), ["XDAI", "XDAI", "18"]) + chainIDMap.set(BigInt.fromI32(10200), ["XDAI", "XDAI", "18"]) + chainIDMap.set(BigInt.fromI32(5000), ["Mantle", "MNT", "18"]) + chainIDMap.set(BigInt.fromI32(250), ["Fantom", "FTM", "18"]) + chainIDMap.set(BigInt.fromI32(4002), ["Fantom", "FTM", "18"]) + chainIDMap.set(BigInt.fromI32(1088), ["Metis", "METIS", "18"]) + chainIDMap.set(BigInt.fromI32(59144), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(40), ["Telos", "TLOS", "18"]) + chainIDMap.set(BigInt.fromI32(1313161554), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(204), ["Binance Coin", "BNB", "18"]) + chainIDMap.set(BigInt.fromI32(41), ["Telos", "TLOS", "18"]) + chainIDMap.set(BigInt.fromI32(5003), ["Mantle", "MNT", "18"]) + chainIDMap.set(BigInt.fromI32(84532), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(421614), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(11155111), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(11155420), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(7700), ["Canto", "CANTO", "18"]) + chainIDMap.set(BigInt.fromI32(59140), ["Ethereum", "ETH", "18"]) + chainIDMap.set(BigInt.fromI32(5611), ["Binance Coin", "tBNB", "18"]) + + let data = chainIDMap.get(chainID) + + if (data != null) { + return data + } + else { + return null + } +} \ No newline at end of file diff --git a/src/v3/Governance.ts b/src/v3/Governance.ts new file mode 100644 index 0000000..1fa01b7 --- /dev/null +++ b/src/v3/Governance.ts @@ -0,0 +1,13 @@ +import { DataSourceContext, dataSource } from "@graphprotocol/graph-ts" +import { ConfigBuilderV3 as ConfigBuilderTemplate } from "../../generated/templates/ConfigBuilderV3/ConfigBuilderV3" +import { SetConfigBuilder as SetConfigbuilderEvent } from "../../generated/templates/AutoGovernanceV3/AutoGovernanceV3" + + +export function handleSetConfigBuilder(event: SetConfigbuilderEvent): void { + let indexAddress = dataSource.context().getBytes('indexAddress') + let reserveAsset = dataSource.context().getBytes('reserveAsset') + let context = new DataSourceContext() + context.setBytes('indexAddress', indexAddress) + context.setBytes('reserveAsset', reserveAsset) + ConfigBuilderTemplate.createWithContext(event.params.param0, context) +} \ No newline at end of file diff --git a/src/v3/IndexFactory.ts b/src/v3/IndexFactory.ts new file mode 100644 index 0000000..0547526 --- /dev/null +++ b/src/v3/IndexFactory.ts @@ -0,0 +1,55 @@ +import { Deployed as DeployedEvent } from "../../generated/IndexFactoryV3/IndexFactoryV3" +import { createOrLoadChainIDToAssetMappingEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity } from "../EntityCreation" +import { Governance as GovernanceTemplate, IndexTokenV3 as indexTemplate } from "../../generated/templates" +import { Address, BigDecimal, BigInt, Bytes, DataSourceContext, dataSource, log } from "@graphprotocol/graph-ts" +import { IndexTokenV3 } from "../../generated/IndexFactoryV3/IndexTokenV3" +import { getTokenInfo } from "../v1/IndexFactory" + + +export function handleIndexDeployed(event: DeployedEvent): void { + let chainID = dataSource.context().getBigInt('chainID') + let context = new DataSourceContext() + context.setBytes('reserveAsset', event.params.reserve) + indexTemplate.createWithContext(event.params.index, context) + context.setBytes('indexAddress', event.params.index) + GovernanceTemplate.createWithContext(event.params.governance, context) + + let index = createOrLoadIndexEntity(event.params.index) + let indexContract = IndexTokenV3.bind(event.params.index) + index.name = event.params.name + index.symbol = event.params.symbol + index.decimals = indexContract.decimals() + index.chainID = chainID + index.version = "v2" + index.creationDate = event.block.timestamp + index.k = BigInt.fromI32(1).times(BigInt.fromI32(10).pow(18)) + index.totalFees = BigDecimal.zero() + let indexAssetEntity = createOrLoadIndexAssetEntity(event.params.index, event.params.reserve, chainID) + if (event.params.reserve != Address.fromString('0x0000000000000000000000000000000000000000')) { + getTokenInfo(indexAssetEntity, event.params.reserve) + } + else { + let nativeAssetInfo = dataSource.context().get("nativeAsset")! + indexAssetEntity.name = nativeAssetInfo.toArray()[0].toString() + indexAssetEntity.symbol = nativeAssetInfo.toArray()[1].toString() + indexAssetEntity.decimals = nativeAssetInfo.toArray()[2].toI32() + } + + let chainIDAssetArray: string[] = [] + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(event.params.index, chainID) + chainIDAssetArray.push(indexAssetEntity.id) + chainIDToAssetMappingEntity.assets = chainIDAssetArray + chainIDToAssetMappingEntity.chainIndex = BigInt.zero() + chainIDToAssetMappingEntity.latestSnapshot = BigInt.zero() + chainIDToAssetMappingEntity.registeredAssets = BigInt.zero() + + indexAssetEntity.currencyID = chainIDToAssetMappingEntity.registeredAssets + chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(BigInt.fromI32(1)) + + let indexAssetArray: string[] = [] + indexAssetArray.push(chainIDToAssetMappingEntity.id) + index.assets = indexAssetArray + chainIDToAssetMappingEntity.save() + indexAssetEntity.save() + index.save() +} \ No newline at end of file diff --git a/src/v3/IndexToken.ts b/src/v3/IndexToken.ts new file mode 100644 index 0000000..52fd3d6 --- /dev/null +++ b/src/v3/IndexToken.ts @@ -0,0 +1,53 @@ +import { Deposit as DepositEvent, FeeAccrued, Withdraw as WithdrawEvent } from "../../generated/templates/IndexTokenV3/IndexTokenV3" +import { createOrLoadIndexEntity, createOrLoadIndexAssetEntity, loadIndexAssetEntity, loadChainIDToAssetMappingEntity } from "../EntityCreation" +import { BigDecimal, Bytes, Address, BigInt, dataSource, log } from "@graphprotocol/graph-ts" +export { handleTransfer } from "../v1/IndexToken" +import { saveHistoricalData } from "./ConfigBuilder" + +export function handleDeposit(event: DepositEvent): void { + let indexEntity = createOrLoadIndexEntity(event.address) + let reserveAsset = dataSource.context().getBytes('reserveAsset') + let reserveAssetEntity = createOrLoadIndexAssetEntity(event.address, reserveAsset, indexEntity.chainID) + let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(reserveAssetEntity.decimals))) + let amount = new BigDecimal(event.params.reserve).div(scalar) + reserveAssetEntity.balance = reserveAssetEntity.balance.plus(amount) + reserveAssetEntity.save() + saveHistoricalData(event.address, event.block.timestamp) +} + +export function handleWithdraw(event: WithdrawEvent): void { + let indexEntity = createOrLoadIndexEntity(event.address) + let reserveAsset = dataSource.context().getBytes('reserveAsset') + let reserveAssetEntity = createOrLoadIndexAssetEntity(event.address, reserveAsset, indexEntity.chainID) + let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(reserveAssetEntity.decimals))) + let amount = new BigDecimal(event.params.reserve).div(scalar) + reserveAssetEntity.balance = reserveAssetEntity.balance.minus(amount) + reserveAssetEntity.save() + let k = indexEntity.k! + if (event.params.k > BigInt.zero()) { + let assetScalar = BigDecimal.fromString("1").minus(new BigDecimal(event.params.k).div(new BigDecimal(k))) + let indexAssets = indexEntity.assets + for (let i = 0; i < indexAssets.length; i++) { + let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexAssets[i]) + let chainIDAssetArray = chainIDToAssetMappingEntity.assets + for (let y = 0; y < chainIDAssetArray.length; y++) { + let indexAssetEntity = loadIndexAssetEntity(chainIDAssetArray[y]) + indexAssetEntity.balance = indexAssetEntity.balance.times(assetScalar) + indexAssetEntity.save() + } + } + indexEntity.k = k.minus(event.params.k) + + indexEntity.save() + } + saveHistoricalData(event.address, event.block.timestamp) +} + +export function handleFeeAccrued(event: FeeAccrued): void { + let indexEntity = createOrLoadIndexEntity(event.address) + let fees = new BigDecimal(event.params.AUMFee.plus(event.params.depositFee).plus(event.params.redemptionFee)) + let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(indexEntity.decimals))) + fees = fees.div(scalar) + indexEntity.totalFees = indexEntity.totalFees!.plus(fees) + indexEntity.save() +} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index fd1483a..f5ec69a 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -89,6 +89,51 @@ dataSources: file: ./src/v2/IndexFactory.ts {{/indexFactory}} {{/v2}} +{{#v3}} +{{#indexFactory}} + - kind: ethereum + name: {{name}} + network: {{network}} + context: + chainID: + type: BigInt + data: "{{chainID}}" + nativeAsset: + type: List + data: + - type: String + data: "{{nativeAsset.name}}" + - type: String + data: "{{nativeAsset.symbol}}" + - type: Int + data: {{nativeAsset.decimals}} + source: + address: "{{address}}" + abi: IndexFactoryV3 + startBlock: {{startBlock}} + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Index + abis: + - name: IndexFactoryV3 + file: ./abis/v3/IndexFactoryV3.json + - name: IndexTokenV3 + file: ./abis/v3/IndexTokenV3.json + - name: AutoGovernance + file: ./abis/v3/AutoGovernanceV3.json + - name: ERC20 + file: ./abis/ERC20.json + - name: MakerERC20 + file: ./abis/v1/MakerERC20.json + eventHandlers: + - event: Deployed(address,string,string,address,address) + handler: handleIndexDeployed + file: ./src/v3/IndexFactory.ts +{{/indexFactory}} +{{/v3}} {{#ephtr}} - kind: ethereum name: ephtr @@ -412,4 +457,84 @@ templates: handler: handleSetLZConfig file: ./src/v2/Messenger.ts -{{/v2}} \ No newline at end of file +{{/v2}} +{{#v3}} + - kind: ethereum + name: IndexTokenV3 + network: {{network}} + source: + abi: IndexTokenV3 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - IndexAsset + - Index + - HistoricalIndexBalances + abis: + - name: IndexTokenV3 + file: ./abis/v3/IndexTokenV3.json + - name: ERC20 + file: ./abis/ERC20.json + - name: MakerERC20 + file: ./abis/v1/MakerERC20.json + eventHandlers: + - event: Deposit(indexed address,indexed address,uint256,uint256) + handler: handleDeposit + - event: Withdraw(indexed address,indexed address,indexed address,uint256,uint256,uint256) + handler: handleWithdraw + - event: FeeAccrued(uint96,uint96,uint96) + handler: handleFeeAccrued + - event: Transfer(indexed address,indexed address,uint256) + handler: handleTransfer + file: ./src/v3/IndexToken.ts + - kind: ethereum + name: ConfigBuilderV3 + network: {{network}} + source: + abi: ConfigBuilderV3 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Index + - IndexAsset + abis: + - name: ConfigBuilderV3 + file: ./abis/v3/ConfigBuilderV3.json + eventHandlers: + - event: ConfigUpdated(bytes) + handler: handleConfigUpdate + - event: CurrencyRegistered(address,string,string,uint8) + handler: handleCurrencyRegistered + - event: FinishVaultRebalancing(uint256,uint256[],address[],uint256[]) + handler: handleFinishChainRebalancing + - event: FinishRebalancing(uint256,uint256[],uint256[]) + handler: handleFinishRebalancing + - event: StartRebalancing() + handler: handleStartRebalancing + file: ./src/v3/ConfigBuilder.ts + - kind: ethereum + name: AutoGovernanceV3 + network: {{network}} + source: + abi: AutoGovernanceV3 + mapping: + kind: ethereum/events + apiVersion: 0.0.7 + language: wasm/assemblyscript + entities: + - Index + abis: + - name: AutoGovernanceV3 + file: ./abis/v3/AutoGovernanceV3.json + - name: ConfigBuilderV3 + file: ./abis/v3/ConfigBuilderV3.json + eventHandlers: + - event: SetConfigBuilder(address) + handler: handleSetConfigBuilder + file: ./src/v3/Governance.ts + +{{/v3}} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..f25db1e --- /dev/null +++ b/yarn.lock @@ -0,0 +1,91 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@graphprotocol/graph-ts@^0.27.0": + version "0.27.0" + resolved "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.27.0.tgz" + integrity sha512-r1SPDIZVQiGMxcY8rhFSM0y7d/xAbQf5vHMWUf59js1KgoyWpM6P3tczZqmQd7JTmeyNsDGIPzd9FeaxllsU4w== + dependencies: + assemblyscript "0.19.10" + +"@graphprotocol/graph-ts@^0.35.0": + version "0.35.1" + resolved "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.35.1.tgz" + integrity sha512-74CfuQmf7JI76/XCC34FTkMMKeaf+3Pn0FIV3m9KNeaOJ+OI3CvjMIVRhOZdKcJxsFCBGaCCl0eQjh47xTjxKA== + dependencies: + assemblyscript "0.19.10" + +assemblyscript@^0.19.20: + version "0.19.23" + resolved "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.23.tgz" + integrity sha512-fwOQNZVTMga5KRsfY80g7cpOl4PsFQczMwHzdtgoqLXaYhkhavufKb0sB0l3T1DUxpAufA0KNhlbpuuhZUwxMA== + dependencies: + binaryen "102.0.0-nightly.20211028" + long "^5.2.0" + source-map-support "^0.5.20" + +assemblyscript@0.19.10: + version "0.19.10" + resolved "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.10.tgz" + integrity sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg== + dependencies: + binaryen "101.0.0-nightly.20210723" + long "^4.0.0" + +binaryen@101.0.0-nightly.20210723: + version "101.0.0-nightly.20210723" + resolved "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz" + integrity sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA== + +binaryen@102.0.0-nightly.20211028: + version "102.0.0-nightly.20211028" + resolved "https://registry.npmjs.org/binaryen/-/binaryen-102.0.0-nightly.20211028.tgz" + integrity sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w== + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +long@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/long/-/long-4.0.0.tgz" + integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== + +long@^5.2.0: + version "5.2.4" + resolved "https://registry.npmjs.org/long/-/long-5.2.4.tgz" + integrity sha512-qtzLbJE8hq7VabR3mISmVGtoXP8KGc2Z/AT8OuqlYD7JTR3oqrgwdjnk07wpj1twXxYmgDXgoKVWUG/fReSzHg== + +matchstick-as@0.5.0: + version "0.5.0" + resolved "https://registry.npmjs.org/matchstick-as/-/matchstick-as-0.5.0.tgz" + integrity sha512-4K619YDH+so129qt4RB4JCNxaFwJJYLXPc7drpG+/mIj86Cfzg6FKs/bA91cnajmS1CLHdhHl9vt6Kd6Oqvfkg== + dependencies: + "@graphprotocol/graph-ts" "^0.27.0" + assemblyscript "^0.19.20" + wabt "1.0.24" + +mustache@^4.2.0: + version "4.2.0" + resolved "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz" + integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== + +source-map-support@^0.5.20: + version "0.5.21" + resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +wabt@1.0.24: + version "1.0.24" + resolved "https://registry.npmjs.org/wabt/-/wabt-1.0.24.tgz" + integrity sha512-8l7sIOd3i5GWfTWciPL0+ff/FK/deVK2Q6FN+MPz4vfUcD78i2M/49XJTwF6aml91uIiuXJEsLKWMB2cw/mtKg== From 10dfc953b389e446ea36084592dcba18324faafb Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Thu, 30 Jan 2025 16:11:34 +0000 Subject: [PATCH 02/13] fix: index-v3 adjustments --- src/v3/ConfigBuilder.ts | 57 +++++++++++++++-------------------------- src/v3/Governance.ts | 2 +- 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index c4174af..7d32247 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -1,6 +1,6 @@ import { Bytes, BigInt, Address, ethereum, dataSource, BigDecimal, log, ByteArray, TypedMap, DataSourceContext } from "@graphprotocol/graph-ts"; import { createOrLoadAnatomyEntity, createOrLoadChainIDToAssetMappingEntity, createOrLoadConfigEntity, createOrLoadCurrencySetEntity, createOrLoadHistoricalIndexAssetEntity, createOrLoadHistoricalIndexBalanceEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity, loadChainIDToAssetMappingEntity, loadIndexAssetEntity } from "../EntityCreation"; -import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishVaultRebalancing as FinishVaultRebalancingEvent, RegisterChain as RegisterChainEvent, FinishRebalancing as FinishRebalancingEvent, StartRebalancing as StartRebalancingEvent } from "../../generated/templates/ConfigBuilderV3/ConfigBuilderV3" +import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishVaultRebalancing as FinishVaultRebalancingEvent, FinishRebalancing as FinishRebalancingEvent, StartRebalancing as StartRebalancingEvent } from "../../generated/templates/ConfigBuilderV3/ConfigBuilderV3" import { convertAUMFeeRate } from "../v1/FeePool"; import { CurrencySet, HistoricalIndexAsset } from "../../generated/schema"; import { Messenger } from "../../generated/templates"; @@ -9,7 +9,7 @@ export function handleConfigUpdate(event: ConfigUpdatedEvent): void { let indexAddress = dataSource.context().getBytes('indexAddress') let indexEntity = createOrLoadIndexEntity(indexAddress) let configEntity = createOrLoadConfigEntity(indexAddress) - let decoded = ethereum.decode('((uint256,bool,address),(uint16,bool),(uint16,bool))', event.params.param0)!.toTuple() + let decoded = ethereum.decode('((uint256,bool,address),(uint16,bool),(uint16,bool))', event.params.encodedConfig)!.toTuple() configEntity.AUMDilutionPerSecond = decoded[0].toTuple()[0].toBigInt() configEntity.useCustomAUMFee = decoded[0].toTuple()[1].toBoolean() configEntity.metadata = decoded[0].toTuple()[2].toAddress() @@ -37,9 +37,10 @@ export function handleStartRebalancing(event: StartRebalancingEvent): void { export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { let indexAddress = dataSource.context().getBytes('indexAddress') - log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), event.params.chainId.toString()]) - let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, event.params.currency, event.params.chainId) - let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, event.params.chainId) + let chainID = dataSource.context().getBigInt('chainID') + log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), chainID.toString()]) + let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, event.params.currency, chainID) + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) indexAssetEntity.name = event.params.name indexAssetEntity.symbol = event.params.symbol indexAssetEntity.decimals = event.params.decimals @@ -55,7 +56,8 @@ export function handleFinishChainRebalancing(event: FinishVaultRebalancingEvent) let indexAddress = dataSource.context().getBytes('indexAddress') let reserveAsset = dataSource.context().getBytes('reserveAsset') let indexEntity = createOrLoadIndexEntity(indexAddress) - let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, event.params.chainId) + let chainID = dataSource.context().getBigInt('chainID') + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) chainIDToAssetMappingEntity.latestSnapshot = event.params.snapshot if (event.params.currencies.length == 0) { for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { @@ -65,13 +67,13 @@ export function handleFinishChainRebalancing(event: FinishVaultRebalancingEvent) indexAssetEntity.save() } let emptyAssetArray: string[] = [] - if (event.params.chainId == indexEntity.chainID) { + if (chainID == indexEntity.chainID) { emptyAssetArray.push(createOrLoadIndexAssetEntity(indexAddress, reserveAsset, indexEntity.chainID).id) } chainIDToAssetMappingEntity.assets = emptyAssetArray chainIDToAssetMappingEntity.save() - if (event.params.chainId != indexEntity.chainID) { + if (chainID != indexEntity.chainID) { let indexAssets = indexEntity.assets let idx = indexAssets.indexOf(chainIDToAssetMappingEntity.id) indexAssets.splice(idx, 1) @@ -82,14 +84,15 @@ export function handleFinishChainRebalancing(event: FinishVaultRebalancingEvent) } else { let chainIDAssetArray: string[] = [] let reserveAssetEntity = createOrLoadIndexAssetEntity(indexAddress, reserveAsset, indexEntity.chainID) - if (event.params.chainId == indexEntity.chainID) { + if (chainID == indexEntity.chainID) { reserveAssetEntity.balance = BigDecimal.zero() reserveAssetEntity.save() chainIDAssetArray.push(reserveAssetEntity.id) } for (let i = 0; i < event.params.currencies.length; i++) { - let balance = new BigDecimal(event.params.currencies[i].rightShift(160)) - let asset = event.params.currencies[i].bitAnd(BigInt.fromI32(2).pow(160).minus(BigInt.fromI32(1))).toHex() + // let balance = new BigDecimal(event.params.currencies[i].rightShift(160)) + let balance = new BigDecimal(event.params.balances[i]) + let asset = event.params.currencies[i].toString() log.debug("{}", [asset]) let assetConverted: Bytes log.debug("{} length = {}", [asset, asset.length.toString()]) @@ -99,8 +102,8 @@ export function handleFinishChainRebalancing(event: FinishVaultRebalancingEvent) else { assetConverted = Address.fromHexString('0x'.concat("0".repeat(42 - asset.length)).concat(asset.slice(2))) } - log.debug("decoded asset = {}, decoded balance {}, chainID {}", [assetConverted.toHexString(), balance.toString(), event.params.chainId.toString()]) - let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, assetConverted, event.params.chainId) + log.debug("decoded asset = {}, decoded balance {}, chainID {}", [assetConverted.toHexString(), balance.toString(), chainID.toString()]) + let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, assetConverted, chainID) let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(indexAssetEntity.decimals))) indexAssetEntity.balance = balance.div(scalar) indexAssetEntity.save() @@ -134,16 +137,6 @@ export function handleFinishChainRebalancing(event: FinishVaultRebalancingEvent) saveHistoricalData(indexAddress, event.block.timestamp) } -export function handleRegisterChain(event: RegisterChainEvent): void { - let indexAddress = dataSource.context().getBytes('indexAddress') - let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, event.params.chainId) - chainIDToAssetMappingEntity.chainIndex = event.params.chainIndex - chainIDToAssetMappingEntity.latestSnapshot = BigInt.zero() - chainIDToAssetMappingEntity.registeredAssets = BigInt.zero() - chainIDToAssetMappingEntity.save() - -} - export function saveHistoricalData(index: Bytes, timestamp: BigInt): void { let indexEntity = createOrLoadIndexEntity(index) let historicalIndexBalanceEntity = createOrLoadHistoricalIndexBalanceEntity(index, timestamp) @@ -173,21 +166,15 @@ export function handleFinishRebalancing(event: FinishRebalancingEvent): void { let indexEntity = createOrLoadIndexEntity(indexAddress) let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) let anatomyArray: string[] = [] - let chainIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newAnatomy.chainIdSet)) - log.debug(" chain index array {}", [chainIndexArray.toString()]) + let chainID = dataSource.context().getBigInt('chainID') let count = 0 - for (let i = 0; i < chainIndexArray.length; i++) { - let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, chainIndexArray[i]) - currencySetEntity.sets = event.params.newAnatomy.currencyIdSets[i] - currencySetEntity.save() - anatomyArray.push(currencySetEntity.id) + - let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newAnatomy.currencyIdSets[i])) - log.debug("Currency index array output {} for chain index {}", [currencyIndexArray.toString(), chainIndexArray[i].toString()]) + let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newCurrencyIdSet)) + log.debug("Currency index array output {} for chain index {}", [currencyIndexArray.toString(), chainID.toString()]) for (let y = 0; y < indexEntity.assets.length; y++) { let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) let chainIndex = chainIDToAssetMappingEntity.chainIndex - if (chainIndex && chainIndex == chainIndexArray[i]) { while (currencyIndexArray.length > 0) { for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) @@ -206,11 +193,9 @@ export function handleFinishRebalancing(event: FinishRebalancingEvent): void { } } break - } } - } indexEntity.isRebalancing = false - anatomyEntity.chainIdSet = event.params.newAnatomy.chainIdSet + anatomyEntity.chainIdSet = [chainID] anatomyEntity.currencyIdSets = anatomyArray anatomyEntity.save() indexEntity.save() diff --git a/src/v3/Governance.ts b/src/v3/Governance.ts index 1fa01b7..36dc8b1 100644 --- a/src/v3/Governance.ts +++ b/src/v3/Governance.ts @@ -1,5 +1,5 @@ import { DataSourceContext, dataSource } from "@graphprotocol/graph-ts" -import { ConfigBuilderV3 as ConfigBuilderTemplate } from "../../generated/templates/ConfigBuilderV3/ConfigBuilderV3" +import { ConfigBuilderV3 as ConfigBuilderTemplate } from "../../generated/templates" import { SetConfigBuilder as SetConfigbuilderEvent } from "../../generated/templates/AutoGovernanceV3/AutoGovernanceV3" From e466f77b51c23228099fcf22d3b6f761a3e1b3d9 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Thu, 30 Jan 2025 16:20:31 +0000 Subject: [PATCH 03/13] fix: issue --- src/v3/ConfigBuilder.ts | 1 - src/v3/IndexFactory.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index 7d32247..a4cd04d 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -90,7 +90,6 @@ export function handleFinishChainRebalancing(event: FinishVaultRebalancingEvent) chainIDAssetArray.push(reserveAssetEntity.id) } for (let i = 0; i < event.params.currencies.length; i++) { - // let balance = new BigDecimal(event.params.currencies[i].rightShift(160)) let balance = new BigDecimal(event.params.balances[i]) let asset = event.params.currencies[i].toString() log.debug("{}", [asset]) diff --git a/src/v3/IndexFactory.ts b/src/v3/IndexFactory.ts index 0547526..2c8f40d 100644 --- a/src/v3/IndexFactory.ts +++ b/src/v3/IndexFactory.ts @@ -20,7 +20,7 @@ export function handleIndexDeployed(event: DeployedEvent): void { index.symbol = event.params.symbol index.decimals = indexContract.decimals() index.chainID = chainID - index.version = "v2" + index.version = "v3" index.creationDate = event.block.timestamp index.k = BigInt.fromI32(1).times(BigInt.fromI32(10).pow(18)) index.totalFees = BigDecimal.zero() From f0855f355d656d413e533cb6df7537e9b7ce48b1 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Thu, 30 Jan 2025 16:22:36 +0000 Subject: [PATCH 04/13] fix: readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..65b9e8a --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# base-index-test + +1. Install node packages +2. Generate types and classes `npm run init` +3. Run `npm run prepare:` to create a subgraph manifest specifically for the deployment chain +4. Deploy subgraph to your studio or hosted service account From c2e011f81123775249f4cc94d5b3384dcf67d4a6 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Thu, 30 Jan 2025 16:22:36 +0000 Subject: [PATCH 05/13] fix: readme --- README.md | 6 + abis/v3/AutoGovernanceV3.json | 1085 --------------------------------- abis/v3/ConfigBuilderV3.json | 886 +-------------------------- abis/v3/IndexFactoryV3.json | 54 -- abis/v3/IndexTokenV3.json | 1020 +------------------------------ src/utils.ts | 36 ++ src/v3/ConfigBuilder.ts | 95 +-- src/v3/Governance.ts | 13 - src/v3/IndexFactory.ts | 14 +- src/v3/IndexToken.ts | 17 +- subgraph.template.yaml | 26 +- yarn.lock | 91 --- 12 files changed, 116 insertions(+), 3227 deletions(-) create mode 100644 README.md delete mode 100644 abis/v3/AutoGovernanceV3.json create mode 100644 src/utils.ts delete mode 100644 src/v3/Governance.ts delete mode 100644 yarn.lock diff --git a/README.md b/README.md new file mode 100644 index 0000000..65b9e8a --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# base-index-test + +1. Install node packages +2. Generate types and classes `npm run init` +3. Run `npm run prepare:` to create a subgraph manifest specifically for the deployment chain +4. Deploy subgraph to your studio or hosted service account diff --git a/abis/v3/AutoGovernanceV3.json b/abis/v3/AutoGovernanceV3.json deleted file mode 100644 index 4b7e66d..0000000 --- a/abis/v3/AutoGovernanceV3.json +++ /dev/null @@ -1,1085 +0,0 @@ -{ - "abi": [ - { - "type": "function", - "name": "NAME_HASH", - "inputs": [], - "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], - "stateMutability": "pure" - }, - { - "type": "function", - "name": "finishMint", - "inputs": [ - { - "name": "configBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "params", - "type": "tuple", - "internalType": "struct IVault.EndRebalancingParams", - "components": [ - { - "name": "anatomyCurrencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "anatomyBalances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "newAnatomy", - "type": "tuple", - "internalType": "struct IVault.SnapshotAnatomy", - "components": [ - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "currencyIndexSet", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "withdrawals", - "type": "tuple", - "internalType": "struct IVault.CurrencyWithdrawal", - "components": [ - { - "name": "currencyIndexSet", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "amounts", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "lastKBalance", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - } - ] - } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "finishRebalancing", - "inputs": [ - { "name": "index", "type": "address", "internalType": "address" }, - { - "name": "configBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "result", - "type": "tuple", - "internalType": "struct IVault.RebalancingResult", - "components": [ - { - "name": "snapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencyIdSet", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "config", - "type": "tuple", - "internalType": "struct IConfigBuilder.Config", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IConfigBuilder.SharedConfig", - "components": [ - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "redemptionFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - }, - { - "name": "currentConfig", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { "name": "payload", "type": "bytes", "internalType": "bytes" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "finishRebalancingAuto", - "inputs": [ - { "name": "index", "type": "address", "internalType": "address" }, - { - "name": "configBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "result", - "type": "tuple", - "internalType": "struct IVault.RebalancingResult", - "components": [ - { - "name": "snapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencyIdSet", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "config", - "type": "tuple", - "internalType": "struct IConfigBuilder.Config", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IConfigBuilder.SharedConfig", - "components": [ - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "redemptionFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - }, - { - "name": "currentConfig", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { "name": "payload", "type": "bytes", "internalType": "bytes" }, - { - "name": "sigs", - "type": "tuple[]", - "internalType": "struct GovernanceSignatureChecker.Signature[]", - "components": [ - { "name": "r", "type": "bytes32", "internalType": "bytes32" }, - { "name": "vs", "type": "bytes32", "internalType": "bytes32" }, - { "name": "signer", "type": "address", "internalType": "address" } - ] - }, - { "name": "deadline", "type": "uint256", "internalType": "uint256" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "initialize", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "isAuthorized", - "inputs": [ - { "name": "selector", "type": "bytes4", "internalType": "bytes4" }, - { "name": "signer", "type": "address", "internalType": "address" } - ], - "outputs": [{ "name": "auth", "type": "bool", "internalType": "bool" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "migrateConfig", - "inputs": [ - { - "name": "newConfigBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "state", - "type": "tuple", - "internalType": "struct IConfigMigration.State", - "components": [ - { - "name": "weights", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencyIdSet", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "configHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "currenciesHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "resultHash", - "type": "bytes32", - "internalType": "bytes32" - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "minSignersCount", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "nonce", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "proxiableUUID", - "inputs": [], - "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "registerCurrencies", - "inputs": [ - { "name": "index", "type": "address", "internalType": "address" }, - { - "name": "configBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setAllowed", - "inputs": [ - { "name": "router", "type": "address", "internalType": "address" }, - { "name": "account", "type": "address", "internalType": "address" }, - { "name": "allowed", "type": "bool", "internalType": "bool" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setConfig", - "inputs": [ - { - "name": "configBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "baseConfig", - "type": "tuple", - "internalType": "struct IConfigBuilder.Config", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IConfigBuilder.SharedConfig", - "components": [ - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "redemptionFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setConfigBuilder", - "inputs": [ - { "name": "target", "type": "address", "internalType": "address" }, - { "name": "router", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setEscrowDeployer", - "inputs": [ - { "name": "router", "type": "address", "internalType": "address" }, - { - "name": "escrowDeployer", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setFeePool", - "inputs": [ - { "name": "index", "type": "address", "internalType": "address" }, - { "name": "feePool", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setInitialConfig", - "inputs": [ - { "name": "index", "type": "address", "internalType": "address" }, - { - "name": "configBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "baseConfig", - "type": "tuple", - "internalType": "struct IConfigBuilder.Config", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IConfigBuilder.SharedConfig", - "components": [ - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "redemptionFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setIsSigner", - "inputs": [ - { "name": "selectors", "type": "bytes4[]", "internalType": "bytes4[]" }, - { "name": "signer", "type": "address", "internalType": "address" }, - { "name": "value", "type": "bool", "internalType": "bool" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setMaxSlippageInBP", - "inputs": [ - { "name": "orderBook", "type": "address", "internalType": "address" }, - { - "name": "maxSlippageInBP", - "type": "uint16", - "internalType": "uint16" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setMinSignersCount", - "inputs": [ - { "name": "value", "type": "uint256", "internalType": "uint256" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setPriceOracle", - "inputs": [ - { "name": "orderBook", "type": "address", "internalType": "address" }, - { "name": "priceOracle", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setPriceOracleDeployer", - "inputs": [ - { - "name": "configBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "priceOracleDeployer", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setPriceSourceMapper", - "inputs": [ - { - "name": "priceOracleDeployer", - "type": "address", - "internalType": "address" - }, - { "name": "mapper", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setRebalancer", - "inputs": [ - { "name": "vault", "type": "address", "internalType": "address" }, - { "name": "rebalancer", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setSequencerUptimeFeed", - "inputs": [ - { - "name": "priceOracleDeployer", - "type": "address", - "internalType": "address" - }, - { "name": "feed", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "startIndexRebalancing", - "inputs": [ - { "name": "index", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "startIndexRebalancingAuto", - "inputs": [ - { "name": "index", "type": "address", "internalType": "address" }, - { - "name": "sigs", - "type": "tuple[]", - "internalType": "struct GovernanceSignatureChecker.Signature[]", - "components": [ - { "name": "r", "type": "bytes32", "internalType": "bytes32" }, - { "name": "vs", "type": "bytes32", "internalType": "bytes32" }, - { "name": "signer", "type": "address", "internalType": "address" } - ] - }, - { "name": "deadline", "type": "uint256", "internalType": "uint256" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferContractOwnership", - "inputs": [ - { "name": "owned", "type": "address", "internalType": "address" }, - { "name": "newOwner", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { "name": "newOwner", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "updateConfig", - "inputs": [ - { "name": "index", "type": "address", "internalType": "address" }, - { - "name": "configBuilder", - "type": "address", - "internalType": "address" - }, - { - "name": "prevConfig", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "baseConfig", - "type": "tuple", - "internalType": "struct IConfigBuilder.Config", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IConfigBuilder.SharedConfig", - "components": [ - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "redemptionFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "updateFundManager", - "inputs": [ - { "name": "orderBook", "type": "address", "internalType": "address" }, - { "name": "fundManager", "type": "address", "internalType": "address" }, - { "name": "isAllowed", "type": "bool", "internalType": "bool" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeTo", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeToAndCall", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - }, - { "name": "data", "type": "bytes", "internalType": "bytes" } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "withdrawCurrency", - "inputs": [ - { "name": "router", "type": "address", "internalType": "address" }, - { "name": "currency", "type": "address", "internalType": "Currency" }, - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "amount", "type": "uint256", "internalType": "uint256" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "event", - "name": "AdminChanged", - "inputs": [ - { - "name": "previousAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - }, - { - "name": "newAdmin", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "BeaconUpgraded", - "inputs": [ - { - "name": "beacon", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Initialized", - "inputs": [ - { - "name": "version", - "type": "uint8", - "indexed": false, - "internalType": "uint8" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "previousOwner", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "SetConfigBuilder", - "inputs": [ - { - "name": "", - "type": "address", - "indexed": false, - "internalType": "address" - } - ], - "anonymous": false - }, - { - "type": "event", - "name": "Upgraded", - "inputs": [ - { - "name": "implementation", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false - }, - { "type": "error", "name": "Expired", "inputs": [] }, - { "type": "error", "name": "Forbidden", "inputs": [] }, - { "type": "error", "name": "InsufficientUniqueSigners", "inputs": [] }, - { "type": "error", "name": "InvalidSigner", "inputs": [] } - ] -} diff --git a/abis/v3/ConfigBuilderV3.json b/abis/v3/ConfigBuilderV3.json index 12026e7..68d0f80 100644 --- a/abis/v3/ConfigBuilderV3.json +++ b/abis/v3/ConfigBuilderV3.json @@ -1,883 +1,5 @@ { "abi": [ - { - "type": "constructor", - "inputs": [ - { "name": "_governance", "type": "address", "internalType": "address" }, - { "name": "_forwarder", "type": "address", "internalType": "address" }, - { - "name": "_priceOracleDeployer", - "type": "address", - "internalType": "address" - }, - { "name": "_index", "type": "address", "internalType": "address" }, - { - "name": "_nativeInfo", - "type": "tuple", - "internalType": "struct ConfigBuilder.NativeInfo", - "components": [ - { "name": "name", "type": "string", "internalType": "string" }, - { "name": "symbol", "type": "string", "internalType": "string" }, - { "name": "decimals", "type": "uint8", "internalType": "uint8" } - ] - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "configHash", - "inputs": [], - "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "configs", - "inputs": [ - { - "name": "config", - "type": "tuple", - "internalType": "struct IConfigBuilder.Config", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IConfigBuilder.SharedConfig", - "components": [ - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "redemptionFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - } - ], - "outputs": [ - { - "name": "deposit", - "type": "tuple", - "internalType": "struct IIndex.DepositConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - }, - { - "name": "redemption", - "type": "tuple", - "internalType": "struct IIndex.RedemptionConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "currenciesUpdated", - "inputs": [ - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "newCurrenciesHash", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "finishMint", - "inputs": [ - { - "name": "params", - "type": "tuple", - "internalType": "struct IVault.EndRebalancingParams", - "components": [ - { - "name": "anatomyCurrencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "anatomyBalances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "newAnatomy", - "type": "tuple", - "internalType": "struct IVault.SnapshotAnatomy", - "components": [ - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "currencyIndexSet", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "withdrawals", - "type": "tuple", - "internalType": "struct IVault.CurrencyWithdrawal", - "components": [ - { - "name": "currencyIndexSet", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "amounts", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "lastKBalance", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "finishRebalancing", - "inputs": [ - { - "name": "vaultResult", - "type": "tuple", - "internalType": "struct IVault.RebalancingResult", - "components": [ - { - "name": "snapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencyIdSet", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "config", - "type": "tuple", - "internalType": "struct IConfigBuilder.Config", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IConfigBuilder.SharedConfig", - "components": [ - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "redemptionFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - }, - { "name": "payload", "type": "bytes", "internalType": "bytes" } - ], - "outputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct IIndex.DepositConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - }, - { - "name": "", - "type": "tuple", - "internalType": "struct IIndex.RedemptionConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "forwarder", - "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "getState", - "inputs": [], - "outputs": [ - { - "name": "state", - "type": "tuple", - "internalType": "struct IConfigMigration.State", - "components": [ - { - "name": "weights", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencyIdSet", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "configHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "currenciesHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "resultHash", - "type": "bytes32", - "internalType": "bytes32" - } - ] - } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "governance", - "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "index", - "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "setConfig", - "inputs": [ - { - "name": "_config", - "type": "tuple", - "internalType": "struct IConfigBuilder.Config", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IConfigBuilder.SharedConfig", - "components": [ - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "depositFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "redemptionFee", - "type": "tuple", - "internalType": "struct IConfigBuilder.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - } - ], - "outputs": [ - { - "name": "deposit", - "type": "tuple", - "internalType": "struct IIndex.DepositConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - }, - { - "name": "redemption", - "type": "tuple", - "internalType": "struct IIndex.RedemptionConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setForwarder", - "inputs": [ - { "name": "_forwarder", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setPriceOracleDeployer", - "inputs": [ - { - "name": "_priceOracleDeployer", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setState", - "inputs": [ - { - "name": "", - "type": "tuple", - "internalType": "struct IConfigMigration.State", - "components": [ - { - "name": "weights", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencyIdSet", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "configHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "currenciesHash", - "type": "bytes32", - "internalType": "bytes32" - }, - { - "name": "resultHash", - "type": "bytes32", - "internalType": "bytes32" - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, { "type": "event", "name": "ConfigUpdated", @@ -1022,12 +144,6 @@ "name": "StartRebalancing", "inputs": [], "anonymous": false - }, - { "type": "error", "name": "ConfigHash", "inputs": [] }, - { "type": "error", "name": "Forbidden", "inputs": [] }, - { "type": "error", "name": "Invalid", "inputs": [] }, - { "type": "error", "name": "QueryFailed", "inputs": [] }, - { "type": "error", "name": "ReserveMissed", "inputs": [] }, - { "type": "error", "name": "ResultHash", "inputs": [] } + } ] } diff --git a/abis/v3/IndexFactoryV3.json b/abis/v3/IndexFactoryV3.json index e7136fb..2ecc3c7 100644 --- a/abis/v3/IndexFactoryV3.json +++ b/abis/v3/IndexFactoryV3.json @@ -1,40 +1,5 @@ { "abi": [ - { - "type": "function", - "name": "deploy", - "inputs": [ - { - "name": "implementation", - "type": "address", - "internalType": "address" - }, - { "name": "name", "type": "string", "internalType": "string" }, - { "name": "symbol", "type": "string", "internalType": "string" }, - { "name": "reserve", "type": "address", "internalType": "Currency" }, - { "name": "gov", "type": "address", "internalType": "address" } - ], - "outputs": [ - { "name": "index", "type": "address", "internalType": "address" } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { "name": "newOwner", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, { "type": "event", "name": "Deployed", @@ -71,25 +36,6 @@ } ], "anonymous": false - }, - { - "type": "event", - "name": "OwnershipTransferred", - "inputs": [ - { - "name": "user", - "type": "address", - "indexed": true, - "internalType": "address" - }, - { - "name": "newOwner", - "type": "address", - "indexed": true, - "internalType": "address" - } - ], - "anonymous": false } ] } diff --git a/abis/v3/IndexTokenV3.json b/abis/v3/IndexTokenV3.json index 2f225c7..5874cdb 100644 --- a/abis/v3/IndexTokenV3.json +++ b/abis/v3/IndexTokenV3.json @@ -1,913 +1,5 @@ { "abi": [ - { - "type": "constructor", - "inputs": [ - { - "name": "_maxDepositFeeInBPs", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "_maxRedemptionFeeInBPs", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "_maxAUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - } - ], - "stateMutability": "nonpayable" - }, - { "type": "receive", "stateMutability": "payable" }, - { - "type": "function", - "name": "DOMAIN_SEPARATOR", - "inputs": [], - "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "accrueFee", - "inputs": [ - { "name": "recipient", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "allowance", - "inputs": [ - { "name": "", "type": "address", "internalType": "address" }, - { "name": "", "type": "address", "internalType": "address" } - ], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "approve", - "inputs": [ - { "name": "spender", "type": "address", "internalType": "address" }, - { "name": "amount", "type": "uint256", "internalType": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "balanceOf", - "inputs": [{ "name": "", "type": "address", "internalType": "address" }], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "consume", - "inputs": [ - { "name": "currency", "type": "address", "internalType": "Currency" }, - { "name": "amount", "type": "uint256", "internalType": "uint256" }, - { "name": "target", "type": "address", "internalType": "address" }, - { "name": "data", "type": "bytes", "internalType": "bytes" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "decimals", - "inputs": [], - "outputs": [{ "name": "", "type": "uint8", "internalType": "uint8" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "deposit", - "inputs": [ - { - "name": "params", - "type": "tuple", - "internalType": "struct IIndex.DepositParams", - "components": [ - { - "name": "config", - "type": "tuple", - "internalType": "struct IIndex.DepositConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { - "name": "BPs", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - }, - { - "name": "recipient", - "type": "address", - "internalType": "address" - }, - { "name": "payload", "type": "bytes", "internalType": "bytes" } - ] - }, - { "name": "cbTarget", "type": "address", "internalType": "address" }, - { "name": "cbData", "type": "bytes", "internalType": "bytes" } - ], - "outputs": [ - { "name": "shares", "type": "uint256", "internalType": "uint256" } - ], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "donate", - "inputs": [ - { "name": "currency", "type": "address", "internalType": "Currency" }, - { "name": "data", "type": "bytes", "internalType": "bytes" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "extsload", - "inputs": [ - { "name": "slot", "type": "bytes32", "internalType": "bytes32" } - ], - "outputs": [ - { "name": "value", "type": "bytes32", "internalType": "bytes32" } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "extsload", - "inputs": [ - { "name": "slots", "type": "bytes32[]", "internalType": "bytes32[]" } - ], - "outputs": [ - { "name": "", "type": "bytes32[]", "internalType": "bytes32[]" } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "fees", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "finishRebalancingPhase", - "inputs": [ - { - "name": "params", - "type": "tuple", - "internalType": "struct IVault.EndRebalancingParams", - "components": [ - { - "name": "anatomyCurrencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "anatomyBalances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "newAnatomy", - "type": "tuple", - "internalType": "struct IVault.SnapshotAnatomy", - "components": [ - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "currencyIndexSet", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "withdrawals", - "type": "tuple", - "internalType": "struct IVault.CurrencyWithdrawal", - "components": [ - { - "name": "currencyIndexSet", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "amounts", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "lastKBalance", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - } - ] - } - ], - "outputs": [ - { "name": "resultHash", "type": "bytes32", "internalType": "bytes32" } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "initialize", - "inputs": [ - { "name": "_name", "type": "string", "internalType": "string" }, - { "name": "_symbol", "type": "string", "internalType": "string" }, - { "name": "_reserve", "type": "address", "internalType": "Currency" }, - { "name": "_governance", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "initialize", - "inputs": [ - { "name": "_owner", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "kBalanceWads", - "inputs": [ - { "name": "", "type": "uint256", "internalType": "uint256" }, - { "name": "", "type": "address", "internalType": "address" } - ], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "kSelf", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "mint", - "inputs": [ - { - "name": "withdrawals", - "type": "tuple", - "internalType": "struct IVault.CurrencyWithdrawal", - "components": [ - { - "name": "currencyIndexSet", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "amounts", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { "name": "amounts", "type": "uint256[]", "internalType": "uint256[]" }, - { "name": "recipient", "type": "address", "internalType": "address" }, - { "name": "shares", "type": "uint128", "internalType": "uint128" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [{ "name": "", "type": "string", "internalType": "string" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "nonces", - "inputs": [{ "name": "", "type": "address", "internalType": "address" }], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "owner", - "inputs": [], - "outputs": [{ "name": "", "type": "address", "internalType": "address" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "permit", - "inputs": [ - { "name": "owner", "type": "address", "internalType": "address" }, - { "name": "spender", "type": "address", "internalType": "address" }, - { "name": "value", "type": "uint256", "internalType": "uint256" }, - { "name": "deadline", "type": "uint256", "internalType": "uint256" }, - { "name": "v", "type": "uint8", "internalType": "uint8" }, - { "name": "r", "type": "bytes32", "internalType": "bytes32" }, - { "name": "s", "type": "bytes32", "internalType": "bytes32" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "proxiableUUID", - "inputs": [], - "outputs": [{ "name": "", "type": "bytes32", "internalType": "bytes32" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "redeem", - "inputs": [ - { - "name": "params", - "type": "tuple", - "internalType": "struct IIndex.RedemptionParams", - "components": [ - { - "name": "config", - "type": "tuple", - "internalType": "struct IIndex.RedemptionConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { - "name": "BPs", - "type": "uint16", - "internalType": "uint16" - }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - }, - { "name": "owner", "type": "address", "internalType": "address" }, - { "name": "shares", "type": "uint128", "internalType": "uint128" }, - { "name": "payload", "type": "bytes", "internalType": "bytes" } - ] - }, - { - "name": "forwardedSender", - "type": "address", - "internalType": "address" - }, - { "name": "recipient", "type": "address", "internalType": "address" } - ], - "outputs": [ - { - "name": "result", - "type": "tuple", - "internalType": "struct IIndex.RedemptionInfo", - "components": [ - { - "name": "reserveValuation", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "totalValuation", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "totalReserveShares", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "totalSupplyAfterAUMAccrual", - "type": "uint128", - "internalType": "uint128" - }, - { - "name": "totalKBeforeRedeem", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "accountBalanceSharesBeforeRedeem", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "accountReserveRedeemed", - "type": "uint96", - "internalType": "uint96" - }, - { - "name": "accountReserveSharesRedeemed", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "accountKRedeemed", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "reservePriceInQ128", - "type": "uint256", - "internalType": "uint256" - } - ] - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "registerCurrencies", - "inputs": [ - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - } - ], - "outputs": [ - { - "name": "currenciesHash", - "type": "bytes32", - "internalType": "bytes32" - } - ], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "renounceOwnership", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "reserve", - "inputs": [], - "outputs": [ - { "name": "", "type": "address", "internalType": "Currency" } - ], - "stateMutability": "view" - }, - { - "type": "function", - "name": "reserveBalance", - "inputs": [], - "outputs": [{ "name": "", "type": "uint96", "internalType": "uint96" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "setConfig", - "inputs": [ - { - "name": "_prevConfig", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "_depositConfig", - "type": "tuple", - "internalType": "struct IIndex.DepositConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - } - ] - }, - { - "name": "_redemptionConfig", - "type": "tuple", - "internalType": "struct IIndex.RedemptionConfig", - "components": [ - { - "name": "shared", - "type": "tuple", - "internalType": "struct IIndex.Config", - "components": [ - { - "name": "latestSnapshot", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "AUMDilutionPerSecond", - "type": "uint256", - "internalType": "uint256" - }, - { - "name": "useCustomAUMFee", - "type": "bool", - "internalType": "bool" - }, - { - "name": "staticPriceOracle", - "type": "address", - "internalType": "address" - }, - { - "name": "metadata", - "type": "address", - "internalType": "address" - }, - { - "name": "forwarder", - "type": "address", - "internalType": "address" - } - ] - }, - { - "name": "fee", - "type": "tuple", - "internalType": "struct IIndex.FeeConfig", - "components": [ - { "name": "BPs", "type": "uint16", "internalType": "uint16" }, - { - "name": "useCustomCallback", - "type": "bool", - "internalType": "bool" - } - ] - }, - { - "name": "currencies", - "type": "address[]", - "internalType": "Currency[]" - }, - { - "name": "balances", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setConfigBuilder", - "inputs": [ - { - "name": "_configBuilder", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setFeePool", - "inputs": [ - { "name": "_feePool", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "setRebalancer", - "inputs": [ - { "name": "_rebalancer", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "startIndexRebalancing", - "inputs": [], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "startRebalancingPhase", - "inputs": [ - { - "name": "withdrawals", - "type": "tuple", - "internalType": "struct IVault.CurrencyWithdrawal", - "components": [ - { - "name": "currencyIndexSet", - "type": "uint256[]", - "internalType": "uint256[]" - }, - { - "name": "amounts", - "type": "uint256[]", - "internalType": "uint256[]" - } - ] - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "symbol", - "inputs": [], - "outputs": [{ "name": "", "type": "string", "internalType": "string" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "totalSupply", - "inputs": [], - "outputs": [{ "name": "", "type": "uint256", "internalType": "uint256" }], - "stateMutability": "view" - }, - { - "type": "function", - "name": "transfer", - "inputs": [ - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "amount", "type": "uint256", "internalType": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferFrom", - "inputs": [ - { "name": "from", "type": "address", "internalType": "address" }, - { "name": "to", "type": "address", "internalType": "address" }, - { "name": "amount", "type": "uint256", "internalType": "uint256" } - ], - "outputs": [{ "name": "", "type": "bool", "internalType": "bool" }], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "transferOwnership", - "inputs": [ - { "name": "newOwner", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeTo", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, - { - "type": "function", - "name": "upgradeToAndCall", - "inputs": [ - { - "name": "newImplementation", - "type": "address", - "internalType": "address" - }, - { "name": "data", "type": "bytes", "internalType": "bytes" } - ], - "outputs": [], - "stateMutability": "payable" - }, - { - "type": "function", - "name": "withdraw", - "inputs": [ - { "name": "snapshot", "type": "uint256", "internalType": "uint256" }, - { "name": "kAmount", "type": "uint256", "internalType": "uint256" }, - { "name": "recipient", "type": "address", "internalType": "address" } - ], - "outputs": [], - "stateMutability": "nonpayable" - }, { "type": "event", "name": "AdminChanged", @@ -1142,6 +234,32 @@ ], "anonymous": false }, + { + "type": "event", + "name": "SetConfigBuilder", + "inputs": [ + { + "name": "configBuilder", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "SetRebalancer", + "inputs": [ + { + "name": "rebalancer", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, { "type": "event", "name": "SnapshotTransfer", @@ -1290,90 +408,6 @@ } ], "anonymous": false - }, - { "type": "error", "name": "CurrenciesHashMismatch", "inputs": [] }, - { "type": "error", "name": "ERC20TransferFailed", "inputs": [] }, - { - "type": "error", - "name": "ExcessNewAnatomyCurrencyIndex", - "inputs": [ - { - "name": "currencyIndex", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { "type": "error", "name": "FeeExceedsMaxFee", "inputs": [] }, - { "type": "error", "name": "Forbidden", "inputs": [] }, - { "type": "error", "name": "HashMismatch", "inputs": [] }, - { "type": "error", "name": "IndexConfigHash", "inputs": [] }, - { "type": "error", "name": "IndexConfigMismatch", "inputs": [] }, - { "type": "error", "name": "IndexInitialConfig", "inputs": [] }, - { "type": "error", "name": "InvalidSender", "inputs": [] }, - { "type": "error", "name": "InvalidSigner", "inputs": [] }, - { "type": "error", "name": "InvalidWithdrawal", "inputs": [] }, - { "type": "error", "name": "NativeTransferFailed", "inputs": [] }, - { - "type": "error", - "name": "NewAnatomyCurrencyCountMismatch", - "inputs": [ - { - "name": "expectedCount", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "NewAnatomyCurrencyIndexNotFound", - "inputs": [ - { - "name": "currencyIndex", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "NewAnatomyCurrencyIndexSetSizeMismatch", - "inputs": [ - { - "name": "expectedCount", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { - "type": "error", - "name": "NewAnatomyCurrencyMismatch", - "inputs": [ - { - "name": "expectedCurrency", - "type": "address", - "internalType": "Currency" - }, - { - "name": "expectedBalance", - "type": "uint256", - "internalType": "uint256" - } - ] - }, - { "type": "error", "name": "PermitDeadlineExpired", "inputs": [] }, - { "type": "error", "name": "Rebalancing", "inputs": [] }, - { - "type": "error", - "name": "Registered", - "inputs": [ - { "name": "currency", "type": "address", "internalType": "Currency" } - ] - }, - { "type": "error", "name": "ZeroAddressTransfer", "inputs": [] }, - { "type": "error", "name": "ZeroDeposit", "inputs": [] }, - { "type": "error", "name": "ZeroShares", "inputs": [] } + } ] } diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..5aeca61 --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,36 @@ +import { BigInt, TypedMap } from "@graphprotocol/graph-ts"; + +let chainIDMap = new TypedMap>() +chainIDMap.set(BigInt.fromI32(43114), ["Avalanche", "AVAX", "18"]) +chainIDMap.set(BigInt.fromI32(43113), ["Avalanche", "AVAX", "18"]) +chainIDMap.set(BigInt.fromI32(80001), ["Matic", "MATIC", "18"]) +chainIDMap.set(BigInt.fromI32(137), ["Matic", "MATIC", "18"]) +chainIDMap.set(BigInt.fromI32(97), ["Binance Coin", "BNB", "18"]) +chainIDMap.set(BigInt.fromI32(56), ["Binance Coin", "BNB", "18"]) +chainIDMap.set(BigInt.fromI32(1), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(42161), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(10), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(8453), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(100), ["XDAI", "XDAI", "18"]) +chainIDMap.set(BigInt.fromI32(10200), ["XDAI", "XDAI", "18"]) +chainIDMap.set(BigInt.fromI32(5000), ["Mantle", "MNT", "18"]) +chainIDMap.set(BigInt.fromI32(250), ["Fantom", "FTM", "18"]) +chainIDMap.set(BigInt.fromI32(4002), ["Fantom", "FTM", "18"]) +chainIDMap.set(BigInt.fromI32(1088), ["Metis", "METIS", "18"]) +chainIDMap.set(BigInt.fromI32(59144), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(40), ["Telos", "TLOS", "18"]) +chainIDMap.set(BigInt.fromI32(1313161554), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(204), ["Binance Coin", "BNB", "18"]) +chainIDMap.set(BigInt.fromI32(41), ["Telos", "TLOS", "18"]) +chainIDMap.set(BigInt.fromI32(5003), ["Mantle", "MNT", "18"]) +chainIDMap.set(BigInt.fromI32(84532), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(421614), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(11155111), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(11155420), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(7700), ["Canto", "CANTO", "18"]) +chainIDMap.set(BigInt.fromI32(59140), ["Ethereum", "ETH", "18"]) +chainIDMap.set(BigInt.fromI32(5611), ["Binance Coin", "tBNB", "18"]) + +export function selectNativeAsset(chainID: BigInt): Array | null { + return chainIDMap.get(chainID) +} \ No newline at end of file diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index a4cd04d..520699b 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -1,9 +1,7 @@ -import { Bytes, BigInt, Address, ethereum, dataSource, BigDecimal, log, ByteArray, TypedMap, DataSourceContext } from "@graphprotocol/graph-ts"; -import { createOrLoadAnatomyEntity, createOrLoadChainIDToAssetMappingEntity, createOrLoadConfigEntity, createOrLoadCurrencySetEntity, createOrLoadHistoricalIndexAssetEntity, createOrLoadHistoricalIndexBalanceEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity, loadChainIDToAssetMappingEntity, loadIndexAssetEntity } from "../EntityCreation"; +import { Bytes, BigInt, Address, ethereum, dataSource, BigDecimal, log } from "@graphprotocol/graph-ts"; +import { createOrLoadAnatomyEntity, createOrLoadChainIDToAssetMappingEntity, createOrLoadConfigEntity, createOrLoadHistoricalIndexAssetEntity, createOrLoadHistoricalIndexBalanceEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity, loadChainIDToAssetMappingEntity, loadIndexAssetEntity } from "../EntityCreation"; import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishVaultRebalancing as FinishVaultRebalancingEvent, FinishRebalancing as FinishRebalancingEvent, StartRebalancing as StartRebalancingEvent } from "../../generated/templates/ConfigBuilderV3/ConfigBuilderV3" import { convertAUMFeeRate } from "../v1/FeePool"; -import { CurrencySet, HistoricalIndexAsset } from "../../generated/schema"; -import { Messenger } from "../../generated/templates"; export function handleConfigUpdate(event: ConfigUpdatedEvent): void { let indexAddress = dataSource.context().getBytes('indexAddress') @@ -167,32 +165,31 @@ export function handleFinishRebalancing(event: FinishRebalancingEvent): void { let anatomyArray: string[] = [] let chainID = dataSource.context().getBigInt('chainID') let count = 0 - - let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newCurrencyIdSet)) - log.debug("Currency index array output {} for chain index {}", [currencyIndexArray.toString(), chainID.toString()]) - for (let y = 0; y < indexEntity.assets.length; y++) { - let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) - let chainIndex = chainIDToAssetMappingEntity.chainIndex - while (currencyIndexArray.length > 0) { - for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { - let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) - let currencyID = indexAssetEntity.currencyID - if (currencyIndexArray.length == 0) { - break - } - if (currencyID && currencyID == currencyIndexArray[0]) { - indexAssetEntity.weight = event.params.weights[count] - currencyIndexArray.splice(0, 1) - indexAssetEntity.save() - count++ - log.debug("currency array length {}", [currencyIndexArray.length.toString()]) - log.debug("count {}", [count.toString()]) - } - } + let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newCurrencyIdSet)) + log.debug("Currency index array output {} for chain index {}", [currencyIndexArray.toString(), chainID.toString()]) + for (let y = 0; y < indexEntity.assets.length; y++) { + let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) + let chainIndex = chainIDToAssetMappingEntity.chainIndex + while (currencyIndexArray.length > 0) { + for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { + let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) + let currencyID = indexAssetEntity.currencyID + if (currencyIndexArray.length == 0) { + break } - break + if (currencyID && currencyID == currencyIndexArray[0]) { + indexAssetEntity.weight = event.params.weights[count] + currencyIndexArray.splice(0, 1) + indexAssetEntity.save() + count++ + log.debug("currency array length {}", [currencyIndexArray.length.toString()]) + log.debug("count {}", [count.toString()]) + } + } } + break + } indexEntity.isRebalancing = false anatomyEntity.chainIdSet = [chainID] anatomyEntity.currencyIdSets = anatomyArray @@ -223,47 +220,3 @@ export function convertBigIntsToBitArray(array: BigInt[]): BigInt[] { } return expandedBitArray } - - - -export function selectNativeAsset(chainID: BigInt): Array | null { - let chainIDMap = new TypedMap>() - chainIDMap.set(BigInt.fromI32(43114), ["Avalanche", "AVAX", "18"]) - chainIDMap.set(BigInt.fromI32(43113), ["Avalanche", "AVAX", "18"]) - chainIDMap.set(BigInt.fromI32(80001), ["Matic", "MATIC", "18"]) - chainIDMap.set(BigInt.fromI32(137), ["Matic", "MATIC", "18"]) - chainIDMap.set(BigInt.fromI32(97), ["Binance Coin", "BNB", "18"]) - chainIDMap.set(BigInt.fromI32(56), ["Binance Coin", "BNB", "18"]) - chainIDMap.set(BigInt.fromI32(1), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(42161), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(10), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(8453), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(100), ["XDAI", "XDAI", "18"]) - chainIDMap.set(BigInt.fromI32(10200), ["XDAI", "XDAI", "18"]) - chainIDMap.set(BigInt.fromI32(5000), ["Mantle", "MNT", "18"]) - chainIDMap.set(BigInt.fromI32(250), ["Fantom", "FTM", "18"]) - chainIDMap.set(BigInt.fromI32(4002), ["Fantom", "FTM", "18"]) - chainIDMap.set(BigInt.fromI32(1088), ["Metis", "METIS", "18"]) - chainIDMap.set(BigInt.fromI32(59144), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(40), ["Telos", "TLOS", "18"]) - chainIDMap.set(BigInt.fromI32(1313161554), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(204), ["Binance Coin", "BNB", "18"]) - chainIDMap.set(BigInt.fromI32(41), ["Telos", "TLOS", "18"]) - chainIDMap.set(BigInt.fromI32(5003), ["Mantle", "MNT", "18"]) - chainIDMap.set(BigInt.fromI32(84532), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(421614), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(11155111), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(11155420), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(7700), ["Canto", "CANTO", "18"]) - chainIDMap.set(BigInt.fromI32(59140), ["Ethereum", "ETH", "18"]) - chainIDMap.set(BigInt.fromI32(5611), ["Binance Coin", "tBNB", "18"]) - - let data = chainIDMap.get(chainID) - - if (data != null) { - return data - } - else { - return null - } -} \ No newline at end of file diff --git a/src/v3/Governance.ts b/src/v3/Governance.ts deleted file mode 100644 index 36dc8b1..0000000 --- a/src/v3/Governance.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { DataSourceContext, dataSource } from "@graphprotocol/graph-ts" -import { ConfigBuilderV3 as ConfigBuilderTemplate } from "../../generated/templates" -import { SetConfigBuilder as SetConfigbuilderEvent } from "../../generated/templates/AutoGovernanceV3/AutoGovernanceV3" - - -export function handleSetConfigBuilder(event: SetConfigbuilderEvent): void { - let indexAddress = dataSource.context().getBytes('indexAddress') - let reserveAsset = dataSource.context().getBytes('reserveAsset') - let context = new DataSourceContext() - context.setBytes('indexAddress', indexAddress) - context.setBytes('reserveAsset', reserveAsset) - ConfigBuilderTemplate.createWithContext(event.params.param0, context) -} \ No newline at end of file diff --git a/src/v3/IndexFactory.ts b/src/v3/IndexFactory.ts index 2c8f40d..d29a68b 100644 --- a/src/v3/IndexFactory.ts +++ b/src/v3/IndexFactory.ts @@ -1,24 +1,20 @@ import { Deployed as DeployedEvent } from "../../generated/IndexFactoryV3/IndexFactoryV3" import { createOrLoadChainIDToAssetMappingEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity } from "../EntityCreation" -import { Governance as GovernanceTemplate, IndexTokenV3 as indexTemplate } from "../../generated/templates" -import { Address, BigDecimal, BigInt, Bytes, DataSourceContext, dataSource, log } from "@graphprotocol/graph-ts" -import { IndexTokenV3 } from "../../generated/IndexFactoryV3/IndexTokenV3" +import { IndexTokenV3 as indexTemplate } from "../../generated/templates" +import { Address, BigDecimal, BigInt, DataSourceContext, dataSource } from "@graphprotocol/graph-ts" import { getTokenInfo } from "../v1/IndexFactory" - export function handleIndexDeployed(event: DeployedEvent): void { let chainID = dataSource.context().getBigInt('chainID') let context = new DataSourceContext() context.setBytes('reserveAsset', event.params.reserve) - indexTemplate.createWithContext(event.params.index, context) context.setBytes('indexAddress', event.params.index) - GovernanceTemplate.createWithContext(event.params.governance, context) + indexTemplate.createWithContext(event.params.index, context) let index = createOrLoadIndexEntity(event.params.index) - let indexContract = IndexTokenV3.bind(event.params.index) index.name = event.params.name index.symbol = event.params.symbol - index.decimals = indexContract.decimals() + index.decimals = 18 index.chainID = chainID index.version = "v3" index.creationDate = event.block.timestamp @@ -52,4 +48,4 @@ export function handleIndexDeployed(event: DeployedEvent): void { chainIDToAssetMappingEntity.save() indexAssetEntity.save() index.save() -} \ No newline at end of file +} diff --git a/src/v3/IndexToken.ts b/src/v3/IndexToken.ts index 52fd3d6..1fed5e9 100644 --- a/src/v3/IndexToken.ts +++ b/src/v3/IndexToken.ts @@ -1,9 +1,11 @@ -import { Deposit as DepositEvent, FeeAccrued, Withdraw as WithdrawEvent } from "../../generated/templates/IndexTokenV3/IndexTokenV3" +import { ConfigBuilderV3 as ConfigBuilderTemplate } from "../../generated/templates" +import { Deposit as DepositEvent, FeeAccrued, Withdraw as WithdrawEvent, SetConfigBuilder as SetConfigbuilderEvent } from "../../generated/templates/IndexTokenV3/IndexTokenV3" import { createOrLoadIndexEntity, createOrLoadIndexAssetEntity, loadIndexAssetEntity, loadChainIDToAssetMappingEntity } from "../EntityCreation" -import { BigDecimal, Bytes, Address, BigInt, dataSource, log } from "@graphprotocol/graph-ts" -export { handleTransfer } from "../v1/IndexToken" +import { BigDecimal, BigInt, dataSource, DataSourceContext } from "@graphprotocol/graph-ts" import { saveHistoricalData } from "./ConfigBuilder" +export { handleTransfer } from "../v1/IndexToken" + export function handleDeposit(event: DepositEvent): void { let indexEntity = createOrLoadIndexEntity(event.address) let reserveAsset = dataSource.context().getBytes('reserveAsset') @@ -51,3 +53,12 @@ export function handleFeeAccrued(event: FeeAccrued): void { indexEntity.totalFees = indexEntity.totalFees!.plus(fees) indexEntity.save() } + +export function handleSetConfigBuilder(event: SetConfigbuilderEvent): void { + let indexAddress = dataSource.context().getBytes('indexAddress') + let reserveAsset = dataSource.context().getBytes('reserveAsset') + let context = new DataSourceContext() + context.setBytes('indexAddress', indexAddress) + context.setBytes('reserveAsset', reserveAsset) + ConfigBuilderTemplate.createWithContext(event.params.configBuilder, context) +} diff --git a/subgraph.template.yaml b/subgraph.template.yaml index f5ec69a..1f1301e 100644 --- a/subgraph.template.yaml +++ b/subgraph.template.yaml @@ -122,8 +122,6 @@ dataSources: file: ./abis/v3/IndexFactoryV3.json - name: IndexTokenV3 file: ./abis/v3/IndexTokenV3.json - - name: AutoGovernance - file: ./abis/v3/AutoGovernanceV3.json - name: ERC20 file: ./abis/ERC20.json - name: MakerERC20 @@ -488,6 +486,8 @@ templates: handler: handleFeeAccrued - event: Transfer(indexed address,indexed address,uint256) handler: handleTransfer + - event: SetConfigBuilder(address) + handler: handleSetConfigBuilder file: ./src/v3/IndexToken.ts - kind: ethereum name: ConfigBuilderV3 @@ -516,25 +516,5 @@ templates: - event: StartRebalancing() handler: handleStartRebalancing file: ./src/v3/ConfigBuilder.ts - - kind: ethereum - name: AutoGovernanceV3 - network: {{network}} - source: - abi: AutoGovernanceV3 - mapping: - kind: ethereum/events - apiVersion: 0.0.7 - language: wasm/assemblyscript - entities: - - Index - abis: - - name: AutoGovernanceV3 - file: ./abis/v3/AutoGovernanceV3.json - - name: ConfigBuilderV3 - file: ./abis/v3/ConfigBuilderV3.json - eventHandlers: - - event: SetConfigBuilder(address) - handler: handleSetConfigBuilder - file: ./src/v3/Governance.ts - + {{/v3}} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index f25db1e..0000000 --- a/yarn.lock +++ /dev/null @@ -1,91 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@graphprotocol/graph-ts@^0.27.0": - version "0.27.0" - resolved "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.27.0.tgz" - integrity sha512-r1SPDIZVQiGMxcY8rhFSM0y7d/xAbQf5vHMWUf59js1KgoyWpM6P3tczZqmQd7JTmeyNsDGIPzd9FeaxllsU4w== - dependencies: - assemblyscript "0.19.10" - -"@graphprotocol/graph-ts@^0.35.0": - version "0.35.1" - resolved "https://registry.npmjs.org/@graphprotocol/graph-ts/-/graph-ts-0.35.1.tgz" - integrity sha512-74CfuQmf7JI76/XCC34FTkMMKeaf+3Pn0FIV3m9KNeaOJ+OI3CvjMIVRhOZdKcJxsFCBGaCCl0eQjh47xTjxKA== - dependencies: - assemblyscript "0.19.10" - -assemblyscript@^0.19.20: - version "0.19.23" - resolved "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.23.tgz" - integrity sha512-fwOQNZVTMga5KRsfY80g7cpOl4PsFQczMwHzdtgoqLXaYhkhavufKb0sB0l3T1DUxpAufA0KNhlbpuuhZUwxMA== - dependencies: - binaryen "102.0.0-nightly.20211028" - long "^5.2.0" - source-map-support "^0.5.20" - -assemblyscript@0.19.10: - version "0.19.10" - resolved "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.10.tgz" - integrity sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg== - dependencies: - binaryen "101.0.0-nightly.20210723" - long "^4.0.0" - -binaryen@101.0.0-nightly.20210723: - version "101.0.0-nightly.20210723" - resolved "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz" - integrity sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA== - -binaryen@102.0.0-nightly.20211028: - version "102.0.0-nightly.20211028" - resolved "https://registry.npmjs.org/binaryen/-/binaryen-102.0.0-nightly.20211028.tgz" - integrity sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w== - -buffer-from@^1.0.0: - version "1.1.2" - resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -long@^4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/long/-/long-4.0.0.tgz" - integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== - -long@^5.2.0: - version "5.2.4" - resolved "https://registry.npmjs.org/long/-/long-5.2.4.tgz" - integrity sha512-qtzLbJE8hq7VabR3mISmVGtoXP8KGc2Z/AT8OuqlYD7JTR3oqrgwdjnk07wpj1twXxYmgDXgoKVWUG/fReSzHg== - -matchstick-as@0.5.0: - version "0.5.0" - resolved "https://registry.npmjs.org/matchstick-as/-/matchstick-as-0.5.0.tgz" - integrity sha512-4K619YDH+so129qt4RB4JCNxaFwJJYLXPc7drpG+/mIj86Cfzg6FKs/bA91cnajmS1CLHdhHl9vt6Kd6Oqvfkg== - dependencies: - "@graphprotocol/graph-ts" "^0.27.0" - assemblyscript "^0.19.20" - wabt "1.0.24" - -mustache@^4.2.0: - version "4.2.0" - resolved "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz" - integrity sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ== - -source-map-support@^0.5.20: - version "0.5.21" - resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -wabt@1.0.24: - version "1.0.24" - resolved "https://registry.npmjs.org/wabt/-/wabt-1.0.24.tgz" - integrity sha512-8l7sIOd3i5GWfTWciPL0+ff/FK/deVK2Q6FN+MPz4vfUcD78i2M/49XJTwF6aml91uIiuXJEsLKWMB2cw/mtKg== From 48a1038b87e37009273f3927983737709571105c Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Fri, 31 Jan 2025 09:46:31 +0000 Subject: [PATCH 06/13] fix: issue --- Pipfile | 11 +++++++++++ dockerfile | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Pipfile create mode 100644 dockerfile diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..ee360a9 --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] + +[requires] +python_version = "3.6" \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..658c823 --- /dev/null +++ b/dockerfile @@ -0,0 +1,22 @@ +FROM --platform=linux/x86_64 ubuntu:22.04 + +ARG DEBIAN_FRONTEND=noninteractive + +ENV ARGS="" + +RUN apt update \ + && apt install -y sudo curl postgresql postgresql-contrib + +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - \ + && sudo apt-get install -y nodejs + +RUN curl -OL https://github.com/LimeChain/matchstick/releases/download/0.6.0/binary-linux-22 \ + && chmod a+x binary-linux-22 + +RUN mkdir matchstick +WORKDIR /matchstick + +# Commenting out for now as it seems there's no need to copy when using bind mount +# COPY ./ . + +CMD ../binary-linux-22 ${ARGS} \ No newline at end of file From 4f334565872bd96c37aaeae10296432408c2d85b Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Fri, 31 Jan 2025 12:38:24 +0200 Subject: [PATCH 07/13] updates --- src/constants.ts | 7 + src/v3/ConfigBuilder.ts | 471 +++++++++++++++++++++++----------------- src/v3/IndexFactory.ts | 120 ++++++---- src/v3/IndexToken.ts | 153 ++++++++----- 4 files changed, 454 insertions(+), 297 deletions(-) create mode 100644 src/constants.ts diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..605610a --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,7 @@ +import { BigInt } from "@graphprotocol/graph-ts"; + +export const ZERO = BigInt.zero(); +export const ONE = BigInt.fromI32(1); +export const TEN = BigInt.fromI32(10); +export const BP = BigInt.fromI32(10000); +export const WAD = TEN.pow(18); diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index 520699b..0e76b9f 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -1,222 +1,297 @@ -import { Bytes, BigInt, Address, ethereum, dataSource, BigDecimal, log } from "@graphprotocol/graph-ts"; -import { createOrLoadAnatomyEntity, createOrLoadChainIDToAssetMappingEntity, createOrLoadConfigEntity, createOrLoadHistoricalIndexAssetEntity, createOrLoadHistoricalIndexBalanceEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity, loadChainIDToAssetMappingEntity, loadIndexAssetEntity } from "../EntityCreation"; -import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishVaultRebalancing as FinishVaultRebalancingEvent, FinishRebalancing as FinishRebalancingEvent, StartRebalancing as StartRebalancingEvent } from "../../generated/templates/ConfigBuilderV3/ConfigBuilderV3" +import { + Address, + BigDecimal, + BigInt, + type Bytes, + dataSource, + ethereum, +} from "@graphprotocol/graph-ts"; + +import type { + ConfigUpdated as ConfigUpdatedEvent, + CurrencyRegistered as CurrencyRegisteredEvent, + FinishRebalancing as FinishRebalancingEvent, + FinishVaultRebalancing as FinishVaultRebalancingEvent, + StartRebalancing as StartRebalancingEvent, +} from "../../generated/templates/ConfigBuilderV3/ConfigBuilderV3"; +import { + createOrLoadAnatomyEntity, + createOrLoadChainIDToAssetMappingEntity, + createOrLoadConfigEntity, + createOrLoadHistoricalIndexAssetEntity, + createOrLoadHistoricalIndexBalanceEntity, + createOrLoadIndexAssetEntity, + createOrLoadIndexEntity, + loadChainIDToAssetMappingEntity, + loadIndexAssetEntity, +} from "../EntityCreation"; + +import { BP, ONE, TEN, WAD, ZERO } from "../constants"; import { convertAUMFeeRate } from "../v1/FeePool"; export function handleConfigUpdate(event: ConfigUpdatedEvent): void { - let indexAddress = dataSource.context().getBytes('indexAddress') - let indexEntity = createOrLoadIndexEntity(indexAddress) - let configEntity = createOrLoadConfigEntity(indexAddress) - let decoded = ethereum.decode('((uint256,bool,address),(uint16,bool),(uint16,bool))', event.params.encodedConfig)!.toTuple() - configEntity.AUMDilutionPerSecond = decoded[0].toTuple()[0].toBigInt() - configEntity.useCustomAUMFee = decoded[0].toTuple()[1].toBoolean() - configEntity.metadata = decoded[0].toTuple()[2].toAddress() - configEntity.depositFeeInBP = decoded[1].toTuple()[0].toBigInt() - configEntity.depositCustomCallback = decoded[1].toTuple()[1].toBoolean() - configEntity.redemptionFeeInBP = decoded[2].toTuple()[0].toBigInt() - configEntity.redemptionCustomCallback = decoded[2].toTuple()[1].toBoolean() - let aumFee = decoded[0].toTuple()[0].toBigInt() - let scalar = new BigDecimal(BigInt.fromI32(10000)) - let mintingFee = new BigDecimal(decoded[1].toTuple()[0].toBigInt()).div(scalar) - let redemptionFee = new BigDecimal(decoded[2].toTuple()[0].toBigInt()).div(scalar) - indexEntity.mintingFee = mintingFee - indexEntity.redemptionFee = redemptionFee - indexEntity.save() - configEntity.save() - convertAUMFeeRate(indexAddress, aumFee) + const indexAddress = dataSource.context().getBytes("indexAddress"); + const indexEntity = createOrLoadIndexEntity(indexAddress); + const configEntity = createOrLoadConfigEntity(indexAddress); + const decoded = ethereum + .decode( + "((uint256,bool,address),(uint16,bool),(uint16,bool))", + event.params.encodedConfig, + )! + .toTuple(); + configEntity.AUMDilutionPerSecond = decoded[0].toTuple()[0].toBigInt(); + configEntity.useCustomAUMFee = decoded[0].toTuple()[1].toBoolean(); + configEntity.metadata = decoded[0].toTuple()[2].toAddress(); + configEntity.depositFeeInBP = decoded[1].toTuple()[0].toBigInt(); + configEntity.depositCustomCallback = decoded[1].toTuple()[1].toBoolean(); + configEntity.redemptionFeeInBP = decoded[2].toTuple()[0].toBigInt(); + configEntity.redemptionCustomCallback = decoded[2].toTuple()[1].toBoolean(); + const aumFee = decoded[0].toTuple()[0].toBigInt(); + const scalar = new BigDecimal(BP); + const mintingFee = new BigDecimal(decoded[1].toTuple()[0].toBigInt()).div( + scalar, + ); + const redemptionFee = new BigDecimal(decoded[2].toTuple()[0].toBigInt()).div( + scalar, + ); + indexEntity.mintingFee = mintingFee; + indexEntity.redemptionFee = redemptionFee; + indexEntity.save(); + configEntity.save(); + convertAUMFeeRate(indexAddress, aumFee); } export function handleStartRebalancing(event: StartRebalancingEvent): void { - let indexAddress = dataSource.context().getBytes('indexAddress') - let indexEntity = createOrLoadIndexEntity(indexAddress) - indexEntity.isRebalancing = true - indexEntity.save() + const indexAddress = dataSource.context().getBytes("indexAddress"); + const indexEntity = createOrLoadIndexEntity(indexAddress); + indexEntity.isRebalancing = true; + indexEntity.save(); } export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { - let indexAddress = dataSource.context().getBytes('indexAddress') - let chainID = dataSource.context().getBigInt('chainID') - log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), chainID.toString()]) - let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, event.params.currency, chainID) - let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) - indexAssetEntity.name = event.params.name - indexAssetEntity.symbol = event.params.symbol - indexAssetEntity.decimals = event.params.decimals - indexAssetEntity.currencyID = chainIDToAssetMappingEntity.registeredAssets - - chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(BigInt.fromI32(1)) - - chainIDToAssetMappingEntity.save() - indexAssetEntity.save() + const indexAddress = dataSource.context().getBytes("indexAddress"); + const chainID = dataSource.context().getBigInt("chainID"); + + const indexAssetEntity = createOrLoadIndexAssetEntity( + indexAddress, + event.params.currency, + chainID, + ); + const chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity( + indexAddress, + chainID, + ); + indexAssetEntity.name = event.params.name; + indexAssetEntity.symbol = event.params.symbol; + indexAssetEntity.decimals = event.params.decimals; + indexAssetEntity.currencyID = chainIDToAssetMappingEntity.registeredAssets; + + chainIDToAssetMappingEntity.registeredAssets = + chainIDToAssetMappingEntity.registeredAssets!.plus(ONE); + + chainIDToAssetMappingEntity.save(); + indexAssetEntity.save(); } -export function handleFinishChainRebalancing(event: FinishVaultRebalancingEvent): void { - let indexAddress = dataSource.context().getBytes('indexAddress') - let reserveAsset = dataSource.context().getBytes('reserveAsset') - let indexEntity = createOrLoadIndexEntity(indexAddress) - let chainID = dataSource.context().getBigInt('chainID') - let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) - chainIDToAssetMappingEntity.latestSnapshot = event.params.snapshot - if (event.params.currencies.length == 0) { - for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { - let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[i]) - indexAssetEntity.balance = BigDecimal.zero() - indexAssetEntity.weight = BigInt.zero() - indexAssetEntity.save() - } - let emptyAssetArray: string[] = [] - if (chainID == indexEntity.chainID) { - emptyAssetArray.push(createOrLoadIndexAssetEntity(indexAddress, reserveAsset, indexEntity.chainID).id) - } - chainIDToAssetMappingEntity.assets = emptyAssetArray - chainIDToAssetMappingEntity.save() - - if (chainID != indexEntity.chainID) { - let indexAssets = indexEntity.assets - let idx = indexAssets.indexOf(chainIDToAssetMappingEntity.id) - indexAssets.splice(idx, 1) - indexEntity.assets = indexAssets - indexEntity.save() - } - - } else { - let chainIDAssetArray: string[] = [] - let reserveAssetEntity = createOrLoadIndexAssetEntity(indexAddress, reserveAsset, indexEntity.chainID) - if (chainID == indexEntity.chainID) { - reserveAssetEntity.balance = BigDecimal.zero() - reserveAssetEntity.save() - chainIDAssetArray.push(reserveAssetEntity.id) - } - for (let i = 0; i < event.params.currencies.length; i++) { - let balance = new BigDecimal(event.params.balances[i]) - let asset = event.params.currencies[i].toString() - log.debug("{}", [asset]) - let assetConverted: Bytes - log.debug("{} length = {}", [asset, asset.length.toString()]) - if (asset.length == 3) { - assetConverted = Address.fromString("0x0000000000000000000000000000000000000000") - } - else { - assetConverted = Address.fromHexString('0x'.concat("0".repeat(42 - asset.length)).concat(asset.slice(2))) - } - log.debug("decoded asset = {}, decoded balance {}, chainID {}", [assetConverted.toHexString(), balance.toString(), chainID.toString()]) - let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, assetConverted, chainID) - let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(indexAssetEntity.decimals))) - indexAssetEntity.balance = balance.div(scalar) - indexAssetEntity.save() - if (indexAssetEntity.id != reserveAssetEntity.id) { - chainIDAssetArray.push(indexAssetEntity.id) - } - - } - for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { - let id = chainIDToAssetMappingEntity.assets[i] - if (!chainIDAssetArray.includes(id)) { - let indexAssetEntity = loadIndexAssetEntity(id) - indexAssetEntity.balance = BigDecimal.zero() - indexAssetEntity.weight = BigInt.zero() - indexAssetEntity.save() - } - } - chainIDToAssetMappingEntity.assets = chainIDAssetArray - - - if (!indexEntity.assets.includes(chainIDToAssetMappingEntity.id)) { - let indexAssetArray = indexEntity.assets - indexAssetArray.push(chainIDToAssetMappingEntity.id) - indexEntity.assets = indexAssetArray - indexEntity.save() - } - } - chainIDToAssetMappingEntity.save() - indexEntity.k = BigInt.fromI32(1).times(BigInt.fromI32(10).pow(18)) - indexEntity.save() - saveHistoricalData(indexAddress, event.block.timestamp) +export function handleFinishChainRebalancing( + event: FinishVaultRebalancingEvent, +): void { + const indexAddress = dataSource.context().getBytes("indexAddress"); + const reserveAsset = dataSource.context().getBytes("reserveAsset"); + const indexEntity = createOrLoadIndexEntity(indexAddress); + const chainID = dataSource.context().getBigInt("chainID"); + const chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity( + indexAddress, + chainID, + ); + chainIDToAssetMappingEntity.latestSnapshot = event.params.snapshot; + if (event.params.currencies.length == 0) { + for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { + const indexAssetEntity = loadIndexAssetEntity( + chainIDToAssetMappingEntity.assets[i], + ); + indexAssetEntity.balance = BigDecimal.zero(); + indexAssetEntity.weight = ZERO; + indexAssetEntity.save(); + } + const emptyAssetArray: string[] = []; + if (chainID == indexEntity.chainID) { + emptyAssetArray.push( + createOrLoadIndexAssetEntity( + indexAddress, + reserveAsset, + indexEntity.chainID, + ).id, + ); + } + chainIDToAssetMappingEntity.assets = emptyAssetArray; + chainIDToAssetMappingEntity.save(); + + if (chainID != indexEntity.chainID) { + const indexAssets = indexEntity.assets; + const idx = indexAssets.indexOf(chainIDToAssetMappingEntity.id); + indexAssets.splice(idx, 1); + indexEntity.assets = indexAssets; + indexEntity.save(); + } + } else { + const chainIDAssetArray: string[] = []; + const reserveAssetEntity = createOrLoadIndexAssetEntity( + indexAddress, + reserveAsset, + indexEntity.chainID, + ); + if (chainID == indexEntity.chainID) { + reserveAssetEntity.balance = BigDecimal.zero(); + reserveAssetEntity.save(); + chainIDAssetArray.push(reserveAssetEntity.id); + } + for (let i = 0; i < event.params.currencies.length; i++) { + const balance = new BigDecimal(event.params.balances[i]); + const asset = event.params.currencies[i].toString(); + let assetConverted: Bytes; + if (asset.length == 3) { + assetConverted = Address.fromString( + "0x0000000000000000000000000000000000000000", + ); + } else { + assetConverted = Address.fromHexString( + "0x".concat("0".repeat(42 - asset.length)).concat(asset.slice(2)), + ); + } + const indexAssetEntity = createOrLoadIndexAssetEntity( + indexAddress, + assetConverted, + chainID, + ); + const scalar = new BigDecimal(TEN.pow(u8(indexAssetEntity.decimals))); + indexAssetEntity.balance = balance.div(scalar); + indexAssetEntity.save(); + if (indexAssetEntity.id != reserveAssetEntity.id) { + chainIDAssetArray.push(indexAssetEntity.id); + } + } + for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { + const id = chainIDToAssetMappingEntity.assets[i]; + if (!chainIDAssetArray.includes(id)) { + const indexAssetEntity = loadIndexAssetEntity(id); + indexAssetEntity.balance = BigDecimal.zero(); + indexAssetEntity.weight = ZERO; + indexAssetEntity.save(); + } + } + chainIDToAssetMappingEntity.assets = chainIDAssetArray; + + if (!indexEntity.assets.includes(chainIDToAssetMappingEntity.id)) { + const indexAssetArray = indexEntity.assets; + indexAssetArray.push(chainIDToAssetMappingEntity.id); + indexEntity.assets = indexAssetArray; + indexEntity.save(); + } + } + chainIDToAssetMappingEntity.save(); + indexEntity.k = WAD; + indexEntity.save(); + saveHistoricalData(indexAddress, event.block.timestamp); } export function saveHistoricalData(index: Bytes, timestamp: BigInt): void { - let indexEntity = createOrLoadIndexEntity(index) - let historicalIndexBalanceEntity = createOrLoadHistoricalIndexBalanceEntity(index, timestamp) - historicalIndexBalanceEntity.totalSupply = indexEntity.totalSupply - let historicalIndexAssetArray: string[] = [] - for (let i = 0; i < indexEntity.assets.length; i++) { - let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[i]) - let chainID = chainIDToAssetMappingEntity.chainID - for (let y = 0; y < chainIDToAssetMappingEntity.assets.length; y++) { - let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[y]) - let historicalIndexAssetEntity = createOrLoadHistoricalIndexAssetEntity(index, indexAssetEntity.asset, chainID, timestamp) - historicalIndexAssetEntity.balance = indexAssetEntity.balance - if (indexAssetEntity.weight) { - historicalIndexAssetEntity.weight = indexAssetEntity.weight - } - historicalIndexAssetEntity.save() - historicalIndexAssetArray.push(historicalIndexAssetEntity.id) - } - } - historicalIndexBalanceEntity.assets = historicalIndexAssetArray - historicalIndexBalanceEntity.save() + const indexEntity = createOrLoadIndexEntity(index); + const historicalIndexBalanceEntity = createOrLoadHistoricalIndexBalanceEntity( + index, + timestamp, + ); + historicalIndexBalanceEntity.totalSupply = indexEntity.totalSupply; + const historicalIndexAssetArray: string[] = []; + for (let i = 0; i < indexEntity.assets.length; i++) { + const chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity( + indexEntity.assets[i], + ); + const chainID = chainIDToAssetMappingEntity.chainID; + for (let y = 0; y < chainIDToAssetMappingEntity.assets.length; y++) { + const indexAssetEntity = loadIndexAssetEntity( + chainIDToAssetMappingEntity.assets[y], + ); + const historicalIndexAssetEntity = createOrLoadHistoricalIndexAssetEntity( + index, + indexAssetEntity.asset, + chainID, + timestamp, + ); + historicalIndexAssetEntity.balance = indexAssetEntity.balance; + if (indexAssetEntity.weight) { + historicalIndexAssetEntity.weight = indexAssetEntity.weight; + } + historicalIndexAssetEntity.save(); + historicalIndexAssetArray.push(historicalIndexAssetEntity.id); + } + } + historicalIndexBalanceEntity.assets = historicalIndexAssetArray; + historicalIndexBalanceEntity.save(); } export function handleFinishRebalancing(event: FinishRebalancingEvent): void { - log.debug("weights {}", [event.params.weights.toString()]) - let indexAddress = dataSource.context().getBytes('indexAddress') - let indexEntity = createOrLoadIndexEntity(indexAddress) - let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) - let anatomyArray: string[] = [] - let chainID = dataSource.context().getBigInt('chainID') - let count = 0 - - let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newCurrencyIdSet)) - log.debug("Currency index array output {} for chain index {}", [currencyIndexArray.toString(), chainID.toString()]) - for (let y = 0; y < indexEntity.assets.length; y++) { - let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) - let chainIndex = chainIDToAssetMappingEntity.chainIndex - while (currencyIndexArray.length > 0) { - for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { - let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) - let currencyID = indexAssetEntity.currencyID - if (currencyIndexArray.length == 0) { - break - } - if (currencyID && currencyID == currencyIndexArray[0]) { - indexAssetEntity.weight = event.params.weights[count] - currencyIndexArray.splice(0, 1) - indexAssetEntity.save() - count++ - log.debug("currency array length {}", [currencyIndexArray.length.toString()]) - log.debug("count {}", [count.toString()]) - } - } - } - break - } - indexEntity.isRebalancing = false - anatomyEntity.chainIdSet = [chainID] - anatomyEntity.currencyIdSets = anatomyArray - anatomyEntity.save() - indexEntity.save() + const indexAddress = dataSource.context().getBytes("indexAddress"); + const indexEntity = createOrLoadIndexEntity(indexAddress); + const anatomyEntity = createOrLoadAnatomyEntity(indexAddress); + const anatomyArray: string[] = []; + const chainID = dataSource.context().getBigInt("chainID"); + let count = 0; + + const currencyIndexArray = convertBitSetToIDs( + convertBigIntsToBitArray(event.params.newCurrencyIdSet), + ); + for (let y = 0; y < indexEntity.assets.length; y++) { + const chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity( + indexEntity.assets[y], + ); + const chainIndex = chainIDToAssetMappingEntity.chainIndex; + while (currencyIndexArray.length > 0) { + for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { + const indexAssetEntity = loadIndexAssetEntity( + chainIDToAssetMappingEntity.assets[x], + ); + const currencyID = indexAssetEntity.currencyID; + if (currencyIndexArray.length == 0) { + break; + } + if (currencyID && currencyID == currencyIndexArray[0]) { + indexAssetEntity.weight = event.params.weights[count]; + currencyIndexArray.splice(0, 1); + indexAssetEntity.save(); + count++; + } + } + } + break; + } + indexEntity.isRebalancing = false; + anatomyEntity.chainIdSet = [chainID]; + anatomyEntity.currencyIdSets = anatomyArray; + anatomyEntity.save(); + indexEntity.save(); } export function convertBitSetToIDs(array: BigInt[]): BigInt[] { - let IDArray: BigInt[] = [] - for (let i = 0; i < array.length; i++) { - if (array[i] == BigInt.fromI32(1)) { - IDArray.push(BigInt.fromI32(i)) - } - } - return IDArray + const IDArray: BigInt[] = []; + for (let i = 0; i < array.length; i++) { + if (array[i] == ONE) { + IDArray.push(BigInt.fromI32(i)); + } + } + return IDArray; } export function convertBigIntsToBitArray(array: BigInt[]): BigInt[] { - let expandedBitArray: BigInt[] = [] - for (let i = 0; i < array.length; i++) { - let bitArray: BigInt[] = [] - let chainBitSet = array[i] - while (chainBitSet > BigInt.zero()) { - bitArray.push(chainBitSet.bitAnd(BigInt.fromI32(1))) - chainBitSet = chainBitSet.rightShift(1) - } - expandedBitArray = expandedBitArray.concat(bitArray) - } - return expandedBitArray + let expandedBitArray: BigInt[] = []; + for (let i = 0; i < array.length; i++) { + const bitArray: BigInt[] = []; + let chainBitSet = array[i]; + while (chainBitSet > ZERO) { + bitArray.push(chainBitSet.bitAnd(ONE)); + chainBitSet = chainBitSet.rightShift(1); + } + expandedBitArray = expandedBitArray.concat(bitArray); + } + return expandedBitArray; } diff --git a/src/v3/IndexFactory.ts b/src/v3/IndexFactory.ts index d29a68b..3d00cae 100644 --- a/src/v3/IndexFactory.ts +++ b/src/v3/IndexFactory.ts @@ -1,51 +1,75 @@ -import { Deployed as DeployedEvent } from "../../generated/IndexFactoryV3/IndexFactoryV3" -import { createOrLoadChainIDToAssetMappingEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity } from "../EntityCreation" -import { IndexTokenV3 as indexTemplate } from "../../generated/templates" -import { Address, BigDecimal, BigInt, DataSourceContext, dataSource } from "@graphprotocol/graph-ts" -import { getTokenInfo } from "../v1/IndexFactory" +import { + Address, + BigDecimal, + DataSourceContext, + dataSource, +} from "@graphprotocol/graph-ts"; + +import type { Deployed as DeployedEvent } from "../../generated/IndexFactoryV3/IndexFactoryV3"; +import { IndexTokenV3 as indexTemplate } from "../../generated/templates"; +import { + createOrLoadChainIDToAssetMappingEntity, + createOrLoadIndexAssetEntity, + createOrLoadIndexEntity, +} from "../EntityCreation"; + +import { ONE, WAD, ZERO } from "../constants"; +import { getTokenInfo } from "../v1/IndexFactory"; export function handleIndexDeployed(event: DeployedEvent): void { - let chainID = dataSource.context().getBigInt('chainID') - let context = new DataSourceContext() - context.setBytes('reserveAsset', event.params.reserve) - context.setBytes('indexAddress', event.params.index) - indexTemplate.createWithContext(event.params.index, context) - - let index = createOrLoadIndexEntity(event.params.index) - index.name = event.params.name - index.symbol = event.params.symbol - index.decimals = 18 - index.chainID = chainID - index.version = "v3" - index.creationDate = event.block.timestamp - index.k = BigInt.fromI32(1).times(BigInt.fromI32(10).pow(18)) - index.totalFees = BigDecimal.zero() - let indexAssetEntity = createOrLoadIndexAssetEntity(event.params.index, event.params.reserve, chainID) - if (event.params.reserve != Address.fromString('0x0000000000000000000000000000000000000000')) { - getTokenInfo(indexAssetEntity, event.params.reserve) - } - else { - let nativeAssetInfo = dataSource.context().get("nativeAsset")! - indexAssetEntity.name = nativeAssetInfo.toArray()[0].toString() - indexAssetEntity.symbol = nativeAssetInfo.toArray()[1].toString() - indexAssetEntity.decimals = nativeAssetInfo.toArray()[2].toI32() - } - - let chainIDAssetArray: string[] = [] - let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(event.params.index, chainID) - chainIDAssetArray.push(indexAssetEntity.id) - chainIDToAssetMappingEntity.assets = chainIDAssetArray - chainIDToAssetMappingEntity.chainIndex = BigInt.zero() - chainIDToAssetMappingEntity.latestSnapshot = BigInt.zero() - chainIDToAssetMappingEntity.registeredAssets = BigInt.zero() - - indexAssetEntity.currencyID = chainIDToAssetMappingEntity.registeredAssets - chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(BigInt.fromI32(1)) - - let indexAssetArray: string[] = [] - indexAssetArray.push(chainIDToAssetMappingEntity.id) - index.assets = indexAssetArray - chainIDToAssetMappingEntity.save() - indexAssetEntity.save() - index.save() + const indexContext = new DataSourceContext(); + indexContext.setBytes("reserveAsset", event.params.reserve); + indexContext.setBytes("indexAddress", event.params.index); + indexTemplate.createWithContext(event.params.index, indexContext); + + const indexFactoryContext = dataSource.context(); + const chainID = indexFactoryContext.getBigInt("chainID"); + const index = createOrLoadIndexEntity(event.params.index); + index.name = event.params.name; + index.symbol = event.params.symbol; + index.decimals = 18; + index.chainID = chainID; + index.version = "v3"; + index.creationDate = event.block.timestamp; + index.k = WAD; + index.totalFees = BigDecimal.zero(); + + const indexAssetEntity = createOrLoadIndexAssetEntity( + event.params.index, + event.params.reserve, + chainID, + ); + if ( + event.params.reserve == + Address.fromString("0x0000000000000000000000000000000000000000") + ) { + const nativeAssetInfo = dataSource.context().get("nativeAsset")!; + indexAssetEntity.name = nativeAssetInfo.toArray()[0].toString(); + indexAssetEntity.symbol = nativeAssetInfo.toArray()[1].toString(); + indexAssetEntity.decimals = nativeAssetInfo.toArray()[2].toI32(); + } else { + getTokenInfo(indexAssetEntity, event.params.reserve); + } + + const chainIDAssetArray: string[] = []; + const chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity( + event.params.index, + chainID, + ); + chainIDAssetArray.push(indexAssetEntity.id); + chainIDToAssetMappingEntity.assets = chainIDAssetArray; + chainIDToAssetMappingEntity.chainIndex = ZERO; + chainIDToAssetMappingEntity.latestSnapshot = ZERO; + chainIDToAssetMappingEntity.registeredAssets = ZERO; + + indexAssetEntity.currencyID = chainIDToAssetMappingEntity.registeredAssets; + chainIDToAssetMappingEntity.registeredAssets = + chainIDToAssetMappingEntity.registeredAssets!.plus(ONE); + + const indexAssetArray: string[] = []; + indexAssetArray.push(chainIDToAssetMappingEntity.id); + index.assets = indexAssetArray; + chainIDToAssetMappingEntity.save(); + indexAssetEntity.save(); + index.save(); } diff --git a/src/v3/IndexToken.ts b/src/v3/IndexToken.ts index 1fed5e9..8295bce 100644 --- a/src/v3/IndexToken.ts +++ b/src/v3/IndexToken.ts @@ -1,64 +1,115 @@ -import { ConfigBuilderV3 as ConfigBuilderTemplate } from "../../generated/templates" -import { Deposit as DepositEvent, FeeAccrued, Withdraw as WithdrawEvent, SetConfigBuilder as SetConfigbuilderEvent } from "../../generated/templates/IndexTokenV3/IndexTokenV3" -import { createOrLoadIndexEntity, createOrLoadIndexAssetEntity, loadIndexAssetEntity, loadChainIDToAssetMappingEntity } from "../EntityCreation" -import { BigDecimal, BigInt, dataSource, DataSourceContext } from "@graphprotocol/graph-ts" -import { saveHistoricalData } from "./ConfigBuilder" +import { + BigDecimal, + DataSourceContext, + dataSource, +} from "@graphprotocol/graph-ts"; +import { ConfigBuilderV3 as ConfigBuilderTemplate } from "../../generated/templates"; +import type { + Deposit as DepositEvent, + FeeAccrued, + SetConfigBuilder as SetConfigbuilderEvent, + Withdraw as WithdrawEvent, +} from "../../generated/templates/IndexTokenV3/IndexTokenV3"; -export { handleTransfer } from "../v1/IndexToken" +import { + createOrLoadIndexAssetEntity, + createOrLoadIndexEntity, + loadChainIDToAssetMappingEntity, + loadIndexAssetEntity, +} from "../EntityCreation"; +import { TEN, ZERO } from "../constants"; +import { saveHistoricalData } from "./ConfigBuilder"; + +export { handleTransfer } from "../v1/IndexToken"; export function handleDeposit(event: DepositEvent): void { - let indexEntity = createOrLoadIndexEntity(event.address) - let reserveAsset = dataSource.context().getBytes('reserveAsset') - let reserveAssetEntity = createOrLoadIndexAssetEntity(event.address, reserveAsset, indexEntity.chainID) - let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(reserveAssetEntity.decimals))) - let amount = new BigDecimal(event.params.reserve).div(scalar) - reserveAssetEntity.balance = reserveAssetEntity.balance.plus(amount) - reserveAssetEntity.save() - saveHistoricalData(event.address, event.block.timestamp) + const indexContext = dataSource.context(); + const reserveAsset = indexContext.getBytes("reserveAsset"); + const chainID = indexContext.getBigInt("chainID"); + + const reserveAssetEntity = createOrLoadIndexAssetEntity( + event.address, + reserveAsset, + chainID, + ); + + const scalar = new BigDecimal(TEN.pow(u8(reserveAssetEntity.decimals))); + const amount = new BigDecimal(event.params.reserve).div(scalar); + + reserveAssetEntity.balance = reserveAssetEntity.balance.plus(amount); + + reserveAssetEntity.save(); + + saveHistoricalData(event.address, event.block.timestamp); } export function handleWithdraw(event: WithdrawEvent): void { - let indexEntity = createOrLoadIndexEntity(event.address) - let reserveAsset = dataSource.context().getBytes('reserveAsset') - let reserveAssetEntity = createOrLoadIndexAssetEntity(event.address, reserveAsset, indexEntity.chainID) - let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(reserveAssetEntity.decimals))) - let amount = new BigDecimal(event.params.reserve).div(scalar) - reserveAssetEntity.balance = reserveAssetEntity.balance.minus(amount) - reserveAssetEntity.save() - let k = indexEntity.k! - if (event.params.k > BigInt.zero()) { - let assetScalar = BigDecimal.fromString("1").minus(new BigDecimal(event.params.k).div(new BigDecimal(k))) - let indexAssets = indexEntity.assets - for (let i = 0; i < indexAssets.length; i++) { - let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexAssets[i]) - let chainIDAssetArray = chainIDToAssetMappingEntity.assets - for (let y = 0; y < chainIDAssetArray.length; y++) { - let indexAssetEntity = loadIndexAssetEntity(chainIDAssetArray[y]) - indexAssetEntity.balance = indexAssetEntity.balance.times(assetScalar) - indexAssetEntity.save() - } - } - indexEntity.k = k.minus(event.params.k) - - indexEntity.save() - } - saveHistoricalData(event.address, event.block.timestamp) + const indexContext = dataSource.context(); + const reserveAsset = indexContext.getBytes("reserveAsset"); + const chainID = indexContext.getBigInt("chainID"); + + const reserveAssetEntity = createOrLoadIndexAssetEntity( + event.address, + reserveAsset, + chainID, + ); + const scalar = new BigDecimal(TEN.pow(u8(reserveAssetEntity.decimals))); + const amount = new BigDecimal(event.params.reserve).div(scalar); + reserveAssetEntity.balance = reserveAssetEntity.balance.minus(amount); + reserveAssetEntity.save(); + + if (event.params.k > ZERO) { + const indexEntity = createOrLoadIndexEntity(event.address); + + const assetScalar = BigDecimal.fromString("1").minus( + new BigDecimal(event.params.k).div(new BigDecimal(indexEntity.k!)), + ); + const indexAssets = indexEntity.assets; + for (let i = 0; i < indexAssets.length; i++) { + const chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity( + indexAssets[i], + ); + const chainIDAssetArray = chainIDToAssetMappingEntity.assets; + for (let y = 0; y < chainIDAssetArray.length; y++) { + const indexAssetEntity = loadIndexAssetEntity(chainIDAssetArray[y]); + indexAssetEntity.balance = indexAssetEntity.balance.times(assetScalar); + indexAssetEntity.save(); + } + } + + indexEntity.k = indexEntity.k!.minus(event.params.k); + + indexEntity.save(); + } + + saveHistoricalData(event.address, event.block.timestamp); } export function handleFeeAccrued(event: FeeAccrued): void { - let indexEntity = createOrLoadIndexEntity(event.address) - let fees = new BigDecimal(event.params.AUMFee.plus(event.params.depositFee).plus(event.params.redemptionFee)) - let scalar = new BigDecimal(BigInt.fromI32(10).pow(u8(indexEntity.decimals))) - fees = fees.div(scalar) - indexEntity.totalFees = indexEntity.totalFees!.plus(fees) - indexEntity.save() + const indexEntity = createOrLoadIndexEntity(event.address); + + const scalar = new BigDecimal(TEN.pow(u8(indexEntity.decimals))); + const fees = new BigDecimal( + event.params.AUMFee.plus(event.params.depositFee).plus( + event.params.redemptionFee, + ), + ).div(scalar); + + indexEntity.totalFees = indexEntity.totalFees!.plus(fees); + + indexEntity.save(); } export function handleSetConfigBuilder(event: SetConfigbuilderEvent): void { - let indexAddress = dataSource.context().getBytes('indexAddress') - let reserveAsset = dataSource.context().getBytes('reserveAsset') - let context = new DataSourceContext() - context.setBytes('indexAddress', indexAddress) - context.setBytes('reserveAsset', reserveAsset) - ConfigBuilderTemplate.createWithContext(event.params.configBuilder, context) + const indexContext = dataSource.context(); + const indexAddress = indexContext.getBytes("indexAddress"); + const reserveAsset = indexContext.getBytes("reserveAsset"); + + const configBuilderContext = new DataSourceContext(); + indexContext.setBytes("indexAddress", indexAddress); + indexContext.setBytes("reserveAsset", reserveAsset); + ConfigBuilderTemplate.createWithContext( + event.params.configBuilder, + configBuilderContext, + ); } From e40983289e676e50f47d5c007058d455c7882634 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Fri, 31 Jan 2025 16:18:43 +0000 Subject: [PATCH 08/13] fix: imports & configs & schema issues --- config/base.json | 51 +++++++++++++++++------------------------ schema.graphql | 1 + src/v3/ConfigBuilder.ts | 13 +++++++---- src/v3/IndexFactory.ts | 10 ++++---- src/v3/IndexToken.ts | 9 +++++--- 5 files changed, 43 insertions(+), 41 deletions(-) diff --git a/config/base.json b/config/base.json index 71b7d6b..4108054 100644 --- a/config/base.json +++ b/config/base.json @@ -1,31 +1,22 @@ { - "network": "base", - "chainID": 8453, - "v1": false, - "v2": { - "indexFactory": [ - { - "name": "CookieTestFactory", - "address": "0x91318C0675df6be2AA16A420cCC22705C66b37De", - "startBlock": 25377665, - "nativeAsset": { - "name": "Ethereum", - "symbol": "ETH", - "decimals": 18 - } - }, - { - "name": "JMXFactory", - "address": "0xb1E88fd8cC0bcfCaB479f7DDDb8e972a52c62Dfd", - "startBlock": 25386107, - "nativeAsset": { - "name": "Ethereum", - "symbol": "ETH", - "decimals": 18 - } - } - ] - }, - "ephtr": false, - "savingsVaults": false -} \ No newline at end of file + "network": "base", + "chainID": 8453, + "v1": false, + "v2": false, + "v3": { + "indexFactory": [ + { + "name": "JMXFactoryProd", + "address": "0x9c5816bd3B4C360427EFC5FCbFB82A60C8c279F8", + "startBlock": 25771303, + "nativeAsset": { + "name": "Ethereum", + "symbol": "ETH", + "decimals": 18 + } + } + ] + }, + "ephtr": false, + "savingsVaults": false +} diff --git a/schema.graphql b/schema.graphql index 4a45075..f609fb3 100644 --- a/schema.graphql +++ b/schema.graphql @@ -88,6 +88,7 @@ enum ProtocolVersion { Undefined v1 v2 + v3 } type ChainIDToAssetMapping @entity { diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index 0e76b9f..ef2e161 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -2,12 +2,13 @@ import { Address, BigDecimal, BigInt, - type Bytes, + Bytes, dataSource, ethereum, + log, } from "@graphprotocol/graph-ts"; -import type { +import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishRebalancing as FinishRebalancingEvent, @@ -30,7 +31,10 @@ import { BP, ONE, TEN, WAD, ZERO } from "../constants"; import { convertAUMFeeRate } from "../v1/FeePool"; export function handleConfigUpdate(event: ConfigUpdatedEvent): void { + log.info("1 TEST LOG: ",['HERE']) + // log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), event.params.chainId.toString()]) const indexAddress = dataSource.context().getBytes("indexAddress"); + log.info("2 TEST LOG: ",[indexAddress.toString()]) const indexEntity = createOrLoadIndexEntity(indexAddress); const configEntity = createOrLoadConfigEntity(indexAddress); const decoded = ethereum @@ -69,8 +73,9 @@ export function handleStartRebalancing(event: StartRebalancingEvent): void { } export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { - const indexAddress = dataSource.context().getBytes("indexAddress"); - const chainID = dataSource.context().getBigInt("chainID"); + const builderContext = dataSource.context() + const indexAddress = builderContext.getBytes("indexAddress"); + const chainID = builderContext.getBigInt("chainID"); const indexAssetEntity = createOrLoadIndexAssetEntity( indexAddress, diff --git a/src/v3/IndexFactory.ts b/src/v3/IndexFactory.ts index 3d00cae..7faae6b 100644 --- a/src/v3/IndexFactory.ts +++ b/src/v3/IndexFactory.ts @@ -5,7 +5,7 @@ import { dataSource, } from "@graphprotocol/graph-ts"; -import type { Deployed as DeployedEvent } from "../../generated/IndexFactoryV3/IndexFactoryV3"; +import { Deployed as DeployedEvent } from "../../generated/IndexFactoryV3/IndexFactoryV3"; import { IndexTokenV3 as indexTemplate } from "../../generated/templates"; import { createOrLoadChainIDToAssetMappingEntity, @@ -17,13 +17,15 @@ import { ONE, WAD, ZERO } from "../constants"; import { getTokenInfo } from "../v1/IndexFactory"; export function handleIndexDeployed(event: DeployedEvent): void { + const indexFactoryContext = dataSource.context(); + const chainID = indexFactoryContext.getBigInt("chainID"); + const indexContext = new DataSourceContext(); indexContext.setBytes("reserveAsset", event.params.reserve); indexContext.setBytes("indexAddress", event.params.index); + indexContext.setBigInt("chainID", chainID); indexTemplate.createWithContext(event.params.index, indexContext); - - const indexFactoryContext = dataSource.context(); - const chainID = indexFactoryContext.getBigInt("chainID"); + const index = createOrLoadIndexEntity(event.params.index); index.name = event.params.name; index.symbol = event.params.symbol; diff --git a/src/v3/IndexToken.ts b/src/v3/IndexToken.ts index 8295bce..acc7870 100644 --- a/src/v3/IndexToken.ts +++ b/src/v3/IndexToken.ts @@ -4,7 +4,7 @@ import { dataSource, } from "@graphprotocol/graph-ts"; import { ConfigBuilderV3 as ConfigBuilderTemplate } from "../../generated/templates"; -import type { +import { Deposit as DepositEvent, FeeAccrued, SetConfigBuilder as SetConfigbuilderEvent, @@ -104,10 +104,13 @@ export function handleSetConfigBuilder(event: SetConfigbuilderEvent): void { const indexContext = dataSource.context(); const indexAddress = indexContext.getBytes("indexAddress"); const reserveAsset = indexContext.getBytes("reserveAsset"); + const chainID = indexContext.getBigInt("chainID"); const configBuilderContext = new DataSourceContext(); - indexContext.setBytes("indexAddress", indexAddress); - indexContext.setBytes("reserveAsset", reserveAsset); + configBuilderContext.setBytes("indexAddress", indexAddress); + configBuilderContext.setBytes("reserveAsset", reserveAsset); + configBuilderContext.setBigInt("chainID", chainID); + ConfigBuilderTemplate.createWithContext( event.params.configBuilder, configBuilderContext, From c7d86c846e037b7bf36c523073256250b0aa4113 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Fri, 31 Jan 2025 17:17:02 +0000 Subject: [PATCH 09/13] fix: finish-rebalancing ossue --- src/v3/ConfigBuilder.ts | 70 ++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index ef2e161..b50712b 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -19,6 +19,7 @@ import { createOrLoadAnatomyEntity, createOrLoadChainIDToAssetMappingEntity, createOrLoadConfigEntity, + createOrLoadCurrencySetEntity, createOrLoadHistoricalIndexAssetEntity, createOrLoadHistoricalIndexBalanceEntity, createOrLoadIndexAssetEntity, @@ -236,45 +237,44 @@ export function saveHistoricalData(index: Bytes, timestamp: BigInt): void { } export function handleFinishRebalancing(event: FinishRebalancingEvent): void { - const indexAddress = dataSource.context().getBytes("indexAddress"); - const indexEntity = createOrLoadIndexEntity(indexAddress); - const anatomyEntity = createOrLoadAnatomyEntity(indexAddress); - const anatomyArray: string[] = []; - const chainID = dataSource.context().getBigInt("chainID"); - let count = 0; + const builderContext = dataSource.context() + let indexAddress = builderContext.getBytes('indexAddress') + let chainID = builderContext.getBigInt('chainID') - const currencyIndexArray = convertBitSetToIDs( - convertBigIntsToBitArray(event.params.newCurrencyIdSet), - ); - for (let y = 0; y < indexEntity.assets.length; y++) { - const chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity( - indexEntity.assets[y], - ); - const chainIndex = chainIDToAssetMappingEntity.chainIndex; - while (currencyIndexArray.length > 0) { - for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { - const indexAssetEntity = loadIndexAssetEntity( - chainIDToAssetMappingEntity.assets[x], - ); - const currencyID = indexAssetEntity.currencyID; - if (currencyIndexArray.length == 0) { - break; - } - if (currencyID && currencyID == currencyIndexArray[0]) { - indexAssetEntity.weight = event.params.weights[count]; - currencyIndexArray.splice(0, 1); - indexAssetEntity.save(); - count++; - } + // update index + let indexEntity = createOrLoadIndexEntity(indexAddress) + indexEntity.isRebalancing = false + indexEntity.save() + + // update currencySet + let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, ZERO) + currencySetEntity.sets = event.params.newCurrencyIdSet + currencySetEntity.save() + + // update asset weights + let count = 0 + let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newCurrencyIdSet)) + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) + while (currencyIndexArray.length > 0) { + for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { + let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[0]) + let currencyID = indexAssetEntity.currencyID + if (currencyIndexArray.length == 0) { + break + } + if (currencyID && currencyID == currencyIndexArray[0]) { + indexAssetEntity.weight = event.params.weights[count] + currencyIndexArray.splice(0, 1) + indexAssetEntity.save() + count++ } } - break; } - indexEntity.isRebalancing = false; - anatomyEntity.chainIdSet = [chainID]; - anatomyEntity.currencyIdSets = anatomyArray; - anatomyEntity.save(); - indexEntity.save(); + + // update anatomy + let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) + anatomyEntity.currencyIdSets = [currencySetEntity.id] + anatomyEntity.save() } export function convertBitSetToIDs(array: BigInt[]): BigInt[] { From 9c2aefa6af97b7f77b2eb569c2480406eec8b1f3 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Mon, 3 Feb 2025 12:47:26 +0000 Subject: [PATCH 10/13] fix: working weights --- src/v3/ConfigBuilder.ts | 119 +++++++++++++++++++++++++++++----------- 1 file changed, 88 insertions(+), 31 deletions(-) diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index b50712b..14dd9a3 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -236,45 +236,102 @@ export function saveHistoricalData(index: Bytes, timestamp: BigInt): void { historicalIndexBalanceEntity.save(); } -export function handleFinishRebalancing(event: FinishRebalancingEvent): void { - const builderContext = dataSource.context() - let indexAddress = builderContext.getBytes('indexAddress') - let chainID = builderContext.getBigInt('chainID') +// export function handleFinishRebalancing(event: FinishRebalancingEvent): void { +// log.error("weights {}", [event.params.weights.toString()]) +// log.error("newCurrencyIdSet {}", [event.params.newCurrencyIdSet.toString()]) - // update index - let indexEntity = createOrLoadIndexEntity(indexAddress) - indexEntity.isRebalancing = false - indexEntity.save() +// const builderContext = dataSource.context() +// let indexAddress = builderContext.getBytes('indexAddress') +// // let chainID = builderContext.getBigInt('chainID') - // update currencySet - let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, ZERO) - currencySetEntity.sets = event.params.newCurrencyIdSet - currencySetEntity.save() +// // update index +// let indexEntity = createOrLoadIndexEntity(indexAddress) +// indexEntity.isRebalancing = false +// indexEntity.save() - // update asset weights +// // update currencySet +// let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, ZERO) +// currencySetEntity.sets = event.params.newCurrencyIdSet +// currencySetEntity.save() + +// // update asset weights +// let count = 0 +// let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newCurrencyIdSet)) +// log.error("currencyIndexArray {}", [currencyIndexArray.toString()]) +// // let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) +// let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[0]) + +// while (currencyIndexArray.length > 0) { +// for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { +// // let indexAssetEntity = loadChainIDToAssetMappingEntity(chainIDToAssetMappingEntity.assets[0]) +// let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) +// let currencyID = indexAssetEntity.currencyID +// if (currencyIndexArray.length == 0) { +// break +// } +// if (currencyID && currencyID == currencyIndexArray[0]) { +// indexAssetEntity.weight = event.params.weights[count] +// currencyIndexArray.splice(0, 1) +// indexAssetEntity.save() +// count++ +// } +// } +// } + +// // update anatomy +// let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) +// anatomyEntity.currencyIdSets = [currencySetEntity.id] +// anatomyEntity.save() +// } + +export function handleFinishRebalancing(event: FinishRebalancingEvent): void { + log.error("weights {}", [event.params.weights.toString()]) + let indexAddress = dataSource.context().getBytes('indexAddress') + const chainID = dataSource.context().getBigInt('chainID') + let indexEntity = createOrLoadIndexEntity(indexAddress) + let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) + let anatomyArray: string[] = [] + let chainIndexArray = [chainID] + log.error(" chain index array {}", [chainIndexArray.toString()]) let count = 0 - let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newCurrencyIdSet)) - let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) - while (currencyIndexArray.length > 0) { - for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { - let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[0]) - let currencyID = indexAssetEntity.currencyID - if (currencyIndexArray.length == 0) { + for (let i = 0; i < chainIndexArray.length; i++) { + let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, chainIndexArray[i]) + currencySetEntity.sets = [event.params.newCurrencyIdSet[i]] + currencySetEntity.save() + anatomyArray.push(currencySetEntity.id) + + let currencyIndexArray = [event.params.newCurrencyIdSet[i]] + for (let y = 0; y < indexEntity.assets.length; y++) { + let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) + // let chainIndex = chainIDToAssetMappingEntity.chainIndex + // if (chainIndex && chainIndex == chainIndexArray[i]) { + log.error('currencyIndexArray: {} ', [currencyIndexArray.toString()]) + while (currencyIndexArray.length > 0) { + for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { + // log.debug('curr asset: {}',[chainIDToAssetMappingEntity.assets[x].toString()]) + let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) + // log.debug('indexAssetEntity:, asset: {}, chainID: {}, id: {}...',[indexAssetEntity.asset.toString(),indexAssetEntity.chainID.toString(),indexAssetEntity.id]) + // if (currencyIndexArray.length == 0) { + // break + // } + log.warning("indexAssetEntity.weight length {} , count : {}", [event.params.weights[count].toString(),count.toString()]) + indexAssetEntity.weight = event.params.weights[count] + currencyIndexArray.splice(0, 1) + indexAssetEntity.save() + count++ + + + } + } break - } - if (currencyID && currencyID == currencyIndexArray[0]) { - indexAssetEntity.weight = event.params.weights[count] - currencyIndexArray.splice(0, 1) - indexAssetEntity.save() - count++ - } + // } } } - - // update anatomy - let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) - anatomyEntity.currencyIdSets = [currencySetEntity.id] + indexEntity.isRebalancing = false + anatomyEntity.chainIdSet = event.params.newCurrencyIdSet + anatomyEntity.currencyIdSets = anatomyArray anatomyEntity.save() + indexEntity.save() } export function convertBitSetToIDs(array: BigInt[]): BigInt[] { From 95294de716104987dd5cc2c34f241a6b923f15ba Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Tue, 4 Feb 2025 13:24:48 +0000 Subject: [PATCH 11/13] WIP --- src/EntityCreation.ts | 1 + src/constants.ts | 2 + src/v3/ConfigBuilder.ts | 100 +++++++++++++++++++++++++++------------- src/v3/IndexFactory.ts | 2 + 4 files changed, 74 insertions(+), 31 deletions(-) diff --git a/src/EntityCreation.ts b/src/EntityCreation.ts index 241ed32..3651025 100644 --- a/src/EntityCreation.ts +++ b/src/EntityCreation.ts @@ -55,6 +55,7 @@ export function createOrLoadIndexAccountEntity(index: Bytes, account: Bytes): In export function createOrLoadIndexAssetEntity(index: Bytes, asset: Bytes, chainID: BigInt): IndexAsset { let id = index.toHexString().concat(chainID.toString()).concat(asset.toHexString()) + log.debug("createOrLoadIndexAssetEntity: index={} asset={} chainID={} new_id={} ", [index.toHexString(), asset.toHexString(), chainID.toString(), id]) let indexAsset = IndexAsset.loadInBlock(id) if (indexAsset == null) { indexAsset = IndexAsset.load(id) diff --git a/src/constants.ts b/src/constants.ts index 605610a..d0e7f11 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -5,3 +5,5 @@ export const ONE = BigInt.fromI32(1); export const TEN = BigInt.fromI32(10); export const BP = BigInt.fromI32(10000); export const WAD = TEN.pow(18); +export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' +export const ADDRESS_LENGTH = ZERO_ADDRESS.length diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index 14dd9a3..e495afe 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -28,7 +28,7 @@ import { loadIndexAssetEntity, } from "../EntityCreation"; -import { BP, ONE, TEN, WAD, ZERO } from "../constants"; +import { ADDRESS_LENGTH, BP, ONE, TEN, WAD, ZERO } from "../constants"; import { convertAUMFeeRate } from "../v1/FeePool"; export function handleConfigUpdate(event: ConfigUpdatedEvent): void { @@ -73,10 +73,27 @@ export function handleStartRebalancing(event: StartRebalancingEvent): void { indexEntity.save(); } +// export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { +// let indexAddress = dataSource.context().getBytes('indexAddress') +// log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), event.params.chainId.toString()]) +// let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, event.params.currency, event.params.chainId) +// let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, event.params.chainId) +// indexAssetEntity.name = event.params.name +// indexAssetEntity.symbol = event.params.symbol +// indexAssetEntity.decimals = event.params.decimals +// indexAssetEntity.currencyID = chainIDToAssetMappingEntity.registeredAssets + +// chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(BigInt.fromI32(1)) + +// chainIDToAssetMappingEntity.save() +// indexAssetEntity.save() +// } + export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { const builderContext = dataSource.context() const indexAddress = builderContext.getBytes("indexAddress"); const chainID = builderContext.getBigInt("chainID"); + log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), chainID.toString()]) const indexAssetEntity = createOrLoadIndexAssetEntity( indexAddress, @@ -95,6 +112,7 @@ export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(ONE); + log.debug('CurrencyRegisteredEvent chainIDToAssetMappingEntity: ',[chainIDToAssetMappingEntity.assets.join('-')]) chainIDToAssetMappingEntity.save(); indexAssetEntity.save(); } @@ -111,6 +129,9 @@ export function handleFinishChainRebalancing( chainID, ); chainIDToAssetMappingEntity.latestSnapshot = event.params.snapshot; + log.debug('FinishVaultRebalancingEvent indexEntity.assets: {} , event.params.currencies: {}',[indexEntity.assets.join('-'),event.params.currencies.join('-')]) + log.debug('FinishVaultRebalancingEvent chainIDToAssetMappingEntity.assets: {}',[chainIDToAssetMappingEntity.assets.join('-')]) + log.debug('FinishVaultRebalancingEvent T/F = {}',[event.params.currencies.length ===0?'true':'false']) if (event.params.currencies.length == 0) { for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { const indexAssetEntity = loadIndexAssetEntity( @@ -133,13 +154,13 @@ export function handleFinishChainRebalancing( chainIDToAssetMappingEntity.assets = emptyAssetArray; chainIDToAssetMappingEntity.save(); - if (chainID != indexEntity.chainID) { + // if (chainID != indexEntity.chainID) { const indexAssets = indexEntity.assets; const idx = indexAssets.indexOf(chainIDToAssetMappingEntity.id); indexAssets.splice(idx, 1); indexEntity.assets = indexAssets; indexEntity.save(); - } + // } } else { const chainIDAssetArray: string[] = []; const reserveAssetEntity = createOrLoadIndexAssetEntity( @@ -154,29 +175,32 @@ export function handleFinishChainRebalancing( } for (let i = 0; i < event.params.currencies.length; i++) { const balance = new BigDecimal(event.params.balances[i]); - const asset = event.params.currencies[i].toString(); - let assetConverted: Bytes; - if (asset.length == 3) { - assetConverted = Address.fromString( - "0x0000000000000000000000000000000000000000", - ); - } else { - assetConverted = Address.fromHexString( - "0x".concat("0".repeat(42 - asset.length)).concat(asset.slice(2)), - ); - } + const asset = event.params.currencies[i]; + log.warning('FinishVaultRebalancingEvent currencies[i] = {}',[asset.toHexString()]) + // if (asset.length == 3) { + // assetConverted = Address.fromString( + // "0x0000000000000000000000000000000000000000", + // ); + // } else { + // assetConverted = Address.fromHexString( + // "0x".concat("0".repeat(42 - asset.length)).concat(asset.slice(2)), + // ); + // } const indexAssetEntity = createOrLoadIndexAssetEntity( indexAddress, - assetConverted, + asset, chainID, ); const scalar = new BigDecimal(TEN.pow(u8(indexAssetEntity.decimals))); indexAssetEntity.balance = balance.div(scalar); + // indexAssetEntity.asset = asset indexAssetEntity.save(); if (indexAssetEntity.id != reserveAssetEntity.id) { chainIDAssetArray.push(indexAssetEntity.id); } } + log.error('chainIDAssetArray = {}', [chainIDAssetArray.join('-')]) + log.error('chainIDToAssetMappingEntity = {}', [chainIDToAssetMappingEntity.assets.join('-')]) for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { const id = chainIDToAssetMappingEntity.assets[i]; if (!chainIDAssetArray.includes(id)) { @@ -186,11 +210,15 @@ export function handleFinishChainRebalancing( indexAssetEntity.save(); } } + log.debug('FinishVaultRebalancingEvent chainIDToAssetMappingEntity.assets: {}',[chainIDToAssetMappingEntity.assets.join('-')]) chainIDToAssetMappingEntity.assets = chainIDAssetArray; + chainIDToAssetMappingEntity.save(); + log.debug('FinishVaultRebalancingEvent chainIDToAssetMappingEntity.id == {} ',[chainIDToAssetMappingEntity.id]) if (!indexEntity.assets.includes(chainIDToAssetMappingEntity.id)) { const indexAssetArray = indexEntity.assets; indexAssetArray.push(chainIDToAssetMappingEntity.id); + log.debug('indexAssetArray: {}',[indexAssetArray.join('-')]) indexEntity.assets = indexAssetArray; indexEntity.save(); } @@ -292,40 +320,50 @@ export function handleFinishRebalancing(event: FinishRebalancingEvent): void { let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) let anatomyArray: string[] = [] let chainIndexArray = [chainID] + // let chainIndexArray = [ZERO] log.error(" chain index array {}", [chainIndexArray.toString()]) - let count = 0 + // let count = 0 for (let i = 0; i < chainIndexArray.length; i++) { let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, chainIndexArray[i]) currencySetEntity.sets = [event.params.newCurrencyIdSet[i]] currencySetEntity.save() anatomyArray.push(currencySetEntity.id) - let currencyIndexArray = [event.params.newCurrencyIdSet[i]] - for (let y = 0; y < indexEntity.assets.length; y++) { - let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) + // let currencyIndexArray = [event.params.newCurrencyIdSet[i]] + log.error('indexEntity.assets: {} ',[indexEntity.assets.join('-')]) + log.error('indexEntity ASSET 1: {} ',[indexEntity.assets[0].toString()]) + // log.error('indexEntity ASSET 2: {} ',[indexEntity.assets[2].toString()]) + // for (let y = 0; y < indexEntity.assets.length; y++) { + // let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress,chainID) + // chainIDToAssetMappingEntity.assets // let chainIndex = chainIDToAssetMappingEntity.chainIndex // if (chainIndex && chainIndex == chainIndexArray[i]) { - log.error('currencyIndexArray: {} ', [currencyIndexArray.toString()]) - while (currencyIndexArray.length > 0) { + // log.error('currencyIndexArray: {} ', [currencyIndexArray.toString()]) + log.error('chainIDToAssetMappingEntity.assets: {} ', [chainIDToAssetMappingEntity.assets.join('-')]) + // while (currencyIndexArray.length > 0) { for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { - // log.debug('curr asset: {}',[chainIDToAssetMappingEntity.assets[x].toString()]) - let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) - // log.debug('indexAssetEntity:, asset: {}, chainID: {}, id: {}...',[indexAssetEntity.asset.toString(),indexAssetEntity.chainID.toString(),indexAssetEntity.id]) + const assetAddress = chainIDToAssetMappingEntity.assets[x].slice(-ADDRESS_LENGTH) + log.warning('curr asset: {} , curr index asset : {}, ADDRESS ={}',[chainIDToAssetMappingEntity.assets[x].toString(),indexEntity.assets[x].toString(),assetAddress]) + // let indexAssetEntity = loadIndexAssetEntity(indexEntity.assets[x]) + // let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) + const indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, Address.fromHexString(assetAddress), chainID) + log.debug('indexAssetEntity::, asset: {}, chainID: {}, id: {}...',[indexAssetEntity.asset.toString(),indexAssetEntity.chainID.toString(),indexAssetEntity.id]) // if (currencyIndexArray.length == 0) { // break // } - log.warning("indexAssetEntity.weight length {} , count : {}", [event.params.weights[count].toString(),count.toString()]) - indexAssetEntity.weight = event.params.weights[count] - currencyIndexArray.splice(0, 1) + log.warning("indexAssetEntity.weight length {} , count : {}", [event.params.weights[x].toString(),x.toString()]) + indexAssetEntity.weight = event.params.weights[x] + // currencyIndexArray.splice(0, 1) indexAssetEntity.save() - count++ + // count++ } - } - break + // } + // break // } - } + // } } indexEntity.isRebalancing = false anatomyEntity.chainIdSet = event.params.newCurrencyIdSet diff --git a/src/v3/IndexFactory.ts b/src/v3/IndexFactory.ts index 7faae6b..e46dd92 100644 --- a/src/v3/IndexFactory.ts +++ b/src/v3/IndexFactory.ts @@ -3,6 +3,7 @@ import { BigDecimal, DataSourceContext, dataSource, + log, } from "@graphprotocol/graph-ts"; import { Deployed as DeployedEvent } from "../../generated/IndexFactoryV3/IndexFactoryV3"; @@ -70,6 +71,7 @@ export function handleIndexDeployed(event: DeployedEvent): void { const indexAssetArray: string[] = []; indexAssetArray.push(chainIDToAssetMappingEntity.id); + log.debug('DeployedEvent indexAssetArray = {}',[indexAssetArray.join('-')]) index.assets = indexAssetArray; chainIDToAssetMappingEntity.save(); indexAssetEntity.save(); From 962a19c28068b46894de1ed1aec51c0347728b17 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Tue, 4 Feb 2025 14:33:31 +0000 Subject: [PATCH 12/13] fix: extra logs deleted --- src/v3/ConfigBuilder.ts | 154 +++++----------------------------------- 1 file changed, 18 insertions(+), 136 deletions(-) diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index e495afe..f124c2a 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -1,14 +1,13 @@ import { - Address, BigDecimal, BigInt, Bytes, dataSource, ethereum, - log, + log } from "@graphprotocol/graph-ts"; -import { +import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishRebalancing as FinishRebalancingEvent, @@ -28,14 +27,11 @@ import { loadIndexAssetEntity, } from "../EntityCreation"; -import { ADDRESS_LENGTH, BP, ONE, TEN, WAD, ZERO } from "../constants"; +import { BP, ONE, TEN, WAD, ZERO } from "../constants"; import { convertAUMFeeRate } from "../v1/FeePool"; export function handleConfigUpdate(event: ConfigUpdatedEvent): void { - log.info("1 TEST LOG: ",['HERE']) - // log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), event.params.chainId.toString()]) const indexAddress = dataSource.context().getBytes("indexAddress"); - log.info("2 TEST LOG: ",[indexAddress.toString()]) const indexEntity = createOrLoadIndexEntity(indexAddress); const configEntity = createOrLoadConfigEntity(indexAddress); const decoded = ethereum @@ -73,22 +69,6 @@ export function handleStartRebalancing(event: StartRebalancingEvent): void { indexEntity.save(); } -// export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { -// let indexAddress = dataSource.context().getBytes('indexAddress') -// log.debug("Currency registered event: {} {} {} {} {}", [event.params.name, event.params.symbol, event.params.decimals.toString(), event.params.currency.toHexString(), event.params.chainId.toString()]) -// let indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, event.params.currency, event.params.chainId) -// let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, event.params.chainId) -// indexAssetEntity.name = event.params.name -// indexAssetEntity.symbol = event.params.symbol -// indexAssetEntity.decimals = event.params.decimals -// indexAssetEntity.currencyID = chainIDToAssetMappingEntity.registeredAssets - -// chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(BigInt.fromI32(1)) - -// chainIDToAssetMappingEntity.save() -// indexAssetEntity.save() -// } - export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { const builderContext = dataSource.context() const indexAddress = builderContext.getBytes("indexAddress"); @@ -112,7 +92,7 @@ export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(ONE); - log.debug('CurrencyRegisteredEvent chainIDToAssetMappingEntity: ',[chainIDToAssetMappingEntity.assets.join('-')]) + log.debug('CurrencyRegisteredEvent chainIDToAssetMappingEntity: ', [chainIDToAssetMappingEntity.assets.join('-')]) chainIDToAssetMappingEntity.save(); indexAssetEntity.save(); } @@ -129,9 +109,6 @@ export function handleFinishChainRebalancing( chainID, ); chainIDToAssetMappingEntity.latestSnapshot = event.params.snapshot; - log.debug('FinishVaultRebalancingEvent indexEntity.assets: {} , event.params.currencies: {}',[indexEntity.assets.join('-'),event.params.currencies.join('-')]) - log.debug('FinishVaultRebalancingEvent chainIDToAssetMappingEntity.assets: {}',[chainIDToAssetMappingEntity.assets.join('-')]) - log.debug('FinishVaultRebalancingEvent T/F = {}',[event.params.currencies.length ===0?'true':'false']) if (event.params.currencies.length == 0) { for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { const indexAssetEntity = loadIndexAssetEntity( @@ -154,13 +131,11 @@ export function handleFinishChainRebalancing( chainIDToAssetMappingEntity.assets = emptyAssetArray; chainIDToAssetMappingEntity.save(); - // if (chainID != indexEntity.chainID) { - const indexAssets = indexEntity.assets; - const idx = indexAssets.indexOf(chainIDToAssetMappingEntity.id); - indexAssets.splice(idx, 1); - indexEntity.assets = indexAssets; - indexEntity.save(); - // } + const indexAssets = indexEntity.assets; + const idx = indexAssets.indexOf(chainIDToAssetMappingEntity.id); + indexAssets.splice(idx, 1); + indexEntity.assets = indexAssets; + indexEntity.save(); } else { const chainIDAssetArray: string[] = []; const reserveAssetEntity = createOrLoadIndexAssetEntity( @@ -176,16 +151,7 @@ export function handleFinishChainRebalancing( for (let i = 0; i < event.params.currencies.length; i++) { const balance = new BigDecimal(event.params.balances[i]); const asset = event.params.currencies[i]; - log.warning('FinishVaultRebalancingEvent currencies[i] = {}',[asset.toHexString()]) - // if (asset.length == 3) { - // assetConverted = Address.fromString( - // "0x0000000000000000000000000000000000000000", - // ); - // } else { - // assetConverted = Address.fromHexString( - // "0x".concat("0".repeat(42 - asset.length)).concat(asset.slice(2)), - // ); - // } + log.warning('FinishVaultRebalancingEvent currencies[i] = {}', [asset.toHexString()]) const indexAssetEntity = createOrLoadIndexAssetEntity( indexAddress, asset, @@ -193,14 +159,11 @@ export function handleFinishChainRebalancing( ); const scalar = new BigDecimal(TEN.pow(u8(indexAssetEntity.decimals))); indexAssetEntity.balance = balance.div(scalar); - // indexAssetEntity.asset = asset indexAssetEntity.save(); if (indexAssetEntity.id != reserveAssetEntity.id) { chainIDAssetArray.push(indexAssetEntity.id); } } - log.error('chainIDAssetArray = {}', [chainIDAssetArray.join('-')]) - log.error('chainIDToAssetMappingEntity = {}', [chainIDToAssetMappingEntity.assets.join('-')]) for (let i = 0; i < chainIDToAssetMappingEntity.assets.length; i++) { const id = chainIDToAssetMappingEntity.assets[i]; if (!chainIDAssetArray.includes(id)) { @@ -210,15 +173,13 @@ export function handleFinishChainRebalancing( indexAssetEntity.save(); } } - log.debug('FinishVaultRebalancingEvent chainIDToAssetMappingEntity.assets: {}',[chainIDToAssetMappingEntity.assets.join('-')]) chainIDToAssetMappingEntity.assets = chainIDAssetArray; chainIDToAssetMappingEntity.save(); - log.debug('FinishVaultRebalancingEvent chainIDToAssetMappingEntity.id == {} ',[chainIDToAssetMappingEntity.id]) if (!indexEntity.assets.includes(chainIDToAssetMappingEntity.id)) { const indexAssetArray = indexEntity.assets; indexAssetArray.push(chainIDToAssetMappingEntity.id); - log.debug('indexAssetArray: {}',[indexAssetArray.join('-')]) + log.debug('indexAssetArray: {}', [indexAssetArray.join('-')]) indexEntity.assets = indexAssetArray; indexEntity.save(); } @@ -264,54 +225,6 @@ export function saveHistoricalData(index: Bytes, timestamp: BigInt): void { historicalIndexBalanceEntity.save(); } -// export function handleFinishRebalancing(event: FinishRebalancingEvent): void { -// log.error("weights {}", [event.params.weights.toString()]) -// log.error("newCurrencyIdSet {}", [event.params.newCurrencyIdSet.toString()]) - -// const builderContext = dataSource.context() -// let indexAddress = builderContext.getBytes('indexAddress') -// // let chainID = builderContext.getBigInt('chainID') - -// // update index -// let indexEntity = createOrLoadIndexEntity(indexAddress) -// indexEntity.isRebalancing = false -// indexEntity.save() - -// // update currencySet -// let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, ZERO) -// currencySetEntity.sets = event.params.newCurrencyIdSet -// currencySetEntity.save() - -// // update asset weights -// let count = 0 -// let currencyIndexArray = convertBitSetToIDs(convertBigIntsToBitArray(event.params.newCurrencyIdSet)) -// log.error("currencyIndexArray {}", [currencyIndexArray.toString()]) -// // let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) -// let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[0]) - -// while (currencyIndexArray.length > 0) { -// for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { -// // let indexAssetEntity = loadChainIDToAssetMappingEntity(chainIDToAssetMappingEntity.assets[0]) -// let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) -// let currencyID = indexAssetEntity.currencyID -// if (currencyIndexArray.length == 0) { -// break -// } -// if (currencyID && currencyID == currencyIndexArray[0]) { -// indexAssetEntity.weight = event.params.weights[count] -// currencyIndexArray.splice(0, 1) -// indexAssetEntity.save() -// count++ -// } -// } -// } - -// // update anatomy -// let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) -// anatomyEntity.currencyIdSets = [currencySetEntity.id] -// anatomyEntity.save() -// } - export function handleFinishRebalancing(event: FinishRebalancingEvent): void { log.error("weights {}", [event.params.weights.toString()]) let indexAddress = dataSource.context().getBytes('indexAddress') @@ -320,50 +233,19 @@ export function handleFinishRebalancing(event: FinishRebalancingEvent): void { let anatomyEntity = createOrLoadAnatomyEntity(indexAddress) let anatomyArray: string[] = [] let chainIndexArray = [chainID] - // let chainIndexArray = [ZERO] - log.error(" chain index array {}", [chainIndexArray.toString()]) - // let count = 0 for (let i = 0; i < chainIndexArray.length; i++) { let currencySetEntity = createOrLoadCurrencySetEntity(indexAddress, chainIndexArray[i]) currencySetEntity.sets = [event.params.newCurrencyIdSet[i]] currencySetEntity.save() anatomyArray.push(currencySetEntity.id) + let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress, chainID) + + for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { + const indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) + indexAssetEntity.weight = event.params.weights[x] + indexAssetEntity.save() + } - // let currencyIndexArray = [event.params.newCurrencyIdSet[i]] - log.error('indexEntity.assets: {} ',[indexEntity.assets.join('-')]) - log.error('indexEntity ASSET 1: {} ',[indexEntity.assets[0].toString()]) - // log.error('indexEntity ASSET 2: {} ',[indexEntity.assets[2].toString()]) - // for (let y = 0; y < indexEntity.assets.length; y++) { - // let chainIDToAssetMappingEntity = loadChainIDToAssetMappingEntity(indexEntity.assets[y]) - let chainIDToAssetMappingEntity = createOrLoadChainIDToAssetMappingEntity(indexAddress,chainID) - // chainIDToAssetMappingEntity.assets - // let chainIndex = chainIDToAssetMappingEntity.chainIndex - // if (chainIndex && chainIndex == chainIndexArray[i]) { - // log.error('currencyIndexArray: {} ', [currencyIndexArray.toString()]) - log.error('chainIDToAssetMappingEntity.assets: {} ', [chainIDToAssetMappingEntity.assets.join('-')]) - // while (currencyIndexArray.length > 0) { - for (let x = 0; x < chainIDToAssetMappingEntity.assets.length; x++) { - const assetAddress = chainIDToAssetMappingEntity.assets[x].slice(-ADDRESS_LENGTH) - log.warning('curr asset: {} , curr index asset : {}, ADDRESS ={}',[chainIDToAssetMappingEntity.assets[x].toString(),indexEntity.assets[x].toString(),assetAddress]) - // let indexAssetEntity = loadIndexAssetEntity(indexEntity.assets[x]) - // let indexAssetEntity = loadIndexAssetEntity(chainIDToAssetMappingEntity.assets[x]) - const indexAssetEntity = createOrLoadIndexAssetEntity(indexAddress, Address.fromHexString(assetAddress), chainID) - log.debug('indexAssetEntity::, asset: {}, chainID: {}, id: {}...',[indexAssetEntity.asset.toString(),indexAssetEntity.chainID.toString(),indexAssetEntity.id]) - // if (currencyIndexArray.length == 0) { - // break - // } - log.warning("indexAssetEntity.weight length {} , count : {}", [event.params.weights[x].toString(),x.toString()]) - indexAssetEntity.weight = event.params.weights[x] - // currencyIndexArray.splice(0, 1) - indexAssetEntity.save() - // count++ - - - } - // } - // break - // } - // } } indexEntity.isRebalancing = false anatomyEntity.chainIdSet = event.params.newCurrencyIdSet From f33446d77f615f5fbbc2c8cb8abeec49fa3281a5 Mon Sep 17 00:00:00 2001 From: Gulikovskiy Date: Tue, 4 Feb 2025 15:30:22 +0000 Subject: [PATCH 13/13] fix: logs --- src/EntityCreation.ts | 1 - src/v2/ConfigBuilder.ts | 7 +++---- src/v3/ConfigBuilder.ts | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/EntityCreation.ts b/src/EntityCreation.ts index 3651025..241ed32 100644 --- a/src/EntityCreation.ts +++ b/src/EntityCreation.ts @@ -55,7 +55,6 @@ export function createOrLoadIndexAccountEntity(index: Bytes, account: Bytes): In export function createOrLoadIndexAssetEntity(index: Bytes, asset: Bytes, chainID: BigInt): IndexAsset { let id = index.toHexString().concat(chainID.toString()).concat(asset.toHexString()) - log.debug("createOrLoadIndexAssetEntity: index={} asset={} chainID={} new_id={} ", [index.toHexString(), asset.toHexString(), chainID.toString(), id]) let indexAsset = IndexAsset.loadInBlock(id) if (indexAsset == null) { indexAsset = IndexAsset.load(id) diff --git a/src/v2/ConfigBuilder.ts b/src/v2/ConfigBuilder.ts index 50fce6e..a893ec3 100644 --- a/src/v2/ConfigBuilder.ts +++ b/src/v2/ConfigBuilder.ts @@ -1,9 +1,8 @@ -import { Bytes, BigInt, Address, ethereum, dataSource, BigDecimal, log, ByteArray, TypedMap, DataSourceContext } from "@graphprotocol/graph-ts"; +import { Address, BigDecimal, BigInt, Bytes, dataSource, DataSourceContext, ethereum, log, TypedMap } from "@graphprotocol/graph-ts"; +import { Messenger } from "../../generated/templates"; +import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishChainRebalancing as FinishChainRebalancingEvent, FinishRebalancing as FinishRebalancingEvent, RegisterChain as RegisterChainEvent, SetMessenger as SetMessengerEvent, StartRebalancing as StartRebalancingEvent } from "../../generated/templates/ConfigBuilder/ConfigBuilder"; import { createOrLoadAnatomyEntity, createOrLoadChainIDToAssetMappingEntity, createOrLoadConfigEntity, createOrLoadCurrencySetEntity, createOrLoadHistoricalIndexAssetEntity, createOrLoadHistoricalIndexBalanceEntity, createOrLoadIndexAssetEntity, createOrLoadIndexEntity, loadChainIDToAssetMappingEntity, loadIndexAssetEntity } from "../EntityCreation"; -import { ConfigUpdated as ConfigUpdatedEvent, CurrencyRegistered as CurrencyRegisteredEvent, FinishChainRebalancing as FinishChainRebalancingEvent, RegisterChain as RegisterChainEvent, FinishRebalancing as FinishRebalancingEvent, SetMessenger as SetMessengerEvent, StartRebalancing as StartRebalancingEvent } from "../../generated/templates/ConfigBuilder/ConfigBuilder" import { convertAUMFeeRate } from "../v1/FeePool"; -import { CurrencySet, HistoricalIndexAsset } from "../../generated/schema"; -import { Messenger } from "../../generated/templates"; export function handleConfigUpdate(event: ConfigUpdatedEvent): void { let indexAddress = dataSource.context().getBytes('indexAddress') diff --git a/src/v3/ConfigBuilder.ts b/src/v3/ConfigBuilder.ts index f124c2a..a4b85ba 100644 --- a/src/v3/ConfigBuilder.ts +++ b/src/v3/ConfigBuilder.ts @@ -92,7 +92,6 @@ export function handleCurrencyRegistered(event: CurrencyRegisteredEvent): void { chainIDToAssetMappingEntity.registeredAssets = chainIDToAssetMappingEntity.registeredAssets!.plus(ONE); - log.debug('CurrencyRegisteredEvent chainIDToAssetMappingEntity: ', [chainIDToAssetMappingEntity.assets.join('-')]) chainIDToAssetMappingEntity.save(); indexAssetEntity.save(); } @@ -226,7 +225,7 @@ export function saveHistoricalData(index: Bytes, timestamp: BigInt): void { } export function handleFinishRebalancing(event: FinishRebalancingEvent): void { - log.error("weights {}", [event.params.weights.toString()]) + log.debug("weights {}", [event.params.weights.toString()]) let indexAddress = dataSource.context().getBytes('indexAddress') const chainID = dataSource.context().getBigInt('chainID') let indexEntity = createOrLoadIndexEntity(indexAddress)