@pancakeswap/pools 4.0.9 → 4.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/constants/contracts.d.ts +9 -0
  2. package/dist/constants/contracts.d.ts.map +1 -1
  3. package/dist/constants/pools/1.d.ts.map +1 -1
  4. package/dist/constants/pools/1101.d.ts +5 -0
  5. package/dist/constants/pools/1101.d.ts.map +1 -0
  6. package/dist/constants/pools/1442.d.ts +5 -0
  7. package/dist/constants/pools/1442.d.ts.map +1 -0
  8. package/dist/constants/pools/56.d.ts.map +1 -1
  9. package/dist/constants/pools/59140.d.ts +5 -0
  10. package/dist/constants/pools/59140.d.ts.map +1 -0
  11. package/dist/constants/pools/59144.d.ts +5 -0
  12. package/dist/constants/pools/59144.d.ts.map +1 -0
  13. package/dist/constants/pools/8453.d.ts +5 -0
  14. package/dist/constants/pools/8453.d.ts.map +1 -0
  15. package/dist/constants/pools/84531.d.ts +5 -0
  16. package/dist/constants/pools/84531.d.ts.map +1 -0
  17. package/dist/constants/pools/index.d.ts +2 -2
  18. package/dist/constants/pools/index.d.ts.map +1 -1
  19. package/dist/constants/supportedChains.d.ts +1 -1
  20. package/dist/constants/supportedChains.d.ts.map +1 -1
  21. package/dist/index.js +216 -16
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +217 -17
  24. package/dist/index.mjs.map +1 -1
  25. package/package.json +8 -5
  26. package/.turbo/turbo-build.log +0 -18
  27. package/CHANGELOG.md +0 -140
  28. package/src/abis/ICake.ts +0 -59
  29. package/src/abis/ICakeFlexibleSideVaultV2.ts +0 -487
  30. package/src/abis/ICakeVaultV2.ts +0 -487
  31. package/src/abis/ISmartChef.ts +0 -326
  32. package/src/abis/ISousChef.ts +0 -122
  33. package/src/abis/ISousChefBNB.ts +0 -166
  34. package/src/abis/ISousChefV2.ts +0 -341
  35. package/src/abis/ISousChefV3.ts +0 -326
  36. package/src/constants/contracts.ts +0 -38
  37. package/src/constants/index.ts +0 -10
  38. package/src/constants/pools/1.ts +0 -80
  39. package/src/constants/pools/280.ts +0 -53
  40. package/src/constants/pools/324.ts +0 -26
  41. package/src/constants/pools/42161.ts +0 -26
  42. package/src/constants/pools/421613.ts +0 -69
  43. package/src/constants/pools/56.ts +0 -2951
  44. package/src/constants/pools/97.ts +0 -74
  45. package/src/constants/pools/index.ts +0 -56
  46. package/src/constants/supportedChains.ts +0 -13
  47. package/src/index.ts +0 -14
  48. package/src/queries/fetchPools.ts +0 -350
  49. package/src/queries/fetchUserIfo.ts +0 -53
  50. package/src/queries/fetchUserPoolsData.ts +0 -143
  51. package/src/queries/fetchVaultPublic.ts +0 -175
  52. package/src/queries/fetchVaultUser.ts +0 -106
  53. package/src/queries/getAddresses.ts +0 -12
  54. package/src/queries/index.ts +0 -6
  55. package/src/types.ts +0 -207
  56. package/src/utils/apr.ts +0 -35
  57. package/src/utils/getContractAddress.ts +0 -11
  58. package/src/utils/getPoolContractBySousId.ts +0 -111
  59. package/src/utils/index.ts +0 -5
  60. package/src/utils/isLegacyPool.ts +0 -15
  61. package/src/utils/isPoolsSupported.ts +0 -5
  62. package/tsconfig.json +0 -14
  63. package/tsup.config.ts +0 -26
  64. package/vitest.config.ts +0 -9
