Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/webapp-yield' into webapp-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
saltict committed Oct 31, 2023
2 parents fdf9202 + fbe1d7e commit ef82766
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 8 deletions.
28 changes: 28 additions & 0 deletions packages/extension-base/src/koni/api/yield/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,33 @@ export const YIELD_POOLS_INFO: Record<string, YieldPoolInfo> = {
waitingTime: 0 // 0 means immediately
}
]
},
xcDOT___stellaswap_liquid_staking: {
slug: 'xcDOT___stellaswap_liquid_staking',
chain: 'moonbeam',
name: 'stDOT Staking',
logo: 'stellaswap',
description: 'Earn rewards by staking xcDOT for stDOT',
type: YieldPoolType.LIQUID_STAKING,
inputAssets: [
'moonbeam-LOCAL-xcDOT'
],
derivativeAssets: [
'moonbeam-LOCAL-stDOT' // TODO: add to chain-list
],
rewardAssets: [
'moonbeam-LOCAL-xcDOT'
],
feeAssets: [
'moonbeam-NATIVE-GLMR'
],
altInputAssets: [],
withdrawalMethods: [
{
name: 'Default withdrawal',
description: 'Withdraw your DOT',
waitingTime: 0 // 0 means immediately
}
]
}
};
17 changes: 11 additions & 6 deletions packages/extension-base/src/koni/api/yield/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
import { BasicTxErrorType, ChainStakingMetadata, ExtrinsicType, OptimalYieldPath, OptimalYieldPathParams, RequestBondingSubmit, RequestStakePoolingBonding, RequestYieldStepSubmit, StakingType, SubmitJoinNativeStaking, SubmitJoinNominationPool, SubmitYieldStepData, YieldAssetExpectedEarning, YieldCompoundingPeriod, YieldPoolInfo, YieldPoolType, YieldPositionInfo, YieldProcessValidation, YieldStepType, YieldValidationStatus } from '@subwallet/extension-base/background/KoniTypes';
import { validatePoolBondingCondition, validateRelayBondingCondition } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
import { createXcmExtrinsic } from '@subwallet/extension-base/koni/api/xcm';
import { getAcalaLiquidStakingExtrinsic, getAcalaLiquidStakingPosition, getAcalaLiquidStakingRedeem, subscribeAcalaLcDOTLiquidStakingStats, subscribeAcalaLiquidStakingStats } from '@subwallet/extension-base/koni/api/yield/acalaLiquidStaking';
import { getBifrostLiquidStakingExtrinsic, getBifrostLiquidStakingPosition, getBifrostLiquidStakingRedeem, subscribeBifrostLiquidStakingStats } from '@subwallet/extension-base/koni/api/yield/bifrostLiquidStaking';
import { getAcalaLiquidStakingExtrinsic, getAcalaLiquidStakingPosition, getAcalaLiquidStakingRedeem, subscribeAcalaLcDOTLiquidStakingStats, subscribeAcalaLiquidStakingStats } from '@subwallet/extension-base/koni/api/yield/acala-liquid-staking';
import { getBifrostLiquidStakingExtrinsic, getBifrostLiquidStakingPosition, getBifrostLiquidStakingRedeem, subscribeBifrostLiquidStakingStats } from '@subwallet/extension-base/koni/api/yield/bifrost-liquid-staking';
import { YIELD_POOLS_INFO } from '@subwallet/extension-base/koni/api/yield/data';
import { DEFAULT_YIELD_FIRST_STEP, fakeAddress, RuntimeDispatchInfo } from '@subwallet/extension-base/koni/api/yield/helper/utils';
import { getInterlayLendingExtrinsic, getInterlayLendingPosition, getInterlayLendingRedeem, subscribeInterlayLendingStats } from '@subwallet/extension-base/koni/api/yield/interlayLending';
import { subscribeMoonwellLendingStats } from '@subwallet/extension-base/koni/api/yield/moonwellLending';
import { generatePathForNativeStaking, getNativeStakingBondExtrinsic, getNativeStakingPosition, getNominationPoolJoinExtrinsic, getNominationPoolPosition, subscribeNativeStakingYieldStats } from '@subwallet/extension-base/koni/api/yield/nativeStaking';
import { getParallelLiquidStakingExtrinsic, getParallelLiquidStakingPosition, getParallelLiquidStakingRedeem, subscribeParallelLiquidStakingStats } from '@subwallet/extension-base/koni/api/yield/parallelLiquidStaking';
import { getInterlayLendingExtrinsic, getInterlayLendingPosition, getInterlayLendingRedeem, subscribeInterlayLendingStats } from '@subwallet/extension-base/koni/api/yield/interlay-lending';
import { subscribeMoonwellLendingStats } from '@subwallet/extension-base/koni/api/yield/moonwell-lending';
import { generatePathForNativeStaking, getNativeStakingBondExtrinsic, getNativeStakingPosition, getNominationPoolJoinExtrinsic, getNominationPoolPosition, subscribeNativeStakingYieldStats } from '@subwallet/extension-base/koni/api/yield/native-staking';
import { getParallelLiquidStakingExtrinsic, getParallelLiquidStakingPosition, getParallelLiquidStakingRedeem, subscribeParallelLiquidStakingStats } from '@subwallet/extension-base/koni/api/yield/parallel-liquid-staking';
import { subscribestDOTLiquidStakingStats } from '@subwallet/extension-base/koni/api/yield/stDOT-staking';
import { BalanceService } from '@subwallet/extension-base/services/balance-service';
import { SubstrateApi } from '@subwallet/extension-base/services/chain-service/handler/SubstrateApi';
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
Expand Down Expand Up @@ -64,6 +65,10 @@ export function subscribeYieldPoolStats (substrateApiMap: Record<string, _Substr
} else if (poolInfo.slug === 'xcDOT___moonwell_lending') {
const unsub = subscribeMoonwellLendingStats(substrateApi, chainInfoMap, poolInfo, callback);

unsubList.push(unsub);
} else if (poolInfo.slug === 'xcDOT___stellaswap_liquid_staking') {
const unsub = subscribestDOTLiquidStakingStats(substrateApi, chainInfoMap, poolInfo, callback);

unsubList.push(unsub);
}
}
Expand Down
44 changes: 44 additions & 0 deletions packages/extension-base/src/koni/api/yield/stDOT-staking.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2019-2022 @subwallet/extension-base
// SPDX-License-Identifier: Apache-2.0

