@subwallet/extension-base 1.1.31-beta.0 → 1.1.32-0

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 (307) hide show
  1. package/background/KoniTypes.d.ts +69 -111
  2. package/background/KoniTypes.js +13 -19
  3. package/background/errors/TransactionError.js +0 -9
  4. package/cjs/background/KoniTypes.js +16 -20
  5. package/cjs/background/errors/TransactionError.js +0 -9
  6. package/cjs/constants/index.js +4 -19
  7. package/cjs/koni/api/nft/config.js +23 -33
  8. package/cjs/koni/api/nft/index.js +0 -14
  9. package/cjs/koni/api/nft/nft.js +22 -1
  10. package/cjs/koni/api/staking/bonding/amplitude.js +15 -17
  11. package/cjs/koni/api/staking/bonding/astar.js +10 -11
  12. package/cjs/koni/api/staking/bonding/index.js +3 -4
  13. package/cjs/koni/api/staking/bonding/paraChain.js +29 -28
  14. package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
  15. package/cjs/koni/api/staking/bonding/utils.js +86 -104
  16. package/cjs/koni/api/staking/index.js +5 -6
  17. package/cjs/koni/api/staking/paraChain.js +5 -6
  18. package/cjs/koni/api/staking/relayChain.js +2 -3
  19. package/cjs/koni/background/cron.js +1 -11
  20. package/cjs/koni/background/handlers/Extension.js +69 -362
  21. package/cjs/koni/background/handlers/State.js +3 -51
  22. package/cjs/koni/background/handlers/index.js +2 -4
  23. package/cjs/koni/background/subscription.js +37 -95
  24. package/cjs/packageInfo.js +1 -1
  25. package/cjs/services/campaign-service/index.js +6 -9
  26. package/cjs/services/chain-service/constants.js +18 -3
  27. package/cjs/services/chain-service/index.js +2 -3
  28. package/cjs/services/chain-service/utils.js +1 -7
  29. package/cjs/services/event-service/index.js +0 -4
  30. package/cjs/services/keyring-service/index.js +2 -14
  31. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  32. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  33. package/cjs/services/migration-service/scripts/index.js +1 -7
  34. package/cjs/services/notification-service/NotificationService.js +1 -1
  35. package/cjs/services/storage-service/DatabaseService.js +0 -51
  36. package/cjs/services/storage-service/databases/index.js +0 -4
  37. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  38. package/cjs/services/subscan-service/index.js +0 -16
  39. package/cjs/services/transaction-service/event-parser/index.js +0 -58
  40. package/cjs/services/transaction-service/helpers/index.js +1 -3
  41. package/cjs/services/transaction-service/index.js +75 -231
  42. package/cjs/services/transaction-service/utils.js +0 -1
  43. package/cjs/types/index.js +0 -44
  44. package/cjs/utils/fetchStaticData.js +1 -2
  45. package/cjs/utils/index.js +1 -89
  46. package/cjs/utils/number.js +1 -3
  47. package/constants/index.d.ts +1 -6
  48. package/constants/index.js +1 -6
  49. package/koni/api/nft/config.js +23 -33
  50. package/koni/api/nft/index.js +1 -15
  51. package/koni/api/nft/nft.js +23 -2
  52. package/koni/api/staking/bonding/amplitude.js +9 -11
  53. package/koni/api/staking/bonding/astar.js +8 -9
  54. package/koni/api/staking/bonding/index.d.ts +2 -1
  55. package/koni/api/staking/bonding/index.js +3 -5
  56. package/koni/api/staking/bonding/paraChain.js +16 -15
  57. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  58. package/koni/api/staking/bonding/relayChain.js +30 -33
  59. package/koni/api/staking/bonding/utils.d.ts +38 -15
  60. package/koni/api/staking/bonding/utils.js +69 -85
  61. package/koni/api/staking/index.js +1 -2
  62. package/koni/api/staking/paraChain.js +6 -7
  63. package/koni/api/staking/relayChain.js +3 -4
  64. package/koni/background/cron.d.ts +0 -1
  65. package/koni/background/cron.js +2 -12
  66. package/koni/background/handlers/Extension.d.ts +1 -17
  67. package/koni/background/handlers/Extension.js +30 -321
  68. package/koni/background/handlers/State.d.ts +2 -18
  69. package/koni/background/handlers/State.js +3 -50
  70. package/koni/background/handlers/index.js +2 -4
  71. package/koni/background/subscription.d.ts +1 -6
  72. package/koni/background/subscription.js +38 -97
  73. package/package.json +8 -321
  74. package/packageInfo.js +1 -1
  75. package/services/campaign-service/index.js +6 -9
  76. package/services/chain-service/constants.d.ts +11 -0
  77. package/services/chain-service/constants.js +16 -2
  78. package/services/chain-service/index.js +2 -3
  79. package/services/chain-service/utils.d.ts +0 -1
  80. package/services/chain-service/utils.js +1 -5
  81. package/services/event-service/index.d.ts +0 -1
  82. package/services/event-service/index.js +0 -4
  83. package/services/event-service/types.d.ts +0 -8
  84. package/services/keyring-service/index.d.ts +1 -2
  85. package/services/keyring-service/index.js +2 -14
  86. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  87. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  88. package/services/migration-service/scripts/index.js +1 -7
  89. package/services/notification-service/NotificationService.js +1 -1
  90. package/services/storage-service/DatabaseService.d.ts +1 -18
  91. package/services/storage-service/DatabaseService.js +0 -51
  92. package/services/storage-service/databases/index.d.ts +1 -3
  93. package/services/storage-service/databases/index.js +0 -4
  94. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  95. package/services/subscan-service/index.d.ts +2 -3
  96. package/services/subscan-service/index.js +0 -15
  97. package/services/subscan-service/types.d.ts +0 -20
  98. package/services/transaction-service/event-parser/index.d.ts +1 -3
  99. package/services/transaction-service/event-parser/index.js +1 -57
  100. package/services/transaction-service/helpers/index.js +1 -3
  101. package/services/transaction-service/index.d.ts +15 -4
  102. package/services/transaction-service/index.js +73 -229
  103. package/services/transaction-service/types.d.ts +0 -2
  104. package/services/transaction-service/utils.js +0 -1
  105. package/types/index.d.ts +0 -5
  106. package/types/index.js +1 -5
  107. package/utils/fetchStaticData.js +1 -2
  108. package/utils/index.d.ts +0 -5
  109. package/utils/index.js +1 -53
  110. package/utils/number.d.ts +1 -1
  111. package/utils/number.js +1 -1
  112. package/cjs/koni/api/dotsama/balance.js +0 -464
  113. package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
  114. package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
  115. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  116. package/cjs/koni/api/yield/helper/utils.js +0 -46
  117. package/cjs/services/earning-service/constants/chains.js +0 -29
  118. package/cjs/services/earning-service/constants/index.js +0 -27
  119. package/cjs/services/earning-service/constants/step.js +0 -18
  120. package/cjs/services/earning-service/handlers/base.js +0 -259
  121. package/cjs/services/earning-service/handlers/index.js +0 -60
  122. package/cjs/services/earning-service/handlers/lending/base.js +0 -20
  123. package/cjs/services/earning-service/handlers/lending/index.js +0 -13
  124. package/cjs/services/earning-service/handlers/lending/interlay.js +0 -191
  125. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -239
  126. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -43
  127. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -297
  128. package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
  129. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -226
  130. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -395
  131. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -384
  132. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -461
  133. package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
  134. package/cjs/services/earning-service/handlers/native-staking/base.js +0 -159
  135. package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
  136. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -385
  137. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
  138. package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -560
  139. package/cjs/services/earning-service/handlers/special.js +0 -503
  140. package/cjs/services/earning-service/service.js +0 -387
  141. package/cjs/services/earning-service/utils/index.js +0 -128
  142. package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
  143. package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
  144. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  145. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  146. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  147. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
  148. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
  149. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
  150. package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
  151. package/cjs/services/mint-campaign-service/constants.js +0 -11
  152. package/cjs/services/mint-campaign-service/index.js +0 -18
  153. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
  154. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
  155. package/cjs/services/storage-service/index.js +0 -241
  156. package/cjs/types/campaigns/index.js +0 -16
  157. package/cjs/types/campaigns/unlock-dot.js +0 -1
  158. package/cjs/types/ordinal.js +0 -1
  159. package/cjs/types/transaction.js +0 -1
  160. package/cjs/types/yield/actions/index.js +0 -27
  161. package/cjs/types/yield/actions/join/index.js +0 -38
  162. package/cjs/types/yield/actions/join/step.js +0 -47
  163. package/cjs/types/yield/actions/join/submit.js +0 -1
  164. package/cjs/types/yield/actions/join/validate.js +0 -16
  165. package/cjs/types/yield/actions/others.js +0 -1
  166. package/cjs/types/yield/index.js +0 -27
  167. package/cjs/types/yield/info/account/index.js +0 -49
  168. package/cjs/types/yield/info/account/info.js +0 -1
  169. package/cjs/types/yield/info/account/reward.js +0 -1
  170. package/cjs/types/yield/info/account/target.js +0 -32
  171. package/cjs/types/yield/info/account/unstake.js +0 -27
  172. package/cjs/types/yield/info/base.js +0 -41
  173. package/cjs/types/yield/info/chain/index.js +0 -27
  174. package/cjs/types/yield/info/chain/info.js +0 -1
  175. package/cjs/types/yield/info/chain/target.js +0 -1
  176. package/cjs/types/yield/info/index.js +0 -49
  177. package/cjs/types/yield/info/pallet.js +0 -15
  178. package/cjs/types.js +0 -1
  179. package/cjs/utils/address.js +0 -34
  180. package/cjs/utils/keyring.js +0 -57
  181. package/cjs/utils/object.js +0 -12
  182. package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
  183. package/koni/api/nft/ordinal_nft/constants.js +0 -12
  184. package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
  185. package/koni/api/nft/ordinal_nft/index.js +0 -114
  186. package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
  187. package/koni/api/nft/ordinal_nft/utils.js +0 -33
  188. package/koni/api/yield/helper/utils.d.ts +0 -10
  189. package/koni/api/yield/helper/utils.js +0 -32
  190. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
  191. package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
  192. package/services/earning-service/constants/chains.d.ts +0 -14
  193. package/services/earning-service/constants/chains.js +0 -21
  194. package/services/earning-service/constants/index.d.ts +0 -2
  195. package/services/earning-service/constants/index.js +0 -5
  196. package/services/earning-service/constants/step.d.ts +0 -3
  197. package/services/earning-service/constants/step.js +0 -10
  198. package/services/earning-service/handlers/base.d.ts +0 -112
  199. package/services/earning-service/handlers/base.js +0 -253
  200. package/services/earning-service/handlers/index.d.ts +0 -5
  201. package/services/earning-service/handlers/index.js +0 -8
  202. package/services/earning-service/handlers/lending/base.d.ts +0 -6
  203. package/services/earning-service/handlers/lending/base.js +0 -12
  204. package/services/earning-service/handlers/lending/index.d.ts +0 -1
  205. package/services/earning-service/handlers/lending/index.js +0 -4
  206. package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
  207. package/services/earning-service/handlers/lending/interlay.js +0 -183
  208. package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
  209. package/services/earning-service/handlers/liquid-staking/acala.js +0 -231
  210. package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -9
  211. package/services/earning-service/handlers/liquid-staking/base.js +0 -35
  212. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
  213. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -286
  214. package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
  215. package/services/earning-service/handlers/liquid-staking/index.js +0 -7
  216. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
  217. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -218
  218. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
  219. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -385
  220. package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
  221. package/services/earning-service/handlers/native-staking/amplitude.js +0 -375
  222. package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
  223. package/services/earning-service/handlers/native-staking/astar.js +0 -451
  224. package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
  225. package/services/earning-service/handlers/native-staking/base-para.js +0 -138
  226. package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
  227. package/services/earning-service/handlers/native-staking/base.js +0 -150
  228. package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
  229. package/services/earning-service/handlers/native-staking/index.js +0 -7
  230. package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
  231. package/services/earning-service/handlers/native-staking/para-chain.js +0 -377
  232. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
  233. package/services/earning-service/handlers/native-staking/relay-chain.js +0 -549
  234. package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
  235. package/services/earning-service/handlers/nomination-pool/index.js +0 -550
  236. package/services/earning-service/handlers/special.d.ts +0 -65
  237. package/services/earning-service/handlers/special.js +0 -495
  238. package/services/earning-service/service.d.ts +0 -45
  239. package/services/earning-service/service.js +0 -379
  240. package/services/earning-service/utils/index.d.ts +0 -18
  241. package/services/earning-service/utils/index.js +0 -112
  242. package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
  243. package/services/migration-service/scripts/DeleteEarningData.js +0 -13
  244. package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
  245. package/services/migration-service/scripts/EnableEarningChains.js +0 -13
  246. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
  247. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
  248. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
  249. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
  250. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
  251. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
  252. package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
  253. package/services/mint-campaign-service/campaigns/index.js +0 -4
  254. package/services/mint-campaign-service/constants.d.ts +0 -1
  255. package/services/mint-campaign-service/constants.js +0 -4
  256. package/services/mint-campaign-service/index.d.ts +0 -7
  257. package/services/mint-campaign-service/index.js +0 -11
  258. package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
  259. package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
  260. package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
  261. package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
  262. package/types/campaigns/index.d.ts +0 -1
  263. package/types/campaigns/index.js +0 -4
  264. package/types/campaigns/unlock-dot.d.ts +0 -71
  265. package/types/campaigns/unlock-dot.js +0 -1
  266. package/types/ordinal.d.ts +0 -69
  267. package/types/ordinal.js +0 -1
  268. package/types/transaction.d.ts +0 -3
  269. package/types/transaction.js +0 -1
  270. package/types/yield/actions/index.d.ts +0 -2
  271. package/types/yield/actions/index.js +0 -5
  272. package/types/yield/actions/join/index.d.ts +0 -3
  273. package/types/yield/actions/join/index.js +0 -6
  274. package/types/yield/actions/join/step.d.ts +0 -95
  275. package/types/yield/actions/join/step.js +0 -46
  276. package/types/yield/actions/join/submit.d.ts +0 -57
  277. package/types/yield/actions/join/submit.js +0 -1
  278. package/types/yield/actions/join/validate.d.ts +0 -18
  279. package/types/yield/actions/join/validate.js +0 -10
  280. package/types/yield/actions/others.d.ts +0 -85
  281. package/types/yield/actions/others.js +0 -1
  282. package/types/yield/index.d.ts +0 -2
  283. package/types/yield/index.js +0 -5
  284. package/types/yield/info/account/index.d.ts +0 -4
  285. package/types/yield/info/account/index.js +0 -7
  286. package/types/yield/info/account/info.d.ts +0 -92
  287. package/types/yield/info/account/info.js +0 -1
  288. package/types/yield/info/account/reward.d.ts +0 -45
  289. package/types/yield/info/account/reward.js +0 -1
  290. package/types/yield/info/account/target.d.ts +0 -43
  291. package/types/yield/info/account/target.js +0 -27
  292. package/types/yield/info/account/unstake.d.ts +0 -31
  293. package/types/yield/info/account/unstake.js +0 -22
  294. package/types/yield/info/base.d.ts +0 -45
  295. package/types/yield/info/base.js +0 -36
  296. package/types/yield/info/chain/index.d.ts +0 -2
  297. package/types/yield/info/chain/index.js +0 -5
  298. package/types/yield/info/chain/info.d.ts +0 -251
  299. package/types/yield/info/chain/info.js +0 -1
  300. package/types/yield/info/chain/target.d.ts +0 -37
  301. package/types/yield/info/chain/target.js +0 -1
  302. package/types/yield/info/index.d.ts +0 -4
  303. package/types/yield/info/index.js +0 -7
  304. package/types/yield/info/pallet.d.ts +0 -143
  305. package/types/yield/info/pallet.js +0 -9
  306. package/utils/object.d.ts +0 -1
  307. package/utils/object.js +0 -6
