@subwallet/extension-base 1.1.28-beta.1 → 1.1.30-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 (292) hide show
  1. package/background/KoniTypes.d.ts +70 -93
  2. package/background/KoniTypes.js +14 -16
  3. package/background/errors/TransactionError.js +4 -9
  4. package/cjs/background/KoniTypes.js +17 -17
  5. package/cjs/background/errors/TransactionError.js +4 -9
  6. package/cjs/constants/index.js +3 -9
  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 +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 +5 -6
  18. package/cjs/koni/api/staking/relayChain.js +2 -3
  19. package/cjs/koni/background/cron.js +0 -2
  20. package/cjs/koni/background/handlers/Extension.js +88 -326
  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 +18 -88
  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 +16 -2
  27. package/cjs/services/chain-service/utils.js +1 -7
  28. package/cjs/services/event-service/index.js +0 -4
  29. package/cjs/services/keyring-service/index.js +2 -14
  30. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  31. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  32. package/cjs/services/migration-service/scripts/index.js +0 -4
  33. package/cjs/services/notification-service/NotificationService.js +1 -1
  34. package/cjs/services/storage-service/DatabaseService.js +0 -47
  35. package/cjs/services/storage-service/databases/index.js +0 -4
  36. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  37. package/cjs/services/transaction-service/event-parser/index.js +0 -58
  38. package/cjs/services/transaction-service/helpers/index.js +1 -3
  39. package/cjs/services/transaction-service/index.js +74 -180
  40. package/cjs/services/transaction-service/utils.js +0 -1
  41. package/cjs/types/index.js +0 -44
  42. package/cjs/utils/fetchStaticData.js +1 -2
  43. package/cjs/utils/index.js +1 -89
  44. package/constants/index.d.ts +0 -2
  45. package/constants/index.js +0 -2
  46. package/koni/api/nft/config.js +23 -33
  47. package/koni/api/nft/index.js +1 -15
  48. package/koni/api/nft/nft.js +23 -2
  49. package/koni/api/staking/bonding/amplitude.js +9 -11
  50. package/koni/api/staking/bonding/astar.js +8 -9
  51. package/koni/api/staking/bonding/index.d.ts +1 -1
  52. package/koni/api/staking/bonding/index.js +1 -5
  53. package/koni/api/staking/bonding/paraChain.js +10 -12
  54. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  55. package/koni/api/staking/bonding/relayChain.js +30 -33
  56. package/koni/api/staking/bonding/utils.d.ts +38 -15
  57. package/koni/api/staking/bonding/utils.js +69 -85
  58. package/koni/api/staking/index.js +1 -2
  59. package/koni/api/staking/paraChain.js +6 -7
  60. package/koni/api/staking/relayChain.js +3 -4
  61. package/koni/background/cron.js +0 -2
  62. package/koni/background/handlers/Extension.d.ts +1 -14
  63. package/koni/background/handlers/Extension.js +50 -286
  64. package/koni/background/handlers/State.d.ts +2 -18
  65. package/koni/background/handlers/State.js +3 -50
  66. package/koni/background/handlers/index.js +2 -4
  67. package/koni/background/subscription.d.ts +1 -5
  68. package/koni/background/subscription.js +20 -90
  69. package/package.json +8 -311
  70. package/packageInfo.js +1 -1
  71. package/services/campaign-service/index.js +6 -9
  72. package/services/chain-service/constants.d.ts +11 -0
  73. package/services/chain-service/constants.js +14 -1
  74. package/services/chain-service/utils.d.ts +0 -1
  75. package/services/chain-service/utils.js +1 -5
  76. package/services/event-service/index.d.ts +0 -1
  77. package/services/event-service/index.js +0 -4
  78. package/services/event-service/types.d.ts +0 -8
  79. package/services/keyring-service/index.d.ts +1 -2
  80. package/services/keyring-service/index.js +2 -14
  81. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  82. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  83. package/services/migration-service/scripts/index.js +0 -4
  84. package/services/notification-service/NotificationService.js +1 -1
  85. package/services/storage-service/DatabaseService.d.ts +1 -17
  86. package/services/storage-service/DatabaseService.js +0 -47
  87. package/services/storage-service/databases/index.d.ts +1 -3
  88. package/services/storage-service/databases/index.js +0 -4
  89. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  90. package/services/subscan-service/index.d.ts +2 -2
  91. package/services/transaction-service/event-parser/index.d.ts +1 -3
  92. package/services/transaction-service/event-parser/index.js +1 -57
  93. package/services/transaction-service/helpers/index.js +1 -3
  94. package/services/transaction-service/index.d.ts +15 -4
  95. package/services/transaction-service/index.js +72 -178
  96. package/services/transaction-service/types.d.ts +0 -2
  97. package/services/transaction-service/utils.js +0 -1
  98. package/types/index.d.ts +0 -5
  99. package/types/index.js +1 -5
  100. package/utils/fetchStaticData.js +1 -2
  101. package/utils/index.d.ts +0 -5
  102. package/utils/index.js +1 -53
  103. package/cjs/koni/api/dotsama/balance.js +0 -464
  104. package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
  105. package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
  106. package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
  107. package/cjs/koni/api/yield/helper/utils.js +0 -46
  108. package/cjs/services/earning-service/constants/chains.js +0 -29
  109. package/cjs/services/earning-service/constants/index.js +0 -27
  110. package/cjs/services/earning-service/constants/step.js +0 -18
  111. package/cjs/services/earning-service/handlers/base.js +0 -202
  112. package/cjs/services/earning-service/handlers/index.js +0 -60
  113. package/cjs/services/earning-service/handlers/lending/base.js +0 -20
  114. package/cjs/services/earning-service/handlers/lending/index.js +0 -13
  115. package/cjs/services/earning-service/handlers/lending/interlay.js +0 -168
  116. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -196
  117. package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -39
  118. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -257
  119. package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
  120. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -180
  121. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -373
  122. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -359
  123. package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -426
  124. package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -137
  125. package/cjs/services/earning-service/handlers/native-staking/base.js +0 -109
  126. package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
  127. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -361
  128. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -512
  129. package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -501
  130. package/cjs/services/earning-service/handlers/special.js +0 -387
  131. package/cjs/services/earning-service/service.js +0 -327
  132. package/cjs/services/earning-service/utils/index.js +0 -111
  133. package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
  134. package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
  135. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
  136. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
  137. package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
  138. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
  139. package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
  140. package/cjs/services/mint-campaign-service/constants.js +0 -11
  141. package/cjs/services/mint-campaign-service/index.js +0 -18
  142. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
  143. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
  144. package/cjs/services/storage-service/index.js +0 -241
  145. package/cjs/types/campaigns/index.js +0 -16
  146. package/cjs/types/campaigns/unlock-dot.js +0 -1
  147. package/cjs/types/ordinal.js +0 -1
  148. package/cjs/types/transaction.js +0 -1
  149. package/cjs/types/yield/actions/index.js +0 -27
  150. package/cjs/types/yield/actions/join/index.js +0 -38
  151. package/cjs/types/yield/actions/join/step.js +0 -37
  152. package/cjs/types/yield/actions/join/submit.js +0 -1
  153. package/cjs/types/yield/actions/join/validate.js +0 -16
  154. package/cjs/types/yield/actions/others.js +0 -1
  155. package/cjs/types/yield/index.js +0 -27
  156. package/cjs/types/yield/info/account/index.js +0 -49
  157. package/cjs/types/yield/info/account/info.js +0 -1
  158. package/cjs/types/yield/info/account/reward.js +0 -1
  159. package/cjs/types/yield/info/account/target.js +0 -32
  160. package/cjs/types/yield/info/account/unstake.js +0 -27
  161. package/cjs/types/yield/info/base.js +0 -34
  162. package/cjs/types/yield/info/chain/index.js +0 -27
  163. package/cjs/types/yield/info/chain/info.js +0 -1
  164. package/cjs/types/yield/info/chain/target.js +0 -1
  165. package/cjs/types/yield/info/index.js +0 -49
  166. package/cjs/types/yield/info/pallet.js +0 -15
  167. package/cjs/types.js +0 -1
  168. package/cjs/utils/address.js +0 -34
  169. package/cjs/utils/keyring.js +0 -57
  170. package/cjs/utils/object.js +0 -12
  171. package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
  172. package/koni/api/nft/ordinal_nft/constants.js +0 -12
  173. package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
  174. package/koni/api/nft/ordinal_nft/index.js +0 -114
  175. package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
  176. package/koni/api/nft/ordinal_nft/utils.js +0 -33
  177. package/koni/api/yield/helper/utils.d.ts +0 -10
  178. package/koni/api/yield/helper/utils.js +0 -32
  179. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
  180. package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
  181. package/services/earning-service/constants/chains.d.ts +0 -14
  182. package/services/earning-service/constants/chains.js +0 -21
  183. package/services/earning-service/constants/index.d.ts +0 -2
  184. package/services/earning-service/constants/index.js +0 -5
  185. package/services/earning-service/constants/step.d.ts +0 -3
  186. package/services/earning-service/constants/step.js +0 -10
  187. package/services/earning-service/handlers/base.d.ts +0 -105
  188. package/services/earning-service/handlers/base.js +0 -195
  189. package/services/earning-service/handlers/index.d.ts +0 -5
  190. package/services/earning-service/handlers/index.js +0 -8
  191. package/services/earning-service/handlers/lending/base.d.ts +0 -6
  192. package/services/earning-service/handlers/lending/base.js +0 -12
  193. package/services/earning-service/handlers/lending/index.d.ts +0 -1
  194. package/services/earning-service/handlers/lending/index.js +0 -4
  195. package/services/earning-service/handlers/lending/interlay.d.ts +0 -22
  196. package/services/earning-service/handlers/lending/interlay.js +0 -160
  197. package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
  198. package/services/earning-service/handlers/liquid-staking/acala.js +0 -188
  199. package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -8
  200. package/services/earning-service/handlers/liquid-staking/base.js +0 -31
  201. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -44
  202. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -246
  203. package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
  204. package/services/earning-service/handlers/liquid-staking/index.js +0 -7
  205. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -27
  206. package/services/earning-service/handlers/liquid-staking/parallel.js +0 -172
  207. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -36
  208. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -363
  209. package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
  210. package/services/earning-service/handlers/native-staking/amplitude.js +0 -350
  211. package/services/earning-service/handlers/native-staking/astar.d.ts +0 -18
  212. package/services/earning-service/handlers/native-staking/astar.js +0 -416
  213. package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
  214. package/services/earning-service/handlers/native-staking/base-para.js +0 -129
  215. package/services/earning-service/handlers/native-staking/base.d.ts +0 -19
  216. package/services/earning-service/handlers/native-staking/base.js +0 -101
  217. package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
  218. package/services/earning-service/handlers/native-staking/index.js +0 -7
  219. package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
  220. package/services/earning-service/handlers/native-staking/para-chain.js +0 -353
  221. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
  222. package/services/earning-service/handlers/native-staking/relay-chain.js +0 -503
  223. package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -33
  224. package/services/earning-service/handlers/nomination-pool/index.js +0 -492
  225. package/services/earning-service/handlers/special.d.ts +0 -56
  226. package/services/earning-service/handlers/special.js +0 -379
  227. package/services/earning-service/service.d.ts +0 -36
  228. package/services/earning-service/service.js +0 -320
  229. package/services/earning-service/utils/index.d.ts +0 -14
  230. package/services/earning-service/utils/index.js +0 -100
  231. package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
  232. package/services/migration-service/scripts/DeleteEarningData.js +0 -13
  233. package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
  234. package/services/migration-service/scripts/EnableEarningChains.js +0 -13
  235. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
  236. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
  237. package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
  238. package/services/mint-campaign-service/campaigns/index.js +0 -4
  239. package/services/mint-campaign-service/constants.d.ts +0 -1
  240. package/services/mint-campaign-service/constants.js +0 -4
  241. package/services/mint-campaign-service/index.d.ts +0 -7
  242. package/services/mint-campaign-service/index.js +0 -11
  243. package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
  244. package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
  245. package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
  246. package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
  247. package/types/campaigns/index.d.ts +0 -1
  248. package/types/campaigns/index.js +0 -4
  249. package/types/campaigns/unlock-dot.d.ts +0 -71
  250. package/types/campaigns/unlock-dot.js +0 -1
  251. package/types/ordinal.d.ts +0 -69
  252. package/types/ordinal.js +0 -1
  253. package/types/transaction.d.ts +0 -3
  254. package/types/transaction.js +0 -1
  255. package/types/yield/actions/index.d.ts +0 -2
  256. package/types/yield/actions/index.js +0 -5
  257. package/types/yield/actions/join/index.d.ts +0 -3
  258. package/types/yield/actions/join/index.js +0 -6
  259. package/types/yield/actions/join/step.d.ts +0 -75
  260. package/types/yield/actions/join/step.js +0 -34
  261. package/types/yield/actions/join/submit.d.ts +0 -53
  262. package/types/yield/actions/join/submit.js +0 -1
  263. package/types/yield/actions/join/validate.d.ts +0 -18
  264. package/types/yield/actions/join/validate.js +0 -10
  265. package/types/yield/actions/others.d.ts +0 -60
  266. package/types/yield/actions/others.js +0 -1
  267. package/types/yield/index.d.ts +0 -2
  268. package/types/yield/index.js +0 -5
  269. package/types/yield/info/account/index.d.ts +0 -4
  270. package/types/yield/info/account/index.js +0 -7
  271. package/types/yield/info/account/info.d.ts +0 -112
  272. package/types/yield/info/account/info.js +0 -1
  273. package/types/yield/info/account/reward.d.ts +0 -41
  274. package/types/yield/info/account/reward.js +0 -1
  275. package/types/yield/info/account/target.d.ts +0 -43
  276. package/types/yield/info/account/target.js +0 -27
  277. package/types/yield/info/account/unstake.d.ts +0 -31
  278. package/types/yield/info/account/unstake.js +0 -22
  279. package/types/yield/info/base.d.ts +0 -28
  280. package/types/yield/info/base.js +0 -28
  281. package/types/yield/info/chain/index.d.ts +0 -2
  282. package/types/yield/info/chain/index.js +0 -5
  283. package/types/yield/info/chain/info.d.ts +0 -190
  284. package/types/yield/info/chain/info.js +0 -1
  285. package/types/yield/info/chain/target.d.ts +0 -33
  286. package/types/yield/info/chain/target.js +0 -1
  287. package/types/yield/info/index.d.ts +0 -4
  288. package/types/yield/info/index.js +0 -7
  289. package/types/yield/info/pallet.d.ts +0 -143
  290. package/types/yield/info/pallet.js +0 -9
  291. package/utils/object.d.ts +0 -1
  292. package/utils/object.js +0 -6
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.YIELD_POOL_STAT_REFRESH_INTERVAL = exports.YIELD_POOL_MIN_AMOUNT_PERCENT = exports.YIELD_EXTRINSIC_TYPES = exports.DEFAULT_YIELD_FIRST_STEP = void 0;
7
- exports.calculateAlternativeFee = calculateAlternativeFee;
8
- exports.convertDerivativeToOriginToken = convertDerivativeToOriginToken;
9
- exports.syntheticSelectedValidators = void 0;
10
- var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
11
- var _utils = require("@subwallet/extension-base/services/chain-service/utils");
12
- var _types = require("@subwallet/extension-base/types");
13
- // Copyright 2019-2022 @subwallet/extension-base
14
- // SPDX-License-Identifier: Apache-2.0
15
-
16
- const syntheticSelectedValidators = ['15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6', '1REAJ1k691g5Eqqg9gL7vvZCBG7FCCZ8zgQkZWd4va5ESih', '1yGJ3h7TQuJWLYSsUVPZbM8aR8UsQXCqMvrFx5Fn1ktiAmq', '16GDRhRYxk42paoK6TfHAqWej8PdDDUwdDazjv4bAn4KGNeb', '13Ybj8CPEArUee78DxUAP9yX3ABmFNVQME1ZH4w8HVncHGzc', '14yx4vPAACZRhoDQm1dyvXD3QdRQyCRRCe5tj1zPomhhS29a', '14Vh8S1DzzycngbAB9vqEgPFR9JpSvmF1ezihTUES1EaHAV', '153YD8ZHD9dRh82U419bSCB5SzWhbdAFzjj4NtA5pMazR2yC', '1LUckyocmz9YzeQZHVpBvYYRGXb3rnSm2tvfz79h3G3JDgP', '14oRE62MB1SWR6h5RTx3GY5HK2oZipi1Gp3zdiLwVYLfEyRZ', '1cFsLn7o74nmjbRyDtMAnMpQMc5ZLsjgCSz9Np2mcejUK83', '15ZvLonEseaWZNy8LDkXXj3Y8bmAjxCjwvpy4pXWSL4nGSBs', '1NebF2xZHb4TJJpiqZZ3reeTo8dZov6LZ49qZqcHHbsmHfo', '1HmAqbBRrWvsqbLkvpiVDkdA2PcctUE5JUe3qokEh1FN455', '15tfUt4iQNjMyhZiJGBf4EpETE2KqtW1nfJwbBT1MvWjvcK9', '12RXTLiaYh59PokjZVhQvKzcfBEB5CvDnjKKUmDUotzcTH3S'];
17
- exports.syntheticSelectedValidators = syntheticSelectedValidators;
18
- function calculateAlternativeFee(feeInfo) {
19
- return feeInfo.partialFee;
20
- }
21
- const DEFAULT_YIELD_FIRST_STEP = {
22
- id: 0,
23
- name: 'Fill information',
24
- type: _types.YieldStepType.DEFAULT
25
- };
26
- exports.DEFAULT_YIELD_FIRST_STEP = DEFAULT_YIELD_FIRST_STEP;
27
- const YIELD_EXTRINSIC_TYPES = [_KoniTypes.ExtrinsicType.MINT_VDOT, _KoniTypes.ExtrinsicType.MINT_LDOT, _KoniTypes.ExtrinsicType.MINT_SDOT, _KoniTypes.ExtrinsicType.MINT_QDOT, _KoniTypes.ExtrinsicType.MINT_STDOT, _KoniTypes.ExtrinsicType.REDEEM_QDOT, _KoniTypes.ExtrinsicType.REDEEM_SDOT, _KoniTypes.ExtrinsicType.REDEEM_VDOT, _KoniTypes.ExtrinsicType.REDEEM_LDOT, _KoniTypes.ExtrinsicType.REDEEM_STDOT, _KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL, _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW];
28
- exports.YIELD_EXTRINSIC_TYPES = YIELD_EXTRINSIC_TYPES;
29
- const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
30
- exports.YIELD_POOL_STAT_REFRESH_INTERVAL = YIELD_POOL_STAT_REFRESH_INTERVAL;
31
- const YIELD_POOL_MIN_AMOUNT_PERCENT = {
32
- DOT___acala_liquid_staking: 0.98,
33
- DOT___bifrost_liquid_staking: 0.99,
34
- DOT___parallel_liquid_staking: 0.97,
35
- default: 0.98
36
- };
37
- exports.YIELD_POOL_MIN_AMOUNT_PERCENT = YIELD_POOL_MIN_AMOUNT_PERCENT;
38
- function convertDerivativeToOriginToken(amount, poolInfo, derivativeTokenInfo, originTokenInfo) {
39
- var _poolInfo$metadata$as;
40
- const derivativeDecimals = (0, _utils._getAssetDecimals)(derivativeTokenInfo);
41
- const originDecimals = (0, _utils._getAssetDecimals)(originTokenInfo);
42
- const exchangeRate = ((_poolInfo$metadata$as = poolInfo.metadata.assetEarning) === null || _poolInfo$metadata$as === void 0 ? void 0 : _poolInfo$metadata$as[0].exchangeRate) || 1;
43
- const formattedAmount = parseInt(amount) / 10 ** derivativeDecimals; // TODO: decimals
44
- const minAmount = formattedAmount * exchangeRate;
45
- return Math.floor(minAmount * 10 ** originDecimals);
46
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports._STAKING_CHAIN_GROUP = exports.ST_LIQUID_TOKEN_ABI = void 0;
7
- // Copyright 2019-2022 @subwallet/extension-base
8
- // SPDX-License-Identifier: Apache-2.0
9
-
10
- const _STAKING_CHAIN_GROUP = {
11
- relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network'],
12
- para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
13
- astar: ['astar', 'shiden', 'shibuya'],
14
- amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
15
- // amplitude and kilt only share some common logic
16
- kilt: ['kilt', 'kilt_peregrine'],
17
- nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network'],
18
- bifrost: ['bifrost', 'bifrost_testnet'],
19
- aleph: ['aleph', 'alephTest'],
20
- // A0 has distinct tokenomics
21
- ternoa: ['ternoa', 'ternoa_alphanet'],
22
- liquidStaking: ['bifrost_dot', 'acala', 'parallel', 'moonbeam'],
23
- lending: ['interlay']
24
- };
25
-
26
- // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
27
- exports._STAKING_CHAIN_GROUP = _STAKING_CHAIN_GROUP;
28
- const ST_LIQUID_TOKEN_ABI = require('./abis/st_liquid_token_abi.json');
29
- exports.ST_LIQUID_TOKEN_ABI = ST_LIQUID_TOKEN_ABI;
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _chains = require("./chains");
7
- Object.keys(_chains).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _chains[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _chains[key];
14
- }
15
- });
16
- });
17
- var _step = require("./step");
18
- Object.keys(_step).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _step[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _step[key];
25
- }
26
- });
27
- });
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fakeAddress = exports.DEFAULT_YIELD_FIRST_STEP = void 0;
7
- var _types = require("@subwallet/extension-base/types");
8
- // Copyright 2019-2022 @subwallet/extension-base
9
- // SPDX-License-Identifier: Apache-2.0
10
-
11
- const DEFAULT_YIELD_FIRST_STEP = {
12
- id: 0,
13
- name: 'Fill information',
14
- type: _types.YieldStepType.DEFAULT
15
- };
16
- exports.DEFAULT_YIELD_FIRST_STEP = DEFAULT_YIELD_FIRST_STEP;
17
- const fakeAddress = '15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6';
18
- exports.fakeAddress = fakeAddress;
@@ -1,202 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
8
- var _constants = require("@subwallet/extension-base/services/earning-service/constants");
9
- // Copyright 2019-2022 @subwallet/extension-base
10
- // SPDX-License-Identifier: Apache-2.0
11
-
12
- /**
13
- * @class BasePoolHandler
14
- * @description Base pool handler
15
- * */
16
- class BasePoolHandler {
17
- /** Koni state */
18
-
19
- /** Pool's chain */
20
-
21
- /** Pool's logo */
22
-
23
- /** Pool's slug */
24
-
25
- /** Pool's type */
26
-
27
- /** Pool's name */
28
-
29
- /** Pool's short name */
30
-
31
- /** Pool's description */
32
-
33
- /** Pool's transaction type */
34
- transactionChainType = _KoniTypes.ChainType.SUBSTRATE;
35
-
36
- /**
37
- * @constructor
38
- * @param {KoniState} state - Koni state
39
- * @param {string} chain - Pool's chain
40
- * */
41
- constructor(state, chain) {
42
- this.state = state;
43
- this.chain = chain;
44
- this._logo = chain;
45
- }
46
- get logo() {
47
- return this._logo;
48
- }
49
- get group() {
50
- const groupSlug = this.nativeToken.multiChainAsset;
51
- return groupSlug || this.nativeToken.slug;
52
- }
53
- get substrateApi() {
54
- return this.state.getSubstrateApi(this.chain);
55
- }
56
- get evmApi() {
57
- return this.state.getEvmApi(this.chain);
58
- }
59
- get chainInfo() {
60
- return this.state.getChainInfo(this.chain);
61
- }
62
- get nativeToken() {
63
- return this.state.getNativeTokenInfo(this.chain);
64
- }
65
- get defaultInfo() {
66
- return {
67
- name: this.name,
68
- shortName: this.shortName,
69
- group: this.group,
70
- logo: this.logo,
71
- chain: this.chain,
72
- slug: this.slug
73
- };
74
- }
75
-
76
- /** Can mint when haven't enough native token (use input token for fee) */
77
- get isPoolSupportAlternativeFee() {
78
- return false;
79
- }
80
- async getPoolInfo() {
81
- return this.state.dbService.getYieldPool(this.slug);
82
- }
83
- async getPoolPosition(address) {
84
- return this.state.dbService.getYieldPositionByAddressAndSlug(address, this.slug);
85
- }
86
-
87
- /* Subscribe data */
88
-
89
- /** Subscribe pool info */
90
-
91
- /* Subscribe data */
92
-
93
- /* Join action */
94
-
95
- /* Generate steps */
96
-
97
- /**
98
- * @function firstStepFee
99
- * */
100
- get firstStepFee() {
101
- return {
102
- slug: ''
103
- };
104
- }
105
-
106
- /**
107
- * @function defaultSubmitStep
108
- * @description Default submit step data
109
- * */
110
-
111
- /**
112
- * @async
113
- * @function getTokenApproveStep
114
- * @param {OptimalYieldPathParams} params - base param to join pool
115
- * @description Generate token approve step data
116
- * */
117
- async getTokenApproveStep(params) {
118
- return Promise.resolve(undefined);
119
- }
120
-
121
- /**
122
- * @async
123
- * @function getXcmStep
124
- * @param {OptimalYieldPathParams} params - base param to join pool
125
- * @description Generate token approve step data
126
- * */
127
- async getXcmStep(params) {
128
- return Promise.resolve(undefined);
129
- }
130
-
131
- /**
132
- * @async
133
- * @function getSubmitStep
134
- * @param {OptimalYieldPathParams} params - base param to join pool
135
- * @description Generate token approve step data
136
- * */
137
-
138
- /** Generate the optimal steps to join pool */
139
- async generateOptimalPath(params) {
140
- const result = {
141
- totalFee: [this.firstStepFee],
142
- steps: [_constants.DEFAULT_YIELD_FIRST_STEP]
143
- };
144
- try {
145
- const stepFunctions = [this.getTokenApproveStep, this.getXcmStep, this.getSubmitStep];
146
- for (const stepFunction of stepFunctions) {
147
- const step = await stepFunction(params);
148
- if (step) {
149
- const [info, fee] = step;
150
- result.steps.push({
151
- id: result.steps.length,
152
- ...info
153
- });
154
- result.totalFee.push(fee);
155
- }
156
- }
157
- return result;
158
- } catch (e) {
159
- const errorMessage = e.message;
160
- if (errorMessage.includes('network')) {
161
- result.connectionError = errorMessage.split(' ')[0];
162
- }
163
-
164
- /* Submit step */
165
-
166
- const [step, fee] = this.defaultSubmitStep;
167
- result.steps.push({
168
- id: result.steps.length,
169
- ...step
170
- });
171
- result.totalFee.push(fee);
172
-
173
- /* Submit step */
174
-
175
- return result;
176
- }
177
- }
178
-
179
- /* Generate steps */
180
-
181
- /* Validate */
182
-
183
- /** Validate param to join the pool */
184
-
185
- /** Create `transaction` to leave the pool */
186
- async handleYieldLeave(fastLeave, amount, address, selectedTarget) {
187
- if (fastLeave) {
188
- return this.handleYieldRedeem(amount, address, selectedTarget);
189
- } else {
190
- return this.handleYieldUnstake(amount, address, selectedTarget);
191
- }
192
- }
193
-
194
- /* Leave action */
195
-
196
- /* Other actions */
197
-
198
- /** Create `transaction` to withdraw unstaked amount */
199
-
200
- /* Other actions */
201
- }
202
- exports.default = BasePoolHandler;
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {
8
- BasePoolHandler: true,
9
- NominationPoolHandler: true
10
- };
11
- Object.defineProperty(exports, "BasePoolHandler", {
12
- enumerable: true,
13
- get: function () {
14
- return _base.default;
15
- }
16
- });
17
- Object.defineProperty(exports, "NominationPoolHandler", {
18
- enumerable: true,
19
- get: function () {
20
- return _nominationPool.default;
21
- }
22
- });
23
- var _base = _interopRequireDefault(require("./base"));
24
- var _nominationPool = _interopRequireDefault(require("./nomination-pool"));
25
- var _lending = require("./lending");
26
- Object.keys(_lending).forEach(function (key) {
27
- if (key === "default" || key === "__esModule") return;
28
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
29
- if (key in exports && exports[key] === _lending[key]) return;
30
- Object.defineProperty(exports, key, {
31
- enumerable: true,
32
- get: function () {
33
- return _lending[key];
34
- }
35
- });
36
- });
37
- var _liquidStaking = require("./liquid-staking");
38
- Object.keys(_liquidStaking).forEach(function (key) {
39
- if (key === "default" || key === "__esModule") return;
40
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
41
- if (key in exports && exports[key] === _liquidStaking[key]) return;
42
- Object.defineProperty(exports, key, {
43
- enumerable: true,
44
- get: function () {
45
- return _liquidStaking[key];
46
- }
47
- });
48
- });
49
- var _nativeStaking = require("./native-staking");
50
- Object.keys(_nativeStaking).forEach(function (key) {
51
- if (key === "default" || key === "__esModule") return;
52
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
53
- if (key in exports && exports[key] === _nativeStaking[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _nativeStaking[key];
58
- }
59
- });
60
- });
@@ -1,20 +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 _types = require("@subwallet/extension-base/types");
9
- var _special = _interopRequireDefault(require("../special"));
10
- // Copyright 2019-2022 @subwallet/extension-base
11
- // SPDX-License-Identifier: Apache-2.0
12
-
13
- class BaseLendingPoolHandler extends _special.default {
14
- type = _types.YieldPoolType.LENDING;
15
-
16
- /* Subscribe pool info */
17
-
18
- /* Subscribe pool info */
19
- }
20
- exports.default = BaseLendingPoolHandler;
@@ -1,13 +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, "InterlayLendingPoolHandler", {
8
- enumerable: true,
9
- get: function () {
10
- return _interlay.default;
11
- }
12
- });
13
- var _interlay = _interopRequireDefault(require("./interlay"));
@@ -1,168 +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 _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
9
- var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
10
- var _utils = require("@subwallet/extension-base/services/chain-service/utils");
11
- var _types = require("@subwallet/extension-base/types");
12
- var _bn = _interopRequireDefault(require("bn.js"));
13
- var _util = require("@polkadot/util");
14
- var _constants = require("../../constants");
15
- var _base = _interopRequireDefault(require("./base"));
16
- // Copyright 2019-2022 @subwallet/extension-base
17
- // SPDX-License-Identifier: Apache-2.0
18
-
19
- class InterlayLendingPoolHandler extends _base.default {
20
- altInputAsset = 'polkadot-NATIVE-DOT';
21
- derivativeAssets = ['interlay-LOCAL-qDOT'];
22
- inputAsset = 'interlay-LOCAL-DOT';
23
- rewardAssets = ['interlay-LOCAL-DOT'];
24
- feeAssets = ['interlay-NATIVE-INTR', 'interlay-LOCAL-DOT'];
25
- constructor(state, chain) {
26
- super(state, chain);
27
- const chainInfo = this.chainInfo;
28
- this.slug = `DOT___lending___${chain}`;
29
- this.name = `${chainInfo.name} Lending`;
30
- this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
31
- this.description = 'Earn rewards by lending DOT';
32
- }
33
-
34
- /* Subscribe pool info */
35
-
36
- async getPoolStat() {
37
- const substrateApi = await this.substrateApi.isReady;
38
- const inputTokenSlug = this.inputAsset;
39
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
40
- const _exchangeRate = await substrateApi.api.query.loans.exchangeRate((0, _utils._getTokenOnChainInfo)(inputTokenInfo));
41
- const exchangeRate = _exchangeRate.toPrimitive();
42
- const decimals = 10 ** 18;
43
- return {
44
- ...this.defaultInfo,
45
- description: this.description,
46
- type: this.type,
47
- metadata: {
48
- ...this.baseMetadata,
49
- isAvailable: true,
50
- allowCancelUnstaking: false,
51
- assetEarning: [{
52
- slug: this.rewardAssets[0],
53
- apr: 1.29,
54
- exchangeRate: exchangeRate / decimals
55
- }],
56
- maxCandidatePerFarmer: 1,
57
- maxWithdrawalRequestPerFarmer: 1,
58
- minJoinPool: '10000000000',
59
- minWithdrawal: '0',
60
- totalApr: 1.29,
61
- tvl: '291890000000000'
62
- }
63
- };
64
- }
65
-
66
- /* Subscribe pool info */
67
-
68
- /* Subscribe pool position */
69
-
70
- async subscribePoolPosition(useAddresses, resultCallback) {
71
- let cancel = false;
72
- const substrateApi = this.substrateApi;
73
- await substrateApi.isReady;
74
- const derivativeTokenSlug = this.derivativeAssets[0];
75
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
76
- const unsub = await substrateApi.api.query.tokens.accounts.multi(useAddresses.map(address => [address, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo)]), _balances => {
77
- if (cancel) {
78
- unsub();
79
- return;
80
- }
81
- const balances = _balances;
82
- for (let i = 0; i < balances.length; i++) {
83
- const balanceItem = balances[i];
84
- const address = useAddresses[i];
85
- const bnTotalBalance = balanceItem.free || _util.BN_ZERO;
86
- const totalBalance = bnTotalBalance.toString();
87
- const result = {
88
- ...this.defaultInfo,
89
- type: this.type,
90
- address,
91
- balanceToken: this.inputAsset,
92
- totalStake: totalBalance,
93
- activeStake: totalBalance,
94
- unstakeBalance: '0',
95
- status: _types.EarningStatus.EARNING_REWARD,
96
- derivativeToken: derivativeTokenSlug,
97
- isBondedBefore: bnTotalBalance.gt(_util.BN_ZERO),
98
- nominations: [],
99
- unstakings: []
100
- };
101
- resultCallback(result);
102
- }
103
- });
104
- return () => {
105
- cancel = true;
106
- unsub();
107
- };
108
- }
109
-
110
- /* Subscribe pool position */
111
-
112
- /* Join pool action */
113
-
114
- get submitJoinStepInfo() {
115
- return {
116
- name: 'Mint qDOT',
117
- type: _types.YieldStepType.MINT_QDOT
118
- };
119
- }
120
- async getSubmitStepFee(params) {
121
- const poolOriginSubstrateApi = await this.substrateApi.isReady;
122
- const inputTokenSlug = this.inputAsset;
123
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
124
- const defaultFeeTokenSlug = this.feeAssets[0];
125
- const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.loans.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), params.amount).paymentInfo(_constants.fakeAddress);
126
- const mintFeeInfo = _mintFeeInfo.toPrimitive();
127
- return {
128
- amount: mintFeeInfo.partialFee.toString(),
129
- slug: defaultFeeTokenSlug
130
- };
131
- }
132
- async handleSubmitStep(data, path) {
133
- const substrateApi = await this.substrateApi.isReady;
134
- const inputTokenSlug = this.inputAsset;
135
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
136
- const extrinsic = substrateApi.api.tx.loans.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), data.amount);
137
- return {
138
- txChain: this.chain,
139
- extrinsicType: _KoniTypes.ExtrinsicType.MINT_QDOT,
140
- extrinsic,
141
- txData: data,
142
- transferNativeAmount: '0'
143
- };
144
- }
145
-
146
- /* Join pool action */
147
-
148
- /* Leave pool action */
149
-
150
- async handleYieldRedeem(amount, address, selectedTarget) {
151
- const substrateApi = await this.substrateApi.isReady;
152
- // @ts-ignore
153
- const inputTokenSlug = this.inputAsset;
154
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
155
- const yieldPositionInfo = await this.getPoolPosition(address);
156
- if (!yieldPositionInfo) {
157
- return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS));
158
- }
159
- const bnAmount = new _bn.default(amount);
160
- const bnActiveBalance = new _bn.default(yieldPositionInfo.activeStake);
161
- const redeemAll = bnAmount.eq(bnActiveBalance);
162
- const extrinsic = !redeemAll ? substrateApi.api.tx.loans.redeem((0, _utils._getTokenOnChainInfo)(inputTokenInfo), amount) : substrateApi.api.tx.loans.redeemAll((0, _utils._getTokenOnChainInfo)(inputTokenInfo));
163
- return [_KoniTypes.ExtrinsicType.REDEEM_QDOT, extrinsic];
164
- }
165
-
166
- /* Leave pool action */
167
- }
168
- exports.default = InterlayLendingPoolHandler;