import { _ChainInfo } from '@subwallet/chain-list/types';
import { YieldPoolInfo } from '@subwallet/extension-base/background/KoniTypes';
import { YIELD_POOL_STAT_REFRESH_INTERVAL } from '@subwallet/extension-base/koni/api/yield/helper/utils';
import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';

export function subscribestDOTLiquidStakingStats (chainApi: _SubstrateApi, chainInfoMap: Record<string, _ChainInfo>, poolInfo: YieldPoolInfo, callback: (rs: YieldPoolInfo) => void) {
function getPoolStat () {
// eslint-disable-next-line node/no-callback-literal
callback({
...poolInfo,
stats: {
isAvailable: false,
assetEarning: [
{
slug: poolInfo.rewardAssets[0],
apr: -1,
exchangeRate: -1
}
],
maxCandidatePerFarmer: 1,
maxWithdrawalRequestPerFarmer: 1,
minJoinPool: '50000000000',
minWithdrawal: '0',
totalApr: -1,
tvl: '0'
}
});
}

function getStatInterval () {
getPoolStat();
}

getStatInterval();

const interval = setInterval(getStatInterval, YIELD_POOL_STAT_REFRESH_INTERVAL);

return () => {
clearInterval(interval);
};
}
2 changes: 1 addition & 1 deletion packages/extension-base/src/koni/api/yield/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { ChainAssetMap, ChainInfoMap } from '@subwallet/chain-list';
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
import { OptimalYieldPath, YieldPoolInfo, YieldStepType } from '@subwallet/extension-base/background/KoniTypes';
import { BifrostLiquidStakingMeta } from '@subwallet/extension-base/koni/api/yield/bifrostLiquidStaking';
import { BifrostLiquidStakingMeta } from '@subwallet/extension-base/koni/api/yield/bifrost-liquid-staking';
import { YIELD_POOLS_INFO } from '@subwallet/extension-base/koni/api/yield/data';
import { DEFAULT_YIELD_FIRST_STEP } from '@subwallet/extension-base/koni/api/yield/helper/utils';
import fetch from 'cross-fetch';
Expand Down
1 change: 1 addition & 0 deletions packages/extension-koni-ui/src/assets/logo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const DefaultLogosMap: Record<string, string> = {
peaq: '/images/projects/peaq.jpg',
t3rn: '/images/projects/t3rn.png',
moonwell: '/images/projects/moonwell-apollo.png',
stellaswap: '/images/projects/stellaswap.png',
subwallet_gradient: '/images/projects/subwallet-gradient.png',
subwallet_mc: '/images/projects/subwallet-monochrome.svg',
polkadot_js: '/images/projects/polkadot-js.png',
Expand Down
3 changes: 2 additions & 1 deletion packages/extension-koni-ui/src/assets/subwallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const SwLogosMap: Record<string, string> = {
coinversation: DefaultLogosMap.coinversation,
peaq: DefaultLogosMap.peaq,
t3rn: DefaultLogosMap.t3rn,
moonwell: DefaultLogosMap.moonwell
moonwell: DefaultLogosMap.moonwell,
stellaswap: DefaultLogosMap.stellaswap
};

export default SwLogosMap;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ef82766

Please sign in to comment.