@@ -1,385 +0,0 @@
1
- // Copyright 2019-2022 @subwallet/extension-base
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
5
- import { BasicTxErrorType, ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
6
- import { getERC20Contract } from '@subwallet/extension-base/koni/api/tokens/evm/web3';
7
- import { _getAssetDecimals, _getContractAddressOfToken } from '@subwallet/extension-base/services/chain-service/utils';
8
- import { EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
9
- import { recalculateGasPrice } from '@subwallet/extension-base/utils/eth';
10
- import fetch from 'cross-fetch';
11
- import { BN, BN_TEN, BN_ZERO } from '@polkadot/util';
12
- import { ST_LIQUID_TOKEN_ABI } from "../../constants/index.js";
13
- import BaseLiquidStakingPoolHandler from "./base.js";
14
- export const getStellaswapLiquidStakingContract = (networkKey, assetAddress, evmApi, options = {}) => {
15
- // @ts-ignore
16
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
17
- return new evmApi.api.eth.Contract(ST_LIQUID_TOKEN_ABI, assetAddress, options);
18
- };
19
- const APR_STATS_URL = 'https://apr-api.stellaswap.com/api/v1/stdot';
20
- const SUBWALLET_REFERRAL = '0x7e6815f45E624768548d085231f2d453f16FD7DD';
21
- const MAX_INT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
22
- export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
23
- inputAsset = 'moonbeam-LOCAL-xcDOT';
24
- altInputAsset = '';
25
- derivativeAssets = ['moonbeam-ERC20-stDOT-0xbc7E02c4178a7dF7d3E564323a5c359dc96C4db4'];
26
- rewardAssets = ['moonbeam-LOCAL-xcDOT'];
27
- feeAssets = ['moonbeam-NATIVE-GLMR'];
28
- transactionChainType = ChainType.EVM;
29
- rateDecimals = 10; // Derivative asset decimals
30
- availableMethod = {
31
- join: true,
32
- defaultUnstake: true,
33
- fastUnstake: false,
34
- cancelUnstake: false,
35
- withdraw: true,
36
- claimReward: false
37
- };
38
- constructor(state, chain) {
39
- super(state, chain);
40
- this.slug = 'xcDOT___liquid_staking___stellaswap';
41
- this.name = 'Stellaswap Liquid Staking';
42
- this._logo = 'stellaswap';
43
- this.shortName = 'Stellaswap';
44
- }
45
- getDescription() {
46
- return 'Earn rewards by staking xcDOT for stDOT';
47
- }
48
-
49
- /* Subscribe pool info */
50
-
51
- async getPoolStat() {
52
- const evmApi = this.evmApi;
53
- const derivativeTokenSlug = this.derivativeAssets[0];
54
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
55
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
56
- const aprPromise = new Promise(function (resolve) {
57
- fetch(APR_STATS_URL, {
58
- method: 'GET'
59
- }).then(res => {
60
- resolve(res.json());
61
- }).catch(console.error);
62
- });
63
- const sampleTokenShare = 10 ** _getAssetDecimals(derivativeTokenInfo);
64
-
65
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
66
- const tvlCall = stakingContract.methods.fundRaisedBalance();
67
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
68
- const exchangeRateCall = stakingContract.methods.getPooledTokenByShares(sampleTokenShare);
69
-
70
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
71
- const [aprObject, tvl, equivalentTokenShare] = await Promise.all([aprPromise,
72
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
73
- tvlCall.call(),
74
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
75
- exchangeRateCall.call()]);
76
- const rate = equivalentTokenShare;
77
- const exchangeRate = rate / 10 ** _getAssetDecimals(derivativeTokenInfo);
78
- this.updateExchangeRate(rate);
79
- return {
80
- ...this.baseInfo,
81
- type: this.type,
82
- metadata: {
83
- ...this.metadataInfo,
84
- description: this.getDescription()
85
- },
86
- statistic: {
87
- assetEarning: [{
88
- slug: this.rewardAssets[0],
89
- apr: aprObject.result,
90
- exchangeRate: exchangeRate
91
- }],
92
- unstakingPeriod: 24 * 28,
93
- maxCandidatePerFarmer: 1,
94
- maxWithdrawalRequestPerFarmer: 1,
95
- earningThreshold: {
96
- join: '0',
97
- defaultUnstake: '0',
98
- fastUnstake: '0'
99
- },
100
- totalApr: aprObject.result,
101
- tvl: tvl.toString()
102
- }
103
- };
104
- }
105
-
106
- /* Subscribe pool info */
107
-
108
- /* Subscribe pool position */
109
-
110
- // eslint-disable-next-line @typescript-eslint/require-await
111
- async subscribePoolPosition(useAddresses, resultCallback) {
112
- var _this$derivativeAsset;
113
- let cancel = false;
114
- const evmApi = this.evmApi;
115
- const derivativeTokenSlug = ((_this$derivativeAsset = this.derivativeAssets) === null || _this$derivativeAsset === void 0 ? void 0 : _this$derivativeAsset[0]) || '';
116
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
117
- const contract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
118
- const getTokenBalance = () => {
119
- if (!cancel) {
120
- useAddresses.map(async address => {
121
- if (cancel) {
122
- return;
123
- }
124
- const rate = await this.getExchangeRate();
125
- const exchangeRate = new BN(rate);
126
- const decimals = BN_TEN.pow(new BN(this.rateDecimals));
127
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
128
- const balance = await contract.methods.balanceOf(address).call();
129
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
130
- const unbondedObject = await contract.methods.getUnbonded(address).call();
131
- const unstakings = [];
132
- let unlockBalance = BN_ZERO;
133
- if (parseInt(unbondedObject.unbonded) > 0) {
134
- unlockBalance = unlockBalance.add(new BN(unbondedObject.unbonded));
135
- unstakings.push({
136
- chain: this.chain,
137
- claimable: unbondedObject.unbonded,
138
- status: UnstakingStatus.CLAIMABLE,
139
- waitingTime: 0
140
- });
141
- }
142
- if (parseInt(unbondedObject.waiting) > 0) {
143
- unlockBalance = unlockBalance.add(new BN(unbondedObject.waiting));
144
- unstakings.push({
145
- chain: this.chain,
146
- claimable: unbondedObject.waiting,
147
- status: UnstakingStatus.UNLOCKING
148
- });
149
- }
150
- const acviteToTotal = new BN(balance).mul(exchangeRate).div(decimals);
151
- const totalBalance = acviteToTotal.add(unlockBalance);
152
- const result = {
153
- ...this.baseInfo,
154
- type: this.type,
155
- address,
156
- balanceToken: this.inputAsset,
157
- totalStake: totalBalance.toString(),
158
- activeStake: balance.toString(),
159
- unstakeBalance: unlockBalance.toString(),
160
- isBondedBefore: totalBalance.gt(BN_ZERO),
161
- derivativeToken: derivativeTokenSlug,
162
- status: EarningStatus.EARNING_REWARD,
163
- nominations: [],
164
- unstakings
165
- };
166
- resultCallback(result);
167
- });
168
- }
169
- };
170
- getTokenBalance();
171
- const interval = setInterval(getTokenBalance, 30000);
172
- return () => {
173
- cancel = true;
174
- clearInterval(interval);
175
- };
176
- }
177
-
178
- /* Subscribe pool position */
179
-
180
- /* Join pool action */
181
-
182
- get submitJoinStepInfo() {
183
- return {
184
- name: 'Mint stDOT',
185
- type: YieldStepType.MINT_STDOT
186
- };
187
- }
188
- async getTokenApproveStep(params) {
189
- const evmApi = this.evmApi;
190
- const derivativeTokenSlug = this.derivativeAssets[0];
191
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
192
- const inputTokenSlug = this.inputAsset;
193
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
194
- const inputTokenContract = getERC20Contract(this.chain, _getContractAddressOfToken(inputTokenInfo), this.state.getEvmApiMap());
195
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
196
- const allowanceCall = inputTokenContract.methods.allowance(params.address, _getContractAddressOfToken(derivativeTokenInfo));
197
- const [allowance, gasPrice] = await Promise.all([
198
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
199
- await allowanceCall.call(), evmApi.api.eth.getGasPrice()]);
200
- if (!allowance || parseInt(allowance) <= 0) {
201
- const step = {
202
- name: 'Authorize token approval',
203
- type: YieldStepType.TOKEN_APPROVAL
204
- };
205
-
206
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
207
- const estimatedGas = await allowanceCall.estimateGas();
208
- const fee = {
209
- slug: this.feeAssets[0],
210
- amount: (estimatedGas * parseInt(gasPrice)).toString()
211
- };
212
- return [step, fee];
213
- }
214
- return undefined;
215
- }
216
- async getSubmitStepFee(params) {
217
- const evmApi = this.evmApi;
218
- const derivativeTokenSlug = this.derivativeAssets[0];
219
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
220
- if (new BN(params.amount).gt(BN_ZERO)) {
221
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
222
-
223
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
224
- const depositCall = stakingContract.methods.deposit(params.amount);
225
-
226
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
227
- const estimatedDepositGas = await depositCall.estimateGas();
228
- const gasPrice = await evmApi.api.eth.getGasPrice();
229
- return {
230
- slug: this.feeAssets[0],
231
- amount: (estimatedDepositGas * parseInt(gasPrice)).toString()
232
- };
233
- } else {
234
- return {
235
- slug: this.feeAssets[0],
236
- amount: '0'
237
- };
238
- }
239
- }
240
- async validateTokenApproveStep(params, path) {
241
- return Promise.resolve([]);
242
- }
243
- async handleTokenApproveStep(data, path) {
244
- const {
245
- address
246
- } = data;
247
- const inputTokenSlug = this.inputAsset;
248
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
249
- const derivativeTokenInfo = this.state.getAssetBySlug(this.derivativeAssets[0]);
250
- const derivativeTokenContractAddress = _getContractAddressOfToken(derivativeTokenInfo);
251
- const evmApi = this.evmApi;
252
- const inputTokenContract = getERC20Contract(this.chain, _getContractAddressOfToken(inputTokenInfo), this.state.getEvmApiMap());
253
-
254
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
255
- const approveCall = inputTokenContract.methods.approve(derivativeTokenContractAddress, MAX_INT); // TODO: need test
256
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
257
- const approveEncodedCall = approveCall.encodeABI();
258
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
259
- const gasLimit = await approveCall.estimateGas({
260
- from: address
261
- });
262
- const _price = await evmApi.api.eth.getGasPrice();
263
- const gasPrice = recalculateGasPrice(_price, this.chain);
264
- const transactionObject = {
265
- from: address,
266
- to: _getContractAddressOfToken(inputTokenInfo),
267
- data: approveEncodedCall,
268
- gasPrice: gasPrice,
269
- gas: gasLimit
270
- };
271
- const _data = {
272
- inputTokenSlug: inputTokenSlug,
273
- spenderTokenSlug: this.derivativeAssets[0]
274
- };
275
- return Promise.resolve({
276
- txChain: this.chain,
277
- extrinsicType: ExtrinsicType.TOKEN_APPROVE,
278
- extrinsic: transactionObject,
279
- txData: _data,
280
- transferNativeAmount: '0'
281
- });
282
- }
283
- async handleSubmitStep(data, path) {
284
- const {
285
- address,
286
- amount
287
- } = data;
288
- const evmApi = this.evmApi;
289
- const derivativeTokenSlug = this.derivativeAssets[0];
290
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
291
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
292
-
293
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
294
- const depositCall = stakingContract.methods.deposit(amount, SUBWALLET_REFERRAL); // TODO: need test
295
-
296
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
297
- const depositEncodedCall = depositCall.encodeABI();
298
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
299
- const gasLimit = await depositCall.estimateGas({
300
- from: address
301
- });
302
- const _price = await evmApi.api.eth.getGasPrice();
303
- const gasPrice = recalculateGasPrice(_price, this.chain);
304
- const transactionObject = {
305
- from: address,
306
- to: _getContractAddressOfToken(derivativeTokenInfo),
307
- data: depositEncodedCall,
308
- gasPrice: gasPrice,
309
- gas: gasLimit
310
- };
311
- return {
312
- txChain: this.chain,
313
- extrinsicType: ExtrinsicType.MINT_STDOT,
314
- extrinsic: transactionObject,
315
- txData: data,
316
- transferNativeAmount: '0'
317
- };
318
- }
319
-
320
- /* Join pool action */
321
-
322
- /* Leave pool action */
323
-
324
- async handleYieldRedeem(amount, address, selectedTarget) {
325
- return Promise.reject(new TransactionError(BasicTxErrorType.UNSUPPORTED));
326
- }
327
- async handleYieldUnstake(amount, address, selectedTarget) {
328
- const evmApi = this.evmApi;
329
- const derivativeTokenSlug = this.derivativeAssets[0];
330
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
331
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
332
-
333
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
334
- const redeemCall = stakingContract.methods.redeem(amount);
335
-
336
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
337
- const redeemEncodedCall = redeemCall.encodeABI();
338
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
339
- const gasLimit = await redeemCall.estimateGas({
340
- from: address
341
- });
342
- const _price = await evmApi.api.eth.getGasPrice();
343
- const gasPrice = recalculateGasPrice(_price, this.chain);
344
- const transaction = {
345
- from: address,
346
- to: _getContractAddressOfToken(derivativeTokenInfo),
347
- data: redeemEncodedCall,
348
- gasPrice: gasPrice,
349
- gas: gasLimit
350
- };
351
- return [ExtrinsicType.UNSTAKE_STDOT, transaction];
352
- }
353
-
354
- /* Leave pool action */
355
-
356
- /* Other actions */
357
-
358
- async handleYieldWithdraw(address, unstakingInfo) {
359
- const evmApi = this.evmApi;
360
- const derivativeTokenSlug = this.derivativeAssets[0];
361
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
362
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
363
-
364
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
365
- const withdrawCall = stakingContract.methods.claimUnbonded();
366
-
367
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
368
- const withdrawEncodedCall = withdrawCall.encodeABI();
369
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
370
- const gasLimit = await withdrawCall.estimateGas({
371
- from: address
372
- });
373
- const _price = await evmApi.api.eth.getGasPrice();
374
- const gasPrice = recalculateGasPrice(_price, this.chain);
375
- return {
376
- from: address,
377
- to: _getContractAddressOfToken(derivativeTokenInfo),
378
- data: withdrawEncodedCall,
379
- gasPrice: gasPrice,
380
- gas: gasLimit
381
- }; // TODO: check tx history parsing
382
- }
383
-
384
- /* Other actions */
385
- }
@@ -1,22 +0,0 @@
1
- import { _ChainInfo } from '@subwallet/chain-list/types';
2
- import { ExtrinsicType, UnstakingInfo } from '@subwallet/extension-base/background/KoniTypes';
3
- import { _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
4
- import { BaseYieldPositionInfo, EarningRewardItem, ParachainStakingStakeOption, StakeCancelWithdrawalParams, SubmitJoinNativeStaking, TransactionData, ValidatorInfo, YieldPoolInfo, YieldPositionInfo, YieldStepBaseInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
5
- import { SubmittableExtrinsic } from '@polkadot/api/types';
6
- import BaseParaNativeStakingPoolHandler from './base-para';
7
- export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeStakingPoolHandler {
8
- subscribePoolInfo(callback: (data: YieldPoolInfo) => void): Promise<VoidFunction>;
9
- parseNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi, delegatorState: ParachainStakingStakeOption, unstakingInfo: Record<string, number>): Promise<Omit<YieldPositionInfo, keyof BaseYieldPositionInfo>>;
10
- subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
11
- getPoolReward(useAddresses: string[], callBack: (rs: EarningRewardItem) => void): Promise<VoidFunction>;
12
- getPoolTargets(): Promise<ValidatorInfo[]>;
13
- get defaultSubmitStep(): YieldStepBaseInfo;
14
- createJoinExtrinsic(data: SubmitJoinNativeStaking, positionInfo?: YieldPositionInfo, bondDest?: string): Promise<[TransactionData, YieldTokenBaseInfo]>;
15
- handleYieldUnstake(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
16
- /**
17
- * @todo Need recheck
18
- * */
19
- handleYieldCancelUnstake(params: StakeCancelWithdrawalParams): Promise<TransactionData>;
20
- handleYieldWithdraw(address: string, unstakingInfo: UnstakingInfo): Promise<TransactionData>;
21
- handleYieldClaimReward(address: string, bondReward?: boolean): Promise<SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult>>;
22
- }