Skip to content

Commit

Permalink
Merge pull request #2087 from Koniverse/koni/dev/issue-2065
Browse files Browse the repository at this point in the history
[Yield Aggregator] Review estimated receivables on withdrawal screen
  • Loading branch information
saltict authored Oct 26, 2023
2 parents 429053d + f32c5b9 commit 992e33a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 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 @@ -214,6 +214,34 @@ export const YIELD_POOLS_INFO: Record<string, YieldPoolInfo> = {
// }
// ]
// },
// stDOT___stellaswap_staking: {
// slug: 'stDOT___stellaswap_staking',
// chain: 'moonbeam',
// name: 'Stellaswap stDOT Staking',
// logo: 'stellaswap',
// description: 'Earn rewards by staking xcDOT',
// 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
// }
// ]
// },
xcDOT___moonwell_lending: {
slug: 'xcDOT___moonwell_lending',
chain: 'moonbeam',
Expand Down
12 changes: 10 additions & 2 deletions packages/extension-base/src/koni/api/yield/helper/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,23 @@ export const YIELD_EXTRINSIC_TYPES = [
ExtrinsicType.STAKING_POOL_WITHDRAW
];

export const YIELD_POOL_STAT_REFRESH_INTERVAL = 300000;
export const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;

const YIELD_POOL_MIN_AMOUNT_PERCENT: Record<string, number> = {
DOT___acala_liquid_staking: 0.98,
DOT___bifrost_liquid_staking: 0.99,
DOT___parallel_liquid_staking: 0.97,
default: 0.98
};

export function convertDerivativeToOriginToken (amount: string, poolInfo: YieldPoolInfo, derivativeTokenInfo: _ChainAsset, originTokenInfo: _ChainAsset) {
const derivativeDecimals = _getAssetDecimals(derivativeTokenInfo);
const originDecimals = _getAssetDecimals(originTokenInfo);

const exchangeRate = poolInfo.stats?.assetEarning?.[0].exchangeRate || 1;
const formattedAmount = parseInt(amount) / (10 ** derivativeDecimals); // TODO: decimals
const minAmount = formattedAmount * exchangeRate * 0.95;
const minAmountPercent = YIELD_POOL_MIN_AMOUNT_PERCENT[poolInfo.slug] || YIELD_POOL_MIN_AMOUNT_PERCENT.default;
const minAmount = formattedAmount * exchangeRate * minAmountPercent;

return Math.floor(minAmount * (10 ** originDecimals));
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export function subscribeParallelLiquidStakingStats (chainApi: _SubstrateApi, po
callback({
...poolInfo,
stats: {
isAvailable: false,
assetEarning: [
{
slug: poolInfo.rewardAssets[0],
Expand Down

0 comments on commit 992e33a

Please sign in to comment.