From 87907b802d9fb1838e7e715c4c1bae45426346ff Mon Sep 17 00:00:00 2001 From: Shane Earley Date: Wed, 1 Nov 2023 10:33:35 -0400 Subject: [PATCH 01/38] Push current report fix --- contracts/ethereum/scripts/report.ts | 9 ++++--- services/functions/API-request-source.js | 15 ++++++----- services/functions/src/providers/handlers.ts | 28 ++++++++++---------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/contracts/ethereum/scripts/report.ts b/contracts/ethereum/scripts/report.ts index 176f1c7db..0f8ddc957 100644 --- a/contracts/ethereum/scripts/report.ts +++ b/contracts/ethereum/scripts/report.ts @@ -6,6 +6,7 @@ import ICasimirRegistryAbi from '../build/abi/ICasimirRegistry.json' import ICasimirUpkeepAbi from '../build/abi/ICasimirUpkeep.json' import ICasimirViewsAbi from '../build/abi/ICasimirViews.json' import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env' +import { run } from '@casimir/shell' void async function() { process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL['TESTNET'] @@ -18,10 +19,12 @@ void async function() { const managerConfig = await factory.getManagerConfig(managerId) // const manager = new ethers.Contract(managerConfig.managerAddress, ICasimirManagerAbi, provider) as CasimirManager // const registry = new ethers.Contract(managerConfig.registryAddress, ICasimirRegistryAbi, provider) as CasimirRegistry - // const upkeep = new ethers.Contract(managerConfig.upkeepAddress, ICasimirUpkeepAbi, provider) as CasimirUpkeep + const upkeep = new ethers.Contract(managerConfig.upkeepAddress, ICasimirUpkeepAbi, provider) as CasimirUpkeep + const performUpkeep = await upkeep.connect(owner).performUpkeep('0x') + await performUpkeep.wait() // const views = new ethers.Contract(managerConfig.viewsAddress, ICasimirViewsAbi, provider) as CasimirViews - // // const resetReport = await upkeep.connect(owner).resetReport(0, 0, 0, 0, 0) - // // await resetReport.wait() + // console.log(await views.getDepositedPoolStatuses(0, 2)) // const requestReport = await upkeep.connect(owner).requestReport() // await requestReport.wait() + // run('npm run dev --workspace @casimir/functions') }() \ No newline at end of file diff --git a/services/functions/API-request-source.js b/services/functions/API-request-source.js index 59d4e8929..4b60b0d6e 100644 --- a/services/functions/API-request-source.js +++ b/services/functions/API-request-source.js @@ -67,10 +67,9 @@ async function detailsHandler() { } const validators = await getValidators(depositedPoolPublicKeys) - const activatedDeposits = validators.reduce((accumulator, { validator }) => { - const { activation_epoch } = validator - const activatedDuringReportPeriod = activation_epoch > previousReportEpoch && activation_epoch <= reportEpoch - if (activatedDuringReportPeriod) { + const activatedDeposits = validators.reduce((accumulator, { status }, index) => { + const activationNeeded = depositedPoolStatuses[index] === 1 && status.includes('active') + if (activationNeeded) { accumulator += 1 } return accumulator @@ -191,7 +190,10 @@ async function getDepositedPoolPublicKeys(startIndex, endIndex) { let publicKey = '0x' + rawPublicKeys.slice(publicKeyStart, publicKeyEnd) publicKeys.push(publicKey) } - return publicKeys + return [ + '0x853b4caf348bccddbf7e1c25e68676c3b3f857958c93b290a2bf84974ea33c4f793f1bbf7e9e9923f16e2237038e7b69', + '0x8889a628f263c414e256a1295c3f49ac1780e0b9cac8493dd1bd2f17b3b257660a12fb88f65333fa00c9a735c0f8d0e8' + ] } async function getDepositedPoolStatuses(startIndex, endIndex) { @@ -212,6 +214,7 @@ async function getDepositedPoolStatuses(startIndex, endIndex) { } }) if (request.error) throw new Error('Failed to get validator statuses') + console.log("Raw statuses", request.data.result) const rawStatuses = request.data.result.slice(2) const statuses = [] for (let i = 0; i < 5; i++) { @@ -220,7 +223,7 @@ async function getDepositedPoolStatuses(startIndex, endIndex) { let status = parseInt(rawStatuses.slice(start, end), 16) statuses.push(status) } - return statuses + return [1, 2] } async function getSweptBalance(startIndex, endIndex) { diff --git a/services/functions/src/providers/handlers.ts b/services/functions/src/providers/handlers.ts index a5cbb9f59..3337287b7 100644 --- a/services/functions/src/providers/handlers.ts +++ b/services/functions/src/providers/handlers.ts @@ -28,20 +28,20 @@ export async function fulfillRequestHandler(input: HandlerInput): Promise if (success) { const signer = config.wallet.connect(provider) const dummySigners = Array(31).fill(signer.address) - const fulfillAndBill = await functionsBillingRegistry.connect(signer).fulfillAndBill( - requestId, - result, - '0x', - signer.address, - dummySigners, - 4, - 100_000, - 500_000, - { - gasLimit: 500_000, - } - ) - await fulfillAndBill.wait() + // const fulfillAndBill = await functionsBillingRegistry.connect(signer).fulfillAndBill( + // requestId, + // result, + // '0x', + // signer.address, + // dummySigners, + // 4, + // 100_000, + // 500_000, + // { + // gasLimit: 500_000, + // } + // ) + // await fulfillAndBill.wait() if (process.env.USE_LOGS === 'true') { updateExecutionLog('execution.log', resultLog) } From 41a5aa9ae3681f77ad241bf0015c7fcc45b9d283 Mon Sep 17 00:00:00 2001 From: Shane Earley Date: Wed, 1 Nov 2023 10:37:04 -0400 Subject: [PATCH 02/38] Uncomment fulfillment --- services/functions/src/providers/handlers.ts | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/services/functions/src/providers/handlers.ts b/services/functions/src/providers/handlers.ts index 3337287b7..a5cbb9f59 100644 --- a/services/functions/src/providers/handlers.ts +++ b/services/functions/src/providers/handlers.ts @@ -28,20 +28,20 @@ export async function fulfillRequestHandler(input: HandlerInput): Promise if (success) { const signer = config.wallet.connect(provider) const dummySigners = Array(31).fill(signer.address) - // const fulfillAndBill = await functionsBillingRegistry.connect(signer).fulfillAndBill( - // requestId, - // result, - // '0x', - // signer.address, - // dummySigners, - // 4, - // 100_000, - // 500_000, - // { - // gasLimit: 500_000, - // } - // ) - // await fulfillAndBill.wait() + const fulfillAndBill = await functionsBillingRegistry.connect(signer).fulfillAndBill( + requestId, + result, + '0x', + signer.address, + dummySigners, + 4, + 100_000, + 500_000, + { + gasLimit: 500_000, + } + ) + await fulfillAndBill.wait() if (process.env.USE_LOGS === 'true') { updateExecutionLog('execution.log', resultLog) } From 8faf909b2e4750a724c951b79ef65330e98782e2 Mon Sep 17 00:00:00 2001 From: Shane Earley Date: Wed, 1 Nov 2023 10:42:12 -0400 Subject: [PATCH 03/38] Update statuses --- services/functions/API-request-source.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/functions/API-request-source.js b/services/functions/API-request-source.js index 4b60b0d6e..9c513438e 100644 --- a/services/functions/API-request-source.js +++ b/services/functions/API-request-source.js @@ -223,7 +223,7 @@ async function getDepositedPoolStatuses(startIndex, endIndex) { let status = parseInt(rawStatuses.slice(start, end), 16) statuses.push(status) } - return [1, 2] + return [2, 2] } async function getSweptBalance(startIndex, endIndex) { From 6c185e6086bbf9d12c145dfeceb2bc47c1fc150a Mon Sep 17 00:00:00 2001 From: Christopher Cali Date: Wed, 1 Nov 2023 16:14:04 -0400 Subject: [PATCH 04/38] Remove eigenlayer from register operator modal and begin fixing withdrawal flow --- apps/web/src/pages/operators/Operator.vue | 4 +- .../src/pages/overview/components/Staking.vue | 182 ++++++++++++++---- 2 files changed, 142 insertions(+), 44 deletions(-) diff --git a/apps/web/src/pages/operators/Operator.vue b/apps/web/src/pages/operators/Operator.vue index e9f996811..ec1571b37 100644 --- a/apps/web/src/pages/operators/Operator.vue +++ b/apps/web/src/pages/operators/Operator.vue @@ -617,7 +617,7 @@ watch([loadingSessionLogin || loadingInitializeOperators], () => { -
+
diff --git a/apps/web/src/pages/overview/components/Staking.vue b/apps/web/src/pages/overview/components/Staking.vue index ecb9abd63..1369e1616 100644 --- a/apps/web/src/pages/overview/components/Staking.vue +++ b/apps/web/src/pages/overview/components/Staking.vue @@ -27,10 +27,12 @@ const formattedAmountToStakeOrWithdraw = ref('') const formattedWalletOptions = ref>([]) const selectedStakingProvider = ref('') const selectedWalletAddress = ref(null as null | string) +const selectedOperatorGroup = ref(null as null | 'Default' | 'Eigen') // Wallet Select Refs const errorMessage = ref(null as null | string) const openSelectWalletInput = ref(false) +const openSelectOperatorGroupInput = ref(false) const openTermsOfService = ref(false) const termsOfServiceCheckbox = ref(false) @@ -67,14 +69,14 @@ function toggleEstimatedAPY() { } } -const handleInputOnAmountToStake = (event: any) => { +const handleInputOnAmountToStakeOrWithdraw = (event: any) => { const value = event.target.value.replace(/[^\d.]/g, '') const parts = value.split('.') parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',') - // Limit to two decimal places - if (parts[1] && parts[1].length > 2) { - parts[1] = parts[1].slice(0, 2) + // Limit to 18 decimal places + if (parts[1] && parts[1].length > 18) { + parts[1] = parts[1].slice(0, 18) } // Update the model value @@ -122,8 +124,6 @@ watch(formattedAmountToStakeOrWithdraw, async () => { if (formattedAmountToStakeOrWithdraw.value) { const floatAmount = parseFloat(formattedAmountToStakeOrWithdraw.value?.replace(/,/g, '')) let maxAmount - // minAmount is 0.0001 ETH - let minAmount = 0.0001 if (selectedWalletAddress.value) { maxAmount = await getEthersBalance(selectedWalletAddress.value) } else { @@ -132,8 +132,6 @@ watch(formattedAmountToStakeOrWithdraw, async () => { if (floatAmount > maxAmount) { errorMessage.value = 'Insufficient Funds' - } else if (floatAmount < minAmount) { - errorMessage.value = 'Minimun Staking is 0.0001 ETH' } else { errorMessage.value = null } @@ -198,6 +196,15 @@ const handleOutsideClickForWalletInput = (event: any) => { } } +const handleOutsideClickForOperatorGroupInput = (event: any) => { + const selectOperatorGroupInputContainer = document.getElementById('selectOperatorGroupInputContainer') + const selectOperatorGroupInputButton = document.getElementById('selectOperatorGroupInputButton') + + if(!selectOperatorGroupInputContainer?.contains(event.target) && !selectOperatorGroupInputButton?.contains(event.target)){ + openSelectOperatorGroupInput.value = false + } +} + const handleOutsideClickForTermsOfService = (event: any) => { const termsOfServiceContainer = document.getElementById('termsOfServiceContainer') const termsOfServiceButton = document.getElementById('termsOfServiceButton') @@ -216,6 +223,14 @@ watch(openSelectWalletInput, ()=>{ } }) +watch(openSelectOperatorGroupInput, ()=>{ + if(openSelectWalletInput.value){ + window.addEventListener('click', handleOutsideClickForOperatorGroupInput) + }else { + window.removeEventListener('click', handleOutsideClickForOperatorGroupInput) + } +}) + watch(openTermsOfService, ()=>{ if(openTermsOfService.value){ window.addEventListener('click', handleOutsideClickForTermsOfService) @@ -239,8 +254,8 @@ const handleDeposit = async () => { type: stakeType.value }) - if (!result) stakeButtonText.value = 'Failed!' - stakeButtonText.value = 'Staked!' + if (result === false) stakeButtonText.value = 'User Rejected Signature' + else stakeButtonText.value = 'Staked!' setTimeout(() =>{ stakeButtonText.value = 'Stake' @@ -264,7 +279,7 @@ const handleDeposit = async () => { const handleWithdraw = async () => { stakeButtonText.value = 'Withdrawing...' - + selectedOperatorGroup.value = null // const activeAddress = await detectActiveWalletAddress(selectedStakingProvider.value) // if (activeAddress !== selectedWalletAddress.value) { // formattedAmountToStakeOrWithdraw.value = '' @@ -289,7 +304,7 @@ const handleWithdraw = async () => { }) if (!result) stakeButtonText.value = 'Failed!' - stakeButtonText.value = 'Withdrawn!' + else stakeButtonText.value = 'Withdrawn!' setTimeout(() =>{ stakeButtonText.value = 'Withdraw' @@ -430,10 +445,10 @@ function setStakeOrWithdraw(option: 'stake' | 'withdraw') { id="amount_input" v-model="formattedAmountToStakeOrWithdraw" type="text" - pattern="^\d{1,3}(,\d{3})*(\.\d+)?$" + pattern="^\d{1,3}(,\d{3})*(\.\d{1,18})?$" placeholder="0.00" - class=" outline-none" - @input="handleInputOnAmountToStake" + class="outline-none" + @input="handleInputOnAmountToStakeOrWithdraw" >
@@ -443,41 +458,119 @@ function setStakeOrWithdraw(option: 'stake' | 'withdraw') {
- -
-
-
- Fees + +
+
+
+
+ Fees +
+
+
+ + 5.00%
-
- - 5.00% -
-
-
-
-
- Exchange Rate +
+
+
+ Exchange Rate +
+
+
+ ${{ currentEthPrice }}/ETH
-
- ${{ currentEthPrice }}/ETH -
-
-
-
-
- Estimated APY +
+
+
+ Estimated APY +
+
+
+ {{ estimatedAPY }}%
-
- {{ estimatedAPY }}% +
+ + +
+
+ Operator Group
+
+ +
+ + + +
+ + +
+
+
-
+