From 607a5eb840d040fc921d1d2ff2c348a5951451b7 Mon Sep 17 00:00:00 2001 From: Another Date: Sat, 27 Jan 2024 12:48:18 -0600 Subject: [PATCH] feat: implement dynamic treshholds --- src/assets/data/contracts/alfajores.json | 6 +- src/assets/data/contracts/celo.json | 6 +- .../pages/dashboard/Cards/RefiProfileCard.vue | 14 +- src/lib/abi/KolektivoRNFT.json | 13 + src/lib/abi/KolektivoSimpleMinter.json | 615 +++++++++++++++++- src/services/campaigns/campaigns.service.ts | 5 + 6 files changed, 623 insertions(+), 36 deletions(-) diff --git a/src/assets/data/contracts/alfajores.json b/src/assets/data/contracts/alfajores.json index 6ca432fab..878b3a9f2 100644 --- a/src/assets/data/contracts/alfajores.json +++ b/src/assets/data/contracts/alfajores.json @@ -69,7 +69,7 @@ "WeightedPoolFactory": "0x997252b17F61fFc6Ca2fDDd7fa1Cb0cdb98f202D", "YearnLinearPoolFactory": "", "Multicall": "0xca11bde05977b3631167028862be2a173976ca11", - "SimpleMinter": "0x236C4B59f22697aC22C8AC3A6442eBD6f2af9dbF", - "RFNFT": "0x976c8244061CC363d1e72d0F1c0B4DBe9a78d483", - "RFP": "0x8431584b4DEfaB5f4aDd6A4221161F2Cb6823DE9" + "SimpleMinter": "0x3052fFcE3A66B4AB60183DA87C31F9e753a051E6", + "RFNFT": "0x5a4A3F1397325522e889B48ff16f69c32b7Db1ba", + "RFP": "0x4AF6b567A189467Ad31b4f5d43982dBe1C75841f" } diff --git a/src/assets/data/contracts/celo.json b/src/assets/data/contracts/celo.json index 552cfda0f..f56bfd1b2 100644 --- a/src/assets/data/contracts/celo.json +++ b/src/assets/data/contracts/celo.json @@ -69,7 +69,7 @@ "WeightedPoolFactory": "0xEB1055c017a1427726F01368C8247649c5A79bF9", "YearnLinearPoolFactory": "", "Multicall": "0xca11bde05977b3631167028862be2a173976ca11", - "SimpleMinter": "0xd437fa025E43ca4578aD682Bcfb1B003041d48D1", - "RFNFT": "0xBA7d3fB1BBD73f4289C7FB42e8EC268EC9C32bE3", - "RFP": "0x74072b693f1Da8B74b24563Cbded727228c0A898" + "SimpleMinter": "0x605b4853B9DE704E24A81955B9476Fe10096bD23", + "RFNFT": "0x342abeB491A776978b1EaA1ae6357f066416E9B9", + "RFP": "0xB55C408d0e511A5b818590E48be26562f8C24bF0" } diff --git a/src/components/contextual/pages/dashboard/Cards/RefiProfileCard.vue b/src/components/contextual/pages/dashboard/Cards/RefiProfileCard.vue index 0dbb53503..8d7973196 100644 --- a/src/components/contextual/pages/dashboard/Cards/RefiProfileCard.vue +++ b/src/components/contextual/pages/dashboard/Cards/RefiProfileCard.vue @@ -27,14 +27,6 @@ const hasNFT = computed( const isAbleToUpgradeNFT = computed(() => NFTData?.value?.isAbleToUpgrade[0]); -const levels = ref([ - { nextLevel: '50', votes: 1 }, - { nextLevel: '250', votes: 10 }, - { nextLevel: '1000', votes: 30 }, - { nextLevel: '2500', votes: 75 }, - { nextLevel: '5000', votes: 150 }, - { nextLevel: 'MAX', votes: 250 }, -]); const isOpenUpgradeNFTModal = ref(false); const isOpenMintNFTModal = ref(false); @@ -103,7 +95,7 @@ function handleMintNFTClose() { >

Next level

- {{ levels[NFTData?.tier - 1].nextLevel }} RFP + {{ NFTData.tresholds[NFTData?.tier] || 'Max' }} RFP

- RFP

@@ -171,7 +163,7 @@ function handleMintNFTClose() { >

Next level

- {{ levels[NFTData?.tier - 1].nextLevel }} RFP + {{ NFTData.tresholds[NFTData?.tier] || 'Max' }} RFP

- RFP

@@ -242,7 +234,7 @@ function handleMintNFTClose() { >

Next level

- {{ levels[NFTData?.tier - 1].nextLevel }} RFP + {{ NFTData.tresholds[NFTData?.tier] || 'Max' }} RFP

- RFP

diff --git a/src/lib/abi/KolektivoRNFT.json b/src/lib/abi/KolektivoRNFT.json index 02987ca4d..ac178bd26 100644 --- a/src/lib/abi/KolektivoRNFT.json +++ b/src/lib/abi/KolektivoRNFT.json @@ -394,6 +394,19 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [], + "name": "getTierThresholds", + "outputs": [ + { + "internalType": "uint256[]", + "name": "tierThresholds", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [ { diff --git a/src/lib/abi/KolektivoSimpleMinter.json b/src/lib/abi/KolektivoSimpleMinter.json index 238f51197..ac178bd26 100644 --- a/src/lib/abi/KolektivoSimpleMinter.json +++ b/src/lib/abi/KolektivoSimpleMinter.json @@ -2,14 +2,19 @@ { "inputs": [ { - "internalType": "contract IRFP", + "internalType": "contract IERC20", "name": "rfp", "type": "address" }, { - "internalType": "contract IRFNFT", - "name": "rfnft", - "type": "address" + "internalType": "uint256[]", + "name": "thresholds", + "type": "uint256[]" + }, + { + "internalType": "string[]", + "name": "uris", + "type": "string[]" } ], "stateMutability": "nonpayable", @@ -17,7 +22,12 @@ }, { "inputs": [], - "name": "ArrayMismatch", + "name": "InsufficientPoints", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTier", "type": "error" }, { @@ -27,20 +37,95 @@ }, { "inputs": [], - "name": "InvalidZeroAllocation", + "name": "OneTokenPerAddress", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "approved", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "LevelUp", + "type": "event" + }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", - "name": "amountClaimers", + "name": "", "type": "uint256" + }, + { + "indexed": false, + "internalType": "string", + "name": "", + "type": "string" } ], - "name": "NewAllocation", + "name": "NewTier", "type": "event" }, { @@ -63,14 +148,120 @@ "type": "event" }, { + "anonymous": false, "inputs": [ { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "points", + "type": "uint256" + } + ], + "name": "PointsAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "thresholds", + "type": "uint256[]" + } + ], + "name": "ThresholdsSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, "internalType": "address", - "name": "", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" } ], - "name": "allocations", + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "string[]", + "name": "uris", + "type": "string[]" + } + ], + "name": "UrisSet", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "threshold", + "type": "uint256" + }, + { + "internalType": "string", + "name": "uri", + "type": "string" + } + ], + "name": "addTier", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", "outputs": [ { "internalType": "uint256", @@ -84,12 +275,46 @@ { "inputs": [ { - "internalType": "address", - "name": "account", - "type": "address" + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "canLevelUp", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" } ], - "name": "claim", + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "idx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "threshold", + "type": "uint256" + }, + { + "internalType": "string", + "name": "uri", + "type": "string" + } + ], + "name": "editTier", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -97,21 +322,154 @@ { "inputs": [ { - "internalType": "address[]", - "name": "accounts", - "type": "address[]" + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "feedToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getApproved", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getOwnerPoints", + "outputs": [ + { + "internalType": "uint256", + "name": "tier", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "getOwnerTier", + "outputs": [ + { + "internalType": "uint256", + "name": "tier", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTierThresholds", + "outputs": [ { "internalType": "uint256[]", - "name": "amounts", + "name": "tierThresholds", "type": "uint256[]" } ], - "name": "createAllocation", + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isApprovedForAll", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "levelUp", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "mint", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "owner", @@ -125,6 +483,44 @@ "stateMutability": "view", "type": "function" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "ownerOf", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "ownerTokenId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "renounceOwnership", @@ -132,6 +528,187 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } + ], + "name": "supportsInterface", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "tokenIdPoints", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "tokenIdTier", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "tokenURI", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { diff --git a/src/services/campaigns/campaigns.service.ts b/src/services/campaigns/campaigns.service.ts index c71e1086c..3c526fb25 100644 --- a/src/services/campaigns/campaigns.service.ts +++ b/src/services/campaigns/campaigns.service.ts @@ -28,6 +28,7 @@ export type NFTData = RFNFTData & { points: number; tier: number; isAbleToUpgrade: [boolean, bigint]; + tresholds: number[]; }; export default class CampaignsService { @@ -74,6 +75,7 @@ export default class CampaignsService { [BigNumber.from(currentNFTId).toNumber()], ], [this.addresses.RFNFT, 'canLevelUp', [currentNFTId]], + [this.addresses.RFNFT, 'getTierThresholds'], ]; const currentNFTDataResponses = (await multicall( String(chainId), @@ -92,6 +94,9 @@ export default class CampaignsService { points: parseInt( formatUnits(BigNumber.from(currentNFTDataResponses[0]), 18) ), + tresholds: (currentNFTDataResponses[4] as bigint[]).map(treshold => + parseInt(formatUnits(BigNumber.from(treshold), 18)) + ), }; } return null;