@subwallet/extension-base 1.1.31-beta.0 → 1.1.33-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 (319) hide show
  1. package/background/KoniTypes.d.ts +71 -111
  2. package/background/KoniTypes.js +14 -19
  3. package/background/errors/TransactionError.js +0 -9
  4. package/cjs/background/KoniTypes.js +17 -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 +108 -76
  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 +36 -11
  18. package/cjs/koni/api/staking/relayChain.js +2 -3
  19. package/cjs/koni/api/xcm/xTokens.js +1 -1
  20. package/cjs/koni/background/cron.js +1 -11
  21. package/cjs/koni/background/handlers/Extension.js +69 -362
  22. package/cjs/koni/background/handlers/State.js +3 -51
  23. package/cjs/koni/background/handlers/Tabs.js +19 -2
  24. package/cjs/koni/background/handlers/index.js +2 -4
  25. package/cjs/koni/background/subscription.js +37 -95
  26. package/cjs/packageInfo.js +1 -1
  27. package/cjs/services/campaign-service/index.js +25 -9
  28. package/cjs/services/chain-service/constants.js +21 -4
  29. package/cjs/services/chain-service/index.js +2 -3
  30. package/cjs/services/chain-service/utils.js +1 -7
  31. package/cjs/services/event-service/index.js +0 -4
  32. package/cjs/services/history-service/index.js +12 -8
  33. package/cjs/services/keyring-service/index.js +2 -14
  34. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  35. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  36. package/cjs/services/migration-service/scripts/index.js +1 -7
  37. package/cjs/services/notification-service/NotificationService.js +1 -1
  38. package/cjs/services/storage-service/DatabaseService.js +3 -51
  39. package/cjs/services/storage-service/databases/index.js +0 -4
  40. package/cjs/services/storage-service/db-stores/Campaign.js +9 -3
  41. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  42. package/cjs/services/subscan-service/index.js +0 -16
  43. package/cjs/services/transaction-service/event-parser/index.js +0 -58
  44. package/cjs/services/transaction-service/helpers/index.js +1 -3
  45. package/cjs/services/transaction-service/index.js +131 -242
  46. package/cjs/services/transaction-service/utils.js +0 -1
  47. package/cjs/types/index.js +0 -44
  48. package/cjs/utils/fetchEvmChainInfo.js +20 -0
  49. package/cjs/utils/fetchStaticData.js +1 -2
  50. package/cjs/utils/index.js +17 -81
  51. package/cjs/utils/number.js +1 -3
  52. package/constants/index.d.ts +1 -6
  53. package/constants/index.js +1 -6
  54. package/koni/api/nft/config.js +23 -33
  55. package/koni/api/nft/index.js +1 -15
  56. package/koni/api/nft/nft.js +23 -2
  57. package/koni/api/staking/bonding/amplitude.d.ts +1 -1
  58. package/koni/api/staking/bonding/amplitude.js +105 -73
  59. package/koni/api/staking/bonding/astar.js +8 -9
  60. package/koni/api/staking/bonding/index.d.ts +2 -1
  61. package/koni/api/staking/bonding/index.js +3 -5
  62. package/koni/api/staking/bonding/paraChain.js +16 -15
  63. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  64. package/koni/api/staking/bonding/relayChain.js +30 -33
  65. package/koni/api/staking/bonding/utils.d.ts +42 -15
  66. package/koni/api/staking/bonding/utils.js +69 -85
  67. package/koni/api/staking/index.js +1 -2
  68. package/koni/api/staking/paraChain.js +37 -12
  69. package/koni/api/staking/relayChain.js +3 -4
  70. package/koni/api/xcm/xTokens.js +1 -1
  71. package/koni/background/cron.d.ts +0 -1
  72. package/koni/background/cron.js +2 -12
  73. package/koni/background/handlers/Extension.d.ts +1 -17
  74. package/koni/background/handlers/Extension.js +30 -321
  75. package/koni/background/handlers/State.d.ts +2 -18
  76. package/koni/background/handlers/State.js +3 -50
  77. package/koni/background/handlers/Tabs.js +20 -3
  78. package/koni/background/handlers/index.js +2 -4
  79. package/koni/background/subscription.d.ts +1 -6
  80. package/koni/background/subscription.js +38 -97
  81. package/package.json +13 -321
  82. package/packageInfo.js +1 -1
  83. package/services/campaign-service/index.js +25 -9
  84. package/services/chain-service/constants.d.ts +12 -0
  85. package/services/chain-service/constants.js +19 -3
  86. package/services/chain-service/index.js +2 -3
  87. package/services/chain-service/utils.d.ts +0 -1
  88. package/services/chain-service/utils.js +1 -5
  89. package/services/event-service/index.d.ts +0 -1
  90. package/services/event-service/index.js +0 -4
  91. package/services/event-service/types.d.ts +1 -8
  92. package/services/history-service/index.js +12 -8
  93. package/services/keyring-service/index.d.ts +1 -2
  94. package/services/keyring-service/index.js +2 -14
  95. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  96. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  97. package/services/migration-service/scripts/index.js +1 -7
  98. package/services/notification-service/NotificationService.js +1 -1
  99. package/services/storage-service/DatabaseService.d.ts +2 -18
  100. package/services/storage-service/DatabaseService.js +3 -51
  101. package/services/storage-service/databases/index.d.ts +1 -3
  102. package/services/storage-service/databases/index.js +0 -4
  103. package/services/storage-service/db-stores/Campaign.js +9 -3
  104. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  105. package/services/subscan-service/index.d.ts +2 -3
  106. package/services/subscan-service/index.js +0 -15
  107. package/services/subscan-service/types.d.ts +0 -20
  108. package/services/transaction-service/event-parser/index.d.ts +1 -3
  109. package/services/transaction-service/event-parser/index.js +1 -57
  110. package/services/transaction-service/helpers/index.js +1 -3
  111. package/services/transaction-service/index.d.ts +16 -4
  112. package/services/transaction-service/index.js +118 -230
  113. package/services/transaction-service/types.d.ts +1 -2
  114. package/services/transaction-service/utils.js +0 -1
  115. package/types/index.d.ts +0 -5
  116. package/types/index.js +1 -5
  117. package/utils/fetchEvmChainInfo.d.ts +17 -0
  118. package/utils/fetchEvmChainInfo.js +14 -0
  119. package/utils/fetchStaticData.js +1 -2
  120. package/utils/index.d.ts +2 -5
  121. package/utils/index.js +2 -52
  122. package/utils/number.d.ts +1 -1
  123. package/utils/number.js +1 -1
  124. package/cjs/koni/api/dotsama/balance.js +0 -464
  125. package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
  126. package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
  127. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  128. package/cjs/koni/api/yield/helper/utils.js +0 -46
  129. package/cjs/services/earning-service/constants/chains.js +0 -29
  130. package/cjs/services/earning-service/constants/index.js +0 -27
  131. package/cjs/services/earning-service/constants/step.js +0 -18
  132. package/cjs/services/earning-service/handlers/base.js +0 -259
  133. package/cjs/services/earning-service/handlers/index.js +0 -60
  134. package/cjs/services/earning-service/handlers/lending/base.js +0 -20
  135. package/cjs/services/earning-service/handlers/lending/index.js +0 -13
  136. package/cjs/services/earning-service/handlers/lending/interlay.js +0 -191
  137. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -239
  138. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -43
  139. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -297
  140. package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
  141. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -226
  142. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -395
  143. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -384
  144. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -461
  145. package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
  146. package/cjs/services/earning-service/handlers/native-staking/base.js +0 -159
  147. package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
  148. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -385
  149. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
  150. package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -560
  151. package/cjs/services/earning-service/handlers/special.js +0 -503
  152. package/cjs/services/earning-service/service.js +0 -387
  153. package/cjs/services/earning-service/utils/index.js +0 -128
  154. package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
  155. package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
  156. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  157. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  158. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  159. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
  160. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
  161. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
  162. package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
  163. package/cjs/services/mint-campaign-service/constants.js +0 -11
  164. package/cjs/services/mint-campaign-service/index.js +0 -18
  165. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
  166. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
  167. package/cjs/services/storage-service/index.js +0 -241
  168. package/cjs/types/campaigns/index.js +0 -16
  169. package/cjs/types/campaigns/unlock-dot.js +0 -1
  170. package/cjs/types/ordinal.js +0 -1
  171. package/cjs/types/transaction.js +0 -1
  172. package/cjs/types/yield/actions/index.js +0 -27
  173. package/cjs/types/yield/actions/join/index.js +0 -38
  174. package/cjs/types/yield/actions/join/step.js +0 -47
  175. package/cjs/types/yield/actions/join/submit.js +0 -1
  176. package/cjs/types/yield/actions/join/validate.js +0 -16
  177. package/cjs/types/yield/actions/others.js +0 -1
  178. package/cjs/types/yield/index.js +0 -27
  179. package/cjs/types/yield/info/account/index.js +0 -49
  180. package/cjs/types/yield/info/account/info.js +0 -1
  181. package/cjs/types/yield/info/account/reward.js +0 -1
  182. package/cjs/types/yield/info/account/target.js +0 -32
  183. package/cjs/types/yield/info/account/unstake.js +0 -27
  184. package/cjs/types/yield/info/base.js +0 -41
  185. package/cjs/types/yield/info/chain/index.js +0 -27
  186. package/cjs/types/yield/info/chain/info.js +0 -1
  187. package/cjs/types/yield/info/chain/target.js +0 -1
  188. package/cjs/types/yield/info/index.js +0 -49
  189. package/cjs/types/yield/info/pallet.js +0 -15
  190. package/cjs/types.js +0 -1
  191. package/cjs/utils/address.js +0 -34
  192. package/cjs/utils/keyring.js +0 -57
  193. package/cjs/utils/object.js +0 -12
  194. package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
  195. package/koni/api/nft/ordinal_nft/constants.js +0 -12
  196. package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
  197. package/koni/api/nft/ordinal_nft/index.js +0 -114
  198. package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
  199. package/koni/api/nft/ordinal_nft/utils.js +0 -33
  200. package/koni/api/yield/helper/utils.d.ts +0 -10
  201. package/koni/api/yield/helper/utils.js +0 -32
  202. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
  203. package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
  204. package/services/earning-service/constants/chains.d.ts +0 -14
  205. package/services/earning-service/constants/chains.js +0 -21
  206. package/services/earning-service/constants/index.d.ts +0 -2
  207. package/services/earning-service/constants/index.js +0 -5
  208. package/services/earning-service/constants/step.d.ts +0 -3
  209. package/services/earning-service/constants/step.js +0 -10
  210. package/services/earning-service/handlers/base.d.ts +0 -112
  211. package/services/earning-service/handlers/base.js +0 -253
  212. package/services/earning-service/handlers/index.d.ts +0 -5
  213. package/services/earning-service/handlers/index.js +0 -8
  214. package/services/earning-service/handlers/lending/base.d.ts +0 -6
  215. package/services/earning-service/handlers/lending/base.js +0 -12
  216. package/services/earning-service/handlers/lending/index.d.ts +0 -1
  217. package/services/earning-service/handlers/lending/index.js +0 -4
  218. package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
  219. package/services/earning-service/handlers/lending/interlay.js +0 -183
  220. package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
  221. package/services/earning-service/handlers/liquid-staking/acala.js +0 -231
  222. package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -9
  223. package/services/earning-service/handlers/liquid-staking/base.js +0 -35
  224. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
  225. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -286
  226. package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
  227. package/services/earning-service/handlers/liquid-staking/index.js +0 -7
  228. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
  229. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -218
  230. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
  231. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -385
  232. package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
  233. package/services/earning-service/handlers/native-staking/amplitude.js +0 -375
  234. package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
  235. package/services/earning-service/handlers/native-staking/astar.js +0 -451
  236. package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
  237. package/services/earning-service/handlers/native-staking/base-para.js +0 -138
  238. package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
  239. package/services/earning-service/handlers/native-staking/base.js +0 -150
  240. package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
  241. package/services/earning-service/handlers/native-staking/index.js +0 -7
  242. package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
  243. package/services/earning-service/handlers/native-staking/para-chain.js +0 -377
  244. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
  245. package/services/earning-service/handlers/native-staking/relay-chain.js +0 -549
  246. package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
  247. package/services/earning-service/handlers/nomination-pool/index.js +0 -550
  248. package/services/earning-service/handlers/special.d.ts +0 -65
  249. package/services/earning-service/handlers/special.js +0 -495
  250. package/services/earning-service/service.d.ts +0 -45
  251. package/services/earning-service/service.js +0 -379
  252. package/services/earning-service/utils/index.d.ts +0 -18
  253. package/services/earning-service/utils/index.js +0 -112
  254. package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
  255. package/services/migration-service/scripts/DeleteEarningData.js +0 -13
  256. package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
  257. package/services/migration-service/scripts/EnableEarningChains.js +0 -13
  258. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
  259. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
  260. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
  261. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
  262. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
  263. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
  264. package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
  265. package/services/mint-campaign-service/campaigns/index.js +0 -4
  266. package/services/mint-campaign-service/constants.d.ts +0 -1
  267. package/services/mint-campaign-service/constants.js +0 -4
  268. package/services/mint-campaign-service/index.d.ts +0 -7
  269. package/services/mint-campaign-service/index.js +0 -11
  270. package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
  271. package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
  272. package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
  273. package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
  274. package/types/campaigns/index.d.ts +0 -1
  275. package/types/campaigns/index.js +0 -4
  276. package/types/campaigns/unlock-dot.d.ts +0 -71
  277. package/types/campaigns/unlock-dot.js +0 -1
  278. package/types/ordinal.d.ts +0 -69
  279. package/types/ordinal.js +0 -1
  280. package/types/transaction.d.ts +0 -3
  281. package/types/transaction.js +0 -1
  282. package/types/yield/actions/index.d.ts +0 -2
  283. package/types/yield/actions/index.js +0 -5
  284. package/types/yield/actions/join/index.d.ts +0 -3
  285. package/types/yield/actions/join/index.js +0 -6
  286. package/types/yield/actions/join/step.d.ts +0 -95
  287. package/types/yield/actions/join/step.js +0 -46
  288. package/types/yield/actions/join/submit.d.ts +0 -57
  289. package/types/yield/actions/join/submit.js +0 -1
  290. package/types/yield/actions/join/validate.d.ts +0 -18
  291. package/types/yield/actions/join/validate.js +0 -10
  292. package/types/yield/actions/others.d.ts +0 -85
  293. package/types/yield/actions/others.js +0 -1
  294. package/types/yield/index.d.ts +0 -2
  295. package/types/yield/index.js +0 -5
  296. package/types/yield/info/account/index.d.ts +0 -4
  297. package/types/yield/info/account/index.js +0 -7
  298. package/types/yield/info/account/info.d.ts +0 -92
  299. package/types/yield/info/account/info.js +0 -1
  300. package/types/yield/info/account/reward.d.ts +0 -45
  301. package/types/yield/info/account/reward.js +0 -1
  302. package/types/yield/info/account/target.d.ts +0 -43
  303. package/types/yield/info/account/target.js +0 -27
  304. package/types/yield/info/account/unstake.d.ts +0 -31
  305. package/types/yield/info/account/unstake.js +0 -22
  306. package/types/yield/info/base.d.ts +0 -45
  307. package/types/yield/info/base.js +0 -36
  308. package/types/yield/info/chain/index.d.ts +0 -2
  309. package/types/yield/info/chain/index.js +0 -5
  310. package/types/yield/info/chain/info.d.ts +0 -251
  311. package/types/yield/info/chain/info.js +0 -1
  312. package/types/yield/info/chain/target.d.ts +0 -37
  313. package/types/yield/info/chain/target.js +0 -1
  314. package/types/yield/info/index.d.ts +0 -4
  315. package/types/yield/info/index.js +0 -7
  316. package/types/yield/info/pallet.d.ts +0 -143
  317. package/types/yield/info/pallet.js +0 -9
  318. package/utils/object.d.ts +0 -1
  319. 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
- }