From b93b2a50ca7d214b58f9344c1820db3d860455ae Mon Sep 17 00:00:00 2001 From: 0xhardrefresh <98540076+0xhardrefresh@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:13:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=E2=99=82=EF=B8=8F=20MimSw?= =?UTF-8?q?ap=20update:=20Integrate=20MIM/USDB=20to=20farm=20logic=20(#512?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * integrate MIM_USDB to farm logic * update conditions --- src/components/pools/pool/PoolActionBlock.vue | 11 ++++++++++- src/components/pools/pool/TokenPair.vue | 19 +++++++++++++++++++ src/components/pools/pool/actions/Unstake.vue | 8 ++++++-- src/components/pools/pool/position/Staked.vue | 11 ++++++----- .../table/poolFarms/PoolFarmCardItem.vue | 12 +++++++++--- .../pools/table/poolFarms/PoolFarmsTable.vue | 15 +++++++++------ .../table/poolFarms/PoolFarmsTableItem.vue | 12 +++++++++--- src/configs/pools/blastPools.ts | 2 ++ src/configs/pools/types.ts | 4 ++++ src/helpers/pools/getPoolInfo.ts | 15 ++++++++++++++- src/helpers/pools/swap/magicLp.ts | 19 +++++++++++++++++++ src/views/pool/PoolFarms.vue | 2 +- 12 files changed, 108 insertions(+), 22 deletions(-) diff --git a/src/components/pools/pool/PoolActionBlock.vue b/src/components/pools/pool/PoolActionBlock.vue index 1e7ec45b3..c1056b981 100644 --- a/src/components/pools/pool/PoolActionBlock.vue +++ b/src/components/pools/pool/PoolActionBlock.vue @@ -3,7 +3,7 @@

{{ titleText }}

- +
{{ feeTier }} @@ -137,6 +137,10 @@ export default { return this.isFarm ? "Farm" : "Pool"; }, + isDeprecatedFarm() { + return this.isFarm && this.pool.settings.isDeprecatedFarm; + }, + isRemove() { return this.activeTab === "remove"; }, @@ -167,6 +171,11 @@ export default { if (value) { this.activeTab = stakeTabItems[0]; this.tabItems = [...stakeTabItems]; + + if(this.isDeprecatedFarm) { + this.activeTab = stakeTabItems[1]; + this.tabItems = [stakeTabItems[1]]; + } } }, immediate: true, diff --git a/src/components/pools/pool/TokenPair.vue b/src/components/pools/pool/TokenPair.vue index a656e71b4..d91efbbda 100644 --- a/src/components/pools/pool/TokenPair.vue +++ b/src/components/pools/pool/TokenPair.vue @@ -30,6 +30,9 @@ 1x Multiplier
+
+ Deprecated +
@@ -43,6 +46,7 @@ const borderRadiusCoefficient = 2.5; export default { props: { + isFarm: { type: Boolean, default: false }, pool: { type: Object }, chainIcon: Boolean, iconSize: { type: Number, default: 46 }, @@ -51,6 +55,10 @@ export default { }, computed: { + isDeprecatedFarm() { + return this.isFarm && this.pool.settings.isDeprecatedFarm; + }, + baseIconSize() { return this.iconSize - this.borderThickness * 2; }, @@ -105,6 +113,17 @@ export default { align-items: center; } +.deprecated-wrap { + padding: 2px 12px; + border-radius: 12px; + background: linear-gradient(90deg, #8c4040 0%, #6b2424 100%); + font-size: 12px; + font-style: normal; + font-weight: 400; + line-height: normal; + margin-top: 3px; +} + .token-icon { margin-right: 0 !important; } diff --git a/src/components/pools/pool/actions/Unstake.vue b/src/components/pools/pool/actions/Unstake.vue index ddc5ec8a2..2b1eada9b 100644 --- a/src/components/pools/pool/actions/Unstake.vue +++ b/src/components/pools/pool/actions/Unstake.vue @@ -12,8 +12,8 @@ /> - - + + {{ buttonText }} @@ -59,6 +59,10 @@ export default { account: "getAccount", }), + isDeprecatedFarm(){ + return this.pool.settings.isDeprecatedFarm; + }, + isBlastLockLogic() { return !!this.pool.lockInfo; }, diff --git a/src/components/pools/pool/position/Staked.vue b/src/components/pools/pool/position/Staked.vue index 6edb4549f..0ff0f9e5d 100644 --- a/src/components/pools/pool/position/Staked.vue +++ b/src/components/pools/pool/position/Staked.vue @@ -15,11 +15,7 @@
{{ poolLabel }}
- +

TVL

@@ -22,7 +22,7 @@ v-if="rewardPointsType" /> -
+
+

-

APR

-
+
{{ poolApr }}
+

-

@@ -66,6 +68,10 @@ export default { type: Object, required: true, }, + isFarm: { + type: Boolean, + default: false, + }, }, computed: { diff --git a/src/components/pools/table/poolFarms/PoolFarmsTable.vue b/src/components/pools/table/poolFarms/PoolFarmsTable.vue index 0f05fa330..ba6dff65b 100644 --- a/src/components/pools/table/poolFarms/PoolFarmsTable.vue +++ b/src/components/pools/table/poolFarms/PoolFarmsTable.vue @@ -34,6 +34,7 @@ v-for="(pool, index) in poolsToRender" :key="index" :pool="pool" + :isFarm="true" />
@@ -42,6 +43,7 @@ v-for="(pool, index) in poolsToRender" :key="index" :pool="pool" + :isFarm="true" />
@@ -132,15 +134,15 @@ export default { }, showDeprecatedButton() { - const hasDeprecatedPool = this.poolsToRender.some( - (pool: MagicLPInfo) => pool.settings.isDeprecated + const hasDeprecatedPool = this.pools.some( + (pool: MagicLPInfo) => pool.settings.isDeprecatedFarm ); return this.poolsToRender.length && hasDeprecatedPool; }, deprecatedButtonText() { - if (this.showActivePools) return " Show Deprecated pools"; - return "Hide Deprecated pools"; + if (this.showActivePools) return "Show Deprecated Farms"; + return "Hide Deprecated Farms"; }, }, @@ -191,7 +193,7 @@ export default { filterByActivepools(pools: MagicLPInfo[]) { if (this.showActivePools) { return pools.filter((pool) => { - return !pool.settings.isDeprecated; + return !pool.settings.isDeprecatedFarm; }); } @@ -199,7 +201,8 @@ export default { const settingsA = a?.settings; const settingsB = b?.settings; if (settingsA || settingsB) { - return +settingsA?.isDeprecated - +settingsB?.isDeprecated; + // @ts-ignore + return +settingsA?.isDeprecatedFarm - +settingsB?.isDeprecatedFarm; } return 1; diff --git a/src/components/pools/table/poolFarms/PoolFarmsTableItem.vue b/src/components/pools/table/poolFarms/PoolFarmsTableItem.vue index 3345b7414..160420000 100644 --- a/src/components/pools/table/poolFarms/PoolFarmsTableItem.vue +++ b/src/components/pools/table/poolFarms/PoolFarmsTableItem.vue @@ -6,7 +6,7 @@ >
{{ poolLabel }}
- +
${{ tvl }}
@@ -18,7 +18,7 @@ name v-if="rewardPointsType" /> -
+
+

-

@@ -35,7 +36,8 @@ multiplier v-if="rewardPointsType" /> - {{ poolApr }} + {{ poolApr }} +

-

@@ -53,6 +55,10 @@ export default { type: Object as PropType, required: true, }, + isFarm: { + type: Boolean, + default: false, + }, }, computed: { diff --git a/src/configs/pools/blastPools.ts b/src/configs/pools/blastPools.ts index ed6887663..b258b5e31 100644 --- a/src/configs/pools/blastPools.ts +++ b/src/configs/pools/blastPools.ts @@ -44,6 +44,8 @@ const blastPools: Array = [ isDeprecated: false, isMim: true, isPointsLogic: true, + isLockAsStake: true, + isDeprecatedFarm: true, }, initialParameters: { I: 1000000000000000000n, diff --git a/src/configs/pools/types.ts b/src/configs/pools/types.ts index f30a27207..281439c2d 100644 --- a/src/configs/pools/types.ts +++ b/src/configs/pools/types.ts @@ -27,6 +27,8 @@ export type AdditionalPoolConfig = { isDeprecated: boolean; isMim: boolean; rewardPointsType?: RewardPointsTypes; + isLockAsStake?: boolean; + isDeprecatedFarm?: boolean; }; stakeContract?: ContractInfo; }; @@ -38,6 +40,8 @@ type PoolSettings = { isMim: boolean; isPointsLogic?: boolean; rewardPointsType?: RewardPointsTypes; + isLockAsStake?: boolean; + isDeprecatedFarm?: boolean; }; type InitialParameters = { diff --git a/src/helpers/pools/getPoolInfo.ts b/src/helpers/pools/getPoolInfo.ts index 1c36f4d05..36b442c71 100644 --- a/src/helpers/pools/getPoolInfo.ts +++ b/src/helpers/pools/getPoolInfo.ts @@ -44,8 +44,12 @@ export const getPoolInfo = async ( swapRouter: getSwapRouterByChain(Number(poolChainId)), }; - if (account && poolConfig.lockContract) + if (account && poolConfig.lockContract) { poolInfo.lockInfo = await getLockInfo(account, poolChainId, poolConfig); + poolInfo.stakeInfo = parseLockAsStake(poolInfo.lockInfo); + poolInfo.stakeContract = poolConfig.lockContract; + } + if (poolConfig.stakeContract) poolInfo.poolAPR = await getPoolApr(poolChainId, poolInfo, tokensPrices); @@ -204,6 +208,15 @@ export const getStakeInfo = async ( }; }; +export const parseLockAsStake = (lockInfo: any) => { + return { + balance: lockInfo.balances.unlocked, + allowance: lockInfo.allowance, + earned: 0, + earnedInfo: [], + }; +} + export const getUserLocks = async ( account: Address, chainId: number, diff --git a/src/helpers/pools/swap/magicLp.ts b/src/helpers/pools/swap/magicLp.ts index 48f599c64..f744e2d9d 100644 --- a/src/helpers/pools/swap/magicLp.ts +++ b/src/helpers/pools/swap/magicLp.ts @@ -140,6 +140,25 @@ export const getLpInfo = async ( }); } + // + if (lp.lockContract?.address) { + const lockedSupply = await publicClient.readContract({ + address: lp.lockContract.address, + abi: lp.lockContract.abi as any, + functionName: "lockedSupply", + args: [], + }); + + const unlockedSupply = await publicClient.readContract({ + address: lp.lockContract.address, + abi: lp.lockContract.abi as any, + functionName: "unlockedSupply", + args: [], + }); + + stakedTotalSupply = lockedSupply + unlockedSupply; + } + const userInfo = await getUserLpInfo( lp.contract.address, getSwapRouterByChain(chainId), diff --git a/src/views/pool/PoolFarms.vue b/src/views/pool/PoolFarms.vue index b3369b967..f187a11e8 100644 --- a/src/views/pool/PoolFarms.vue +++ b/src/views/pool/PoolFarms.vue @@ -66,7 +66,7 @@ export default { }), poolFarmsConfigs() { - return this.poolConfigs.filter(({ stakeContract }) => stakeContract); + return this.poolConfigs.filter(({ stakeContract, lockContract }) => stakeContract || lockContract); }, },