@subwallet/extension-base 1.1.33-beta.0 → 1.1.34-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 (312) 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 +16 -19
  11. package/cjs/koni/api/staking/bonding/astar.js +10 -11
  12. package/cjs/koni/api/staking/bonding/index.js +1 -4
  13. package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
  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 +17 -10
  18. package/cjs/koni/api/staking/relayChain.js +2 -3
  19. package/cjs/koni/background/cron.js +21 -3
  20. package/cjs/koni/background/handlers/Extension.js +69 -368
  21. package/cjs/koni/background/handlers/State.js +12 -18
  22. package/cjs/koni/background/handlers/index.js +2 -4
  23. package/cjs/koni/background/subscription.js +104 -7
  24. package/cjs/packageInfo.js +1 -1
  25. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -3
  26. package/cjs/services/campaign-service/index.js +6 -9
  27. package/cjs/services/chain-service/constants.js +19 -2
  28. package/cjs/services/chain-service/handler/SubstrateApi.js +10 -5
  29. package/cjs/services/chain-service/index.js +101 -40
  30. package/cjs/services/chain-service/utils.js +69 -7
  31. package/cjs/services/event-service/index.js +0 -5
  32. package/cjs/services/keyring-service/index.js +2 -14
  33. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  34. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  35. package/cjs/services/migration-service/scripts/index.js +1 -6
  36. package/cjs/services/notification-service/NotificationService.js +1 -1
  37. package/cjs/services/storage-service/DatabaseService.js +0 -63
  38. package/cjs/services/storage-service/databases/index.js +0 -4
  39. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  40. package/cjs/services/subscan-service/index.js +0 -16
  41. package/cjs/services/transaction-service/event-parser/index.js +0 -58
  42. package/cjs/services/transaction-service/helpers/index.js +1 -3
  43. package/cjs/services/transaction-service/index.js +75 -249
  44. package/cjs/services/transaction-service/utils.js +0 -1
  45. package/cjs/types/index.js +0 -44
  46. package/cjs/utils/fetchStaticData.js +1 -2
  47. package/cjs/utils/index.js +1 -89
  48. package/cjs/utils/number.js +2 -6
  49. package/constants/index.d.ts +1 -6
  50. package/constants/index.js +1 -6
  51. package/koni/api/nft/config.js +23 -33
  52. package/koni/api/nft/index.js +1 -15
  53. package/koni/api/nft/nft.js +23 -2
  54. package/koni/api/staking/bonding/amplitude.js +10 -13
  55. package/koni/api/staking/bonding/astar.js +8 -9
  56. package/koni/api/staking/bonding/index.d.ts +1 -1
  57. package/koni/api/staking/bonding/index.js +1 -5
  58. package/koni/api/staking/bonding/paraChain.js +10 -12
  59. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  60. package/koni/api/staking/bonding/relayChain.js +30 -33
  61. package/koni/api/staking/bonding/utils.d.ts +38 -15
  62. package/koni/api/staking/bonding/utils.js +69 -85
  63. package/koni/api/staking/index.js +1 -2
  64. package/koni/api/staking/paraChain.js +18 -11
  65. package/koni/api/staking/relayChain.js +3 -4
  66. package/koni/background/cron.d.ts +4 -0
  67. package/koni/background/cron.js +22 -4
  68. package/koni/background/handlers/Extension.d.ts +1 -17
  69. package/koni/background/handlers/Extension.js +30 -327
  70. package/koni/background/handlers/State.d.ts +1 -6
  71. package/koni/background/handlers/State.js +12 -17
  72. package/koni/background/handlers/index.js +2 -4
  73. package/koni/background/subscription.d.ts +6 -1
  74. package/koni/background/subscription.js +104 -8
  75. package/package.json +7 -320
  76. package/packageInfo.js +1 -1
  77. package/services/balance-service/helpers/subscribe/substrate/index.js +2 -4
  78. package/services/campaign-service/index.js +6 -9
  79. package/services/chain-service/constants.d.ts +13 -0
  80. package/services/chain-service/constants.js +15 -0
  81. package/services/chain-service/handler/SubstrateApi.js +10 -5
  82. package/services/chain-service/index.d.ts +9 -1
  83. package/services/chain-service/index.js +97 -37
  84. package/services/chain-service/utils.d.ts +10 -2
  85. package/services/chain-service/utils.js +67 -6
  86. package/services/event-service/index.d.ts +0 -2
  87. package/services/event-service/index.js +0 -5
  88. package/services/event-service/types.d.ts +0 -9
  89. package/services/keyring-service/index.d.ts +1 -2
  90. package/services/keyring-service/index.js +2 -14
  91. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  92. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  93. package/services/migration-service/scripts/index.js +1 -6
  94. package/services/notification-service/NotificationService.js +1 -1
  95. package/services/storage-service/DatabaseService.d.ts +1 -22
  96. package/services/storage-service/DatabaseService.js +0 -63
  97. package/services/storage-service/databases/index.d.ts +1 -3
  98. package/services/storage-service/databases/index.js +0 -4
  99. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  100. package/services/subscan-service/index.d.ts +2 -3
  101. package/services/subscan-service/index.js +0 -15
  102. package/services/subscan-service/types.d.ts +0 -20
  103. package/services/transaction-service/event-parser/index.d.ts +1 -3
  104. package/services/transaction-service/event-parser/index.js +1 -57
  105. package/services/transaction-service/helpers/index.js +1 -3
  106. package/services/transaction-service/index.d.ts +13 -6
  107. package/services/transaction-service/index.js +73 -247
  108. package/services/transaction-service/types.d.ts +0 -2
  109. package/services/transaction-service/utils.js +0 -1
  110. package/types/index.d.ts +0 -5
  111. package/types/index.js +1 -5
  112. package/utils/fetchStaticData.js +1 -2
  113. package/utils/index.d.ts +0 -5
  114. package/utils/index.js +0 -52
  115. package/utils/number.d.ts +1 -2
  116. package/utils/number.js +1 -2
  117. package/cjs/koni/api/dotsama/balance.js +0 -464
  118. package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
  119. package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
  120. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  121. package/cjs/koni/api/yield/helper/utils.js +0 -46
  122. package/cjs/services/earning-service/constants/chains.js +0 -30
  123. package/cjs/services/earning-service/constants/index.js +0 -27
  124. package/cjs/services/earning-service/constants/step.js +0 -18
  125. package/cjs/services/earning-service/handlers/base.js +0 -262
  126. package/cjs/services/earning-service/handlers/index.js +0 -60
  127. package/cjs/services/earning-service/handlers/lending/base.js +0 -81
  128. package/cjs/services/earning-service/handlers/lending/index.js +0 -13
  129. package/cjs/services/earning-service/handlers/lending/interlay.js +0 -192
  130. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -240
  131. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -97
  132. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -298
  133. package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
  134. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -227
  135. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -404
  136. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -434
  137. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -466
  138. package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
  139. package/cjs/services/earning-service/handlers/native-staking/base.js +0 -161
  140. package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
  141. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -390
  142. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -567
  143. package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -566
  144. package/cjs/services/earning-service/handlers/special.js +0 -493
  145. package/cjs/services/earning-service/service.js +0 -740
  146. package/cjs/services/earning-service/utils/index.js +0 -128
  147. package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
  148. package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
  149. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  150. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  151. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  152. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
  153. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
  154. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
  155. package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
  156. package/cjs/services/mint-campaign-service/constants.js +0 -11
  157. package/cjs/services/mint-campaign-service/index.js +0 -18
  158. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
  159. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -71
  160. package/cjs/services/storage-service/index.js +0 -241
  161. package/cjs/types/campaigns/index.js +0 -16
  162. package/cjs/types/campaigns/unlock-dot.js +0 -1
  163. package/cjs/types/ordinal.js +0 -1
  164. package/cjs/types/transaction.js +0 -1
  165. package/cjs/types/yield/actions/index.js +0 -27
  166. package/cjs/types/yield/actions/join/index.js +0 -38
  167. package/cjs/types/yield/actions/join/step.js +0 -47
  168. package/cjs/types/yield/actions/join/submit.js +0 -1
  169. package/cjs/types/yield/actions/join/validate.js +0 -16
  170. package/cjs/types/yield/actions/others.js +0 -1
  171. package/cjs/types/yield/index.js +0 -27
  172. package/cjs/types/yield/info/account/index.js +0 -49
  173. package/cjs/types/yield/info/account/info.js +0 -1
  174. package/cjs/types/yield/info/account/reward.js +0 -1
  175. package/cjs/types/yield/info/account/target.js +0 -32
  176. package/cjs/types/yield/info/account/unstake.js +0 -27
  177. package/cjs/types/yield/info/base.js +0 -41
  178. package/cjs/types/yield/info/chain/index.js +0 -27
  179. package/cjs/types/yield/info/chain/info.js +0 -1
  180. package/cjs/types/yield/info/chain/target.js +0 -1
  181. package/cjs/types/yield/info/index.js +0 -49
  182. package/cjs/types/yield/info/pallet.js +0 -15
  183. package/cjs/types.js +0 -1
  184. package/cjs/utils/address.js +0 -34
  185. package/cjs/utils/keyring.js +0 -57
  186. package/cjs/utils/object.js +0 -12
  187. package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
  188. package/koni/api/nft/ordinal_nft/constants.js +0 -12
  189. package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
  190. package/koni/api/nft/ordinal_nft/index.js +0 -114
  191. package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
  192. package/koni/api/nft/ordinal_nft/utils.js +0 -33
  193. package/koni/api/yield/helper/utils.d.ts +0 -10
  194. package/koni/api/yield/helper/utils.js +0 -32
  195. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
  196. package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
  197. package/services/earning-service/constants/chains.d.ts +0 -15
  198. package/services/earning-service/constants/chains.js +0 -22
  199. package/services/earning-service/constants/index.d.ts +0 -2
  200. package/services/earning-service/constants/index.js +0 -5
  201. package/services/earning-service/constants/step.d.ts +0 -3
  202. package/services/earning-service/constants/step.js +0 -10
  203. package/services/earning-service/handlers/base.d.ts +0 -113
  204. package/services/earning-service/handlers/base.js +0 -256
  205. package/services/earning-service/handlers/index.d.ts +0 -5
  206. package/services/earning-service/handlers/index.js +0 -8
  207. package/services/earning-service/handlers/lending/base.d.ts +0 -8
  208. package/services/earning-service/handlers/lending/base.js +0 -73
  209. package/services/earning-service/handlers/lending/index.d.ts +0 -1
  210. package/services/earning-service/handlers/lending/index.js +0 -4
  211. package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
  212. package/services/earning-service/handlers/lending/interlay.js +0 -184
  213. package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
  214. package/services/earning-service/handlers/liquid-staking/acala.js +0 -232
  215. package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -11
  216. package/services/earning-service/handlers/liquid-staking/base.js +0 -89
  217. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
  218. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -287
  219. package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
  220. package/services/earning-service/handlers/liquid-staking/index.js +0 -7
  221. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
  222. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -219
  223. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
  224. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -394
  225. package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
  226. package/services/earning-service/handlers/native-staking/amplitude.js +0 -425
  227. package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
  228. package/services/earning-service/handlers/native-staking/astar.js +0 -456
  229. package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
  230. package/services/earning-service/handlers/native-staking/base-para.js +0 -138
  231. package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
  232. package/services/earning-service/handlers/native-staking/base.js +0 -152
  233. package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
  234. package/services/earning-service/handlers/native-staking/index.js +0 -7
  235. package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
  236. package/services/earning-service/handlers/native-staking/para-chain.js +0 -382
  237. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
  238. package/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
  239. package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
  240. package/services/earning-service/handlers/nomination-pool/index.js +0 -556
  241. package/services/earning-service/handlers/special.d.ts +0 -64
  242. package/services/earning-service/handlers/special.js +0 -485
  243. package/services/earning-service/service.d.ts +0 -94
  244. package/services/earning-service/service.js +0 -729
  245. package/services/earning-service/utils/index.d.ts +0 -18
  246. package/services/earning-service/utils/index.js +0 -112
  247. package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
  248. package/services/migration-service/scripts/DeleteEarningData.js +0 -13
  249. package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
  250. package/services/migration-service/scripts/EnableEarningChains.js +0 -13
  251. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
  252. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
  253. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
  254. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
  255. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
  256. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
  257. package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
  258. package/services/mint-campaign-service/campaigns/index.js +0 -4
  259. package/services/mint-campaign-service/constants.d.ts +0 -1
  260. package/services/mint-campaign-service/constants.js +0 -4
  261. package/services/mint-campaign-service/index.d.ts +0 -7
  262. package/services/mint-campaign-service/index.js +0 -11
  263. package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
  264. package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
  265. package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -11
  266. package/services/storage-service/db-stores/YieldPositionStore.js +0 -63
  267. package/types/campaigns/index.d.ts +0 -1
  268. package/types/campaigns/index.js +0 -4
  269. package/types/campaigns/unlock-dot.d.ts +0 -71
  270. package/types/campaigns/unlock-dot.js +0 -1
  271. package/types/ordinal.d.ts +0 -69
  272. package/types/ordinal.js +0 -1
  273. package/types/transaction.d.ts +0 -3
  274. package/types/transaction.js +0 -1
  275. package/types/yield/actions/index.d.ts +0 -2
  276. package/types/yield/actions/index.js +0 -5
  277. package/types/yield/actions/join/index.d.ts +0 -3
  278. package/types/yield/actions/join/index.js +0 -6
  279. package/types/yield/actions/join/step.d.ts +0 -95
  280. package/types/yield/actions/join/step.js +0 -46
  281. package/types/yield/actions/join/submit.d.ts +0 -58
  282. package/types/yield/actions/join/submit.js +0 -1
  283. package/types/yield/actions/join/validate.d.ts +0 -18
  284. package/types/yield/actions/join/validate.js +0 -10
  285. package/types/yield/actions/others.d.ts +0 -85
  286. package/types/yield/actions/others.js +0 -1
  287. package/types/yield/index.d.ts +0 -2
  288. package/types/yield/index.js +0 -5
  289. package/types/yield/info/account/index.d.ts +0 -4
  290. package/types/yield/info/account/index.js +0 -7
  291. package/types/yield/info/account/info.d.ts +0 -92
  292. package/types/yield/info/account/info.js +0 -1
  293. package/types/yield/info/account/reward.d.ts +0 -47
  294. package/types/yield/info/account/reward.js +0 -1
  295. package/types/yield/info/account/target.d.ts +0 -43
  296. package/types/yield/info/account/target.js +0 -27
  297. package/types/yield/info/account/unstake.d.ts +0 -31
  298. package/types/yield/info/account/unstake.js +0 -22
  299. package/types/yield/info/base.d.ts +0 -45
  300. package/types/yield/info/base.js +0 -36
  301. package/types/yield/info/chain/index.d.ts +0 -2
  302. package/types/yield/info/chain/index.js +0 -5
  303. package/types/yield/info/chain/info.d.ts +0 -252
  304. package/types/yield/info/chain/info.js +0 -1
  305. package/types/yield/info/chain/target.d.ts +0 -37
  306. package/types/yield/info/chain/target.js +0 -1
  307. package/types/yield/info/index.d.ts +0 -4
  308. package/types/yield/info/index.js +0 -7
  309. package/types/yield/info/pallet.d.ts +0 -143
  310. package/types/yield/info/pallet.js +0 -9
  311. package/utils/object.d.ts +0 -1
  312. package/utils/object.js +0 -6
