@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,196 +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 _utils = require("@subwallet/extension-base/services/chain-service/utils");
10
- var _constants = require("@subwallet/extension-base/services/earning-service/constants");
11
- var _types = require("@subwallet/extension-base/types");
12
- var _crossFetch = _interopRequireDefault(require("cross-fetch"));
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
- const GRAPHQL_API = 'https://api.polkawallet.io/acala-liquid-staking-subql';
19
- const EXCHANGE_RATE_REQUEST = 'query { dailySummaries(first:30, orderBy:TIMESTAMP_DESC) {nodes { exchangeRate timestamp }}}';
20
- class AcalaLiquidStakingPoolHandler extends _base.default {
21
- altInputAsset = 'polkadot-NATIVE-DOT';
22
- derivativeAssets = ['acala-LOCAL-LDOT'];
23
- inputAsset = 'acala-LOCAL-DOT';
24
- rewardAssets = ['acala-LOCAL-DOT'];
25
- feeAssets = ['acala-NATIVE-ACA', 'acala-LOCAL-DOT'];
26
- /** @inner */
27
- minAmountPercent = 0.98;
28
- /** @inner */
29
- allowDefaultUnstake = true;
30
- constructor(state, chain) {
31
- super(state, chain);
32
- const chainInfo = this.chainInfo;
33
- this.slug = `DOT___liquid_staking___${chain}`;
34
- this.name = `${chainInfo.name} Liquid Staking`;
35
- this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
36
- this.description = 'Stake DOT to earn yield on LDOT';
37
- }
38
-
39
- /* Subscribe pool info */
40
-
41
- async getPoolStat() {
42
- const substrateApi = await this.substrateApi.isReady;
43
- const stakingMetaPromise = new Promise(function (resolve) {
44
- (0, _crossFetch.default)(GRAPHQL_API, {
45
- method: 'POST',
46
- headers: {
47
- 'Content-Type': 'application/json'
48
- },
49
- body: JSON.stringify({
50
- query: EXCHANGE_RATE_REQUEST
51
- })
52
- }).then(res => {
53
- resolve(res.json());
54
- }).catch(console.error);
55
- });
56
- const [_toBondPool, _totalStakingBonded, _stakingMeta] = await Promise.all([substrateApi.api.query.homa.toBondPool(), substrateApi.api.query.homa.totalStakingBonded(), stakingMetaPromise]);
57
- const stakingMeta = _stakingMeta;
58
- const stakingMetaList = stakingMeta.data.dailySummaries.nodes;
59
- const latestExchangeRate = parseInt(stakingMetaList[0].exchangeRate);
60
- const decimals = 10 ** 10;
61
- const endingBalance = parseInt(stakingMetaList[0].exchangeRate);
62
- const beginBalance = parseInt(stakingMetaList[29].exchangeRate);
63
- const diff = endingBalance / beginBalance;
64
- const apy = diff ** (365 / 30) - 1;
65
- const toBondPool = new _util.BN(_toBondPool.toString());
66
- const totalStakingBonded = new _util.BN(_totalStakingBonded.toString());
67
- return {
68
- ...this.defaultInfo,
69
- description: this.description,
70
- type: this.type,
71
- metadata: {
72
- ...this.baseMetadata,
73
- isAvailable: true,
74
- allowCancelUnstaking: false,
75
- assetEarning: [{
76
- slug: this.rewardAssets[0],
77
- apy: apy * 100,
78
- exchangeRate: latestExchangeRate / decimals
79
- }],
80
- maxCandidatePerFarmer: 1,
81
- maxWithdrawalRequestPerFarmer: 1,
82
- minJoinPool: '50000000000',
83
- minWithdrawal: '50000000000',
84
- totalApy: apy * 100,
85
- tvl: totalStakingBonded.add(toBondPool).toString()
86
- }
87
- };
88
- }
89
-
90
- /* Subscribe pool info */
91
-
92
- /* Subscribe pool position */
93
-
94
- async subscribePoolPosition(useAddresses, resultCallback) {
95
- let cancel = false;
96
- const substrateApi = this.substrateApi;
97
- await substrateApi.isReady;
98
- const derivativeTokenSlug = this.derivativeAssets[0];
99
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
100
- const unsub = await substrateApi.api.query.tokens.accounts.multi(useAddresses.map(address => [address, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo)]), _balances => {
101
- if (cancel) {
102
- unsub();
103
- return;
104
- }
105
- const balances = _balances;
106
- for (let i = 0; i < balances.length; i++) {
107
- const balanceItem = balances[i];
108
- const address = useAddresses[i];
109
- const bnTotalBalance = balanceItem.free || _util.BN_ZERO;
110
- const totalBalance = bnTotalBalance.toString();
111
- const result = {
112
- ...this.defaultInfo,
113
- type: this.type,
114
- address,
115
- balanceToken: this.inputAsset,
116
- totalStake: totalBalance,
117
- activeStake: totalBalance,
118
- unstakeBalance: '0',
119
- status: _types.EarningStatus.EARNING_REWARD,
120
- derivativeToken: derivativeTokenSlug,
121
- isBondedBefore: bnTotalBalance.gt(_util.BN_ZERO),
122
- nominations: [],
123
- unstakings: []
124
- };
125
- resultCallback(result);
126
- }
127
- });
128
- return () => {
129
- cancel = true;
130
- unsub();
131
- };
132
- }
133
-
134
- /* Subscribe pool position */
135
-
136
- /* Join pool action */
137
-
138
- get submitJoinStepInfo() {
139
- return {
140
- name: 'Mint LDOT',
141
- type: _types.YieldStepType.MINT_LDOT
142
- };
143
- }
144
- async getSubmitStepFee(params) {
145
- const poolOriginSubstrateApi = await this.substrateApi.isReady;
146
- const defaultFeeTokenSlug = this.feeAssets[0];
147
- const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.homa.mint(params.amount).paymentInfo(_constants.fakeAddress);
148
- const mintFeeInfo = _mintFeeInfo.toPrimitive();
149
- return {
150
- amount: mintFeeInfo.partialFee.toString(),
151
- slug: defaultFeeTokenSlug
152
- };
153
- }
154
- async handleSubmitStep(data, path) {
155
- const substrateApi = await this.substrateApi.isReady;
156
- const extrinsic = substrateApi.api.tx.homa.mint(data.amount);
157
- return {
158
- txChain: this.chain,
159
- extrinsicType: _KoniTypes.ExtrinsicType.MINT_LDOT,
160
- extrinsic,
161
- txData: data,
162
- transferNativeAmount: '0'
163
- };
164
- }
165
-
166
- /* Join pool action */
167
-
168
- /* Leave pool action */
169
-
170
- async handleYieldRedeem(amount, address, selectedTarget) {
171
- const substrateApi = await this.substrateApi.isReady;
172
- const weightedMinAmount = await this.createParamToRedeem(amount, address);
173
- const extrinsic = substrateApi.api.tx.aggregatedDex.swapWithExactSupply(
174
- // Swap path
175
- [{
176
- Taiga: [0, /* pool id */
177
- 1, /* supply asset */
178
- 0 /* target asset */]
179
- }],
180
- // Supply amount
181
- amount,
182
- // Min target amount
183
- weightedMinAmount // should always set a min target to prevent unexpected result
184
- );
185
-
186
- return [_KoniTypes.ExtrinsicType.REDEEM_QDOT, extrinsic];
187
- }
188
- async handleYieldUnstake(amount, address, selectedTarget) {
189
- const chainApi = await this.substrateApi.isReady;
190
- const extrinsic = chainApi.api.tx.homa.requestRedeem(amount, false);
191
- return [_KoniTypes.ExtrinsicType.UNSTAKE_QDOT, extrinsic];
192
- }
193
-
194
- /* Leave pool action */
195
- }
196
- exports.default = AcalaLiquidStakingPoolHandler;
@@ -1,39 +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/koni/api/yield/helper/utils");
11
- var _types = require("@subwallet/extension-base/types");
12
- var _special = _interopRequireDefault(require("../special"));
13
- // Copyright 2019-2022 @subwallet/extension-base
14
- // SPDX-License-Identifier: Apache-2.0
15
-
16
- class BaseLiquidStakingPoolHandler extends _special.default {
17
- type = _types.YieldPoolType.LIQUID_STAKING;
18
- /** Rate convert token when redeem */
19
- minAmountPercent = 0.98;
20
-
21
- /* Leave pool action */
22
-
23
- async createParamToRedeem(amount, address) {
24
- const yieldPositionInfo = await this.getPoolPosition(address);
25
- const poolInfo = await this.getPoolInfo();
26
- const originTokenSlug = this.inputAsset;
27
- const derivativeTokenSlug = this.derivativeAssets[0];
28
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
29
- const originTokenInfo = this.state.getAssetBySlug(originTokenSlug);
30
- if (!yieldPositionInfo || !poolInfo) {
31
- return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS));
32
- }
33
- const formattedMinAmount = (0, _utils.convertDerivativeToOriginToken)(amount, poolInfo, derivativeTokenInfo, originTokenInfo);
34
- return Math.floor(this.minAmountPercent * formattedMinAmount);
35
- }
36
-
37
- /* Leave pool action */
38
- }
39
- exports.default = BaseLiquidStakingPoolHandler;
@@ -1,257 +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 _crossFetch = _interopRequireDefault(require("cross-fetch"));
15
- var _util = require("@polkadot/util");
16
- var _base = _interopRequireDefault(require("./base"));
17
- // Copyright 2019-2022 @subwallet/extension-base
18
- // SPDX-License-Identifier: Apache-2.0
19
-
20
- const STATS_URL = 'https://api.bifrost.app/api/site';
21
- const BIFROST_GRAPHQL_ENDPOINT = 'https://bifrost-subsql.liebi.com/v1/graphql';
22
- 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}}';
23
- class BifrostLiquidStakingPoolHandler extends _base.default {
24
- altInputAsset = 'polkadot-NATIVE-DOT';
25
- derivativeAssets = ['bifrost_dot-LOCAL-vDOT'];
26
- inputAsset = 'bifrost_dot-LOCAL-DOT';
27
- rewardAssets = ['bifrost_dot-LOCAL-DOT'];
28
- feeAssets = ['bifrost_dot-NATIVE-BNC', 'bifrost_dot-LOCAL-DOT'];
29
- /** @inner */
30
- minAmountPercent = 0.99;
31
- constructor(state, chain) {
32
- super(state, chain);
33
- const chainInfo = this.chainInfo;
34
- this.slug = `DOT___liquid_staking___${chain}`;
35
- this.name = `${chainInfo.name} Liquid Staking`;
36
- this.description = 'Stake DOT to earn yield on vDOT';
37
- this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
38
- }
39
-
40
- /* Subscribe pool info */
41
-
42
- async getPoolStat() {
43
- const stakingMetaPromise = new Promise(function (resolve) {
44
- (0, _crossFetch.default)(STATS_URL, {
45
- method: 'GET'
46
- }).then(res => {
47
- resolve(res.json());
48
- }).catch(console.error);
49
- });
50
- const exchangeRatePromise = new Promise(function (resolve) {
51
- (0, _crossFetch.default)(BIFROST_GRAPHQL_ENDPOINT, {
52
- method: 'POST',
53
- headers: {
54
- 'Content-Type': 'application/json'
55
- },
56
- body: JSON.stringify({
57
- query: BIFROST_EXCHANGE_RATE_REQUEST
58
- })
59
- }).then(resp => {
60
- resolve(resp.json());
61
- }).catch(console.error);
62
- });
63
- const [_stakingMeta, _exchangeRate] = await Promise.all([stakingMetaPromise, exchangeRatePromise]);
64
- const stakingMeta = _stakingMeta;
65
- const exchangeRate = _exchangeRate;
66
- const vDOTStats = stakingMeta.vDOT;
67
- const assetInfo = this.state.getAssetBySlug(this.inputAsset);
68
- const assetDecimals = 10 ** (0, _utils._getAssetDecimals)(assetInfo);
69
- return {
70
- ...this.defaultInfo,
71
- description: this.description,
72
- type: this.type,
73
- metadata: {
74
- ...this.baseMetadata,
75
- isAvailable: true,
76
- allowCancelUnstaking: false,
77
- assetEarning: [{
78
- slug: this.rewardAssets[0],
79
- apy: parseFloat(vDOTStats.apyBase),
80
- exchangeRate: parseFloat(exchangeRate.data.slp_polkadot_ratio[0].ratio)
81
- }],
82
- maxCandidatePerFarmer: 1,
83
- maxWithdrawalRequestPerFarmer: 1,
84
- minJoinPool: '5000000000',
85
- minWithdrawal: '4000000000',
86
- totalApy: parseFloat(vDOTStats.apyBase),
87
- tvl: (vDOTStats.tvm * assetDecimals).toString()
88
- }
89
- };
90
- }
91
-
92
- /* Subscribe pool info */
93
-
94
- /* Subscribe pool position */
95
-
96
- async subscribePoolPosition(useAddresses, resultCallback) {
97
- let cancel = false;
98
- const substrateApi = this.substrateApi;
99
- await substrateApi.isReady;
100
-
101
- // @ts-ignore
102
- const derivativeTokenSlug = this.derivativeAssets[0];
103
- const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
104
- const inputTokenSlug = this.inputAsset;
105
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
106
- const unsub = await substrateApi.api.query.tokens.accounts.multi(useAddresses.map(address => [address, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo)]), async _balance => {
107
- if (cancel) {
108
- unsub();
109
- return;
110
- }
111
- const balances = _balance;
112
- const [_unlockLedgerList, _currentRelayEra] = 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))]);
113
- const currentRelayEraObj = _currentRelayEra.toPrimitive();
114
- const currentRelayEra = currentRelayEraObj.Era;
115
- const unlockLedgerList = [];
116
- const activeBalanceMap = {};
117
- for (let i = 0; i < balances.length; i++) {
118
- const balanceItem = balances[i];
119
- const address = useAddresses[i];
120
- const formattedAddress = (0, _utils2.reformatAddress)(address);
121
- activeBalanceMap[formattedAddress] = balanceItem.free || _util.BN_ZERO;
122
- const _unlockLedger = _unlockLedgerList[i];
123
- const unlockLedger = _unlockLedger.toPrimitive();
124
- if (unlockLedger) {
125
- // @ts-ignore
126
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
127
- const unstakingLedgerIds = unlockLedger[1];
128
- unstakingLedgerIds.forEach(ledgerId => {
129
- unlockLedgerList.push({
130
- address: formattedAddress,
131
- ledgerId
132
- });
133
- });
134
- }
135
-
136
- // const bnTotalBalance = bnActiveBalance.add(bnUnstakingBalance);
137
- }
138
-
139
- const unlockingMap = {};
140
- const _unlockInfoList = await substrateApi.api.query.vtokenMinting.tokenUnlockLedger.multi(unlockLedgerList.map(_ref => {
141
- let {
142
- ledgerId
143
- } = _ref;
144
- return [(0, _utils._getTokenOnChainInfo)(inputTokenInfo), ledgerId];
145
- }));
146
- for (let i = 0; i < _unlockInfoList.length; i++) {
147
- const unlockInfo = _unlockInfoList[i].toPrimitive();
148
- const owner = (0, _utils2.reformatAddress)(unlockInfo[0]);
149
- const amount = unlockInfo[1].toString();
150
- // @ts-ignore
151
- const withdrawalEra = unlockInfo[2].era;
152
- if (owner in unlockingMap) {
153
- unlockingMap[owner].push({
154
- balance: amount,
155
- era: withdrawalEra
156
- });
157
- } else {
158
- unlockingMap[owner] = [{
159
- balance: amount,
160
- era: withdrawalEra
161
- }];
162
- }
163
- }
164
- const unstakingList = [];
165
- useAddresses.forEach(address => {
166
- const formattedAddress = (0, _utils2.reformatAddress)(address);
167
- const bnActiveBalance = activeBalanceMap[formattedAddress];
168
- const unlockings = unlockingMap[formattedAddress];
169
- let unlockBalance = _util.BN_ZERO;
170
- if (unlockings) {
171
- unlockings.forEach(unlocking => {
172
- const isClaimable = unlocking.era - currentRelayEra < 0;
173
- const remainingEra = unlocking.era - currentRelayEra;
174
- const waitingTime = remainingEra * _constants._STAKING_ERA_LENGTH_MAP[this.chain];
175
- unlockBalance = unlockBalance.add(new _util.BN(unlocking.balance));
176
- unstakingList.push({
177
- chain: this.chain,
178
- status: isClaimable ? _types.UnstakingStatus.CLAIMABLE : _types.UnstakingStatus.UNLOCKING,
179
- claimable: unlocking.balance,
180
- waitingTime: waitingTime
181
- });
182
- });
183
- }
184
- const totalBalance = bnActiveBalance.add(unlockBalance);
185
- const result = {
186
- ...this.defaultInfo,
187
- type: this.type,
188
- address,
189
- balanceToken: this.inputAsset,
190
- derivativeToken: derivativeTokenSlug,
191
- totalStake: totalBalance.toString(),
192
- activeStake: bnActiveBalance.toString(),
193
- unstakeBalance: unlockBalance.toString(),
194
- status: bnActiveBalance.eq(_util.BN_ZERO) ? _types.EarningStatus.NOT_EARNING : _types.EarningStatus.EARNING_REWARD,
195
- isBondedBefore: totalBalance.gt(_util.BN_ZERO),
196
- nominations: [],
197
- unstakings: unstakingList
198
- };
199
- resultCallback(result);
200
- });
201
- });
202
- return () => {
203
- cancel = true;
204
- unsub();
205
- };
206
- }
207
-
208
- /* Subscribe pool position */
209
-
210
- /* Join pool action */
211
-
212
- get submitJoinStepInfo() {
213
- return {
214
- name: 'Mint vDOT',
215
- type: _types.YieldStepType.MINT_VDOT
216
- };
217
- }
218
- async getSubmitStepFee(params) {
219
- const poolOriginSubstrateApi = await this.substrateApi.isReady;
220
- const inputTokenSlug = this.inputAsset;
221
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
222
- const defaultFeeTokenSlug = this.feeAssets[0];
223
- const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.vtokenMinting.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), params.amount, null).paymentInfo(_constants2.fakeAddress);
224
- const mintFeeInfo = _mintFeeInfo.toPrimitive();
225
- return {
226
- amount: mintFeeInfo.partialFee.toString(),
227
- slug: defaultFeeTokenSlug
228
- };
229
- }
230
- async handleSubmitStep(data, path) {
231
- const substrateApi = await this.substrateApi.isReady;
232
- const inputTokenSlug = this.inputAsset;
233
- const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
234
- const extrinsic = substrateApi.api.tx.vtokenMinting.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), data.amount, undefined);
235
- return {
236
- txChain: this.chain,
237
- extrinsicType: _KoniTypes.ExtrinsicType.MINT_VDOT,
238
- extrinsic,
239
- txData: data,
240
- transferNativeAmount: '0'
241
- };
242
- }
243
-
244
- /* Join pool action */
245
-
246
- /* Leave pool action */
247
-
248
- async handleYieldRedeem(amount, address, selectedTarget) {
249
- const substrateApi = await this.substrateApi.isReady;
250
- const weightedMinAmount = await this.createParamToRedeem(amount, address);
251
- const extrinsic = substrateApi.api.tx.stablePool.swap(0, 1, 0, amount, weightedMinAmount);
252
- return [_KoniTypes.ExtrinsicType.REDEEM_VDOT, extrinsic];
253
- }
254
-
255
- /* Leave pool action */
256
- }
257
- 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"));