From 9b1987c663890ae056ba663ce72bc6e914b0cc58 Mon Sep 17 00:00:00 2001 From: PDTnhah Date: Wed, 4 Dec 2024 14:24:15 +0700 Subject: [PATCH] [Bifrost] Add referral code for Bifrost Liquid Staking (vDOT, vMANTA) --- .../src/services/earning-service/constants/chains.ts | 2 ++ .../handlers/liquid-staking/bifrost-manta.ts | 3 ++- .../earning-service/handlers/liquid-staking/bifrost.ts | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/extension-base/src/services/earning-service/constants/chains.ts b/packages/extension-base/src/services/earning-service/constants/chains.ts index 9c3d3666f7..8f5c77fee7 100644 --- a/packages/extension-base/src/services/earning-service/constants/chains.ts +++ b/packages/extension-base/src/services/earning-service/constants/chains.ts @@ -27,3 +27,5 @@ export const ST_LIQUID_TOKEN_ABI: Record = require('./abis/st_liqui export const MANTA_VALIDATOR_POINTS_PER_BLOCK = 20; export const MANTA_MIN_DELEGATION = 500; + +export const CHANNEL_ID = 7; diff --git a/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost-manta.ts b/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost-manta.ts index 8d49cb9a55..7a01ef831b 100644 --- a/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost-manta.ts +++ b/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost-manta.ts @@ -4,6 +4,7 @@ import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes'; import KoniState from '@subwallet/extension-base/koni/background/handlers/State'; import { _getAssetDecimals, _getTokenOnChainInfo } from '@subwallet/extension-base/services/chain-service/utils'; +import { CHANNEL_ID } from '@subwallet/extension-base/services/earning-service/constants'; import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, SubmitYieldJoinData, TransactionData, YieldStepType } from '@subwallet/extension-base/types'; import BifrostLiquidStakingPoolHandler from './bifrost'; @@ -143,7 +144,7 @@ export default class BifrostMantaLiquidStakingPoolHandler extends BifrostLiquidS const substrateApi = await this.substrateApi.isReady; const inputTokenSlug = this.inputAsset; const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug); - const extrinsic = substrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), data.amount, undefined, undefined); + const extrinsic = substrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), data.amount, undefined, CHANNEL_ID); return { txChain: this.chain, diff --git a/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost.ts b/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost.ts index 02387d8fdd..94ea547781 100644 --- a/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost.ts +++ b/packages/extension-base/src/services/earning-service/handlers/liquid-staking/bifrost.ts @@ -5,7 +5,7 @@ import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/K import KoniState from '@subwallet/extension-base/koni/background/handlers/State'; import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants'; import { _getAssetDecimals, _getTokenOnChainInfo } from '@subwallet/extension-base/services/chain-service/utils'; -import { fakeAddress } from '@subwallet/extension-base/services/earning-service/constants'; +import { CHANNEL_ID, fakeAddress } from '@subwallet/extension-base/services/earning-service/constants'; import { BaseYieldStepDetail, EarningStatus, HandleYieldStepData, LiquidYieldPoolInfo, LiquidYieldPositionInfo, OptimalYieldPath, OptimalYieldPathParams, RuntimeDispatchInfo, SubmitYieldJoinData, TokenBalanceRaw, TransactionData, UnstakingInfo, UnstakingStatus, YieldPoolMethodInfo, YieldPositionInfo, YieldStepType, YieldTokenBaseInfo } from '@subwallet/extension-base/types'; import { reformatAddress } from '@subwallet/extension-base/utils'; import BigNumber from 'bignumber.js'; @@ -337,7 +337,7 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo const defaultFeeTokenSlug = this.feeAssets[0]; if (new BN(params.amount).gt(BN_ZERO)) { - const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), params.amount, undefined, undefined).paymentInfo(fakeAddress); + const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), params.amount, undefined, CHANNEL_ID).paymentInfo(fakeAddress); const mintFeeInfo = _mintFeeInfo.toPrimitive() as unknown as RuntimeDispatchInfo; return { @@ -356,7 +356,7 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo const substrateApi = await this.substrateApi.isReady; const inputTokenSlug = this.inputAsset; const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug); - const extrinsic = substrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), data.amount, undefined, undefined); + const extrinsic = substrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), data.amount, undefined, CHANNEL_ID); return { txChain: this.chain,