@@ -1,394 +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 activeBalance = new BN(balance);
151
- const acviteToTotal = activeBalance.mul(exchangeRate).div(decimals);
152
- const totalBalance = acviteToTotal.add(unlockBalance);
153
- const result = {
154
- ...this.baseInfo,
155
- type: this.type,
156
- address,
157
- balanceToken: this.inputAsset,
158
- totalStake: totalBalance.toString(),
159
- activeStake: balance.toString(),
160
- unstakeBalance: unlockBalance.toString(),
161
- isBondedBefore: totalBalance.gt(BN_ZERO),
162
- derivativeToken: derivativeTokenSlug,
163
- status: activeBalance.gt(BN_ZERO) ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING,
164
- nominations: [],
165
- unstakings
166
- };
167
- resultCallback(result);
168
- });
169
- }
170
- };
171
- getTokenBalance();
172
- const interval = setInterval(getTokenBalance, 30000);
173
- return () => {
174
- cancel = true;
175
- clearInterval(interval);
176
- };
177
- }
178
-
179
- /* Subscribe pool position */
180
-
181
- /* Join pool action */
182
-
183
- get submitJoinStepInfo() {
184
- return {
185
- name: 'Mint stDOT',
186
- type: YieldStepType.MINT_STDOT
187
- };
188
- }
189
- async getTokenApproveStep(params) {
190
- const evmApi = this.evmApi;
191
- const derivativeTokenSlug = this.derivativeAssets[0];
192
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
193
- const inputTokenSlug = this.inputAsset;
194
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
195
- const inputTokenContract = getERC20Contract(this.chain, _getContractAddressOfToken(inputTokenInfo), this.state.getEvmApiMap());
196
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
197
- const allowanceCall = inputTokenContract.methods.allowance(params.address, _getContractAddressOfToken(derivativeTokenInfo));
198
- const [allowance, gasPrice] = await Promise.all([
199
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
200
- await allowanceCall.call(), evmApi.api.eth.getGasPrice()]);
201
- if (!allowance || parseInt(allowance) <= 0) {
202
- const step = {
203
- name: 'Authorize token approval',
204
- type: YieldStepType.TOKEN_APPROVAL
205
- };
206
-
207
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
208
- const estimatedGas = await allowanceCall.estimateGas();
209
- const fee = {
210
- slug: this.feeAssets[0],
211
- amount: (estimatedGas * parseInt(gasPrice)).toString()
212
- };
213
- return [step, fee];
214
- }
215
- return undefined;
216
- }
217
- async getSubmitStepFee(params) {
218
- const evmApi = this.evmApi;
219
- const derivativeTokenSlug = this.derivativeAssets[0];
220
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
221
- if (new BN(params.amount).gt(BN_ZERO)) {
222
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
223
-
224
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
225
- const depositCall = stakingContract.methods.deposit(params.amount);
226
- let estimatedDepositGas = 0;
227
- try {
228
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
229
- estimatedDepositGas = await depositCall.estimateGas({
230
- from: params.address
231
- });
232
- } catch (e) {
233
- console.error(e);
234
- }
235
- const gasPrice = await evmApi.api.eth.getGasPrice();
236
- return {
237
- slug: this.feeAssets[0],
238
- amount: (estimatedDepositGas * parseInt(gasPrice)).toString()
239
- };
240
- } else {
241
- return {
242
- slug: this.feeAssets[0],
243
- amount: '0'
244
- };
245
- }
246
- }
247
- async validateTokenApproveStep(params, path) {
248
- return Promise.resolve([]);
249
- }
250
- async handleTokenApproveStep(data, path) {
251
- const {
252
- address
253
- } = data;
254
- const inputTokenSlug = this.inputAsset;
255
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
256
- const derivativeTokenInfo = this.state.getAssetBySlug(this.derivativeAssets[0]);
257
- const derivativeTokenContractAddress = _getContractAddressOfToken(derivativeTokenInfo);
258
- const evmApi = this.evmApi;
259
- const inputTokenContract = getERC20Contract(this.chain, _getContractAddressOfToken(inputTokenInfo), this.state.getEvmApiMap());
260
-
261
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
262
- const approveCall = inputTokenContract.methods.approve(derivativeTokenContractAddress, MAX_INT); // TODO: need test
263
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
264
- const approveEncodedCall = approveCall.encodeABI();
265
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
266
- const gasLimit = await approveCall.estimateGas({
267
- from: address
268
- });
269
- const _price = await evmApi.api.eth.getGasPrice();
270
- const gasPrice = recalculateGasPrice(_price, this.chain);
271
- const transactionObject = {
272
- from: address,
273
- to: _getContractAddressOfToken(inputTokenInfo),
274
- data: approveEncodedCall,
275
- gasPrice: gasPrice,
276
- gas: gasLimit
277
- };
278
- const _data = {
279
- inputTokenSlug: inputTokenSlug,
280
- spenderTokenSlug: this.derivativeAssets[0]
281
- };
282
- return Promise.resolve({
283
- txChain: this.chain,
284
- extrinsicType: ExtrinsicType.TOKEN_APPROVE,
285
- extrinsic: transactionObject,
286
- txData: _data,
287
- transferNativeAmount: '0',
288
- chainType: ChainType.EVM
289
- });
290
- }
291
- async handleSubmitStep(data, path) {
292
- const {
293
- address,
294
- amount
295
- } = data;
296
- const evmApi = this.evmApi;
297
- const derivativeTokenSlug = this.derivativeAssets[0];
298
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
299
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
300
-
301
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
302
- const depositCall = stakingContract.methods.deposit(amount, SUBWALLET_REFERRAL); // TODO: need test
303
-
304
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
305
- const depositEncodedCall = depositCall.encodeABI();
306
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
307
- const gasLimit = await depositCall.estimateGas({
308
- from: address
309
- });
310
- const _price = await evmApi.api.eth.getGasPrice();
311
- const gasPrice = recalculateGasPrice(_price, this.chain);
312
- const transactionObject = {
313
- from: address,
314
- to: _getContractAddressOfToken(derivativeTokenInfo),
315
- data: depositEncodedCall,
316
- gasPrice: gasPrice,
317
- gas: gasLimit
318
- };
319
- return {
320
- txChain: this.chain,
321
- extrinsicType: ExtrinsicType.MINT_STDOT,
322
- extrinsic: transactionObject,
323
- txData: data,
324
- transferNativeAmount: '0',
325
- chainType: ChainType.EVM
326
- };
327
- }
328
-
329
- /* Join pool action */
330
-
331
- /* Leave pool action */
332
-
333
- async handleYieldRedeem(amount, address, selectedTarget) {
334
- return Promise.reject(new TransactionError(BasicTxErrorType.UNSUPPORTED));
335
- }
336
- async handleYieldUnstake(amount, address, selectedTarget) {
337
- const evmApi = this.evmApi;
338
- const derivativeTokenSlug = this.derivativeAssets[0];
339
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
340
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
341
-
342
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
343
- const redeemCall = stakingContract.methods.redeem(amount);
344
-
345
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
346
- const redeemEncodedCall = redeemCall.encodeABI();
347
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
348
- const gasLimit = await redeemCall.estimateGas({
349
- from: address
350
- });
351
- const _price = await evmApi.api.eth.getGasPrice();
352
- const gasPrice = recalculateGasPrice(_price, this.chain);
353
- const transaction = {
354
- from: address,
355
- to: _getContractAddressOfToken(derivativeTokenInfo),
356
- data: redeemEncodedCall,
357
- gasPrice: gasPrice,
358
- gas: gasLimit
359
- };
360
- return [ExtrinsicType.UNSTAKE_STDOT, transaction];
361
- }
362
-
363
- /* Leave pool action */
364
-
365
- /* Other actions */
366
-
367
- async handleYieldWithdraw(address, unstakingInfo) {
368
- const evmApi = this.evmApi;
369
- const derivativeTokenSlug = this.derivativeAssets[0];
370
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
371
- const stakingContract = getStellaswapLiquidStakingContract(this.chain, _getContractAddressOfToken(derivativeTokenInfo), evmApi);
372
-
373
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
374
- const withdrawCall = stakingContract.methods.claimUnbonded();
375
-
376
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
377
- const withdrawEncodedCall = withdrawCall.encodeABI();
378
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
379
- const gasLimit = await withdrawCall.estimateGas({
380
- from: address
381
- });
382
- const _price = await evmApi.api.eth.getGasPrice();
383
- const gasPrice = recalculateGasPrice(_price, this.chain);
384
- return {
385
- from: address,
386
- to: _getContractAddressOfToken(derivativeTokenInfo),
387
- data: withdrawEncodedCall,
388
- gasPrice: gasPrice,
389
- gas: gasLimit
390
- }; // TODO: check tx history parsing
391
- }
392
-
393
- /* Other actions */
394
- }
@@ -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
- }