@@ -1,143 +0,0 @@
1
- import { ChainId } from '@pancakeswap/sdk'
2
- import BigNumber from 'bignumber.js'
3
- import uniq from 'lodash/uniq'
4
- import fromPairs from 'lodash/fromPairs'
5
- import { erc20ABI } from 'wagmi'
6
- import { Address } from 'viem'
7
- import { getPoolsConfig } from '../constants'
8
- import { sousChefABI } from '../abis/ISousChef'
9
- import { OnChainProvider, SerializedPool } from '../types'
10
-
11
- // Pool 0, Cake / Cake is a different kind of contract (master chef)
12
- // BNB pools use the native BNB token (wrapping ? unwrapping is done at the contract level)
13
- const getPoolsFactory = (filter: (pool: SerializedPool) => boolean) => (chainId: ChainId) => {
14
- const poolsConfig = getPoolsConfig(chainId)
15
- if (!poolsConfig) {
16
- throw new Error(`Unable to get pools config on chain ${chainId}`)
17
- }
18
- return poolsConfig.filter(filter)
19
- }
20
- const getNonBnbPools = getPoolsFactory((pool) => pool.stakingToken.symbol !== 'BNB')
21
- const getBnbPools = getPoolsFactory((pool) => pool.stakingToken.symbol === 'BNB')
22
- const getNonMasterPools = getPoolsFactory((pool) => pool.sousId !== 0)
23
-
24
- interface FetchUserDataParams {
25
- account: string
26
- chainId: ChainId
27
- provider: OnChainProvider
28
- }
29
-
30
- export const fetchPoolsAllowance = async ({ account, chainId, provider }: FetchUserDataParams) => {
31
- const nonBnbPools = getNonBnbPools(chainId)
32
-
33
- const client = provider({ chainId })
34
- const allowances = await client.multicall({
35
- contracts: nonBnbPools.map(
36
- ({ contractAddress, stakingToken }) =>
37
- ({
38
- address: stakingToken.address,
39
- abi: erc20ABI,
40
- functionName: 'allowance',
41
- args: [account as Address, contractAddress] as const,
42
- } as const),
43
- ),
44
- allowFailure: false,
45
- })
46
- return fromPairs(
47
- nonBnbPools.map((pool, index) => [pool.sousId, new BigNumber(allowances[index].toString()).toJSON()]),
48
- )
49
- }
50
-
51
- export const fetchUserBalances = async ({ account, chainId, provider }: FetchUserDataParams) => {
52
- const nonBnbPools = getNonBnbPools(chainId)
53
- const bnbPools = getBnbPools(chainId)
54
- // Non BNB pools
55
- const tokens = uniq(nonBnbPools.map((pool) => pool.stakingToken.address))
56
- const client = provider({ chainId })
57
- const tokenBalance = await client.multicall({
58
- contracts: [
59
- {
60
- abi: [
61
- {
62
- inputs: [{ internalType: 'address', name: 'addr', type: 'address' }],
63
- name: 'getEthBalance',
64
- outputs: [{ internalType: 'uint256', name: 'balance', type: 'uint256' }],
65
- stateMutability: 'view',
66
- type: 'function',
67
- },
68
- ] as const,
69
- address: '0xcA11bde05977b3631167028862bE2a173976CA11', // TODO: Here is multicall address, should extract addresses to a package for multi chain
70
- functionName: 'getEthBalance',
71
- args: [account as Address] as const,
72
- } as const,
73
- ...tokens.map(
74
- (token) =>
75
- ({
76
- abi: erc20ABI,
77
- address: token,
78
- functionName: 'balanceOf',
79
- args: [account] as const,
80
- } as const),
81
- ),
82
- ],
83
- })
84
- const [bnbBalance, ...tokenBalancesResults] = tokenBalance
85
-
86
- const tokenBalances = fromPairs(tokens.map((token, index) => [token, tokenBalancesResults[index].result as bigint]))
87
-
88
- const poolTokenBalances = fromPairs(
89
- nonBnbPools
90
- .map<[number, string] | null>((pool) => {
91
- if (!tokenBalances[pool.stakingToken.address]) return null
92
- return [pool.sousId, new BigNumber(tokenBalances[pool.stakingToken.address].toString()).toJSON()]
93
- })
94
- .filter((p): p is [number, string] => Boolean(p)),
95
- )
96
-
97
- // BNB pools
98
- const bnbBalanceJson = new BigNumber((bnbBalance.result as bigint)?.toString()).toJSON()
99
- const bnbBalances = fromPairs(bnbPools.map((pool) => [pool.sousId, bnbBalanceJson]))
100
-
101
- return { ...poolTokenBalances, ...bnbBalances }
102
- }
103
-
104
- export const fetchUserStakeBalances = async ({ account, chainId, provider }: FetchUserDataParams) => {
105
- const nonMasterPools = getNonMasterPools(chainId)
106
-
107
- const client = provider({ chainId })
108
- const userInfo = await client.multicall({
109
- contracts: nonMasterPools.map(
110
- ({ contractAddress }) =>
111
- ({
112
- abi: sousChefABI.filter((r) => r.name === 'userInfo'),
113
- address: contractAddress,
114
- functionName: 'userInfo',
115
- args: [account as Address] as const,
116
- } as const),
117
- ),
118
- allowFailure: false,
119
- })
120
-
121
- return fromPairs(
122
- nonMasterPools.map((pool, index) => [pool.sousId, new BigNumber(userInfo[index][0].toString()).toJSON()]),
123
- )
124
- }
125
-
126
- export const fetchUserPendingRewards = async ({ account, chainId, provider }: FetchUserDataParams) => {
127
- const nonMasterPools = getNonMasterPools(chainId)
128
-
129
- const client = provider({ chainId })
130
- const res = await client.multicall({
131
- contracts: nonMasterPools.map(
132
- ({ contractAddress }) =>
133
- ({
134
- abi: sousChefABI.filter((r) => r.name === 'pendingReward'),
135
- address: contractAddress,
136
- functionName: 'pendingReward',
137
- args: [account as Address] as const,
138
- } as const),
139
- ),
140
- allowFailure: false,
141
- })
142
- return fromPairs(nonMasterPools.map((pool, index) => [pool.sousId, new BigNumber(res[index].toString()).toJSON()]))
143
- }
@@ -1,175 +0,0 @@
1
- import BigNumber from 'bignumber.js'
2
- import { BIG_ZERO } from '@pancakeswap/utils/bigNumber'
3
- import { ChainId } from '@pancakeswap/sdk'
4
- import { CAKE } from '@pancakeswap/tokens'
5
- import { Address } from 'viem'
6
-
7
- import { cakeVaultV2ABI } from '../abis/ICakeVaultV2'
8
- import { OnChainProvider } from '../types'
9
- import { getCakeFlexibleSideVaultAddress, getCakeVaultAddress } from './getAddresses'
10
-
11
- interface Params {
12
- cakeVaultAddress?: Address
13
- chainId: ChainId
14
- provider: OnChainProvider
15
- }
16
-
17
- const balanceOfAbi = [
18
- {
19
- inputs: [{ internalType: 'address', name: 'account', type: 'address' }],
20
- name: 'balanceOf',
21
- outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
22
- stateMutability: 'view',
23
- type: 'function',
24
- },
25
- ] as const
26
-
27
- export const fetchPublicVaultData = async ({
28
- chainId,
29
- cakeVaultAddress = getCakeVaultAddress(chainId),
30
- provider,
31
- }: Params) => {
32
- try {
33
- const client = provider({ chainId })
34
-
35
- const [sharePrice, shares, totalLockedAmount, totalCakeInVault] = await client.multicall({
36
- contracts: [
37
- {
38
- abi: cakeVaultV2ABI,
39
- address: cakeVaultAddress,
40
- functionName: 'getPricePerFullShare',
41
- },
42
- {
43
- abi: cakeVaultV2ABI,
44
- address: cakeVaultAddress,
45
- functionName: 'totalShares',
46
- },
47
- {
48
- abi: cakeVaultV2ABI,
49
- address: cakeVaultAddress,
50
- functionName: 'totalLockedAmount',
51
- },
52
- {
53
- abi: balanceOfAbi,
54
- address: CAKE[ChainId.BSC].address,
55
- functionName: 'balanceOf',
56
- args: [cakeVaultAddress],
57
- },
58
- ],
59
- allowFailure: true,
60
- })
61
-
62
- const totalSharesAsBigNumber =
63
- shares.status === 'success' && shares.result ? new BigNumber(shares.result.toString()) : BIG_ZERO
64
- const totalLockedAmountAsBigNumber =
65
- totalLockedAmount.status === 'success' && totalLockedAmount.result
66
- ? new BigNumber(totalLockedAmount.result.toString())
67
- : BIG_ZERO
68
- const sharePriceAsBigNumber =
69
- sharePrice.status === 'success' && sharePrice.result ? new BigNumber(sharePrice.result.toString()) : BIG_ZERO
70
-
71
- return {
72
- totalShares: totalSharesAsBigNumber.toJSON(),
73
- totalLockedAmount: totalLockedAmountAsBigNumber.toJSON(),
74
- pricePerFullShare: sharePriceAsBigNumber.toJSON(),
75
- totalCakeInVault: totalCakeInVault.result ? new BigNumber(totalCakeInVault.result.toString()).toJSON() : '0',
76
- }
77
- } catch (error) {
78
- return {
79
- totalShares: null,
80
- totalLockedAmount: null,
81
- pricePerFullShare: null,
82
- totalCakeInVault: null,
83
- }
84
- }
85
- }
86
-
87
- export const fetchPublicFlexibleSideVaultData = async ({
88
- chainId,
89
- cakeVaultAddress = getCakeFlexibleSideVaultAddress(chainId),
90
- provider,
91
- }: Params) => {
92
- try {
93
- const client = provider({ chainId })
94
-
95
- const [sharePrice, shares, totalCakeInVault] = await client.multicall({
96
- contracts: [
97
- {
98
- abi: cakeVaultV2ABI,
99
- address: cakeVaultAddress,
100
- functionName: 'getPricePerFullShare',
101
- },
102
- {
103
- abi: cakeVaultV2ABI,
104
- address: cakeVaultAddress,
105
- functionName: 'totalShares',
106
- },
107
- {
108
- abi: balanceOfAbi,
109
- address: CAKE[ChainId.BSC].address,
110
- functionName: 'balanceOf',
111
- args: [cakeVaultAddress],
112
- },
113
- ],
114
- allowFailure: true,
115
- })
116
-
117
- const totalSharesAsBigNumber = shares.status === 'success' ? new BigNumber(shares.result.toString()) : BIG_ZERO
118
- const sharePriceAsBigNumber =
119
- sharePrice.status === 'success' ? new BigNumber(sharePrice.result.toString()) : BIG_ZERO
120
- return {
121
- totalShares: totalSharesAsBigNumber.toJSON(),
122
- pricePerFullShare: sharePriceAsBigNumber.toJSON(),
123
- totalCakeInVault: new BigNumber((totalCakeInVault.result || '0').toString()).toJSON(),
124
- }
125
- } catch (error) {
126
- return {
127
- totalShares: null,
128
- pricePerFullShare: null,
129
- totalCakeInVault: null,
130
- }
131
- }
132
- }
133
-
134
- export const fetchVaultFees = async ({
135
- chainId,
136
- cakeVaultAddress = getCakeVaultAddress(chainId),
137
- provider,
138
- }: Params) => {
139
- try {
140
- const client = provider({ chainId })
141
-
142
- const [performanceFee, withdrawalFee, withdrawalFeePeriod] = await client.multicall({
143
- contracts: [
144
- {
145
- abi: cakeVaultV2ABI,
146
- address: cakeVaultAddress,
147
- functionName: 'performanceFee',
148
- },
149
- {
150
- abi: cakeVaultV2ABI,
151
- address: cakeVaultAddress,
152
- functionName: 'withdrawFee',
153
- },
154
- {
155
- abi: cakeVaultV2ABI,
156
- address: cakeVaultAddress,
157
- functionName: 'withdrawFeePeriod',
158
- },
159
- ],
160
- allowFailure: false,
161
- })
162
-
163
- return {
164
- performanceFee: Number(performanceFee),
165
- withdrawalFee: Number(withdrawalFee),
166
- withdrawalFeePeriod: Number(withdrawalFeePeriod),
167
- }
168
- } catch (error) {
169
- return {
170
- performanceFee: null,
171
- withdrawalFee: null,
172
- withdrawalFeePeriod: null,
173
- }
174
- }
175
- }
@@ -1,106 +0,0 @@
1
- import BigNumber from 'bignumber.js'
2
- import { ChainId } from '@pancakeswap/sdk'
3
- import { Address } from 'viem'
4
-
5
- import { OnChainProvider, SerializedLockedVaultUser, SerializedVaultUser } from '../types'
6
- import { cakeVaultV2ABI } from '../abis/ICakeVaultV2'
7
- import { getCakeFlexibleSideVaultAddress, getCakeVaultAddress } from './getAddresses'
8
- import { cakeFlexibleSideVaultV2ABI } from '../abis/ICakeFlexibleSideVaultV2'
9
-
10
- interface Params {
11
- account: Address
12
- chainId: ChainId
13
- provider: OnChainProvider
14
- }
15
-
16
- export const fetchVaultUser = async ({ account, chainId, provider }: Params): Promise<SerializedLockedVaultUser> => {
17
- try {
18
- const cakeVaultAddress = getCakeVaultAddress(chainId)
19
-
20
- const client = provider({ chainId })
21
-
22
- const [userContractResponse, currentPerformanceFee, currentOverdueFee] = await client.multicall({
23
- contracts: [
24
- {
25
- abi: cakeVaultV2ABI,
26
- address: cakeVaultAddress,
27
- functionName: 'userInfo',
28
- args: [account],
29
- },
30
- {
31
- abi: cakeVaultV2ABI,
32
- address: cakeVaultAddress,
33
- functionName: 'calculatePerformanceFee',
34
- args: [account],
35
- },
36
- {
37
- abi: cakeVaultV2ABI,
38
- address: cakeVaultAddress,
39
- functionName: 'calculateOverdueFee',
40
- args: [account],
41
- },
42
- ],
43
- allowFailure: false,
44
- })
45
-
46
- return {
47
- isLoading: false,
48
- userShares: new BigNumber(userContractResponse[0].toString()).toJSON(),
49
- lastDepositedTime: userContractResponse[1].toString(),
50
- lastUserActionTime: userContractResponse[3].toString(),
51
- cakeAtLastUserAction: new BigNumber(userContractResponse[2].toString()).toJSON(),
52
- userBoostedShare: new BigNumber(userContractResponse[6].toString()).toJSON(),
53
- locked: userContractResponse[7],
54
- lockEndTime: userContractResponse[5].toString(),
55
- lockStartTime: userContractResponse[4].toString(),
56
- lockedAmount: new BigNumber(userContractResponse[8].toString()).toJSON(),
57
- currentPerformanceFee: new BigNumber(currentPerformanceFee.toString()).toJSON(),
58
- currentOverdueFee: new BigNumber(currentOverdueFee.toString()).toJSON(),
59
- }
60
- } catch (error) {
61
- return {
62
- isLoading: true,
63
- userShares: '',
64
- lastDepositedTime: '',
65
- lastUserActionTime: '',
66
- cakeAtLastUserAction: '',
67
- userBoostedShare: '',
68
- lockEndTime: '',
69
- lockStartTime: '',
70
- locked: false,
71
- lockedAmount: '',
72
- currentPerformanceFee: '',
73
- currentOverdueFee: '',
74
- }
75
- }
76
- }
77
-
78
- export const fetchFlexibleSideVaultUser = async ({
79
- account,
80
- chainId,
81
- provider,
82
- }: Params): Promise<SerializedVaultUser> => {
83
- try {
84
- const userContractResponse = await await provider({ chainId }).readContract({
85
- abi: cakeFlexibleSideVaultV2ABI,
86
- address: getCakeFlexibleSideVaultAddress(chainId),
87
- functionName: 'userInfo',
88
- args: [account],
89
- })
90
- return {
91
- isLoading: false,
92
- userShares: new BigNumber(userContractResponse[0].toString()).toJSON(),
93
- lastDepositedTime: userContractResponse[1].toString(),
94
- lastUserActionTime: userContractResponse[3].toString(),
95
- cakeAtLastUserAction: new BigNumber(userContractResponse[2].toString()).toJSON(),
96
- }
97
- } catch (error) {
98
- return {
99
- isLoading: true,
100
- userShares: '',
101
- lastDepositedTime: '',
102
- lastUserActionTime: '',
103
- cakeAtLastUserAction: '',
104
- }
105
- }
106
- }
@@ -1,12 +0,0 @@
1
- import { ChainId } from '@pancakeswap/sdk'
2
-
3
- import { CAKE_FLEXIBLE_SIDE_VAULT, CAKE_VAULT } from '../constants/contracts'
4
- import { getContractAddress } from '../utils'
5
-
6
- export function getCakeFlexibleSideVaultAddress(chainId: ChainId) {
7
- return getContractAddress(CAKE_FLEXIBLE_SIDE_VAULT, chainId)
8
- }
9
-
10
- export function getCakeVaultAddress(chainId: ChainId) {
11
- return getContractAddress(CAKE_VAULT, chainId)
12
- }
@@ -1,6 +0,0 @@
1
- export * from './fetchPools'
2
- export * from './fetchUserPoolsData'
3
- export * from './fetchUserIfo'
4
- export * from './fetchVaultPublic'
5
- export * from './getAddresses'
6
- export * from './fetchVaultUser'
package/src/types.ts DELETED
@@ -1,207 +0,0 @@
1
- import { ChainId } from '@pancakeswap/sdk'
2
- import { PublicClient, Address } from 'viem'
3
- import type { SerializedWrappedToken } from '@pancakeswap/token-lists'
4
- import BigNumber from 'bignumber.js'
5
-
6
- export type OnChainProvider = ({ chainId }: { chainId?: ChainId }) => PublicClient
7
-
8
- export type SerializedBigNumber = string
9
-
10
- export interface Addresses {
11
- [chainId: number]: string
12
- }
13
-
14
- export enum PoolCategory {
15
- 'COMMUNITY' = 'Community',
16
- 'CORE' = 'Core',
17
- 'BINANCE' = 'Binance', // Pools using native BNB behave differently than pools using a token
18
- 'AUTO' = 'Auto',
19
- }
20
-
21
- // @deprecated
22
- export interface LegacyPoolConfigBaseProps {
23
- sousId: number
24
- contractAddress: Address
25
- poolCategory: PoolCategory
26
- tokenPerBlock: string
27
- isFinished?: boolean
28
- enableEmergencyWithdraw?: boolean
29
- version?: number
30
- }
31
-
32
- export interface PoolConfigBaseProps {
33
- sousId: number
34
- contractAddress: Address
35
- poolCategory: PoolCategory
36
- tokenPerSecond: string
37
- isFinished?: boolean
38
- enableEmergencyWithdraw?: boolean
39
- }
40
-
41
- interface GenericToken {
42
- decimals: number
43
- symbol: string
44
- address: string
45
- }
46
-
47
- export interface LegacySerializedPoolConfig<T> extends LegacyPoolConfigBaseProps {
48
- earningToken: T & GenericToken
49
- stakingToken: T & GenericToken
50
- }
51
-
52
- export interface SerializedPoolConfig<T> extends PoolConfigBaseProps {
53
- earningToken: T & GenericToken
54
- stakingToken: T & GenericToken
55
- }
56
-
57
- export type LegacySerializedPool = LegacySerializedPoolConfig<SerializedWrappedToken>
58
-
59
- export type UpgradedSerializedPool = SerializedPoolConfig<SerializedWrappedToken>
60
-
61
- export type SerializedPool = LegacySerializedPool | UpgradedSerializedPool
62
-
63
- export type UpgradedSerializedPoolWithInfo = UpgradedSerializedPool & SerializedPoolInfo
64
-
65
- export type LegacySerializedPoolWithInfo = LegacySerializedPool & SerializedPoolInfo
66
-
67
- export type SerializedPoolWithInfo = LegacySerializedPoolWithInfo | UpgradedSerializedPoolWithInfo
68
-
69
- export interface SerializedVaultUser {
70
- isLoading: boolean
71
- userShares: SerializedBigNumber
72
- cakeAtLastUserAction: SerializedBigNumber
73
- lastDepositedTime: string
74
- lastUserActionTime: string
75
- }
76
-
77
- export interface SerializedLockedVaultUser extends SerializedVaultUser {
78
- lockStartTime: string
79
- lockEndTime: string
80
- userBoostedShare: SerializedBigNumber
81
- locked: boolean
82
- lockedAmount: SerializedBigNumber
83
- currentPerformanceFee: SerializedBigNumber
84
- currentOverdueFee: SerializedBigNumber
85
- }
86
-
87
- export interface LegacyDeserializedPoolConfig<T> extends LegacyPoolConfigBaseProps {
88
- earningToken: T & GenericToken
89
- stakingToken: T & GenericToken
90
- }
91
-
92
- export interface UpgradedDeserializedPoolConfig<T> extends PoolConfigBaseProps {
93
- earningToken: T & GenericToken
94
- stakingToken: T & GenericToken
95
- }
96
-
97
- export type DeserializedPoolConfig<T> = LegacyDeserializedPoolConfig<T> | UpgradedDeserializedPoolConfig<T>
98
-
99
- interface SerializedPoolInfo extends CorePoolProps {
100
- totalStaked?: string
101
- stakingLimit?: string
102
- stakingLimitEndTimestamp?: number
103
- profileRequirement?: {
104
- required: boolean
105
- thresholdPoints: string
106
- }
107
- userDataLoaded?: boolean
108
- userData?: {
109
- allowance: string
110
- stakingTokenBalance: string
111
- stakedBalance: string
112
- pendingReward: string
113
- }
114
- }
115
-
116
- interface PoolInfo extends CorePoolProps {
117
- totalStaked?: BigNumber
118
- stakingLimit?: BigNumber
119
- stakingLimitEndTimestamp?: number
120
- profileRequirement?: {
121
- required: boolean
122
- thresholdPoints: BigNumber
123
- }
124
- userDataLoaded?: boolean
125
- userData?: {
126
- allowance: BigNumber
127
- stakingTokenBalance: BigNumber
128
- stakedBalance: BigNumber
129
- pendingReward: BigNumber
130
- }
131
- }
132
-
133
- export type UpgradedDeserializedPool<T> = UpgradedDeserializedPoolConfig<T> & PoolInfo
134
-
135
- export type LegacyDeserializedPool<T> = LegacyDeserializedPoolConfig<T> & PoolInfo
136
-
137
- export type DeserializedPool<T> = UpgradedDeserializedPool<T> | LegacyDeserializedPool<T>
138
-
139
- export type DeserializedPoolVault<T> = DeserializedPool<T> & DeserializedCakeVault
140
- export type DeserializedPoolLockedVault<T> = DeserializedPool<T> & DeserializedLockedCakeVault
141
-
142
- export interface DeserializedLockedVaultUser extends DeserializedVaultUser {
143
- lastDepositedTime: string
144
- lastUserActionTime: string
145
- lockStartTime: string
146
- lockEndTime: string
147
- burnStartTime: string
148
- userBoostedShare: BigNumber
149
- locked: boolean
150
- lockedAmount: BigNumber
151
- currentPerformanceFee: BigNumber
152
- currentOverdueFee: BigNumber
153
- }
154
-
155
- export interface DeserializedLockedCakeVault extends Omit<DeserializedCakeVault, 'userData'> {
156
- totalLockedAmount?: BigNumber
157
- userData?: DeserializedLockedVaultUser
158
- }
159
-
160
- export interface SerializedVaultFees {
161
- performanceFee: number
162
- withdrawalFee: number
163
- withdrawalFeePeriod: number
164
- }
165
-
166
- export interface DeserializedVaultFees extends SerializedVaultFees {
167
- performanceFeeAsDecimal: number
168
- }
169
-
170
- export interface DeserializedVaultUser {
171
- isLoading: boolean
172
- userShares: BigNumber
173
- cakeAtLastUserAction: BigNumber
174
- lastDepositedTime: string
175
- lastUserActionTime: string
176
- balance: {
177
- cakeAsNumberBalance: number
178
- cakeAsBigNumber: BigNumber
179
- cakeAsDisplayBalance: string
180
- }
181
- }
182
-
183
- export interface DeserializedCakeVault {
184
- totalShares?: BigNumber
185
- totalLockedAmount?: BigNumber
186
- pricePerFullShare: BigNumber
187
- totalCakeInVault?: BigNumber
188
- fees?: DeserializedVaultFees
189
- userData?: DeserializedVaultUser
190
- }
191
-
192
- export enum VaultKey {
193
- CakeVaultV1 = 'cakeVaultV1',
194
- CakeVault = 'cakeVault',
195
- CakeFlexibleSideVault = 'cakeFlexibleSideVault',
196
- IfoPool = 'ifoPool',
197
- }
198
-
199
- interface CorePoolProps {
200
- startTimestamp?: number
201
- endTimestamp?: number
202
- apr?: number
203
- rawApr?: number
204
- stakingTokenPrice?: number
205
- earningTokenPrice?: number
206
- vaultKey?: VaultKey
207
- }
package/src/utils/apr.ts DELETED
@@ -1,35 +0,0 @@
1
- import BigNumber from 'bignumber.js'
2
-
3
- import { BLOCKS_PER_YEAR, SECONDS_IN_YEAR } from '../constants'
4
-
5
- /**
6
- * Get the APR value in %
7
- * @param stakingTokenPrice Token price in the same quote currency
8
- * @param rewardTokenPrice Token price in the same quote currency
9
- * @param totalStaked Total amount of stakingToken in the pool
10
- * @param tokenPerBlock Amount of new cake allocated to the pool for each new block
11
- * @returns Null if the APR is NaN or infinite.
12
- */
13
- export const getPoolAprByTokenPerBlock = (
14
- stakingTokenPrice: number,
15
- rewardTokenPrice: number,
16
- totalStaked: number,
17
- tokenPerBlock: number,
18
- ): number | null => {
19
- const totalRewardPricePerYear = new BigNumber(rewardTokenPrice).times(tokenPerBlock).times(BLOCKS_PER_YEAR)
20
- const totalStakingTokenInPool = new BigNumber(stakingTokenPrice).times(totalStaked)
21
- const apr = totalRewardPricePerYear.div(totalStakingTokenInPool).times(100)
22
- return apr.isNaN() || !apr.isFinite() ? null : apr.toNumber()
23
- }
24
-
25
- export const getPoolAprByTokenPerSecond = (
26
- stakingTokenPrice: number,
27
- rewardTokenPrice: number,
28
- totalStaked: number,
29
- tokenPerSecond: number,
30
- ): number | null => {
31
- const totalRewardPricePerYear = new BigNumber(rewardTokenPrice).times(tokenPerSecond).times(SECONDS_IN_YEAR)
32
- const totalStakingTokenInPool = new BigNumber(stakingTokenPrice).times(totalStaked)
33
- const apr = totalRewardPricePerYear.div(totalStakingTokenInPool).times(100)
34
- return apr.isNaN() || !apr.isFinite() ? null : apr.toNumber()
35
- }
@@ -1,11 +0,0 @@
1
- import { ChainId } from '@pancakeswap/sdk'
2
-
3
- import { ContractAddresses } from '../constants/contracts'
4
- import { isPoolsSupported } from './isPoolsSupported'
5
-
6
- export function getContractAddress(addresses: ContractAddresses, chainId: ChainId) {
7
- if (!isPoolsSupported(chainId)) {
8
- throw new Error(`Cannot get contract address. Unsupported chain ${chainId}`)
9
- }
10
- return addresses[chainId]
11
- }