@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,297 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
9
- var _constants = require("@subwallet/extension-base/services/chain-service/constants");
10
- var _utils = require("@subwallet/extension-base/services/chain-service/utils");
11
- var _constants2 = require("@subwallet/extension-base/services/earning-service/constants");
12
- var _types = require("@subwallet/extension-base/types");
13
- var _utils2 = require("@subwallet/extension-base/utils");
14
- var _bignumber = _interopRequireDefault(require("bignumber.js"));
15
- var _crossFetch = _interopRequireDefault(require("cross-fetch"));
16
- var _util = require("@polkadot/util");
17
- var _base = _interopRequireDefault(require("./base"));
18
- // Copyright 2019-2022 @subwallet/extension-base
19
- // SPDX-License-Identifier: Apache-2.0
20
-
21
- const STATS_URL = 'https://api.bifrost.app/api/site';
22
- const BIFROST_GRAPHQL_ENDPOINT = 'https://bifrost-subsql.liebi.com/v1/graphql';
23
- const BIFROST_EXCHANGE_RATE_REQUEST = 'query MyQuery{slp_polkadot_ratio(limit:1 where:{key:{_eq:"0"}} order_by:{timestamp:desc_nulls_first}){ratio key timestamp total_issuance token_pool}}';
24
- class BifrostLiquidStakingPoolHandler extends _base.default {
25
- altInputAsset = 'polkadot-NATIVE-DOT';
26
- derivativeAssets = ['bifrost_dot-LOCAL-vDOT'];
27
- inputAsset = 'bifrost_dot-LOCAL-DOT';
28
- rewardAssets = ['bifrost_dot-LOCAL-DOT'];
29
- feeAssets = ['bifrost_dot-NATIVE-BNC', 'bifrost_dot-LOCAL-DOT'];
30
- minAmountPercent = 0.99;
31
- availableMethod = {
32
- join: true,
33
- defaultUnstake: true,
34
- fastUnstake: true,
35
- cancelUnstake: false,
36
- withdraw: false,
37
- claimReward: false
38
- };
39
- rateDecimals = 0;
40
- constructor(state, chain) {
41
- super(state, chain);
42
- const chainInfo = this.chainInfo;
43
- this.slug = `DOT___liquid_staking___${chain}`;
44
- this.name = `${chainInfo.name} Liquid Staking`;
45
- this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
46
- }
47
- getDescription() {
48
- return 'Stake DOT to earn yield on vDOT';
49
- }
50
-
51
- /* Subscribe pool info */
52
-
53
- async getPoolStat() {
54
- const substrateApi = await this.substrateApi.isReady;
55
- const stakingMetaPromise = new Promise(function (resolve) {
56
- (0, _crossFetch.default)(STATS_URL, {
57
- method: 'GET'
58
- }).then(res => {
59
- resolve(res.json());
60
- }).catch(console.error);
61
- });
62
- const exchangeRatePromise = new Promise(function (resolve) {
63
- (0, _crossFetch.default)(BIFROST_GRAPHQL_ENDPOINT, {
64
- method: 'POST',
65
- headers: {
66
- 'Content-Type': 'application/json'
67
- },
68
- body: JSON.stringify({
69
- query: BIFROST_EXCHANGE_RATE_REQUEST
70
- })
71
- }).then(resp => {
72
- resolve(resp.json());
73
- }).catch(console.error);
74
- });
75
- const derivativeTokenInfo = this.state.getAssetBySlug(this.derivativeAssets[0]);
76
- const inputTokenInfo = this.state.getAssetBySlug(this.inputAsset);
77
- const [_stakingMeta, _exchangeRate, _minimumRedeem, _minimumMint] = await Promise.all([stakingMetaPromise, exchangeRatePromise, substrateApi.api.query.vtokenMinting.minimumRedeem((0, _utils._getTokenOnChainInfo)(derivativeTokenInfo)), substrateApi.api.query.vtokenMinting.minimumMint((0, _utils._getTokenOnChainInfo)(inputTokenInfo))]);
78
- const minimumRedeem = _minimumRedeem.toString();
79
- const minimumMint = _minimumMint.toString();
80
- const stakingMeta = _stakingMeta;
81
- const exchangeRate = _exchangeRate;
82
- const vDOTStats = stakingMeta.vDOT;
83
- const assetInfo = this.state.getAssetBySlug(this.inputAsset);
84
- const assetDecimals = 10 ** (0, _utils._getAssetDecimals)(assetInfo);
85
- const rate = parseFloat(exchangeRate.data.slp_polkadot_ratio[0].ratio);
86
- this.updateExchangeRate(rate);
87
- return {
88
- ...this.baseInfo,
89
- type: this.type,
90
- metadata: {
91
- ...this.metadataInfo,
92
- description: this.getDescription()
93
- },
94
- statistic: {
95
- assetEarning: [{
96
- slug: this.rewardAssets[0],
97
- apy: parseFloat(vDOTStats.apyBase),
98
- exchangeRate: rate
99
- }],
100
- unstakingPeriod: 24 * 28,
101
- maxCandidatePerFarmer: 1,
102
- maxWithdrawalRequestPerFarmer: 1,
103
- earningThreshold: {
104
- join: minimumMint,
105
- defaultUnstake: minimumRedeem,
106
- fastUnstake: '0'
107
- },
108
- totalApy: parseFloat(vDOTStats.apyBase),
109
- tvl: (vDOTStats.tvm * assetDecimals).toString()
110
- }
111
- };
112
- }
113
-
114
- /* Subscribe pool info */
115
-
116
- /* Subscribe pool position */
117
-
118
- async subscribePoolPosition(useAddresses, resultCallback) {
119
- let cancel = false;
120
- const substrateApi = this.substrateApi;
121
- await substrateApi.isReady;
122
-
123
- // @ts-ignore
124
- const derivativeTokenSlug = this.derivativeAssets[0];
125
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
126
- const inputTokenSlug = this.inputAsset;
127
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
128
- const unsub = await substrateApi.api.query.tokens.accounts.multi(useAddresses.map(address => [address, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo)]), async _balance => {
129
- if (cancel) {
130
- unsub();
131
- return;
132
- }
133
- const balances = _balance;
134
- const [_unlockLedgerList, _currentRelayEra, rate] = await Promise.all([substrateApi.api.query.vtokenMinting.userUnlockLedger.multi(useAddresses.map(address => [address, (0, _utils._getTokenOnChainInfo)(inputTokenInfo)])), substrateApi.api.query.vtokenMinting.ongoingTimeUnit((0, _utils._getTokenOnChainInfo)(inputTokenInfo)), this.getExchangeRate()]);
135
- const exchangeRate = new _bignumber.default(rate);
136
- const currentRelayEraObj = _currentRelayEra.toPrimitive();
137
- const currentRelayEra = currentRelayEraObj.Era;
138
- const unlockLedgerList = [];
139
- const activeBalanceMap = {};
140
- for (let i = 0; i < balances.length; i++) {
141
- const balanceItem = balances[i];
142
- const address = useAddresses[i];
143
- const formattedAddress = (0, _utils2.reformatAddress)(address);
144
- activeBalanceMap[formattedAddress] = balanceItem.free || _util.BN_ZERO;
145
- const _unlockLedger = _unlockLedgerList[i];
146
- const unlockLedger = _unlockLedger.toPrimitive();
147
- if (unlockLedger) {
148
- // @ts-ignore
149
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
150
- const unstakingLedgerIds = unlockLedger[1];
151
- unstakingLedgerIds.forEach(ledgerId => {
152
- unlockLedgerList.push({
153
- address: formattedAddress,
154
- ledgerId
155
- });
156
- });
157
- }
158
-
159
- // const bnTotalBalance = bnActiveBalance.add(bnUnstakingBalance);
160
- }
161
-
162
- const unlockingMap = {};
163
-
164
- // TODO: review unstaking info vtokenMinting.userUnlockLedger
165
- const _unlockInfoList = await substrateApi.api.query.vtokenMinting.tokenUnlockLedger.multi(unlockLedgerList.map(_ref => {
166
- let {
167
- ledgerId
168
- } = _ref;
169
- return [(0, _utils._getTokenOnChainInfo)(inputTokenInfo), ledgerId];
170
- }));
171
- for (let i = 0; i < _unlockInfoList.length; i++) {
172
- const unlockInfo = _unlockInfoList[i].toPrimitive();
173
- const owner = (0, _utils2.reformatAddress)(unlockInfo[0]);
174
- const amount = unlockInfo[1].toString();
175
- // @ts-ignore
176
- const withdrawalEra = unlockInfo[2].era;
177
- if (owner in unlockingMap) {
178
- unlockingMap[owner].push({
179
- balance: amount,
180
- era: withdrawalEra
181
- });
182
- } else {
183
- unlockingMap[owner] = [{
184
- balance: amount,
185
- era: withdrawalEra
186
- }];
187
- }
188
- }
189
- const unstakingList = [];
190
- useAddresses.forEach(address => {
191
- const formattedAddress = (0, _utils2.reformatAddress)(address);
192
- const bnActiveBalance = activeBalanceMap[formattedAddress];
193
- const unlockings = unlockingMap[formattedAddress];
194
- let unlockBalance = _util.BN_ZERO;
195
- if (unlockings) {
196
- unlockings.forEach(unlocking => {
197
- const isClaimable = unlocking.era - currentRelayEra < 0;
198
- const remainingEra = unlocking.era - currentRelayEra;
199
- const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[this.chain];
200
- unlockBalance = unlockBalance.add(new _util.BN(unlocking.balance));
201
- unstakingList.push({
202
- chain: this.chain,
203
- status: isClaimable ? _types.UnstakingStatus.CLAIMABLE : _types.UnstakingStatus.UNLOCKING,
204
- claimable: unlocking.balance,
205
- waitingTime: waitingTime
206
- });
207
- });
208
- }
209
- const activeToTotalBalance = exchangeRate.multipliedBy(bnActiveBalance.toString());
210
- const totalBalance = activeToTotalBalance.plus(unlockBalance.toString());
211
- const result = {
212
- ...this.baseInfo,
213
- type: this.type,
214
- address,
215
- balanceToken: this.inputAsset,
216
- derivativeToken: derivativeTokenSlug,
217
- totalStake: totalBalance.toString(),
218
- activeStake: bnActiveBalance.toString(),
219
- unstakeBalance: unlockBalance.toString(),
220
- status: bnActiveBalance.eq(_util.BN_ZERO) ? _types.EarningStatus.NOT_EARNING : _types.EarningStatus.EARNING_REWARD,
221
- isBondedBefore: totalBalance.gt(_util.BN_ZERO.toString()),
222
- nominations: [],
223
- unstakings: unstakingList
224
- };
225
- resultCallback(result);
226
- });
227
- });
228
- return () => {
229
- cancel = true;
230
- unsub();
231
- };
232
- }
233
-
234
- /* Subscribe pool position */
235
-
236
- /* Join pool action */
237
-
238
- get submitJoinStepInfo() {
239
- return {
240
- name: 'Mint vDOT',
241
- type: _types.YieldStepType.MINT_VDOT
242
- };
243
- }
244
- async getSubmitStepFee(params) {
245
- const poolOriginSubstrateApi = await this.substrateApi.isReady;
246
- const inputTokenSlug = this.inputAsset;
247
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
248
- const defaultFeeTokenSlug = this.feeAssets[0];
249
- if (new _util.BN(params.amount).gt(_util.BN_ZERO)) {
250
- const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.vtokenMinting.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), params.amount, null).paymentInfo(_constants2.fakeAddress);
251
- const mintFeeInfo = _mintFeeInfo.toPrimitive();
252
- return {
253
- amount: mintFeeInfo.partialFee.toString(),
254
- slug: defaultFeeTokenSlug
255
- };
256
- } else {
257
- return {
258
- amount: '0',
259
- slug: defaultFeeTokenSlug
260
- };
261
- }
262
- }
263
- async handleSubmitStep(data, path) {
264
- const substrateApi = await this.substrateApi.isReady;
265
- const inputTokenSlug = this.inputAsset;
266
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
267
- const extrinsic = substrateApi.api.tx.vtokenMinting.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), data.amount, undefined);
268
- return {
269
- txChain: this.chain,
270
- extrinsicType: _KoniTypes.ExtrinsicType.MINT_VDOT,
271
- extrinsic,
272
- txData: data,
273
- transferNativeAmount: '0'
274
- };
275
- }
276
-
277
- /* Join pool action */
278
-
279
- /* Leave pool action */
280
-
281
- async handleYieldRedeem(amount, address, selectedTarget) {
282
- const substrateApi = await this.substrateApi.isReady;
283
- const weightedMinAmount = await this.createParamToRedeem(amount, address);
284
- const extrinsic = substrateApi.api.tx.stablePool.swap(0, 1, 0, amount, weightedMinAmount);
285
- return [_KoniTypes.ExtrinsicType.REDEEM_VDOT, extrinsic];
286
- }
287
- async handleYieldUnstake(amount, address, selectedTarget) {
288
- const chainApi = await this.substrateApi.isReady;
289
- const derivativeTokenSlug = this.derivativeAssets[0];
290
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
291
- const extrinsic = chainApi.api.tx.vtokenMinting.redeem((0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
292
- return [_KoniTypes.ExtrinsicType.UNSTAKE_VDOT, extrinsic];
293
- }
294
-
295
- /* Leave pool action */
296
- }
297
- exports.default = BifrostLiquidStakingPoolHandler;
@@ -1,34 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- Object.defineProperty(exports, "AcalaLiquidStakingPoolHandler", {
8
- enumerable: true,
9
- get: function () {
10
- return _acala.default;
11
- }
12
- });
13
- Object.defineProperty(exports, "BifrostLiquidStakingPoolHandler", {
14
- enumerable: true,
15
- get: function () {
16
- return _bifrost.default;
17
- }
18
- });
19
- Object.defineProperty(exports, "ParallelLiquidStakingPoolHandler", {
20
- enumerable: true,
21
- get: function () {
22
- return _parallel.default;
23
- }
24
- });
25
- Object.defineProperty(exports, "StellaSwapLiquidStakingPoolHandler", {
26
- enumerable: true,
27
- get: function () {
28
- return _stellaSwap.default;
29
- }
30
- });
31
- var _acala = _interopRequireDefault(require("./acala"));
32
- var _bifrost = _interopRequireDefault(require("./bifrost"));
33
- var _parallel = _interopRequireDefault(require("./parallel"));
34
- var _stellaSwap = _interopRequireDefault(require("./stella-swap"));
@@ -1,226 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
9
- var _constants = require("@subwallet/extension-base/services/chain-service/constants");
10
- var _utils = require("@subwallet/extension-base/services/chain-service/utils");
11
- var _constants2 = require("@subwallet/extension-base/services/earning-service/constants");
12
- var _types = require("@subwallet/extension-base/types");
13
- var _util = require("@polkadot/util");
14
- var _base = _interopRequireDefault(require("./base"));
15
- // Copyright 2019-2022 @subwallet/extension-base
16
- // SPDX-License-Identifier: Apache-2.0
17
-
18
- class ParallelLiquidStakingPoolHandler extends _base.default {
19
- altInputAsset = 'polkadot-NATIVE-DOT';
20
- derivativeAssets = ['parallel-LOCAL-sDOT'];
21
- inputAsset = 'parallel-LOCAL-DOT';
22
- rewardAssets = ['parallel-LOCAL-DOT'];
23
- feeAssets = ['parallel-NATIVE-PARA'];
24
- minAmountPercent = 0.97;
25
- rateDecimals = 18;
26
- availableMethod = {
27
- join: true,
28
- defaultUnstake: true,
29
- fastUnstake: true,
30
- cancelUnstake: false,
31
- withdraw: false,
32
- claimReward: false
33
- };
34
- constructor(state, chain) {
35
- super(state, chain);
36
- const chainInfo = this.chainInfo;
37
- this.slug = `DOT___liquid_staking___${chain}`;
38
- this.name = `${chainInfo.name} Liquid Staking`;
39
- this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
40
- }
41
- getDescription() {
42
- return 'Stake DOT to earn yield on sDOT';
43
- }
44
-
45
- /* Subscribe pool info */
46
-
47
- async getPoolStat() {
48
- const substrateApi = await this.substrateApi.isReady;
49
- const [_exchangeRate, _currentBlockHeader, _currentTimestamp, _stakingLedgers] = await Promise.all([substrateApi.api.query.liquidStaking.exchangeRate(), substrateApi.api.rpc.chain.getHeader(), substrateApi.api.query.timestamp.now(), substrateApi.api.query.liquidStaking.stakingLedgers.entries()]);
50
- let tvl = _util.BN_ZERO;
51
- for (const _stakingLedger of _stakingLedgers) {
52
- const _ledger = _stakingLedger[1];
53
- const ledger = _ledger.toPrimitive();
54
- tvl = tvl.add(new _util.BN(ledger.total.toString()));
55
- }
56
- const exchangeRate = _exchangeRate.toPrimitive();
57
- const currentBlockHeader = _currentBlockHeader.toPrimitive();
58
- const currentTimestamp = _currentTimestamp.toPrimitive();
59
- const beginBlock = currentBlockHeader.number - 24 * 60 * 60 / 6 * 14;
60
- const _beginBlockHash = await substrateApi.api.rpc.chain.getBlockHash(beginBlock);
61
- const beginBlockHash = _beginBlockHash.toString();
62
- const [_beginTimestamp, _beginExchangeRate] = await Promise.all([substrateApi.api.query.timestamp.now.at(beginBlockHash), substrateApi.api.query.liquidStaking.exchangeRate.at(beginBlockHash)]);
63
- const beginTimestamp = _beginTimestamp.toPrimitive();
64
- const beginExchangeRate = _beginExchangeRate.toPrimitive();
65
- const decimals = 10 ** this.rateDecimals;
66
- const apy = (exchangeRate / beginExchangeRate) ** (365 * 24 * 60 * 60000 / (currentTimestamp - beginTimestamp)) - 1;
67
- const minStake = substrateApi.api.consts.liquidStaking.minStake.toString();
68
- const minUnstake = substrateApi.api.consts.liquidStaking.minUnstake.toString();
69
- this.updateExchangeRate(exchangeRate);
70
- return {
71
- ...this.baseInfo,
72
- type: this.type,
73
- metadata: {
74
- ...this.metadataInfo,
75
- description: this.getDescription()
76
- },
77
- statistic: {
78
- assetEarning: [{
79
- slug: this.rewardAssets[0],
80
- apy: apy * 100,
81
- exchangeRate: exchangeRate / decimals
82
- }],
83
- unstakingPeriod: 24 * 28,
84
- maxCandidatePerFarmer: 1,
85
- maxWithdrawalRequestPerFarmer: 1,
86
- earningThreshold: {
87
- join: minStake,
88
- defaultUnstake: minUnstake,
89
- fastUnstake: '0'
90
- },
91
- totalApy: apy * 100,
92
- tvl: tvl.toString()
93
- }
94
- };
95
- }
96
-
97
- /* Subscribe pool info */
98
-
99
- /* Subscribe pool position */
100
-
101
- async subscribePoolPosition(useAddresses, resultCallback) {
102
- let cancel = false;
103
- const substrateApi = this.substrateApi;
104
- await substrateApi.isReady;
105
- const derivativeTokenSlug = this.derivativeAssets[0];
106
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
107
- const unsub = await substrateApi.api.query.assets.account.multi(useAddresses.map(address => [(0, _utils._getTokenOnChainAssetId)(derivativeTokenInfo), address]), async balances => {
108
- if (cancel) {
109
- unsub();
110
- return;
111
- }
112
- const [unlockingChunks, _currentEra, exchangeRate] = await Promise.all([substrateApi.api.query.liquidStaking.unlockings.multi(useAddresses), substrateApi.api.query.liquidStaking.currentEra(), this.getExchangeRate()]);
113
- const currentEra = _currentEra.toPrimitive();
114
- const decimals = _util.BN_TEN.pow(new _util.BN(this.rateDecimals));
115
- for (let i = 0; i < balances.length; i++) {
116
- const b = balances[i];
117
- const address = useAddresses[i];
118
- // @ts-ignore
119
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment
120
- const bdata = b === null || b === void 0 ? void 0 : b.toHuman();
121
- const chunks = unlockingChunks[i].toPrimitive();
122
-
123
- // @ts-ignore
124
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument
125
- const activeBalance = bdata && bdata.balance ? new _util.BN(String(bdata === null || bdata === void 0 ? void 0 : bdata.balance).replaceAll(',', '') || '0') : _util.BN_ZERO;
126
- let totalBalance = activeBalance.mul(new _util.BN(exchangeRate)).div(decimals);
127
- let unlockingBalance = _util.BN_ZERO;
128
- const unstakings = [];
129
- if (chunks) {
130
- for (const chunk of chunks) {
131
- const amount = new _util.BN(chunk.value);
132
- const isClaimable = chunk.era - currentEra < 0;
133
- const remainingEra = chunk.era - currentEra;
134
- const eraTime = _constants._STAKING_ERA_LENGTH_MAP[this.chain] || _constants._STAKING_ERA_LENGTH_MAP.default;
135
- const waitingTime = remainingEra * eraTime;
136
- totalBalance = totalBalance.add(amount);
137
- unlockingBalance = unlockingBalance.add(amount);
138
- unstakings.push({
139
- chain: this.chain,
140
- status: isClaimable ? _types.UnstakingStatus.CLAIMABLE : _types.UnstakingStatus.UNLOCKING,
141
- claimable: amount.toString(),
142
- waitingTime: waitingTime
143
- });
144
- }
145
- }
146
- const result = {
147
- ...this.baseInfo,
148
- type: this.type,
149
- address,
150
- balanceToken: this.inputAsset,
151
- totalStake: totalBalance.toString(),
152
- activeStake: activeBalance.toString(),
153
- unstakeBalance: unlockingBalance.toString(),
154
- status: _types.EarningStatus.EARNING_REWARD,
155
- derivativeToken: derivativeTokenSlug,
156
- isBondedBefore: totalBalance.gt(_util.BN_ZERO),
157
- nominations: [],
158
- unstakings: unstakings
159
- };
160
- resultCallback(result);
161
- }
162
- });
163
- return () => {
164
- cancel = true;
165
- unsub();
166
- };
167
- }
168
-
169
- /* Subscribe pool position */
170
-
171
- /* Join pool action */
172
-
173
- get submitJoinStepInfo() {
174
- return {
175
- name: 'Mint sDOT',
176
- type: _types.YieldStepType.MINT_SDOT
177
- };
178
- }
179
- async getSubmitStepFee(params) {
180
- const poolOriginSubstrateApi = await this.substrateApi.isReady;
181
- const defaultFeeTokenSlug = this.feeAssets[0];
182
- if (new _util.BN(params.amount).gt(_util.BN_ZERO)) {
183
- const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.liquidStaking.stake(params.amount).paymentInfo(_constants2.fakeAddress);
184
- const mintFeeInfo = _mintFeeInfo.toPrimitive();
185
- return {
186
- amount: mintFeeInfo.partialFee.toString(),
187
- slug: defaultFeeTokenSlug
188
- };
189
- } else {
190
- return {
191
- amount: '0',
192
- slug: defaultFeeTokenSlug
193
- };
194
- }
195
- }
196
- async handleSubmitStep(data, path) {
197
- const substrateApi = await this.substrateApi.isReady;
198
- const extrinsic = substrateApi.api.tx.liquidStaking.stake(data.amount);
199
- return {
200
- txChain: this.chain,
201
- extrinsicType: _KoniTypes.ExtrinsicType.MINT_SDOT,
202
- extrinsic,
203
- txData: data,
204
- transferNativeAmount: '0'
205
- };
206
- }
207
-
208
- /* Join pool action */
209
-
210
- /* Leave pool action */
211
-
212
- async handleYieldRedeem(amount, address, selectedTarget) {
213
- const substrateApi = await this.substrateApi.isReady;
214
- const weightedMinAmount = await this.createParamToRedeem(amount, address);
215
- const extrinsic = substrateApi.api.tx.ammRoute.swapExactTokensForTokens(['1001', '101'], amount, weightedMinAmount);
216
- return [_KoniTypes.ExtrinsicType.REDEEM_SDOT, extrinsic];
217
- }
218
- async handleYieldUnstake(amount, address, selectedTarget) {
219
- const chainApi = await this.substrateApi.isReady;
220
- const extrinsic = chainApi.api.tx.liquidStaking.unstake(amount, 'RelayChain');
221
- return [_KoniTypes.ExtrinsicType.UNSTAKE_SDOT, extrinsic];
222
- }
223
-
224
- /* Leave pool action */
225
- }
226
- exports.default = ParallelLiquidStakingPoolHandler;