From f20fd6ce923d7de28e7f1319e8fdbf2342fd06a9 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 8 Aug 2024 15:47:41 +0530 Subject: [PATCH 01/22] fix: update dispenser ABI --- .../src/lib/abiAndAddresses/dispenser.js | 872 ++++++++++++++---- 1 file changed, 709 insertions(+), 163 deletions(-) diff --git a/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js b/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js index a35b2fe2..05fd04f7 100644 --- a/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js +++ b/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js @@ -7,6 +7,11 @@ export const DISPENSER = { abi: [ { inputs: [ + { + internalType: 'address', + name: '_olas', + type: 'address', + }, { internalType: 'address', name: '_tokenomics', @@ -17,51 +22,39 @@ export const DISPENSER = { name: '_treasury', type: 'address', }, - ], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - inputs: [], - name: 'AlreadyInitialized', - type: 'error', - }, - { - inputs: [ + { + internalType: 'address', + name: '_voteWeighting', + type: 'address', + }, + { + internalType: 'bytes32', + name: '_retainer', + type: 'bytes32', + }, { internalType: 'uint256', - name: 'bondId', + name: '_maxNumClaimingEpochs', type: 'uint256', }, - ], - name: 'BondNotRedeemable', - type: 'error', - }, - { - inputs: [ { - internalType: 'address', - name: 'account', - type: 'address', + internalType: 'uint256', + name: '_maxNumStakingTargets', + type: 'uint256', }, { internalType: 'uint256', - name: 'reward', + name: '_defaultMinStakingWeight', type: 'uint256', }, { internalType: 'uint256', - name: 'topUp', + name: '_defaultMaxStakingIncentive', type: 'uint256', }, ], - name: 'ClaimIncentivesFailed', - type: 'error', - }, - { - inputs: [], - name: 'DelegatecallOnly', - type: 'error', + stateMutability: 'nonpayable', + type: 'constructor', }, { inputs: [ @@ -70,40 +63,34 @@ export const DISPENSER = { name: 'account', type: 'address', }, - ], - name: 'DonatorBlacklisted', - type: 'error', - }, - { - inputs: [ { internalType: 'uint256', - name: 'provided', + name: 'reward', type: 'uint256', }, { internalType: 'uint256', - name: 'expected', + name: 'topUp', type: 'uint256', }, ], - name: 'InsufficientAllowance', + name: 'ClaimIncentivesFailed', type: 'error', }, { inputs: [ { - internalType: 'uint256', - name: 'provided', - type: 'uint256', + internalType: 'address', + name: 'sender', + type: 'address', }, { - internalType: 'uint256', - name: 'expected', - type: 'uint256', + internalType: 'address', + name: 'depositProcessor', + type: 'address', }, ], - name: 'LowerThan', + name: 'DepositProcessorOnly', type: 'error', }, { @@ -122,11 +109,6 @@ export const DISPENSER = { name: 'ManagerOnly', type: 'error', }, - { - inputs: [], - name: 'NonZeroValue', - type: 'error', - }, { inputs: [ { @@ -164,222 +146,250 @@ export const DISPENSER = { name: 'Paused', type: 'error', }, + { + inputs: [], + name: 'ReentrancyGuard', + type: 'error', + }, { inputs: [ { - internalType: 'uint256', - name: 'productId', - type: 'uint256', + internalType: 'bytes32', + name: 'account', + type: 'bytes32', }, ], - name: 'ProductClosed', + name: 'WrongAccount', type: 'error', }, { inputs: [ - { - internalType: 'address', - name: 'tokenAddress', - type: 'address', - }, - { - internalType: 'uint256', - name: 'productId', - type: 'uint256', - }, { internalType: 'uint256', - name: 'deadline', + name: 'provided', type: 'uint256', }, { internalType: 'uint256', - name: 'curTime', + name: 'expected', type: 'uint256', }, ], - name: 'ProductExpired', + name: 'WrongAmount', type: 'error', }, { inputs: [ - { - internalType: 'address', - name: 'tokenAddress', - type: 'address', - }, { internalType: 'uint256', - name: 'productId', + name: 'numValues1', type: 'uint256', }, { internalType: 'uint256', - name: 'requested', + name: 'numValues2', type: 'uint256', }, + ], + name: 'WrongArrayLength', + type: 'error', + }, + { + inputs: [ { internalType: 'uint256', - name: 'actual', + name: 'chainId', type: 'uint256', }, ], - name: 'ProductSupplyLow', + name: 'WrongChainId', type: 'error', }, { inputs: [], - name: 'ReentrancyGuard', + name: 'ZeroAddress', type: 'error', }, { inputs: [], - name: 'SameBlockNumberViolation', + name: 'ZeroValue', type: 'error', }, { + anonymous: false, inputs: [ { - internalType: 'uint256', - name: 'serviceId', - type: 'uint256', + indexed: true, + internalType: 'bytes32', + name: 'nomineeHash', + type: 'bytes32', }, ], - name: 'ServiceDoesNotExist', - type: 'error', + name: 'AddNomineeHash', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: false, internalType: 'uint256', - name: 'serviceId', + name: 'reward', type: 'uint256', }, - ], - name: 'ServiceNeverDeployed', - type: 'error', - }, - { - inputs: [ { - internalType: 'address', - name: 'token', - type: 'address', + indexed: false, + internalType: 'uint256', + name: 'topUp', + type: 'uint256', }, { - internalType: 'address', - name: 'from', - type: 'address', + indexed: false, + internalType: 'uint256[]', + name: 'unitTypes', + type: 'uint256[]', }, { - internalType: 'address', - name: 'to', - type: 'address', + indexed: false, + internalType: 'uint256[]', + name: 'unitIds', + type: 'uint256[]', }, + ], + name: 'IncentivesClaimed', + type: 'event', + }, + { + anonymous: false, + inputs: [ { - internalType: 'uint256', - name: 'amount', - type: 'uint256', + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', }, ], - name: 'TransferFailed', - type: 'error', + name: 'OwnerUpdated', + type: 'event', }, { + anonymous: false, inputs: [ { - internalType: 'uint256', - name: 'epochNumber', - type: 'uint256', + indexed: false, + internalType: 'enum Dispenser.Pause', + name: 'pauseState', + type: 'uint8', }, ], - name: 'TreasuryRebalanceFailed', - type: 'error', + name: 'PauseDispenser', + type: 'event', }, { + anonymous: false, inputs: [ { - internalType: 'address', - name: 'tokenAddress', - type: 'address', + indexed: true, + internalType: 'bytes32', + name: 'nomineeHash', + type: 'bytes32', }, ], - name: 'UnauthorizedToken', - type: 'error', + name: 'RemoveNomineeHash', + type: 'event', }, { + anonymous: false, inputs: [ { - internalType: 'uint256', - name: 'provided', - type: 'uint256', + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', }, { + indexed: false, internalType: 'uint256', - name: 'expected', + name: 'returnAmount', type: 'uint256', }, ], - name: 'WrongAmount', - type: 'error', + name: 'Retained', + type: 'event', }, { + anonymous: false, inputs: [ { - internalType: 'uint256', - name: 'numValues1', - type: 'uint256', + indexed: false, + internalType: 'address[]', + name: 'depositProcessors', + type: 'address[]', }, { - internalType: 'uint256', - name: 'numValues2', - type: 'uint256', + indexed: false, + internalType: 'uint256[]', + name: 'chainIds', + type: 'uint256[]', }, ], - name: 'WrongArrayLength', - type: 'error', + name: 'SetDepositProcessorChainIds', + type: 'event', }, { + anonymous: false, inputs: [ { + indexed: true, internalType: 'address', - name: 'provided', + name: 'account', type: 'address', }, { - internalType: 'address', - name: 'expected', - type: 'address', + indexed: false, + internalType: 'uint256[]', + name: 'chainIds', + type: 'uint256[]', }, - ], - name: 'WrongTokenAddress', - type: 'error', - }, - { - inputs: [ { + indexed: false, + internalType: 'bytes32[][]', + name: 'stakingTargets', + type: 'bytes32[][]', + }, + { + indexed: false, + internalType: 'uint256[][]', + name: 'stakingIncentives', + type: 'uint256[][]', + }, + { + indexed: false, + internalType: 'uint256', + name: 'totalStakingIncentive', + type: 'uint256', + }, + { + indexed: false, internalType: 'uint256', - name: 'unitId', + name: 'totalTransferAmount', type: 'uint256', }, { + indexed: false, internalType: 'uint256', - name: 'unitType', + name: 'totalReturnAmount', type: 'uint256', }, ], - name: 'WrongUnitId', - type: 'error', - }, - { - inputs: [], - name: 'ZeroAddress', - type: 'error', - }, - { - inputs: [], - name: 'ZeroValue', - type: 'error', + name: 'StakingIncentivesBatchClaimed', + type: 'event', }, { anonymous: false, @@ -387,36 +397,60 @@ export const DISPENSER = { { indexed: true, internalType: 'address', - name: 'owner', + name: 'account', type: 'address', }, { indexed: false, internalType: 'uint256', - name: 'reward', + name: 'chainId', type: 'uint256', }, + { + indexed: false, + internalType: 'bytes32', + name: 'stakingTarget', + type: 'bytes32', + }, { indexed: false, internalType: 'uint256', - name: 'topUp', + name: 'stakingIncentive', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'transferAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'returnAmount', type: 'uint256', }, ], - name: 'IncentivesClaimed', + name: 'StakingIncentivesClaimed', type: 'event', }, { anonymous: false, inputs: [ { - indexed: true, - internalType: 'address', - name: 'owner', - type: 'address', - }, + indexed: false, + internalType: 'uint256', + name: 'maxNumClaimingEpochs', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'maxNumStakingTargets', + type: 'uint256', + }, ], - name: 'OwnerUpdated', + name: 'StakingParamsUpdated', type: 'event', }, { @@ -445,6 +479,125 @@ export const DISPENSER = { name: 'TreasuryUpdated', type: 'event', }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'voteWeighting', + type: 'address', + }, + ], + name: 'VoteWeightingUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'updatedWithheldAmount', + type: 'uint256', + }, + { + indexed: true, + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + ], + name: 'WithheldAmountSynced', + type: 'event', + }, + { + inputs: [], + name: 'MAX_EVM_CHAIN_ID', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'nomineeHash', + type: 'bytes32', + }, + ], + name: 'addNominee', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'numClaimedEpochs', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'stakingTarget', + type: 'bytes32', + }, + { + internalType: 'uint256', + name: 'bridgingDecimals', + type: 'uint256', + }, + ], + name: 'calculateStakingIncentives', + outputs: [ + { + internalType: 'uint256', + name: 'totalStakingIncentive', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'totalReturnAmount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'lastClaimedEpoch', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'nomineeHash', + type: 'bytes32', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { @@ -457,6 +610,11 @@ export const DISPENSER = { name: '_treasury', type: 'address', }, + { + internalType: 'address', + name: '_voteWeighting', + type: 'address', + }, ], name: 'changeManagers', outputs: [], @@ -476,6 +634,24 @@ export const DISPENSER = { stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [ + { + internalType: 'uint256', + name: '_maxNumClaimingEpochs', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_maxNumStakingTargets', + type: 'uint256', + }, + ], + name: 'changeStakingParams', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { @@ -505,6 +681,227 @@ export const DISPENSER = { stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [ + { + internalType: 'uint256', + name: 'numClaimedEpochs', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'stakingTarget', + type: 'bytes32', + }, + { + internalType: 'bytes', + name: 'bridgePayload', + type: 'bytes', + }, + ], + name: 'claimStakingIncentives', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'numClaimedEpochs', + type: 'uint256', + }, + { + internalType: 'uint256[]', + name: 'chainIds', + type: 'uint256[]', + }, + { + internalType: 'bytes32[][]', + name: 'stakingTargets', + type: 'bytes32[][]', + }, + { + internalType: 'bytes[]', + name: 'bridgePayloads', + type: 'bytes[]', + }, + { + internalType: 'uint256[]', + name: 'valueAmounts', + type: 'uint256[]', + }, + ], + name: 'claimStakingIncentivesBatch', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'defaultMaxStakingIncentive', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'defaultMinStakingWeight', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'mapChainIdDepositProcessors', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'mapChainIdWithheldAmounts', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + name: 'mapLastClaimedStakingEpochs', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + name: 'mapRemovedNomineeEpochs', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'mapZeroWeightEpochRefunded', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'maxNumClaimingEpochs', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'maxNumStakingTargets', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'olas', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [], name: 'owner', @@ -518,6 +915,142 @@ export const DISPENSER = { stateMutability: 'view', type: 'function', }, + { + inputs: [], + name: 'paused', + outputs: [ + { + internalType: 'enum Dispenser.Pause', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'nomineeHash', + type: 'bytes32', + }, + ], + name: 'removeNominee', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'retain', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'retainer', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'retainerHash', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address[]', + name: 'depositProcessors', + type: 'address[]', + }, + { + internalType: 'uint256[]', + name: 'chainIds', + type: 'uint256[]', + }, + ], + name: 'setDepositProcessorChainIds', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'enum Dispenser.Pause', + name: 'pauseState', + type: 'uint8', + }, + ], + name: 'setPauseState', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + ], + name: 'syncWithheldAmount', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'chainId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'bytes32', + name: 'batchHash', + type: 'bytes32', + }, + ], + name: 'syncWithheldAmountMaintenance', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [], name: 'tokenomics', @@ -544,5 +1077,18 @@ export const DISPENSER = { stateMutability: 'view', type: 'function', }, + { + inputs: [], + name: 'voteWeighting', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, ], }; From 3149f9c4a94d895f206c62f808b89aa0844c2889 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 8 Aug 2024 15:48:01 +0530 Subject: [PATCH 02/22] fix: update tokenomics ABI --- .../src/lib/abiAndAddresses/tokenomics.ts | 383 +++++++++--------- 1 file changed, 187 insertions(+), 196 deletions(-) diff --git a/libs/util-contracts/src/lib/abiAndAddresses/tokenomics.ts b/libs/util-contracts/src/lib/abiAndAddresses/tokenomics.ts index 704ae4f0..423ef314 100644 --- a/libs/util-contracts/src/lib/abiAndAddresses/tokenomics.ts +++ b/libs/util-contracts/src/lib/abiAndAddresses/tokenomics.ts @@ -15,38 +15,6 @@ export const TOKENOMICS = { name: 'AlreadyInitialized', type: 'error', }, - { - inputs: [ - { - internalType: 'uint256', - name: 'bondId', - type: 'uint256', - }, - ], - name: 'BondNotRedeemable', - type: 'error', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - { - internalType: 'uint256', - name: 'reward', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'topUp', - type: 'uint256', - }, - ], - name: 'ClaimIncentivesFailed', - type: 'error', - }, { inputs: [], name: 'DelegatecallOnly', @@ -63,22 +31,6 @@ export const TOKENOMICS = { name: 'DonatorBlacklisted', type: 'error', }, - { - inputs: [ - { - internalType: 'uint256', - name: 'provided', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'expected', - type: 'uint256', - }, - ], - name: 'InsufficientAllowance', - type: 'error', - }, { inputs: [ { @@ -111,11 +63,6 @@ export const TOKENOMICS = { name: 'ManagerOnly', type: 'error', }, - { - inputs: [], - name: 'NonZeroValue', - type: 'error', - }, { inputs: [ { @@ -196,79 +143,6 @@ export const TOKENOMICS = { name: 'PRBMath_UD60x18_Convert_Overflow', type: 'error', }, - { - inputs: [], - name: 'Paused', - type: 'error', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'productId', - type: 'uint256', - }, - ], - name: 'ProductClosed', - type: 'error', - }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenAddress', - type: 'address', - }, - { - internalType: 'uint256', - name: 'productId', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'curTime', - type: 'uint256', - }, - ], - name: 'ProductExpired', - type: 'error', - }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenAddress', - type: 'address', - }, - { - internalType: 'uint256', - name: 'productId', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'requested', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'actual', - type: 'uint256', - }, - ], - name: 'ProductSupplyLow', - type: 'error', - }, - { - inputs: [], - name: 'ReentrancyGuard', - type: 'error', - }, { inputs: [], name: 'SameBlockNumberViolation', @@ -296,32 +170,6 @@ export const TOKENOMICS = { name: 'ServiceNeverDeployed', type: 'error', }, - { - inputs: [ - { - internalType: 'address', - name: 'token', - type: 'address', - }, - { - internalType: 'address', - name: 'from', - type: 'address', - }, - { - internalType: 'address', - name: 'to', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - ], - name: 'TransferFailed', - type: 'error', - }, { inputs: [ { @@ -333,17 +181,6 @@ export const TOKENOMICS = { name: 'TreasuryRebalanceFailed', type: 'error', }, - { - inputs: [ - { - internalType: 'address', - name: 'tokenAddress', - type: 'address', - }, - ], - name: 'UnauthorizedToken', - type: 'error', - }, { inputs: [ { @@ -376,22 +213,6 @@ export const TOKENOMICS = { name: 'WrongArrayLength', type: 'error', }, - { - inputs: [ - { - internalType: 'address', - name: 'provided', - type: 'address', - }, - { - internalType: 'address', - name: 'expected', - type: 'address', - }, - ], - name: 'WrongTokenAddress', - type: 'error', - }, { inputs: [ { @@ -486,6 +307,12 @@ export const TOKENOMICS = { { anonymous: false, inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'epochNumber', + type: 'uint256', + }, { indexed: false, internalType: 'uint256', @@ -536,6 +363,24 @@ export const TOKENOMICS = { name: 'accountTopUps', type: 'uint256', }, + { + indexed: false, + internalType: 'uint256', + name: 'effectiveBond', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'returnedStakingIncentive', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'totalStakingIncentive', + type: 'uint256', + }, ], name: 'EpochSettled', type: 'event', @@ -592,6 +437,12 @@ export const TOKENOMICS = { name: 'topUpAgentFraction', type: 'uint256', }, + { + indexed: false, + internalType: 'uint256', + name: 'stakingFraction', + type: 'uint256', + }, ], name: 'IncentiveFractionsUpdateRequested', type: 'event', @@ -635,6 +486,63 @@ export const TOKENOMICS = { name: 'ServiceRegistryUpdated', type: 'event', }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'epochNumber', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'maxStakingIncentive', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'minStakingWeight', + type: 'uint256', + }, + ], + name: 'StakingParamsUpdateRequested', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'epochNumber', + type: 'uint256', + }, + ], + name: 'StakingParamsUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'uint256', + name: 'epochNumber', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'StakingRefunded', + type: 'event', + }, { anonymous: false, inputs: [ @@ -717,6 +625,32 @@ export const TOKENOMICS = { name: 'TreasuryUpdated', type: 'event', }, + { + inputs: [], + name: 'MAX_EPOCH_LENGTH', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_STAKING_WEIGHT', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [], name: 'MIN_EPOCH_LENGTH', @@ -869,6 +803,11 @@ export const TOKENOMICS = { name: '_topUpAgentFraction', type: 'uint256', }, + { + internalType: 'uint256', + name: '_stakingFraction', + type: 'uint256', + }, ], name: 'changeIncentiveFractions', outputs: [], @@ -934,6 +873,24 @@ export const TOKENOMICS = { stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [ + { + internalType: 'uint256', + name: '_maxStakingIncentive', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '_minStakingWeight', + type: 'uint256', + }, + ], + name: 'changeStakingParams', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { @@ -1144,11 +1101,11 @@ export const TOKENOMICS = { type: 'uint256', }, ], - name: 'getIDF', + name: 'getEpochEndTime', outputs: [ { internalType: 'uint256', - name: 'idf', + name: '', type: 'uint256', }, ], @@ -1174,26 +1131,13 @@ export const TOKENOMICS = { stateMutability: 'pure', type: 'function', }, - { - inputs: [], - name: 'getInflationPerEpoch', - outputs: [ - { - internalType: 'uint256', - name: 'inflationPerEpoch', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, { inputs: [], name: 'getLastIDF', outputs: [ { internalType: 'uint256', - name: 'idf', + name: '', type: 'uint256', }, ], @@ -1292,7 +1236,7 @@ export const TOKENOMICS = { }, ], internalType: 'struct UnitPoint', - name: 'up', + name: '', type: 'tuple', }, ], @@ -1383,6 +1327,40 @@ export const TOKENOMICS = { stateMutability: 'view', type: 'function', }, + { + inputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + name: 'mapEpochStakingPoints', + outputs: [ + { + internalType: 'uint96', + name: 'stakingIncentive', + type: 'uint96', + }, + { + internalType: 'uint96', + name: 'maxStakingIncentive', + type: 'uint96', + }, + { + internalType: 'uint16', + name: 'minStakingWeight', + type: 'uint16', + }, + { + internalType: 'uint8', + name: 'stakingFraction', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, { inputs: [ { @@ -1661,6 +1639,19 @@ export const TOKENOMICS = { stateMutability: 'nonpayable', type: 'function', }, + { + inputs: [ + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'refundFromStaking', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, { inputs: [ { From e104e992bbb3db3a92657998ecf30d67f8d6ab32 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 8 Aug 2024 21:54:48 +0530 Subject: [PATCH 03/22] feat: update bonding products --- .env.example | 11 +++- apps/bond/common-util/graphql/clients.js | 33 +++++++---- .../Bonding/BondingList/BondingList.jsx | 39 +++++++++---- .../Bonding/BondingList/useBondingList.jsx | 1 + .../Bonding/Deposit/Deposit.jsx | 42 ++++++++------ .../TokenManagement/hooks/useWhirlpool.jsx | 56 +++++++++++++------ apps/bond/components/Layout/styles.jsx | 10 +++- apps/bond/components/MyBonds/MyBonds.jsx | 1 + apps/tokenomics/components/Donate/index.jsx | 8 ++- libs/common-middleware/src/lib/cspHeader.ts | 3 + libs/ui-theme/src/lib/GlobalStyles.tsx | 4 +- libs/ui-theme/src/lib/ui-theme.tsx | 3 - 12 files changed, 143 insertions(+), 68 deletions(-) diff --git a/.env.example b/.env.example index b295163b..7a4076d6 100644 --- a/.env.example +++ b/.env.example @@ -19,7 +19,7 @@ NEXT_PUBLIC_GNOSIS_TEST_RPC=__URL__ NEXT_PUBLIC_POLYGON_TEST_RPC=__URL__ NEXT_PUBLIC_IS_CONNECTED_TO_TEST_NET= -# autonolas-registry-frontend +# registry NEXT_PUBLIC_REGISTRY_URL=__value__ NEXT_PUBLIC_AUTONOLAS_URL=__value__ NEXT_PUBLIC_GNOSIS_SAFE_API_MAINNET=__value__ @@ -30,8 +30,13 @@ NEXT_PUBLIC_ETHERSCAN_API_KEY=__value__ NEXT_PUBLIC_SOLANA_MAINNET_BETA_URL=__value__ NEXT_PUBLIC_SVM_PUBLIC_KEY=__value__ -# autonolas-tokenomics-frontend +# tokenomics NEXT_PUBLIC_GRAPH_ENDPOINT_MAINNET=__URL__ NEXT_PUBLIC_SHYFT_API_KEY=__KEY__ -NEXT_PUBLIC_IS_CONNECTED_TO_LOCAL=__TRUE_OR_FALSE__ +# bond +NEXT_PUBLIC_MAINNET_BALANCER_URL=__URL__ +NEXT_PUBLIC_OPTIMISM_BALANCER_URL=__URL__ +NEXT_PUBLIC_GNOSIS_BALANCER_URL=__URL__ +NEXT_PUBLIC_POLYGON_BALANCER_URL=__URL__ +NEXT_PUBLIC_ARBITRUM_BALANCER_URL=__URL__ diff --git a/apps/bond/common-util/graphql/clients.js b/apps/bond/common-util/graphql/clients.js index 0d7a080d..2643dd09 100644 --- a/apps/bond/common-util/graphql/clients.js +++ b/apps/bond/common-util/graphql/clients.js @@ -1,4 +1,13 @@ import { GraphQLClient } from 'graphql-request'; +import { + arbitrum, + base, + gnosis, + goerli, + mainnet, + optimism, + polygon, +} from 'viem/chains'; const requestConfig = { jsonSerializer: { @@ -16,32 +25,32 @@ export const AUTONOLAS_GRAPH_CLIENTS = { // https://docs.balancer.fi/reference/subgraph/ for future subgraph endpoints export const BALANCER_GRAPH_CLIENTS = { - 1: new GraphQLClient( - 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2', + [mainnet.id]: new GraphQLClient( + process.env.NEXT_PUBLIC_MAINNET_BALANCER_URL, requestConfig, ), - 5: new GraphQLClient( + [goerli.id]: new GraphQLClient( 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-goerli-v2', requestConfig, ), - 10: new GraphQLClient( - 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-optimism-v2', + [optimism.id]: new GraphQLClient( + process.env.NEXT_PUBLIC_OPTIMISM_BALANCER_URL, requestConfig, ), - 100: new GraphQLClient( - 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-gnosis-chain-v2', + [gnosis.id]: new GraphQLClient( + process.env.NEXT_PUBLIC_GNOSIS_BALANCER_URL, requestConfig, ), - 137: new GraphQLClient( - 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2', + [polygon.id]: new GraphQLClient( + process.env.NEXT_PUBLIC_POLYGON_BALANCER_URL, requestConfig, ), - 8453: new GraphQLClient( + [base.id]: new GraphQLClient( 'https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest', requestConfig, ), - 42161: new GraphQLClient( - 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-arbitrum-v2', + [arbitrum.id]: new GraphQLClient( + process.env.NEXT_PUBLIC_ARBITRUM_BALANCER_URL, requestConfig, ), }; diff --git a/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx b/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx index 02565841..aa1a42b4 100644 --- a/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx +++ b/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx @@ -3,7 +3,7 @@ import { QuestionCircleOutlined, UnorderedListOutlined, } from '@ant-design/icons'; -import { Button, Empty, Popconfirm, Spin, Table, Tag, Tooltip, Typography } from 'antd'; +import { Button, Empty, Popconfirm, Skeleton, Spin, Table, Tag, Tooltip, Typography } from 'antd'; import { isNaN, remove, round } from 'lodash'; import Link from 'next/link'; import PropTypes from 'prop-types'; @@ -33,6 +33,10 @@ const Container = styled.div` } `; +const Loader = () => ; + +const isCurrentPriceLpZero = (currentPrice) => Number(currentPrice) === 0; + const getTitle = (title, tooltipDesc) => ( @@ -86,11 +90,17 @@ const getColumns = (onClick, isActive, acc, depositoryAddress, hideEmptyProducts dataIndex: 'fullCurrentPriceLp', key: 'fullCurrentPriceLp', width: 140, - render: (x, details) => ( - - {x} - - ), + render: (x, details) => { + if (isCurrentPriceLpZero(x)) { + return ; + } + + return ( + + {x} + + ); + }, }, { title: getTitle( @@ -223,8 +233,16 @@ const getColumns = (onClick, isActive, acc, depositoryAddress, hideEmptyProducts return columns; }; -const sortList = (list) => +const sortProducts = (list) => list.sort((a, b) => { + // if the current price of the LP token is zero, then move it to the end of the list + // NOTE: It can be zero because + // - the API returns zero (shouldn't happen) OR + // - has error OR + // - not fetched yet + const isSvm = a.lpChainId === VM_TYPE.SVM || b.lpChainId === VM_TYPE.SVM; + if (isSvm && isCurrentPriceLpZero(a.fullCurrentPriceLp)) return 1; + if (isNaN(a.projectedChange)) return 1; if (isNaN(b.projectedChange)) return -1; return b.projectedChange - a.projectedChange; @@ -282,7 +300,7 @@ export const BondingList = ({ bondingProgramType, hideEmptyProducts }) => { }, [handleProductDetails]); const getProductsDataSource = useCallback(() => { - const sortedList = sortList(filteredProducts); + const sortedList = sortProducts(filteredProducts); const processedList = hideEmptyProducts ? sortedList.filter((x) => x.supplyLeft > 0.00001) : sortedList; @@ -308,16 +326,17 @@ export const BondingList = ({ bondingProgramType, hideEmptyProducts }) => { pagination={false} scroll={{ x: 400 }} className="mb-16" + rowHoverable={false} /> {!!productDetails && ( { - const supplyInWei = new BigNumber(productSupply || '0'); + const productSupplyInWei = new BigNumber(productSupply || '0'); + const lpBalanceInBg = new BigNumber(lpBalance); - const remainingSupply = supplyInWei + const remainingSupply = productSupplyInWei .multipliedBy(ONE_ETH_IN_STRING) - .dividedBy(productLpPriceInBg); + .dividedBy(productLpPriceAfterDiscountInBg); - const remainingSupplyInWei = remainingSupply.lt(lpBalance) ? remainingSupply : lpBalance; + const remainingSupplyInWei = remainingSupply.lt(lpBalanceInBg) ? remainingSupply : lpBalance; return parseToEth(remainingSupplyInWei); }; @@ -147,8 +148,7 @@ export const Deposit = ({ ? tokenAmountInputValue : new BigNumber(parseToWei(tokenAmountInputValue)); - const payoutInBg = new BigNumber(productLpPriceInBg.toString()).multipliedBy(tokenAmountValue); - + const payoutInBg = productLpPriceAfterDiscountInBg.multipliedBy(tokenAmountValue); const payout = isSvmProduct ? payoutInBg.dividedBy(BigNumber(`1${'0'.repeat(28)}`)).toFixed(2) : Number(payoutInBg.dividedBy(ONE_ETH_IN_STRING).dividedBy(ONE_ETH_IN_STRING).toFixed(2)); @@ -178,7 +178,11 @@ export const Deposit = ({ autoComplete="off" className="mt-16" > - + {`Bonding Product ID: ${productId}`} @@ -222,7 +226,6 @@ export const Deposit = ({ form.setFieldsValue({ tokenAmount: remainingLpSupplyInEth }); form.validateFields(['tokenAmount']); }} - className="pl-0" > Max @@ -291,8 +294,11 @@ export const Deposit = ({ Deposit.propTypes = { productId: PropTypes.string, productToken: PropTypes.string, - productSupply: PropTypes.string, - productLpPriceInBg: PropTypes.shape({}), + productSupply: PropTypes.oneOfType([ + PropTypes.instanceOf(PropTypes.string), + PropTypes.instanceOf(BigNumber), + ]), + productLpPriceAfterDiscount: PropTypes.shape({}), closeModal: PropTypes.func, getProducts: PropTypes.func, }; @@ -300,7 +306,7 @@ Deposit.propTypes = { Deposit.defaultProps = { productId: undefined, productToken: null, - productLpPriceInBg: null, + productLpPriceAfterDiscount: null, productSupply: null, closeModal: () => {}, getProducts: () => {}, diff --git a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWhirlpool.jsx b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWhirlpool.jsx index 1939b877..10573a82 100644 --- a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWhirlpool.jsx +++ b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWhirlpool.jsx @@ -6,7 +6,7 @@ import { buildWhirlpoolClient, } from '@orca-so/whirlpools-sdk'; import { GraphQLClient, gql } from 'graphql-request'; -import { useCallback, useEffect, useState } from 'react'; +import { useCallback } from 'react'; import { VM_TYPE, areAddressesEqual } from '@autonolas/frontend-library'; @@ -75,17 +75,10 @@ const whirlpoolQuery = async () => { }; const useWhirlpoolQuery = () => { - const [queryResult, setQueryResult] = useState(null); - - useEffect(() => { - const fetchData = async () => { - const result = await whirlpoolQuery(); - setQueryResult(result); - }; - fetchData(); + return useCallback(async () => { + const result = await whirlpoolQuery(); + return result; }, []); - - return queryResult; }; /** @@ -110,13 +103,40 @@ export const useWhirlpool = () => { }; export const useWhirlPoolInformation = () => { - const positions = useWhirlpoolQuery(); + const getPositions = useWhirlpoolQuery(); const { getWhirlpoolData } = useWhirlpool(); return useCallback(async () => { + const positions = await getPositions(); + if (!positions) return null; - const { whirlpoolData, whirlpoolTokenA } = await getWhirlpoolData(); + let whirlpoolData; + let whirlpoolTokenA; + + const fetchWhirlpoolDataWithRetry = async () => { + try { + const data = await getWhirlpoolData(); + + if (data) { + whirlpoolData = data.whirlpoolData; + whirlpoolTokenA = data.whirlpoolTokenA; + } + + if (!whirlpoolData || !whirlpoolTokenA) { + /* eslint-disable-next-line no-console */ + console.log('Invalid whirlpool data, retrying in 2 seconds'); + setTimeout(fetchWhirlpoolDataWithRetry, 2000); + } + } catch (error) { + /* eslint-disable-next-line no-console */ + console.warn('Error fetching whirlpool data, retrying in 2 seconds'); + setTimeout(fetchWhirlpoolDataWithRetry, 2000); + } + }; + + await fetchWhirlpoolDataWithRetry(); + let reserveToken0 = new BN(0); let reserveToken1 = new BN(0); let totalSupply = new BN(0); @@ -137,8 +157,12 @@ export const useWhirlPoolInformation = () => { const address1 = whirlpoolTokenA.mint.toString(); const address2 = ADDRESSES[VM_TYPE.SVM].olasAddress; - const reserveOlas = areAddressesEqual(address1, address2) ? reserveToken0 : reserveToken1; - return getSvmCalculatedPriceLp(reserveOlas.toString(), totalSupply.toString()); - }, [positions, getWhirlpoolData]); + const reserveOlas = areAddressesEqual(address1, address2) + ? reserveToken0.toString() + : reserveToken1.toString(); + + const svmPriceLp = getSvmCalculatedPriceLp(reserveOlas, totalSupply.toString()); + return svmPriceLp; + }, [getPositions, getWhirlpoolData]); }; diff --git a/apps/bond/components/Layout/styles.jsx b/apps/bond/components/Layout/styles.jsx index 1314e579..f5fb32f1 100644 --- a/apps/bond/components/Layout/styles.jsx +++ b/apps/bond/components/Layout/styles.jsx @@ -4,7 +4,6 @@ import styled from 'styled-components'; import { COLOR, MEDIA_QUERY } from 'libs/ui-theme/src'; export const CustomLayout = styled(Layout)` - background-color: ${COLOR.WHITE}; min-height: 100vh; /* layout */ @@ -61,6 +60,15 @@ export const CustomLayout = styled(Layout)` } } + .ant-table { + .ant-table-thead > tr > th.ant-table-cell { + background-color: ${COLOR.WHITE}; + } + .ant-table-tbody > tr > td { + padding: 10px; + } + } + ${MEDIA_QUERY.tablet} { .ant-layout-header { position: relative; diff --git a/apps/bond/components/MyBonds/MyBonds.jsx b/apps/bond/components/MyBonds/MyBonds.jsx index 7a2315b1..af8ce0c2 100644 --- a/apps/bond/components/MyBonds/MyBonds.jsx +++ b/apps/bond/components/MyBonds/MyBonds.jsx @@ -170,6 +170,7 @@ export const MyBonds = () => { } : undefined } + rowHoverable={false} /> diff --git a/apps/tokenomics/components/Donate/index.jsx b/apps/tokenomics/components/Donate/index.jsx index c10c6982..74d416ff 100644 --- a/apps/tokenomics/components/Donate/index.jsx +++ b/apps/tokenomics/components/Donate/index.jsx @@ -1,4 +1,4 @@ -import { Alert, Button, Typography } from 'antd'; +import { Alert, Button, Skeleton, Typography } from 'antd'; import { ethers } from 'ethers'; import isNumber from 'lodash/isNumber'; import { useEffect, useState } from 'react'; @@ -194,7 +194,11 @@ export const DepositServiceDonation = () => { {epochStatusList.map((e, index) => ( {`${e.text}:`} - {e.value} + {isEpochDetailsLoading ? ( + + ) : ( + {e.value} + )} ))} diff --git a/libs/common-middleware/src/lib/cspHeader.ts b/libs/common-middleware/src/lib/cspHeader.ts index 0b349f1f..2fb35942 100644 --- a/libs/common-middleware/src/lib/cspHeader.ts +++ b/libs/common-middleware/src/lib/cspHeader.ts @@ -70,7 +70,10 @@ const ALLOWED_ORIGINS = [ // others 'https://api.thegraph.com/', + 'https://api.studio.thegraph.com/', 'https://sockjs-us3.pusher.com/', + 'https://programs.shyft.to/', + 'https://*.network.thegraph.com/', ...VERCEL_LINKS, ]; diff --git a/libs/ui-theme/src/lib/GlobalStyles.tsx b/libs/ui-theme/src/lib/GlobalStyles.tsx index 082a6b14..a9d46596 100644 --- a/libs/ui-theme/src/lib/GlobalStyles.tsx +++ b/libs/ui-theme/src/lib/GlobalStyles.tsx @@ -1,8 +1,6 @@ import { createGlobalStyle } from 'styled-components'; -import { COLOR, MEDIA_QUERY } from 'libs/ui-theme/src'; - -import { ANTD_COLOR } from './ui-theme'; +import { ANTD_COLOR, COLOR, MEDIA_QUERY } from './ui-theme'; export const GlobalStyles = createGlobalStyle` *, diff --git a/libs/ui-theme/src/lib/ui-theme.tsx b/libs/ui-theme/src/lib/ui-theme.tsx index aac5b991..da3f9acb 100644 --- a/libs/ui-theme/src/lib/ui-theme.tsx +++ b/libs/ui-theme/src/lib/ui-theme.tsx @@ -1,4 +1,3 @@ -// TODO: move to theme export const COLOR = { PRIMARY: '#7e22ce', SECONDARY: '#4d596a', @@ -32,7 +31,6 @@ export const COLOR = { YELLOW_SECONDARY: '#fefce8', // tailwind orange.50 }; -// TODO: move to theme export const BREAK_POINT = { xxs: '375px', xs: '480px', @@ -43,7 +41,6 @@ export const BREAK_POINT = { xxl: '1600px', }; -// TODO: move to theme export const MEDIA_QUERY = { mobileS: `@media only screen and (max-width: ${BREAK_POINT.xxs})`, mobileM: `@media only screen and (max-width: ${BREAK_POINT.xs})`, From 8165e72a0ae036296b4ebe9b930d1ac79d691bc2 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 9 Aug 2024 16:53:58 +0530 Subject: [PATCH 04/22] feat: update deposit component tag --- .../BondingProducts/Bonding/Deposit/Deposit.jsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx index 0e35f463..ca7bf43e 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx @@ -178,12 +178,8 @@ export const Deposit = ({ autoComplete="off" className="mt-16" > - - {`Bonding Product ID: ${productId}`} + + {`Bonding Product ID: ${productId}`} Date: Fri, 9 Aug 2024 17:20:02 +0530 Subject: [PATCH 05/22] chore: raw send transaction for deposit --- .../Bonding/Deposit/useDeposit.jsx | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx index 8fdf5db0..28182c65 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx @@ -29,6 +29,7 @@ export const useDeposit = () => { const getLpBalanceRequest = useCallback( async ({ token }) => { + console.log('token', token); const contract = getUniswapV2PairContract(token); const response = await contract.methods.balanceOf(account).call(); return response.toString(); @@ -42,15 +43,30 @@ export const useDeposit = () => { const approveRequest = useCallback( async ({ token, amountToApprove }) => { const contract = getUniswapV2PairContract(token); + console.log('contract', contract); + const treasuryAddress = ADDRESSES[chainId].treasury; - const fnApprove = contract.methods.approve(treasuryAddress, amountToApprove); - const estimatedGas = await getEstimatedGasLimit(fnApprove, account); - const fn = await fnApprove.send({ - from: account, - gasLimit: estimatedGas, - }); - - const response = await sendTransaction(fn, account); + console.log('treasuryAddress', treasuryAddress); + + const fnApprove = contract.methods + .approve(treasuryAddress, amountToApprove) + .send({ from: account }); + console.log('fnApprove', fnApprove); + + // const estimatedGas = await getEstimatedGasLimit(fnApprove, account); + // console.log('estimatedGas', estimatedGas); + + // const fn = fnApprove.send({ + // from: account, + // gasLimit: estimatedGas, + // }); + // console.log('fn', fn); + + // const response = await sendTransaction(fnApprove, account); + // console.log('response', response); + + const response = await fnApprove; + return response; }, [account, chainId], @@ -58,10 +74,22 @@ export const useDeposit = () => { const depositRequest = useCallback( async ({ productId, tokenAmount }) => { + console.log('inside deposit Request'); + const contract = getDepositoryContract(); - const fn = contract.methods.deposit(productId, tokenAmount).send({ from: account }); + console.log('contract', contract); + + const fnDeposit = contract.methods.deposit(productId, tokenAmount).send({ from: account }); + console.log('fnDeposit', fnDeposit); + + // const estimatedGas = await getEstimatedGasLimit(fnDeposit, account); + // console.log('estimatedGas', estimatedGas); + + // const fn = fnDeposit.send({ from: account, gasLimit: estimatedGas }); + // console.log('fn', fn); - const response = await sendTransaction(fn, account); + const response = await fnDeposit; + // const response = await sendTransaction(fnDeposit, account); return response?.transactionHash; }, [account], From f7da5b5bd96bd7706e435355596a415a6d1c50b4 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 9 Aug 2024 17:56:03 +0530 Subject: [PATCH 06/22] chore: minor updates to deposit --- .../Bonding/Deposit/Deposit.jsx | 12 ++--- .../Bonding/Deposit/useDeposit.jsx | 44 ++++--------------- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx index ca7bf43e..9ed5a4dd 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx @@ -82,7 +82,7 @@ export const Deposit = ({ notifySuccess('Deposited successfully!', `Transaction Hash: ${txHash}`); // fetch the products details again - getProducts(); + await getProducts(); // close the modal after successful deposit closeModal(); @@ -254,12 +254,12 @@ export const Deposit = ({ htmlType="submit" loading={isLoading} onClick={async () => { - try { - if (!account) { - notifyError('Please connect your wallet'); - return; - } + if (!account) { + notifyError('Please connect your wallet'); + return; + } + try { setIsLoading(true); await approveRequest({ token: productToken, diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx index 28182c65..bb4a241f 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx @@ -43,30 +43,12 @@ export const useDeposit = () => { const approveRequest = useCallback( async ({ token, amountToApprove }) => { const contract = getUniswapV2PairContract(token); - console.log('contract', contract); - const treasuryAddress = ADDRESSES[chainId].treasury; - console.log('treasuryAddress', treasuryAddress); - - const fnApprove = contract.methods - .approve(treasuryAddress, amountToApprove) - .send({ from: account }); - console.log('fnApprove', fnApprove); - - // const estimatedGas = await getEstimatedGasLimit(fnApprove, account); - // console.log('estimatedGas', estimatedGas); - - // const fn = fnApprove.send({ - // from: account, - // gasLimit: estimatedGas, - // }); - // console.log('fn', fn); - - // const response = await sendTransaction(fnApprove, account); - // console.log('response', response); - - const response = await fnApprove; + const fnApprove = contract.methods.approve(treasuryAddress, amountToApprove); + const estimatedGas = await getEstimatedGasLimit(fnApprove, account); + const fn = await fnApprove.send({ from: account, gasLimit: estimatedGas }); + const response = await sendTransaction(fn, account); return response; }, [account, chainId], @@ -74,22 +56,12 @@ export const useDeposit = () => { const depositRequest = useCallback( async ({ productId, tokenAmount }) => { - console.log('inside deposit Request'); - const contract = getDepositoryContract(); - console.log('contract', contract); - - const fnDeposit = contract.methods.deposit(productId, tokenAmount).send({ from: account }); - console.log('fnDeposit', fnDeposit); - - // const estimatedGas = await getEstimatedGasLimit(fnDeposit, account); - // console.log('estimatedGas', estimatedGas); - - // const fn = fnDeposit.send({ from: account, gasLimit: estimatedGas }); - // console.log('fn', fn); + const fnDeposit = contract.methods.deposit(productId, tokenAmount); + const estimatedGas = await getEstimatedGasLimit(fnDeposit, account); + const fn = fnDeposit.send({ from: account, gasLimit: estimatedGas }); - const response = await fnDeposit; - // const response = await sendTransaction(fnDeposit, account); + const response = await sendTransaction(fn, account); return response?.transactionHash; }, [account], From a1386c0bbea7f536642ba61aad7d2b9f85cedb05 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 9 Aug 2024 19:00:23 +0530 Subject: [PATCH 07/22] chore: remove logs --- .../BondingProducts/Bonding/Deposit/useDeposit.jsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx index bb4a241f..ee65e731 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx @@ -29,7 +29,6 @@ export const useDeposit = () => { const getLpBalanceRequest = useCallback( async ({ token }) => { - console.log('token', token); const contract = getUniswapV2PairContract(token); const response = await contract.methods.balanceOf(account).call(); return response.toString(); @@ -57,9 +56,7 @@ export const useDeposit = () => { const depositRequest = useCallback( async ({ productId, tokenAmount }) => { const contract = getDepositoryContract(); - const fnDeposit = contract.methods.deposit(productId, tokenAmount); - const estimatedGas = await getEstimatedGasLimit(fnDeposit, account); - const fn = fnDeposit.send({ from: account, gasLimit: estimatedGas }); + const fn = contract.methods.deposit(productId, tokenAmount).send({ from: account }); const response = await sendTransaction(fn, account); return response?.transactionHash; From b3a13f00e7a24dab5a45c76f11de7079df80407c Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 9 Aug 2024 19:49:38 +0530 Subject: [PATCH 08/22] refactor: Remove unused code and optimize useWhirlPoolInformation hook --- .../Bonding/TokenManagement/hooks/useWhirlpool.jsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWhirlpool.jsx b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWhirlpool.jsx index 10573a82..5bae5b45 100644 --- a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWhirlpool.jsx +++ b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWhirlpool.jsx @@ -74,13 +74,6 @@ const whirlpoolQuery = async () => { return filteredPositions; }; -const useWhirlpoolQuery = () => { - return useCallback(async () => { - const result = await whirlpoolQuery(); - return result; - }, []); -}; - /** * Hook to get the data from the whirlpool */ @@ -103,11 +96,10 @@ export const useWhirlpool = () => { }; export const useWhirlPoolInformation = () => { - const getPositions = useWhirlpoolQuery(); const { getWhirlpoolData } = useWhirlpool(); return useCallback(async () => { - const positions = await getPositions(); + const positions = await whirlpoolQuery(); if (!positions) return null; @@ -164,5 +156,5 @@ export const useWhirlPoolInformation = () => { const svmPriceLp = getSvmCalculatedPriceLp(reserveOlas, totalSupply.toString()); return svmPriceLp; - }, [getPositions, getWhirlpoolData]); + }, [getWhirlpoolData]); }; From af689c3cceaf4e81ab82e4cd948a50db8c1fb659 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 9 Aug 2024 20:38:09 +0530 Subject: [PATCH 09/22] chore: address Tanya's review request --- .../BondingProducts/Bonding/BondingList/BondingList.jsx | 8 ++++---- .../BondingProducts/Bonding/Deposit/Deposit.jsx | 3 ++- libs/util-contracts/src/lib/abiAndAddresses/dispenser.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx b/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx index aa1a42b4..045316e8 100644 --- a/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx +++ b/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx @@ -33,7 +33,7 @@ const Container = styled.div` } `; -const Loader = () => ; +const Loader = () => ; const isCurrentPriceLpZero = (currentPrice) => Number(currentPrice) === 0; @@ -90,14 +90,14 @@ const getColumns = (onClick, isActive, acc, depositoryAddress, hideEmptyProducts dataIndex: 'fullCurrentPriceLp', key: 'fullCurrentPriceLp', width: 140, - render: (x, details) => { - if (isCurrentPriceLpZero(x)) { + render: (currentPriceLp, details) => { + if (isCurrentPriceLpZero(currentPriceLp)) { return ; } return ( - {x} + {currentPriceLp} ); }, diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx index 9ed5a4dd..46f0394b 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx @@ -5,9 +5,10 @@ import { isNil } from 'lodash'; import PropTypes from 'prop-types'; import { useCallback, useEffect, useState } from 'react'; -import { getCommaSeparatedNumber, notifyError, notifySuccess } from '@autonolas/frontend-library'; +import { getCommaSeparatedNumber } from '@autonolas/frontend-library'; import { COLOR } from 'libs/ui-theme/src'; +import { notifyError, notifySuccess } from 'libs/util-functions/src'; import { ONE_ETH_IN_STRING } from 'common-util/constants/numbers'; import { diff --git a/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js b/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js index 05fd04f7..377bf4a1 100644 --- a/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js +++ b/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js @@ -1,7 +1,7 @@ export const DISPENSER = { contractName: 'Dispenser', addresses: { - 1: '0xeED0000fE94d7cfeF4Dc0CA86a223f0F603A61B8', + 1: '0x5650300fCBab43A0D7D02F8Cb5d0f039402593f0', 5: '0xeDd71796B90eaCc56B074C39BAC90ED2Ca6D93Ee', }, abi: [ From 0097a420f44fcb547dd9d207f90d587cdeca2f27 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Mon, 12 Aug 2024 14:53:25 +0530 Subject: [PATCH 10/22] chore: remove duplicate middleware --- apps/tokenomics/middleware.js | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 apps/tokenomics/middleware.js diff --git a/apps/tokenomics/middleware.js b/apps/tokenomics/middleware.js deleted file mode 100644 index 48909f10..00000000 --- a/apps/tokenomics/middleware.js +++ /dev/null @@ -1,32 +0,0 @@ -import { NextResponse } from 'next/server'; -import prohibitedCountries from 'libs/util-prohibited-data/src/lib/prohibited-countries.json'; - - -const prohibitedCountriesCode = Object.values(prohibitedCountries); - -/** - * Middleware to validate the country - * - * @param {NextRequest} request - */ -export default function validateCountryMiddleware(request) { - const country = request.geo?.country; - const isProhibited = prohibitedCountriesCode.includes(country); - - // if already on the not-legal page, don't redirect - if (request.nextUrl.pathname === '/not-legal') { - if (isProhibited) { - return NextResponse.next(); - } - - // if not prohibited & trying to access not-legal page, redirect to home - return NextResponse.redirect(new URL('/', request.url)); - } - - // if country is prohibited, redirect to not-legal page - if (isProhibited) { - return NextResponse.redirect(new URL('/not-legal', request.url)); - } - - return NextResponse.next(); -} From 43dae318591cf7ca6b64fb420128f8ea3c711a35 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Mon, 12 Aug 2024 20:30:01 +0530 Subject: [PATCH 11/22] chore: remvoe support for goerli --- apps/bond/common-util/graphql/clients.js | 5 ----- libs/util-contracts/src/lib/abiAndAddresses/dispenser.js | 1 - 2 files changed, 6 deletions(-) diff --git a/apps/bond/common-util/graphql/clients.js b/apps/bond/common-util/graphql/clients.js index 2643dd09..873f7d64 100644 --- a/apps/bond/common-util/graphql/clients.js +++ b/apps/bond/common-util/graphql/clients.js @@ -3,7 +3,6 @@ import { arbitrum, base, gnosis, - goerli, mainnet, optimism, polygon, @@ -29,10 +28,6 @@ export const BALANCER_GRAPH_CLIENTS = { process.env.NEXT_PUBLIC_MAINNET_BALANCER_URL, requestConfig, ), - [goerli.id]: new GraphQLClient( - 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-goerli-v2', - requestConfig, - ), [optimism.id]: new GraphQLClient( process.env.NEXT_PUBLIC_OPTIMISM_BALANCER_URL, requestConfig, diff --git a/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js b/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js index 377bf4a1..6f3ea6f7 100644 --- a/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js +++ b/libs/util-contracts/src/lib/abiAndAddresses/dispenser.js @@ -2,7 +2,6 @@ export const DISPENSER = { contractName: 'Dispenser', addresses: { 1: '0x5650300fCBab43A0D7D02F8Cb5d0f039402593f0', - 5: '0xeDd71796B90eaCc56B074C39BAC90ED2Ca6D93Ee', }, abi: [ { From 3afe31420afed0d9cfad12e5b7b48126d9bc8dc2 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Mon, 12 Aug 2024 21:00:08 +0530 Subject: [PATCH 12/22] chore: remove goerli and some CSS change --- .../Bonding/BondingList/BondingList.jsx | 7 ++++--- .../BondingProducts/Bonding/Deposit/Deposit.jsx | 7 +++++-- .../BondingProducts/BondingProducts.jsx | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx b/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx index 045316e8..f10c4b9a 100644 --- a/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx +++ b/apps/bond/components/BondingProducts/Bonding/BondingList/BondingList.jsx @@ -90,14 +90,14 @@ const getColumns = (onClick, isActive, acc, depositoryAddress, hideEmptyProducts dataIndex: 'fullCurrentPriceLp', key: 'fullCurrentPriceLp', width: 140, - render: (currentPriceLp, details) => { - if (isCurrentPriceLpZero(currentPriceLp)) { + render: (text, details) => { + if (isCurrentPriceLpZero(text)) { return ; } return ( - {currentPriceLp} + {text} ); }, @@ -338,6 +338,7 @@ export const BondingList = ({ bondingProgramType, hideEmptyProducts }) => { productDetails?.discount, ).toString()} productSupply={productDetails?.supply} + productLpTokenName={productDetails?.lpTokenName} getProducts={refetch} closeModal={handleModalClose} /> diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx index 46f0394b..668cd356 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx @@ -28,6 +28,7 @@ const fullWidth = { width: '100%' }; export const Deposit = ({ productId, productToken, + productLpTokenName, productLpPriceAfterDiscount, productSupply, getProducts, @@ -238,12 +239,12 @@ export const Deposit = ({ {isApproveModalVisible && ( setIsApproveModalVisible(false)} > @@ -291,6 +292,7 @@ export const Deposit = ({ Deposit.propTypes = { productId: PropTypes.string, productToken: PropTypes.string, + productLpTokenName: PropTypes.string, productSupply: PropTypes.oneOfType([ PropTypes.instanceOf(PropTypes.string), PropTypes.instanceOf(BigInt), @@ -306,6 +308,7 @@ Deposit.propTypes = { Deposit.defaultProps = { productId: undefined, productToken: null, + productLpTokenName: null, productLpPriceAfterDiscount: null, productSupply: null, closeModal: () => {}, diff --git a/apps/bond/components/BondingProducts/BondingProducts.jsx b/apps/bond/components/BondingProducts/BondingProducts.jsx index 084d23d4..2505af98 100644 --- a/apps/bond/components/BondingProducts/BondingProducts.jsx +++ b/apps/bond/components/BondingProducts/BondingProducts.jsx @@ -14,11 +14,11 @@ const { Title } = Typography; const PageHeader = styled.div` align-items: center; margin-bottom: 12px; - display: ${(props) => (props.isMobile ? 'block' : 'flex')}; + display: ${(props) => (props.is_mobile === 'true' ? 'block' : 'flex')}; `; const StyledDivider = styled(Divider)` - margin: ${(props) => (props.isMobile ? '12px 0 ' : '0 12px')}; + margin: ${(props) => (props.is_mobile === 'true' ? '12px 0 ' : '0 12px')}; `; const SwitchContainer = styled.div` @@ -26,10 +26,16 @@ const SwitchContainer = styled.div` display: flex; `; +const manageSolanaLiquidityBtnCss = { + width: '160px', + whiteSpace: 'normal', + height: 'auto', +}; + const ResponsiveDivider = () => { const { isMobile } = useScreen(); - return ; + return ; }; export const BondingProducts = () => { @@ -50,9 +56,9 @@ export const BondingProducts = () => { return ( <> - + - + Bonding Products @@ -80,6 +86,7 @@ export const BondingProducts = () => { type="primary" ghost onClick={() => router.push('manage-solana-liquidity')} + style={isMobile ? manageSolanaLiquidityBtnCss : undefined} > Manage Solana Liquidity From aad7b57ddb1c0aee736cb3274088db456da50e01 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Tue, 13 Aug 2024 18:24:49 +0530 Subject: [PATCH 13/22] fix: bond error resolved --- apps/bond/common-util/functions/frontend-library.js | 9 +++------ .../BondingProducts/Bonding/Deposit/Deposit.jsx | 7 ++----- .../BondingProducts/Bonding/Deposit/useDeposit.jsx | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/bond/common-util/functions/frontend-library.js b/apps/bond/common-util/functions/frontend-library.js index 413b89f2..fd3485de 100644 --- a/apps/bond/common-util/functions/frontend-library.js +++ b/apps/bond/common-util/functions/frontend-library.js @@ -1,10 +1,10 @@ +import { notifyError } from 'libs/util-functions/src'; import { getProvider as getProviderFn, getChainId as getChainIdFn, getChainIdOrDefaultToMainnet as getChainIdOrDefaultToMainnetFn, - sendTransaction as sendTransactionFn, LOCAL_FORK_ID, - notifyError, + sendTransaction as sendTransactionFn, } from '@autonolas/frontend-library'; import { RPC_URLS } from 'common-util/constants/rpcs'; @@ -39,7 +39,4 @@ export const getChainId = (chainId) => { }; export const sendTransaction = (fn, account) => - sendTransactionFn(fn, account, { - supportedChains, - rpcUrls: RPC_URLS, - }); + sendTransactionFn(fn, account, { supportedChains, rpcUrls: RPC_URLS }); diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx index 668cd356..5539573c 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx @@ -293,12 +293,9 @@ Deposit.propTypes = { productId: PropTypes.string, productToken: PropTypes.string, productLpTokenName: PropTypes.string, - productSupply: PropTypes.oneOfType([ - PropTypes.instanceOf(PropTypes.string), - PropTypes.instanceOf(BigInt), - ]), + productSupply: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(BigInt)]), productLpPriceAfterDiscount: PropTypes.oneOfType([ - PropTypes.instanceOf(PropTypes.string), + PropTypes.string, PropTypes.instanceOf(BigInt), ]), closeModal: PropTypes.func, diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx index ee65e731..2800a78d 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx @@ -45,7 +45,7 @@ export const useDeposit = () => { const treasuryAddress = ADDRESSES[chainId].treasury; const fnApprove = contract.methods.approve(treasuryAddress, amountToApprove); const estimatedGas = await getEstimatedGasLimit(fnApprove, account); - const fn = await fnApprove.send({ from: account, gasLimit: estimatedGas }); + const fn = fnApprove.send({ from: account, gasLimit: estimatedGas }); const response = await sendTransaction(fn, account); return response; From 6226a889f432733da493dc58e62d657834a249cc Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 16 Aug 2024 17:17:11 +0530 Subject: [PATCH 14/22] chore: add logs for issue faced on Solana Liquidity --- .../Bonding/TokenManagement/hooks/useWsolDeposit.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx index 80729d8f..82d1e3e0 100644 --- a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx @@ -153,6 +153,8 @@ export const useWsolDeposit = () => { } const { whirlpoolTokenA, whirlpoolTokenB } = await getWhirlpoolData(); + console.log({ whirlpoolTokenA, whirlpoolTokenB }); + const quote = await getDepositIncreaseLiquidityQuote({ sol, slippage }); const { solMax, olasMax } = await getDepositTransformedQuote(quote); @@ -161,8 +163,11 @@ export const useWsolDeposit = () => { whirlpoolTokenB.mint, svmWalletPublicKey, ); + console.log({ tokenOwnerAccountB }); const accountInfo = await connection.getAccountInfo(tokenOwnerAccountB); + console.log({ accountInfo }); + if (!accountInfo) { notifyError('OLAS Associated token account does not exist'); return null; From 7db34fc48596f9246e29a4b3563b99645997b085 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 16 Aug 2024 19:42:37 +0530 Subject: [PATCH 15/22] feat: calculation fix for deposit --- .../Bonding/Deposit/Deposit.jsx | 32 +++++++++++-------- .../Bonding/Deposit/useDeposit.jsx | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx index 5539573c..374a4d7d 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx @@ -10,7 +10,7 @@ import { getCommaSeparatedNumber } from '@autonolas/frontend-library'; import { COLOR } from 'libs/ui-theme/src'; import { notifyError, notifySuccess } from 'libs/util-functions/src'; -import { ONE_ETH_IN_STRING } from 'common-util/constants/numbers'; +import { ONE_ETH, ONE_ETH_IN_STRING } from 'common-util/constants/numbers'; import { notifyCustomErrors, parseToEth, @@ -34,11 +34,19 @@ export const Deposit = ({ getProducts, closeModal, }) => { + console.log({ + productId, + productToken, + productLpTokenName, + productLpPriceAfterDiscount, + productSupply, + }); + const { account } = useHelpers(); const [form] = Form.useForm(); const [isLoading, setIsLoading] = useState(false); const [isApproveModalVisible, setIsApproveModalVisible] = useState(false); - const [lpBalance, setLpBalance] = useState(0); + const [lpBalance, setLpBalance] = useState(0n); const isSvmProduct = isSvmLpAddress(productToken); @@ -128,15 +136,13 @@ export const Deposit = ({ }; const getRemainingLpSupplyInEth = () => { - const productSupplyInWei = new BigNumber(productSupply || '0'); - const lpBalanceInBg = new BigNumber(lpBalance); - - const remainingSupply = productSupplyInWei - .multipliedBy(ONE_ETH_IN_STRING) - .dividedBy(productLpPriceAfterDiscountInBg); - - const remainingSupplyInWei = remainingSupply.lt(lpBalanceInBg) ? remainingSupply : lpBalance; - return parseToEth(remainingSupplyInWei); + const totalProductSupplyInWei = productSupply || 0n; + const lpBalanceInWei = BigInt(lpBalance); + const maxRedeemableSupply = + (totalProductSupplyInWei * ONE_ETH) / BigInt(productLpPriceAfterDiscount); + const remainingLPSupply = + maxRedeemableSupply < lpBalanceInWei ? maxRedeemableSupply : lpBalanceInWei; + return parseToEth(remainingLPSupply); }; const remainingLpSupplyInEth = getRemainingLpSupplyInEth(); @@ -164,9 +170,7 @@ export const Deposit = ({ open title="Bond LP tokens for OLAS" okText="Bond" - okButtonProps={{ - disabled: !account || lpBalance === new BigNumber(0), - }} + okButtonProps={{ disabled: !account || lpBalance === 0n }} cancelText="Cancel" onCancel={closeModal} onOk={onCreate} diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx index 2800a78d..c25b27e2 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/useDeposit.jsx @@ -31,7 +31,7 @@ export const useDeposit = () => { async ({ token }) => { const contract = getUniswapV2PairContract(token); const response = await contract.methods.balanceOf(account).call(); - return response.toString(); + return response; }, [account], ); From 3ff28ac479c6bcad3708726d5931538575a83ba8 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 16 Aug 2024 20:04:31 +0530 Subject: [PATCH 16/22] feat: calculate OLAS payout --- .../Bonding/Deposit/Deposit.jsx | 30 ++++++------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx index 374a4d7d..e011886f 100644 --- a/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx @@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js'; import { ethers } from 'ethers'; import { isNil } from 'lodash'; import PropTypes from 'prop-types'; -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { getCommaSeparatedNumber } from '@autonolas/frontend-library'; @@ -34,25 +34,13 @@ export const Deposit = ({ getProducts, closeModal, }) => { - console.log({ - productId, - productToken, - productLpTokenName, - productLpPriceAfterDiscount, - productSupply, - }); - const { account } = useHelpers(); const [form] = Form.useForm(); const [isLoading, setIsLoading] = useState(false); const [isApproveModalVisible, setIsApproveModalVisible] = useState(false); const [lpBalance, setLpBalance] = useState(0n); - const isSvmProduct = isSvmLpAddress(productToken); - // convert to BigNumber of bignumber.js and not ethers - const productLpPriceAfterDiscountInBg = new BigNumber(productLpPriceAfterDiscount); - const { getLpBalanceRequest, depositRequest, approveRequest, hasSufficientTokenRequest } = useDeposit(); @@ -135,7 +123,9 @@ export const Deposit = ({ }); }; - const getRemainingLpSupplyInEth = () => { + const tokenAmountInputValue = Form.useWatch('tokenAmount', form) || 0; + + const remainingLpSupplyInEth = useMemo(() => { const totalProductSupplyInWei = productSupply || 0n; const lpBalanceInWei = BigInt(lpBalance); const maxRedeemableSupply = @@ -143,11 +133,9 @@ export const Deposit = ({ const remainingLPSupply = maxRedeemableSupply < lpBalanceInWei ? maxRedeemableSupply : lpBalanceInWei; return parseToEth(remainingLPSupply); - }; + }, [lpBalance, productSupply, productLpPriceAfterDiscount]); - const remainingLpSupplyInEth = getRemainingLpSupplyInEth(); - const tokenAmountInputValue = Form.useWatch('tokenAmount', form) || 0; - const getOlasPayout = () => { + const olasPayout = useMemo(() => { if (!tokenAmountInputValue || tokenAmountInputValue > remainingLpSupplyInEth) { return '--'; } @@ -156,13 +144,13 @@ export const Deposit = ({ ? tokenAmountInputValue : new BigNumber(parseToWei(tokenAmountInputValue)); - const payoutInBg = productLpPriceAfterDiscountInBg.multipliedBy(tokenAmountValue); + const payoutInBg = new BigNumber(productLpPriceAfterDiscount).multipliedBy(tokenAmountValue); const payout = isSvmProduct ? payoutInBg.dividedBy(BigNumber(`1${'0'.repeat(28)}`)).toFixed(2) : Number(payoutInBg.dividedBy(ONE_ETH_IN_STRING).dividedBy(ONE_ETH_IN_STRING).toFixed(2)); return getCommaSeparatedNumber(payout, 4); - }; + }, [tokenAmountInputValue, remainingLpSupplyInEth, productLpPriceAfterDiscount, isSvmProduct]); return ( <> @@ -235,7 +223,7 @@ export const Deposit = ({
- {`OLAS Payout: ${getOlasPayout()}`} + {`OLAS Payout: ${olasPayout}`}
From 6cf8d7df061c4bdb1e3ccbb8dbf3585b715ad874 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 22 Aug 2024 18:30:43 +0530 Subject: [PATCH 17/22] feat: enhance error message in Solana liquidity management --- .../TokenManagement/hooks/useWsolDeposit.jsx | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx index 82d1e3e0..f0650467 100644 --- a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx @@ -11,9 +11,11 @@ import { import { useWallet } from '@solana/wallet-adapter-react'; import { SystemProgram, Transaction } from '@solana/web3.js'; import Decimal from 'decimal.js'; +import Link from 'next/link'; import { notifyError, notifySuccess } from '@autonolas/frontend-library'; +import { UNICODE_SYMBOLS } from 'libs/util-constants/src/lib/symbols'; import idl from 'libs/util-contracts/src/lib/abiAndAddresses/liquidityLockbox.json'; import { useSvmConnectivity } from 'common-util/hooks/useSvmConnectivity'; @@ -44,6 +46,19 @@ import { import { useGetOrCreateAssociatedTokenAccount } from './useGetOrCreateAssociatedTokenAccount'; import { useWhirlpool } from './useWhirlpool'; +const GetSomeOlas = () => ( + <> + OLAS Associated token account does not exist.  + + Get some OLAS first {UNICODE_SYMBOLS.EXTERNAL_LINK}. + + +); + const getOlasAmount = async (connection, walletPublicKey, tokenAddress) => { const tokenAccounts = await connection.getTokenAccountsByOwner(walletPublicKey, { programId: TOKEN_PROGRAM_ID, @@ -153,7 +168,6 @@ export const useWsolDeposit = () => { } const { whirlpoolTokenA, whirlpoolTokenB } = await getWhirlpoolData(); - console.log({ whirlpoolTokenA, whirlpoolTokenB }); const quote = await getDepositIncreaseLiquidityQuote({ sol, slippage }); const { solMax, olasMax } = await getDepositTransformedQuote(quote); @@ -163,13 +177,13 @@ export const useWsolDeposit = () => { whirlpoolTokenB.mint, svmWalletPublicKey, ); - console.log({ tokenOwnerAccountB }); const accountInfo = await connection.getAccountInfo(tokenOwnerAccountB); - console.log({ accountInfo }); - if (!accountInfo) { - notifyError('OLAS Associated token account does not exist'); + if (accountInfo) { + // If the user has no associated token account, they need to get some OLAS first + // from orca + notifyError(); return null; } From b7ac6976d57a4e8a3ef622038a0037fd26089eff Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 22 Aug 2024 18:31:08 +0530 Subject: [PATCH 18/22] feat: add tooltip to MyBonds - OLAS payout column --- apps/bond/components/MyBonds/MyBonds.jsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/bond/components/MyBonds/MyBonds.jsx b/apps/bond/components/MyBonds/MyBonds.jsx index af8ce0c2..b2afa1c8 100644 --- a/apps/bond/components/MyBonds/MyBonds.jsx +++ b/apps/bond/components/MyBonds/MyBonds.jsx @@ -1,7 +1,7 @@ import { CheckOutlined, CloseOutlined } from '@ant-design/icons'; -import { Button, ConfigProvider, Empty, Radio, Table, Typography } from 'antd'; +import { Button, ConfigProvider, Empty, Radio, Table, Tooltip, Typography } from 'antd'; import { round } from 'lodash'; -import { useEffect, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { getFormattedDate, notifyError, notifySuccess } from '@autonolas/frontend-library'; @@ -20,7 +20,14 @@ const getBondsColumns = () => { title: 'Payout in OLAS', dataIndex: 'payout', key: 'payout', - render: (value) => `${round(parseToEth(value), 4)}`, + render: (value) => { + const parseValue = `${parseToEth(value)}`; + return ( + + {round(parseValue, 4)} + + ); + }, }, { title: 'Matured?', @@ -57,7 +64,7 @@ export const MyBonds = () => { const [nonMaturedBondList, setNonMaturedBondList] = useState([]); const [selectedBondIds, setSelectedBondIds] = useState([]); - const getBondsListHelper = async () => { + const getBondsListHelper = useCallback(async () => { try { setIsLoading(true); @@ -71,7 +78,7 @@ export const MyBonds = () => { } finally { setIsLoading(false); } - }; + }, [account]); // on load, get the list of bonds & set the maturity type radio button useEffect(() => { @@ -103,7 +110,7 @@ export const MyBonds = () => { if (account && chainId) { getBondsListHelper(); } - }, [account, chainId, maturityType]); + }, [account, chainId, maturityType, getBondsListHelper]); const onRedeem = async () => { try { From 5c33ca95f0904c29ec8e3e9f71cfce9df3d63427 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 22 Aug 2024 18:33:30 +0530 Subject: [PATCH 19/22] fix: Add missing file to .gitleaksignore --- .gitleaksignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitleaksignore b/.gitleaksignore index 1fcfc9aa..c47657ad 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -155,3 +155,4 @@ c286a015e94a4abfa474749e6d0d38d944b25e8b:apps/govern/common-util/Contracts/addre 19198deff3574e55dbb56fba98533722a641c6e7:apps/launcher/common-util/Contracts/addresses.tsx:generic-api-key:31 19198deff3574e55dbb56fba98533722a641c6e7:apps/launcher/common-util/Contracts/addresses.tsx:generic-api-key:29 c286a015e94a4abfa474749e6d0d38d944b25e8b:apps/govern/common-util/Contracts/addresses.tsx:generic-api-key:74 +6cf8d7df061c4bdb1e3ccbb8dbf3585b715ad874:apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx:generic-api-key:53 From 501e5043158cddbc84aa3d9c4661e832ad7319b1 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 22 Aug 2024 19:19:38 +0530 Subject: [PATCH 20/22] fix: minor chnages --- .../TokenManagement/hooks/useWsolDeposit.jsx | 4 +--- apps/bond/components/MyBonds/MyBonds.jsx | 2 +- apps/bond/pages/paths/[pathId].jsx | 15 +++++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx index f0650467..08c1fa00 100644 --- a/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx +++ b/apps/bond/components/BondingProducts/Bonding/TokenManagement/hooks/useWsolDeposit.jsx @@ -179,10 +179,8 @@ export const useWsolDeposit = () => { ); const accountInfo = await connection.getAccountInfo(tokenOwnerAccountB); - - if (accountInfo) { + if (!accountInfo) { // If the user has no associated token account, they need to get some OLAS first - // from orca notifyError(); return null; } diff --git a/apps/bond/components/MyBonds/MyBonds.jsx b/apps/bond/components/MyBonds/MyBonds.jsx index b2afa1c8..14a6ad6d 100644 --- a/apps/bond/components/MyBonds/MyBonds.jsx +++ b/apps/bond/components/MyBonds/MyBonds.jsx @@ -21,7 +21,7 @@ const getBondsColumns = () => { dataIndex: 'payout', key: 'payout', render: (value) => { - const parseValue = `${parseToEth(value)}`; + const parseValue = parseToEth(value); return ( {round(parseValue, 4)} diff --git a/apps/bond/pages/paths/[pathId].jsx b/apps/bond/pages/paths/[pathId].jsx index d9d3111a..7030c25d 100644 --- a/apps/bond/pages/paths/[pathId].jsx +++ b/apps/bond/pages/paths/[pathId].jsx @@ -1,7 +1,7 @@ import { Button, Card, Col, Collapse, Flex, Grid, Row, Typography } from 'antd'; import Head from 'next/head'; import Image from 'next/image'; -import { useRouter } from 'next/router'; +import Link from 'next/link'; import { PropTypes } from 'prop-types'; import styled from 'styled-components'; @@ -162,19 +162,18 @@ BridgeCollapseItem.propTypes = { isEthereumPath: PropTypes.bool.isRequired, }; -const BondCollapseItem = () => { - const router = useRouter(); +const BondCollapseItem = () => ( Bond LP Token into Olas Protocol - router.push('/bonding-products')}> - View available products - + + View available products + - ; -}; + +); BondCollapseItem.propTypes = { path: PropTypes.shape({ From 91701fc3a156324e20e42a22b772870178427c6e Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 22 Aug 2024 19:25:16 +0530 Subject: [PATCH 21/22] feat: fix bonds-footer --- apps/bond/components/Layout/Footer.jsx | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/bond/components/Layout/Footer.jsx b/apps/bond/components/Layout/Footer.jsx index 6c7290b1..a3bd9a93 100644 --- a/apps/bond/components/Layout/Footer.jsx +++ b/apps/bond/components/Layout/Footer.jsx @@ -1,19 +1,25 @@ -import { useRouter } from 'next/router'; import { Grid } from 'antd'; import Image from 'next/image'; -import { - Footer as CommonFooter, - getExplorerURL, -} from '@autonolas/frontend-library'; +import { useRouter } from 'next/router'; + +import { Footer as CommonFooter, getExplorerURL } from '@autonolas/frontend-library'; import { ADDRESSES } from 'common-util/constants/addresses'; import { useHelpers } from 'common-util/hooks/useHelpers'; -import { ContractsInfoContainer } from './styles'; import { OPERATOR_NAME } from 'util/meta'; +import { ContractsInfoContainer } from './styles'; + const { useBreakpoint } = Grid; -const PATHS_NOT_TO_SHOW = ['/docs', '/disclaimer', '/not-legal']; +const PATHS_NOT_TO_SHOW = [ + '/', + '/paths', + '/manage-solana-liquidity', + '/docs', + '/disclaimer', + '/not-legal', +]; const ContractInfo = () => { const { chainId } = useHelpers(); @@ -51,19 +57,13 @@ const ContractInfo = () => { ); - const { textOne, addressOne, textTwo, addressTwo } = - getCurrentPageAddresses(); + const { textOne, addressOne, textTwo, addressTwo } = getCurrentPageAddresses(); return ( {!PATHS_NOT_TO_SHOW.includes(pathname) && ( <> - Etherscan link + Etherscan link Contracts  •  {getContractInfo(textOne, addressOne)} From 04202e37783720fb37dc1fb5d4011811960c7d8f Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 22 Aug 2024 19:31:41 +0530 Subject: [PATCH 22/22] feat: add RPC endpoint to allowed origins in CSP header --- libs/common-middleware/src/lib/cspHeader.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/common-middleware/src/lib/cspHeader.ts b/libs/common-middleware/src/lib/cspHeader.ts index 2fb35942..f4bb376c 100644 --- a/libs/common-middleware/src/lib/cspHeader.ts +++ b/libs/common-middleware/src/lib/cspHeader.ts @@ -61,6 +61,7 @@ const ALLOWED_ORIGINS = [ 'https://forno.celo.org', 'https://alfajores-forno.celo-testnet.org', 'https://api.web3modal.com/', + 'https://rpc.ankr.com/', // tenderly 'https://virtual.mainnet.rpc.tenderly.co/',