From 4eba927c3364c09277bee135a448a6630683927b Mon Sep 17 00:00:00 2001 From: S2kael Date: Mon, 23 Oct 2023 15:37:11 +0700 Subject: [PATCH 1/8] [Issue-1929] Update text --- .../Popup/Transaction/variants/Yield/Earn.tsx | 7 ++++- .../src/components/Earning/EarningItem.tsx | 13 ++++++++- .../Earning/HorizontalEarningItem.tsx | 10 ++----- .../Modal/Earning/EarningCalculatorModal.tsx | 2 +- .../Modal/Earning/EarningInfoModal.tsx | 28 ++++++++++++++----- .../Modal/Earning/StakingProcessModal.tsx | 7 ++++- .../Earning/YieldPositionDetailModal.tsx | 2 +- 7 files changed, 50 insertions(+), 19 deletions(-) diff --git a/packages/extension-koni-ui/src/Popup/Transaction/variants/Yield/Earn.tsx b/packages/extension-koni-ui/src/Popup/Transaction/variants/Yield/Earn.tsx index caeb4a8643..194b32c170 100644 --- a/packages/extension-koni-ui/src/Popup/Transaction/variants/Yield/Earn.tsx +++ b/packages/extension-koni-ui/src/Popup/Transaction/variants/Yield/Earn.tsx @@ -731,7 +731,7 @@ const Component = () => { - {t('This content is for informational purposes only and does not constitute a guarantee. All rates are annualized and are subject to change.')} + {t('The provided information is for informational purposes only and should not be considered as guarantee. All rates are calculated on an annual basis and are subject to change.')} @@ -764,6 +764,11 @@ const Component = () => { /> ) } + + + + {t('All steps in the process are designed based on your available multi-chain assets to optimize fee structure and enhance your overall experience.')} + )} diff --git a/packages/extension-koni-ui/src/components/Earning/EarningItem.tsx b/packages/extension-koni-ui/src/components/Earning/EarningItem.tsx index 874b6ba848..af8b75a7a7 100644 --- a/packages/extension-koni-ui/src/components/Earning/EarningItem.tsx +++ b/packages/extension-koni-ui/src/components/Earning/EarningItem.tsx @@ -64,6 +64,17 @@ const Component: React.FC = (props: Props) => { } }, [t, type]); + const totalTitle = useMemo(() => { + switch (type) { + case YieldPoolType.LENDING: + return t('Total value supplied'); + case YieldPoolType.NOMINATION_POOL: + case YieldPoolType.LIQUID_STAKING: + default: + return t('Total value staked'); + } + }, [t, type]); + const childClick = useCallback((onClick: VoidFunction) => { return (e?: SyntheticEvent) => { e && e.stopPropagation(); @@ -215,7 +226,7 @@ const Component: React.FC = (props: Props) => {
-
{t('Total value staked')}:
+
{totalTitle}:
= (props: Props) => { switch (item) { case YieldAction.STAKE: + case YieldAction.START_EARNING: temp.icon = PlusCircle; - temp.label = t('Stake now'); temp.onClick = onClickButton(onClickStakeBtn, getEarnExtrinsicType(slug)); + temp.label = yieldPoolInfo.type === YieldPoolType.LENDING ? t('Supply now') : t('Stake now'); break; case YieldAction.CLAIM_REWARD: temp.icon = Wallet; @@ -200,18 +201,13 @@ const Component: React.FC = (props: Props) => { temp.label = t('Cancel unstake'); temp.schema = 'secondary'; break; - case YieldAction.START_EARNING: - temp.icon = PlusCircle; - temp.onClick = onClickButton(onClickStakeBtn, ExtrinsicType.JOIN_YIELD_POOL); - temp.label = t('Earn now'); - break; } result.push(temp); }); return result; - }, [onClickButton, onClickCalculatorBtn, t, onClickInfoBtn, actionListByChain, availableActionsByMetadata, onClickStakeBtn, slug, onClickClaimBtn, onClickWithdrawBtn, onClickUnStakeBtn, onClickCancelUnStakeBtn]); + }, [onClickButton, onClickCalculatorBtn, t, onClickInfoBtn, actionListByChain, availableActionsByMetadata, onClickStakeBtn, slug, yieldPoolInfo.type, onClickClaimBtn, onClickWithdrawBtn, onClickUnStakeBtn, onClickCancelUnStakeBtn]); const derivativeTokenState = useMemo(() => { if (!yieldPoolInfo.derivativeAssets) { diff --git a/packages/extension-koni-ui/src/components/Modal/Earning/EarningCalculatorModal.tsx b/packages/extension-koni-ui/src/components/Modal/Earning/EarningCalculatorModal.tsx index 69d338bb5d..6fdd72820e 100644 --- a/packages/extension-koni-ui/src/components/Modal/Earning/EarningCalculatorModal.tsx +++ b/packages/extension-koni-ui/src/components/Modal/Earning/EarningCalculatorModal.tsx @@ -279,7 +279,7 @@ const Component = (props: Props) => { /> - {t('This content is for informational purposes only and does not constitute a guarantee. All rates are annualized and are subject to change.')} + {t('The provided information is for informational purposes only and should not be considered as guarantee. All rates are calculated on an annual basis and are subject to change.')}
); diff --git a/packages/extension-koni-ui/src/components/Modal/Earning/YieldPositionDetailModal.tsx b/packages/extension-koni-ui/src/components/Modal/Earning/YieldPositionDetailModal.tsx index cc3d7aa9f4..582d165e29 100644 --- a/packages/extension-koni-ui/src/components/Modal/Earning/YieldPositionDetailModal.tsx +++ b/packages/extension-koni-ui/src/components/Modal/Earning/YieldPositionDetailModal.tsx @@ -292,7 +292,7 @@ const Component: React.FC = (props: Props) => { ) } {t('{{number}} hours', { replace: { number: 24 } })} From 40b8e95f82b35df02b8bad36f3b824810e810864 Mon Sep 17 00:00:00 2001 From: S2kael Date: Mon, 23 Oct 2023 15:44:02 +0700 Subject: [PATCH 2/8] [Issue-1929] Handle sort by incentive --- .../src/Popup/Home/Earning/parts/Overview.tsx | 9 +++++++-- packages/extension-koni-ui/src/constants/index.ts | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/extension-koni-ui/src/Popup/Home/Earning/parts/Overview.tsx b/packages/extension-koni-ui/src/Popup/Home/Earning/parts/Overview.tsx index 0d1576d0c3..28d64f0e43 100644 --- a/packages/extension-koni-ui/src/Popup/Home/Earning/parts/Overview.tsx +++ b/packages/extension-koni-ui/src/Popup/Home/Earning/parts/Overview.tsx @@ -7,7 +7,7 @@ import { _getSubstrateGenesisHash, _isChainEvmCompatible } from '@subwallet/exte import { EarningCalculatorModal, EarningItem, EarningToolbar, EmptyList } from '@subwallet/extension-koni-ui/components'; import EarningInfoModal from '@subwallet/extension-koni-ui/components/Modal/Earning/EarningInfoModal'; import Search from '@subwallet/extension-koni-ui/components/Search'; -import { BN_TEN, CREATE_RETURN, DEFAULT_ROUTER_PATH, DEFAULT_YIELD_PARAMS, EARNING_INFO_MODAL, STAKING_CALCULATOR_MODAL, YIELD_TRANSACTION } from '@subwallet/extension-koni-ui/constants'; +import { BN_TEN, CREATE_RETURN, DEFAULT_ROUTER_PATH, DEFAULT_YIELD_PARAMS, EARNING_INFO_MODAL, EXCLUSIVE_REWARD_SLUGS, STAKING_CALCULATOR_MODAL, YIELD_TRANSACTION } from '@subwallet/extension-koni-ui/constants'; import { ScreenContext } from '@subwallet/extension-koni-ui/contexts/ScreenContext'; import { useFilterModal, usePreCheckAction, useTranslation } from '@subwallet/extension-koni-ui/hooks'; import { RootState } from '@subwallet/extension-koni-ui/stores'; @@ -82,7 +82,7 @@ const Component: React.FC = (props: Props) => { }, { desc: true, - label: t('Incentive'), + label: t('Rewards'), value: SortKey.INCENTIVE } ]; @@ -238,12 +238,14 @@ const Component: React.FC = (props: Props) => { const aInputDecimals = aInputAsset.decimals || 0; const aTotalValue = new BigN(a.stats?.tvl || '0').div(BN_TEN.pow(aInputDecimals)); const aTotalApy = a.stats?.totalApy ?? calculateReward(a.stats?.totalApr || 0, 0, YieldCompoundingPeriod.YEARLY).apy ?? 0; + const aIncentive = EXCLUSIVE_REWARD_SLUGS.includes(a.slug) ? 1 : 0; const bInputSlug = b.inputAssets[0]; const bInputAsset = assetRegistry[bInputSlug]; const bInputDecimals = bInputAsset.decimals || 0; const bTotalValue = new BigN(b.stats?.tvl || '0').div(BN_TEN.pow(bInputDecimals)); const bTotalApy = b.stats?.totalApy ?? calculateReward(b.stats?.totalApr || 0, 0, YieldCompoundingPeriod.YEARLY).apy ?? 0; + const bIncentive = EXCLUSIVE_REWARD_SLUGS.includes(b.slug) ? 1 : 0; switch (sortSelection) { case SortKey.TOTAL_VALUE: @@ -252,6 +254,9 @@ const Component: React.FC = (props: Props) => { case SortKey.APY: return bTotalApy - aTotalApy; + case SortKey.INCENTIVE: + return (bIncentive - aIncentive) || new BigN(bTotalValue).minus(aTotalValue).toNumber(); + default: return 0; } diff --git a/packages/extension-koni-ui/src/constants/index.ts b/packages/extension-koni-ui/src/constants/index.ts index f84713709d..319fed509d 100644 --- a/packages/extension-koni-ui/src/constants/index.ts +++ b/packages/extension-koni-ui/src/constants/index.ts @@ -4,6 +4,7 @@ export * from './account'; export * from './buy'; export * from './common'; +export * from './earning'; export * from './history'; export * from './ledger'; export * from './localStorage'; From 01f50164df5f7b5c5896b53a703321d731cad679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nam=20Ph=E1=BA=A1m?= Date: Mon, 23 Oct 2023 16:01:32 +0700 Subject: [PATCH 3/8] [Yield-Aggregator] update filtering history earning items --- .../src/koni/api/yield/helper/utils.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/extension-base/src/koni/api/yield/helper/utils.ts b/packages/extension-base/src/koni/api/yield/helper/utils.ts index 5a269f187a..ee84d2a411 100644 --- a/packages/extension-base/src/koni/api/yield/helper/utils.ts +++ b/packages/extension-base/src/koni/api/yield/helper/utils.ts @@ -45,7 +45,20 @@ export const DEFAULT_YIELD_FIRST_STEP: YieldStepDetail = { type: YieldStepType.DEFAULT }; -export const YIELD_EXTRINSIC_TYPES = [ExtrinsicType.MINT_VDOT, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_QDOT]; +export const YIELD_EXTRINSIC_TYPES = [ + ExtrinsicType.MINT_VDOT, + ExtrinsicType.MINT_LDOT, + ExtrinsicType.MINT_SDOT, + ExtrinsicType.MINT_QDOT, + ExtrinsicType.REDEEM_QDOT, + ExtrinsicType.REDEEM_SDOT, + ExtrinsicType.REDEEM_VDOT, + ExtrinsicType.REDEEM_LDOT, + ExtrinsicType.STAKING_JOIN_POOL, + ExtrinsicType.STAKING_CLAIM_REWARD, + ExtrinsicType.STAKING_LEAVE_POOL, + ExtrinsicType.STAKING_POOL_WITHDRAW +]; export const YIELD_POOL_STAT_REFRESH_INTERVAL = 300000; From f3c2ce54fd90866ccdcab32956d0e8c9f3c886f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nam=20Ph=E1=BA=A1m?= Date: Mon, 23 Oct 2023 16:50:03 +0700 Subject: [PATCH 4/8] [Yield-Aggregator] remove logs --- .../src/koni/background/handlers/Extension.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/extension-base/src/koni/background/handlers/Extension.ts b/packages/extension-base/src/koni/background/handlers/Extension.ts index e084e1582a..c4e6e80f40 100644 --- a/packages/extension-base/src/koni/background/handlers/Extension.ts +++ b/packages/extension-base/src/koni/background/handlers/Extension.ts @@ -3919,8 +3919,6 @@ export default class KoniExtension { substrateApiMap: this.#koniState.getSubstrateApiMap() }, inputData, path, inputData.currentStep, this.#koniState.balanceService); - console.log('extrinsic', extrinsic.toHex()); - const isMintingStep = YIELD_EXTRINSIC_TYPES.includes(extrinsicType); const isPoolSupportAlternativeFee = yieldPoolInfo.feeAssets.length > 1; @@ -3957,8 +3955,6 @@ export default class KoniExtension { substrateApiMap: this.#koniState.getSubstrateApiMap() }, address, amount, yieldPositionInfo); - console.log('extrinsic', extrinsic.toHex()); - return await this.#koniState.transactionService.handleTransaction({ address, chain: yieldPoolInfo.chain, @@ -4014,6 +4010,8 @@ export default class KoniExtension { substrateApiMap: this.#koniState.getSubstrateApiMap() }; + return []; + return validateYieldProcess( inputData.address, params, From 4f0d54a734c8d5251c132dc95e10eabe103a0b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nam=20Ph=E1=BA=A1m?= Date: Mon, 23 Oct 2023 17:38:06 +0700 Subject: [PATCH 5/8] [Yield-Aggregator] update handling error when generate steps --- .../src/background/KoniTypes.ts | 3 +- .../src/koni/api/yield/index.ts | 234 +++++++++++------- 2 files changed, 140 insertions(+), 97 deletions(-) diff --git a/packages/extension-base/src/background/KoniTypes.ts b/packages/extension-base/src/background/KoniTypes.ts index 05cd272799..8a31b801a9 100644 --- a/packages/extension-base/src/background/KoniTypes.ts +++ b/packages/extension-base/src/background/KoniTypes.ts @@ -2207,7 +2207,8 @@ export interface YieldStepDetail { export interface OptimalYieldPath { totalFee: YieldTokenBaseInfo[], - steps: YieldStepDetail[] + steps: YieldStepDetail[], + connectionError?: string } export enum YieldValidationStatus { diff --git a/packages/extension-base/src/koni/api/yield/index.ts b/packages/extension-base/src/koni/api/yield/index.ts index 823c5c8a1a..0cb9a9650d 100644 --- a/packages/extension-base/src/koni/api/yield/index.ts +++ b/packages/extension-base/src/koni/api/yield/index.ts @@ -178,115 +178,157 @@ export async function generatePathForLiquidStaking (params: OptimalYieldPathPara steps: [DEFAULT_YIELD_FIRST_STEP] }; - const poolOriginSubstrateApi = await params.substrateApiMap[params.poolInfo.chain].isReady; - - const inputTokenSlug = params.poolInfo.inputAssets[0]; // assume that the pool only has 1 input token, will update later - const inputTokenInfo = params.assetInfoMap[inputTokenSlug]; - - const altInputTokenSlug = params.poolInfo.altInputAssets ? params.poolInfo?.altInputAssets[0] : ''; - const altInputTokenInfo = params.assetInfoMap[altInputTokenSlug]; - - const [inputTokenBalance, altInputTokenBalance] = await Promise.all([ - balanceService.getTokenFreeBalance(params.address, inputTokenInfo.originChain, inputTokenSlug), - balanceService.getTokenFreeBalance(params.address, altInputTokenInfo.originChain, altInputTokenSlug) - ]); - - const bnInputTokenBalance = new BN(inputTokenBalance.value); - const defaultFeeTokenSlug = params.poolInfo.feeAssets[0]; - - if (!bnInputTokenBalance.gte(bnAmount)) { - if (params.poolInfo.altInputAssets) { - const bnAltInputTokenBalance = new BN(altInputTokenBalance.value || '0'); - - if (bnAltInputTokenBalance.gt(BN_ZERO)) { - result.steps.push({ - id: result.steps.length, - metadata: { - sendingValue: bnAmount.toString(), + try { + const poolOriginSubstrateApi = await params.substrateApiMap[params.poolInfo.chain].isReady; + + const inputTokenSlug = params.poolInfo.inputAssets[0]; // assume that the pool only has 1 input token, will update later + const inputTokenInfo = params.assetInfoMap[inputTokenSlug]; + + const altInputTokenSlug = params.poolInfo.altInputAssets ? params.poolInfo?.altInputAssets[0] : ''; + const altInputTokenInfo = params.assetInfoMap[altInputTokenSlug]; + + const [inputTokenBalance, altInputTokenBalance] = await Promise.all([ + balanceService.getTokenFreeBalance(params.address, inputTokenInfo.originChain, inputTokenSlug), + balanceService.getTokenFreeBalance(params.address, altInputTokenInfo.originChain, altInputTokenSlug) + ]); + + const bnInputTokenBalance = new BN(inputTokenBalance.value); + const defaultFeeTokenSlug = params.poolInfo.feeAssets[0]; + + if (!bnInputTokenBalance.gte(bnAmount)) { + if (params.poolInfo.altInputAssets) { + const bnAltInputTokenBalance = new BN(altInputTokenBalance.value || '0'); + + if (bnAltInputTokenBalance.gt(BN_ZERO)) { + result.steps.push({ + id: result.steps.length, + metadata: { + sendingValue: bnAmount.toString(), + originTokenInfo: altInputTokenInfo, + destinationTokenInfo: inputTokenInfo + }, + name: 'Transfer DOT from Polkadot', + type: YieldStepType.XCM + }); + + const xcmOriginSubstrateApi = await params.substrateApiMap[altInputTokenInfo.originChain].isReady; + + const xcmTransfer = await createXcmExtrinsic({ originTokenInfo: altInputTokenInfo, - destinationTokenInfo: inputTokenInfo - }, - name: 'Transfer DOT from Polkadot', - type: YieldStepType.XCM - }); - - const xcmOriginSubstrateApi = await params.substrateApiMap[altInputTokenInfo.originChain].isReady; - - const xcmTransfer = await createXcmExtrinsic({ - originTokenInfo: altInputTokenInfo, - destinationTokenInfo: inputTokenInfo, - sendingValue: bnAmount.toString(), - recipient: fakeAddress, - chainInfoMap: params.chainInfoMap, - substrateApi: xcmOriginSubstrateApi - }); - - const _xcmFeeInfo = await xcmTransfer.paymentInfo(fakeAddress); - const xcmFeeInfo = _xcmFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; - // TODO: calculate fee for destination chain - - result.totalFee.push({ - slug: altInputTokenSlug, - amount: (xcmFeeInfo.partialFee * 1.2).toString() // TODO - }); + destinationTokenInfo: inputTokenInfo, + sendingValue: bnAmount.toString(), + recipient: fakeAddress, + chainInfoMap: params.chainInfoMap, + substrateApi: xcmOriginSubstrateApi + }); + + const _xcmFeeInfo = await xcmTransfer.paymentInfo(fakeAddress); + const xcmFeeInfo = _xcmFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; + // TODO: calculate fee for destination chain + + result.totalFee.push({ + slug: altInputTokenSlug, + amount: (xcmFeeInfo.partialFee * 1.2).toString() // TODO + }); + } } } - } - - let mintFee = '0'; - - if (params.poolInfo.slug === 'DOT___bifrost_liquid_staking') { - result.steps.push({ - id: result.steps.length, - name: 'Mint vDOT', - type: YieldStepType.MINT_VDOT - }); - const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), params.amount, null).paymentInfo(fakeAddress); - const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; + let mintFee = '0'; + + if (params.poolInfo.slug === 'DOT___bifrost_liquid_staking') { + result.steps.push({ + id: result.steps.length, + name: 'Mint vDOT', + type: YieldStepType.MINT_VDOT + }); + + const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), params.amount, null).paymentInfo(fakeAddress); + const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; + + mintFee = mintFeeInfo.partialFee.toString(); + } else if (params.poolInfo.slug === 'DOT___acala_liquid_staking') { + result.steps.push({ + id: result.steps.length, + name: 'Mint LDOT', + type: YieldStepType.MINT_LDOT + }); + + const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.homa.mint(params.amount).paymentInfo(fakeAddress); + const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; + + mintFee = mintFeeInfo.partialFee.toString(); + } else if (params.poolInfo.slug === 'DOT___interlay_lending') { + result.steps.push({ + id: result.steps.length, + name: 'Mint qDOT', + type: YieldStepType.MINT_QDOT + }); + + const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.loans.mint(_getTokenOnChainInfo(inputTokenInfo), params.amount).paymentInfo(fakeAddress); + const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; + + mintFee = mintFeeInfo.partialFee.toString(); + } else if (params.poolInfo.slug === 'DOT___parallel_liquid_staking') { + result.steps.push({ + id: result.steps.length, + name: 'Mint sDOT', + type: YieldStepType.MINT_SDOT + }); + + const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.liquidStaking.stake(params.amount).paymentInfo(fakeAddress); + const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; + + mintFee = mintFeeInfo.partialFee.toString(); + } - mintFee = mintFeeInfo.partialFee.toString(); - } else if (params.poolInfo.slug === 'DOT___acala_liquid_staking') { - result.steps.push({ - id: result.steps.length, - name: 'Mint LDOT', - type: YieldStepType.MINT_LDOT + result.totalFee.push({ + slug: defaultFeeTokenSlug, + amount: mintFee }); - const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.homa.mint(params.amount).paymentInfo(fakeAddress); - const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; + return result; + } catch (e) { + // @ts-ignore + const errorMessage = e.message as string; - mintFee = mintFeeInfo.partialFee.toString(); - } else if (params.poolInfo.slug === 'DOT___interlay_lending') { - result.steps.push({ - id: result.steps.length, - name: 'Mint qDOT', - type: YieldStepType.MINT_QDOT - }); + if (errorMessage.includes('network')) { + result.connectionError = errorMessage.split(' ')[0]; + } - const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.loans.mint(_getTokenOnChainInfo(inputTokenInfo), params.amount).paymentInfo(fakeAddress); - const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; + if (params.poolInfo.slug === 'DOT___bifrost_liquid_staking') { + result.steps.push({ + id: result.steps.length, + name: 'Mint vDOT', + type: YieldStepType.MINT_VDOT + }); + } else if (params.poolInfo.slug === 'DOT___acala_liquid_staking') { + result.steps.push({ + id: result.steps.length, + name: 'Mint LDOT', + type: YieldStepType.MINT_LDOT + }); + } else if (params.poolInfo.slug === 'DOT___interlay_lending') { + result.steps.push({ + id: result.steps.length, + name: 'Mint qDOT', + type: YieldStepType.MINT_QDOT + }); + } else if (params.poolInfo.slug === 'DOT___parallel_liquid_staking') { + result.steps.push({ + id: result.steps.length, + name: 'Mint sDOT', + type: YieldStepType.MINT_SDOT + }); + } - mintFee = mintFeeInfo.partialFee.toString(); - } else if (params.poolInfo.slug === 'DOT___parallel_liquid_staking') { - result.steps.push({ - id: result.steps.length, - name: 'Mint sDOT', - type: YieldStepType.MINT_SDOT + result.totalFee.push({ + slug: params.poolInfo.feeAssets[0], + amount: '0' }); - const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.liquidStaking.stake(params.amount).paymentInfo(fakeAddress); - const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; - - mintFee = mintFeeInfo.partialFee.toString(); + return result; } - - result.totalFee.push({ - slug: defaultFeeTokenSlug, - amount: mintFee - }); - - return result; } export async function validateEarningProcess (address: string, params: OptimalYieldPathParams, path: OptimalYieldPath, balanceService: BalanceService): Promise { From 09f1030f34796ac45cccc45a74cc1092c9627cde Mon Sep 17 00:00:00 2001 From: S2kael Date: Mon, 23 Oct 2023 17:55:29 +0700 Subject: [PATCH 6/8] [Issue-1929] Update text --- .../Popup/Transaction/variants/Yield/Earn.tsx | 19 +++++++++++++++++-- .../Earning/YieldPositionDetailModal.tsx | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/extension-koni-ui/src/Popup/Transaction/variants/Yield/Earn.tsx b/packages/extension-koni-ui/src/Popup/Transaction/variants/Yield/Earn.tsx index 194b32c170..13b0f3da79 100644 --- a/packages/extension-koni-ui/src/Popup/Transaction/variants/Yield/Earn.tsx +++ b/packages/extension-koni-ui/src/Popup/Transaction/variants/Yield/Earn.tsx @@ -79,6 +79,7 @@ const Component = () => { const [stepLoading, setStepLoading] = useState(true); const [submitLoading, setSubmitLoading] = useState(false); const [submitString, setSubmitString] = useState(); + const [connectionError, setConnectionError] = useState(); const currentStep = processState.currentStep; const nextStepType = processState.steps?.[currentStep + 1]?.type; @@ -542,13 +543,27 @@ const Component = () => { }, type: EarningActionType.STEP_CREATE }); + + const errorNetwork = res.connectionError; + + if (errorNetwork) { + const networkName = chainInfoMap[errorNetwork].name; + const text = t('Please enable {{networkName}} network', { replace: { networkName } }); + + notify({ + type: 'error', + message: text + }); + } + + setConnectionError(errorNetwork); }) .catch(console.error) .finally(() => setStepLoading(false)); }, 1000, 5000, false); } } - }, [submitString, currentPoolInfo, currentAmount, currentStep, currentFrom]); + }, [submitString, currentPoolInfo, currentAmount, currentStep, currentFrom, chainInfoMap, t, notify]); return (
@@ -711,7 +726,7 @@ const Component = () => { + >{t(yieldPoolInfo.slug === 'DOT___interlay_lending' ? t('Supply now') : t('Stake now'))}
); };