@subwallet/extension-base 1.1.34-0 → 1.1.35-beta.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 (325) hide show
  1. package/background/KoniTypes.d.ts +111 -69
  2. package/background/KoniTypes.js +19 -13
  3. package/background/errors/TransactionError.js +9 -0
  4. package/cjs/background/KoniTypes.js +20 -16
  5. package/cjs/background/errors/TransactionError.js +9 -0
  6. package/cjs/constants/index.js +19 -4
  7. package/cjs/constants/staking.js +1 -1
  8. package/cjs/koni/api/dotsama/balance.js +464 -0
  9. package/cjs/koni/api/nft/config.js +33 -23
  10. package/cjs/koni/api/nft/index.js +14 -0
  11. package/cjs/koni/api/nft/nft.js +1 -22
  12. package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
  13. package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
  14. package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
  15. package/cjs/koni/api/staking/bonding/amplitude.js +19 -16
  16. package/cjs/koni/api/staking/bonding/astar.js +11 -10
  17. package/cjs/koni/api/staking/bonding/index.js +4 -1
  18. package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
  19. package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
  20. package/cjs/koni/api/staking/bonding/utils.js +104 -86
  21. package/cjs/koni/api/staking/index.js +6 -5
  22. package/cjs/koni/api/staking/paraChain.js +6 -5
  23. package/cjs/koni/api/staking/relayChain.js +3 -2
  24. package/cjs/koni/api/yield/helper/utils.js +46 -0
  25. package/cjs/koni/background/cron.js +3 -21
  26. package/cjs/koni/background/handlers/Extension.js +368 -69
  27. package/cjs/koni/background/handlers/State.js +18 -12
  28. package/cjs/koni/background/handlers/index.js +4 -2
  29. package/cjs/koni/background/subscription.js +7 -104
  30. package/cjs/packageInfo.js +1 -1
  31. package/cjs/services/campaign-service/index.js +9 -6
  32. package/cjs/services/chain-service/constants.js +2 -17
  33. package/cjs/services/chain-service/index.js +50 -3
  34. package/cjs/services/chain-service/utils.js +7 -1
  35. package/cjs/services/earning-service/constants/chains.js +30 -0
  36. package/cjs/services/earning-service/constants/index.js +27 -0
  37. package/cjs/services/earning-service/constants/step.js +18 -0
  38. package/cjs/services/earning-service/handlers/base.js +262 -0
  39. package/cjs/services/earning-service/handlers/index.js +60 -0
  40. package/cjs/services/earning-service/handlers/lending/base.js +81 -0
  41. package/cjs/services/earning-service/handlers/lending/index.js +13 -0
  42. package/cjs/services/earning-service/handlers/lending/interlay.js +192 -0
  43. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +240 -0
  44. package/cjs/services/earning-service/handlers/liquid-staking/base.js +97 -0
  45. package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
  46. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +298 -0
  47. package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
  48. package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +227 -0
  49. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +404 -0
  50. package/cjs/services/earning-service/handlers/native-staking/amplitude.js +434 -0
  51. package/cjs/services/earning-service/handlers/native-staking/astar.js +466 -0
  52. package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
  53. package/cjs/services/earning-service/handlers/native-staking/base.js +161 -0
  54. package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
  55. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +390 -0
  56. package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +567 -0
  57. package/cjs/services/earning-service/handlers/nomination-pool/index.js +566 -0
  58. package/cjs/services/earning-service/handlers/special.js +493 -0
  59. package/cjs/services/earning-service/service.js +733 -0
  60. package/cjs/services/earning-service/utils/index.js +128 -0
  61. package/cjs/services/event-service/index.js +5 -0
  62. package/cjs/services/keyring-service/index.js +14 -2
  63. package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
  64. package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
  65. package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
  66. package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  67. package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
  68. package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
  69. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  70. package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
  71. package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
  72. package/cjs/services/migration-service/scripts/index.js +6 -1
  73. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
  74. package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
  75. package/cjs/services/mint-campaign-service/constants.js +11 -0
  76. package/cjs/services/mint-campaign-service/index.js +18 -0
  77. package/cjs/services/notification-service/NotificationService.js +3 -2
  78. package/cjs/services/request-service/handler/PopupHandler.js +2 -3
  79. package/cjs/services/storage-service/DatabaseService.js +97 -0
  80. package/cjs/services/storage-service/databases/index.js +4 -0
  81. package/cjs/services/storage-service/db-stores/AssetRef.js +24 -0
  82. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  83. package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
  84. package/cjs/services/storage-service/db-stores/YieldPositionStore.js +71 -0
  85. package/cjs/services/storage-service/index.js +241 -0
  86. package/cjs/services/subscan-service/index.js +16 -0
  87. package/cjs/services/transaction-service/event-parser/index.js +58 -0
  88. package/cjs/services/transaction-service/helpers/index.js +3 -1
  89. package/cjs/services/transaction-service/index.js +249 -75
  90. package/cjs/services/transaction-service/utils.js +1 -0
  91. package/cjs/types/campaigns/index.js +16 -0
  92. package/cjs/types/campaigns/unlock-dot.js +1 -0
  93. package/cjs/types/index.js +44 -0
  94. package/cjs/types/ordinal.js +1 -0
  95. package/cjs/types/transaction.js +1 -0
  96. package/cjs/types/yield/actions/index.js +27 -0
  97. package/cjs/types/yield/actions/join/index.js +38 -0
  98. package/cjs/types/yield/actions/join/step.js +47 -0
  99. package/cjs/types/yield/actions/join/submit.js +1 -0
  100. package/cjs/types/yield/actions/join/validate.js +16 -0
  101. package/cjs/types/yield/actions/others.js +1 -0
  102. package/cjs/types/yield/index.js +27 -0
  103. package/cjs/types/yield/info/account/index.js +49 -0
  104. package/cjs/types/yield/info/account/info.js +1 -0
  105. package/cjs/types/yield/info/account/reward.js +1 -0
  106. package/cjs/types/yield/info/account/target.js +32 -0
  107. package/cjs/types/yield/info/account/unstake.js +27 -0
  108. package/cjs/types/yield/info/base.js +41 -0
  109. package/cjs/types/yield/info/chain/index.js +27 -0
  110. package/cjs/types/yield/info/chain/info.js +1 -0
  111. package/cjs/types/yield/info/chain/target.js +1 -0
  112. package/cjs/types/yield/info/index.js +49 -0
  113. package/cjs/types/yield/info/pallet.js +15 -0
  114. package/cjs/types.js +1 -0
  115. package/cjs/utils/address.js +34 -0
  116. package/cjs/utils/environment.js +23 -28
  117. package/cjs/utils/fetchStaticCache.js +22 -0
  118. package/cjs/utils/fetchStaticData.js +2 -1
  119. package/cjs/utils/index.js +94 -10
  120. package/cjs/utils/keyring.js +57 -0
  121. package/cjs/utils/mv3.js +14 -0
  122. package/cjs/utils/number.js +6 -2
  123. package/cjs/utils/object.js +12 -0
  124. package/constants/index.d.ts +6 -1
  125. package/constants/index.js +6 -1
  126. package/constants/staking.js +1 -1
  127. package/koni/api/nft/config.js +33 -23
  128. package/koni/api/nft/index.js +15 -1
  129. package/koni/api/nft/nft.js +2 -23
  130. package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
  131. package/koni/api/nft/ordinal_nft/constants.js +12 -0
  132. package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
  133. package/koni/api/nft/ordinal_nft/index.js +114 -0
  134. package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
  135. package/koni/api/nft/ordinal_nft/utils.js +33 -0
  136. package/koni/api/staking/bonding/amplitude.js +13 -10
  137. package/koni/api/staking/bonding/astar.js +9 -8
  138. package/koni/api/staking/bonding/index.d.ts +1 -1
  139. package/koni/api/staking/bonding/index.js +5 -1
  140. package/koni/api/staking/bonding/paraChain.js +12 -10
  141. package/koni/api/staking/bonding/relayChain.d.ts +2 -2
  142. package/koni/api/staking/bonding/relayChain.js +33 -30
  143. package/koni/api/staking/bonding/utils.d.ts +15 -38
  144. package/koni/api/staking/bonding/utils.js +85 -69
  145. package/koni/api/staking/index.js +2 -1
  146. package/koni/api/staking/paraChain.js +7 -6
  147. package/koni/api/staking/relayChain.js +4 -3
  148. package/koni/api/yield/helper/utils.d.ts +10 -0
  149. package/koni/api/yield/helper/utils.js +32 -0
  150. package/koni/background/cron.d.ts +0 -4
  151. package/koni/background/cron.js +4 -22
  152. package/koni/background/handlers/Extension.d.ts +17 -1
  153. package/koni/background/handlers/Extension.js +327 -30
  154. package/koni/background/handlers/State.d.ts +6 -1
  155. package/koni/background/handlers/State.js +17 -12
  156. package/koni/background/handlers/index.js +4 -2
  157. package/koni/background/subscription.d.ts +1 -6
  158. package/koni/background/subscription.js +8 -104
  159. package/package.json +335 -7
  160. package/packageInfo.js +1 -1
  161. package/services/campaign-service/index.js +9 -6
  162. package/services/chain-service/constants.d.ts +1 -13
  163. package/services/chain-service/constants.js +1 -15
  164. package/services/chain-service/index.d.ts +3 -0
  165. package/services/chain-service/index.js +50 -3
  166. package/services/chain-service/utils.d.ts +1 -0
  167. package/services/chain-service/utils.js +5 -1
  168. package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
  169. package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
  170. package/services/earning-service/constants/chains.d.ts +15 -0
  171. package/services/earning-service/constants/chains.js +22 -0
  172. package/services/earning-service/constants/index.d.ts +2 -0
  173. package/services/earning-service/constants/index.js +5 -0
  174. package/services/earning-service/constants/step.d.ts +3 -0
  175. package/services/earning-service/constants/step.js +10 -0
  176. package/services/earning-service/handlers/base.d.ts +113 -0
  177. package/services/earning-service/handlers/base.js +256 -0
  178. package/services/earning-service/handlers/index.d.ts +5 -0
  179. package/services/earning-service/handlers/index.js +8 -0
  180. package/services/earning-service/handlers/lending/base.d.ts +8 -0
  181. package/services/earning-service/handlers/lending/base.js +73 -0
  182. package/services/earning-service/handlers/lending/index.d.ts +1 -0
  183. package/services/earning-service/handlers/lending/index.js +4 -0
  184. package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
  185. package/services/earning-service/handlers/lending/interlay.js +184 -0
  186. package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
  187. package/services/earning-service/handlers/liquid-staking/acala.js +232 -0
  188. package/services/earning-service/handlers/liquid-staking/base.d.ts +11 -0
  189. package/services/earning-service/handlers/liquid-staking/base.js +89 -0
  190. package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
  191. package/services/earning-service/handlers/liquid-staking/bifrost.js +287 -0
  192. package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
  193. package/services/earning-service/handlers/liquid-staking/index.js +7 -0
  194. package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
  195. package/services/earning-service/handlers/liquid-staking/parallel.js +219 -0
  196. package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
  197. package/services/earning-service/handlers/liquid-staking/stella-swap.js +394 -0
  198. package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
  199. package/services/earning-service/handlers/native-staking/amplitude.js +425 -0
  200. package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
  201. package/services/earning-service/handlers/native-staking/astar.js +456 -0
  202. package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
  203. package/services/earning-service/handlers/native-staking/base-para.js +138 -0
  204. package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
  205. package/services/earning-service/handlers/native-staking/base.js +152 -0
  206. package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
  207. package/services/earning-service/handlers/native-staking/index.js +7 -0
  208. package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
  209. package/services/earning-service/handlers/native-staking/para-chain.js +382 -0
  210. package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
  211. package/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
  212. package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
  213. package/services/earning-service/handlers/nomination-pool/index.js +556 -0
  214. package/services/earning-service/handlers/special.d.ts +64 -0
  215. package/services/earning-service/handlers/special.js +485 -0
  216. package/services/earning-service/service.d.ts +94 -0
  217. package/services/earning-service/service.js +722 -0
  218. package/services/earning-service/utils/index.d.ts +18 -0
  219. package/services/earning-service/utils/index.js +112 -0
  220. package/services/event-service/index.d.ts +2 -0
  221. package/services/event-service/index.js +5 -0
  222. package/services/event-service/types.d.ts +9 -0
  223. package/services/keyring-service/index.d.ts +2 -1
  224. package/services/keyring-service/index.js +14 -2
  225. package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
  226. package/services/migration-service/scripts/DeleteEarningData.js +13 -0
  227. package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
  228. package/services/migration-service/scripts/EnableEarningChains.js +13 -0
  229. package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
  230. package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
  231. package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
  232. package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
  233. package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
  234. package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
  235. package/services/migration-service/scripts/index.js +6 -1
  236. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
  237. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
  238. package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
  239. package/services/mint-campaign-service/campaigns/index.js +4 -0
  240. package/services/mint-campaign-service/constants.d.ts +1 -0
  241. package/services/mint-campaign-service/constants.js +4 -0
  242. package/services/mint-campaign-service/index.d.ts +7 -0
  243. package/services/mint-campaign-service/index.js +11 -0
  244. package/services/notification-service/NotificationService.js +3 -2
  245. package/services/request-service/handler/PopupHandler.js +3 -4
  246. package/services/storage-service/DatabaseService.d.ts +22 -1
  247. package/services/storage-service/DatabaseService.js +97 -0
  248. package/services/storage-service/databases/index.d.ts +7 -2
  249. package/services/storage-service/databases/index.js +4 -0
  250. package/services/storage-service/db-stores/AssetRef.d.ts +7 -0
  251. package/services/storage-service/db-stores/AssetRef.js +16 -0
  252. package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
  253. package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
  254. package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
  255. package/services/storage-service/db-stores/YieldPositionStore.d.ts +11 -0
  256. package/services/storage-service/db-stores/YieldPositionStore.js +63 -0
  257. package/services/subscan-service/index.d.ts +3 -2
  258. package/services/subscan-service/index.js +15 -0
  259. package/services/subscan-service/types.d.ts +20 -0
  260. package/services/transaction-service/event-parser/index.d.ts +3 -1
  261. package/services/transaction-service/event-parser/index.js +57 -1
  262. package/services/transaction-service/helpers/index.js +3 -1
  263. package/services/transaction-service/index.d.ts +6 -13
  264. package/services/transaction-service/index.js +247 -73
  265. package/services/transaction-service/types.d.ts +2 -0
  266. package/services/transaction-service/utils.js +1 -0
  267. package/types/campaigns/index.d.ts +1 -0
  268. package/types/campaigns/index.js +4 -0
  269. package/types/campaigns/unlock-dot.d.ts +71 -0
  270. package/types/campaigns/unlock-dot.js +1 -0
  271. package/types/index.d.ts +5 -0
  272. package/types/index.js +5 -1
  273. package/types/ordinal.d.ts +69 -0
  274. package/types/ordinal.js +1 -0
  275. package/types/transaction.d.ts +3 -0
  276. package/types/transaction.js +1 -0
  277. package/types/yield/actions/index.d.ts +2 -0
  278. package/types/yield/actions/index.js +5 -0
  279. package/types/yield/actions/join/index.d.ts +3 -0
  280. package/types/yield/actions/join/index.js +6 -0
  281. package/types/yield/actions/join/step.d.ts +95 -0
  282. package/types/yield/actions/join/step.js +46 -0
  283. package/types/yield/actions/join/submit.d.ts +58 -0
  284. package/types/yield/actions/join/submit.js +1 -0
  285. package/types/yield/actions/join/validate.d.ts +18 -0
  286. package/types/yield/actions/join/validate.js +10 -0
  287. package/types/yield/actions/others.d.ts +85 -0
  288. package/types/yield/actions/others.js +1 -0
  289. package/types/yield/index.d.ts +2 -0
  290. package/types/yield/index.js +5 -0
  291. package/types/yield/info/account/index.d.ts +4 -0
  292. package/types/yield/info/account/index.js +7 -0
  293. package/types/yield/info/account/info.d.ts +92 -0
  294. package/types/yield/info/account/info.js +1 -0
  295. package/types/yield/info/account/reward.d.ts +47 -0
  296. package/types/yield/info/account/reward.js +1 -0
  297. package/types/yield/info/account/target.d.ts +43 -0
  298. package/types/yield/info/account/target.js +27 -0
  299. package/types/yield/info/account/unstake.d.ts +31 -0
  300. package/types/yield/info/account/unstake.js +22 -0
  301. package/types/yield/info/base.d.ts +45 -0
  302. package/types/yield/info/base.js +36 -0
  303. package/types/yield/info/chain/index.d.ts +2 -0
  304. package/types/yield/info/chain/index.js +5 -0
  305. package/types/yield/info/chain/info.d.ts +252 -0
  306. package/types/yield/info/chain/info.js +1 -0
  307. package/types/yield/info/chain/target.d.ts +37 -0
  308. package/types/yield/info/chain/target.js +1 -0
  309. package/types/yield/info/index.d.ts +4 -0
  310. package/types/yield/info/index.js +7 -0
  311. package/types/yield/info/pallet.d.ts +143 -0
  312. package/types/yield/info/pallet.js +9 -0
  313. package/utils/environment.d.ts +9 -2
  314. package/utils/environment.js +14 -26
  315. package/utils/fetchStaticCache.d.ts +1 -0
  316. package/utils/fetchStaticCache.js +14 -0
  317. package/utils/fetchStaticData.js +2 -1
  318. package/utils/index.d.ts +5 -1
  319. package/utils/index.js +53 -3
  320. package/utils/mv3.d.ts +2 -0
  321. package/utils/mv3.js +6 -0
  322. package/utils/number.d.ts +2 -1
  323. package/utils/number.js +2 -1
  324. package/utils/object.d.ts +1 -0
  325. package/utils/object.js +6 -0
@@ -0,0 +1,287 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
5
+ import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
6
+ import { _getAssetDecimals, _getTokenOnChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
7
+ import { fakeAddress } from '@subwallet/extension-base/services/earning-service/constants';
8
+ import { EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
9
+ import { reformatAddress } from '@subwallet/extension-base/utils';
10
+ import BigNumber from 'bignumber.js';
11
+ import fetch from 'cross-fetch';
12
+ import { BN, BN_ZERO } from '@polkadot/util';
13
+ import BaseLiquidStakingPoolHandler from "./base.js";
14
+ const STATS_URL = 'https://api.bifrost.app/api/site';
15
+ const BIFROST_GRAPHQL_ENDPOINT = 'https://bifrost-subsql.liebi.com/v1/graphql';
16
+ 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}}';
17
+ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
18
+ altInputAsset = 'polkadot-NATIVE-DOT';
19
+ derivativeAssets = ['bifrost_dot-LOCAL-vDOT'];
20
+ inputAsset = 'bifrost_dot-LOCAL-DOT';
21
+ rewardAssets = ['bifrost_dot-LOCAL-DOT'];
22
+ feeAssets = ['bifrost_dot-NATIVE-BNC', 'bifrost_dot-LOCAL-DOT'];
23
+ minAmountPercent = 0.99;
24
+ availableMethod = {
25
+ join: true,
26
+ defaultUnstake: true,
27
+ fastUnstake: true,
28
+ cancelUnstake: false,
29
+ withdraw: false,
30
+ claimReward: false
31
+ };
32
+ rateDecimals = 0;
33
+ constructor(state, chain) {
34
+ super(state, chain);
35
+ const chainInfo = this.chainInfo;
36
+ this.slug = `DOT___liquid_staking___${chain}`;
37
+ this.name = `${chainInfo.name} Liquid Staking`;
38
+ this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
39
+ }
40
+ getDescription() {
41
+ return 'Stake DOT to earn yield on vDOT';
42
+ }
43
+
44
+ /* Subscribe pool info */
45
+
46
+ async getPoolStat() {
47
+ const substrateApi = await this.substrateApi.isReady;
48
+ const stakingMetaPromise = new Promise(function (resolve) {
49
+ fetch(STATS_URL, {
50
+ method: 'GET'
51
+ }).then(res => {
52
+ resolve(res.json());
53
+ }).catch(console.error);
54
+ });
55
+ const exchangeRatePromise = new Promise(function (resolve) {
56
+ fetch(BIFROST_GRAPHQL_ENDPOINT, {
57
+ method: 'POST',
58
+ headers: {
59
+ 'Content-Type': 'application/json'
60
+ },
61
+ body: JSON.stringify({
62
+ query: BIFROST_EXCHANGE_RATE_REQUEST
63
+ })
64
+ }).then(resp => {
65
+ resolve(resp.json());
66
+ }).catch(console.error);
67
+ });
68
+ const derivativeTokenInfo = this.state.getAssetBySlug(this.derivativeAssets[0]);
69
+ const inputTokenInfo = this.state.getAssetBySlug(this.inputAsset);
70
+ const [_stakingMeta, _exchangeRate, _minimumRedeem, _minimumMint] = await Promise.all([stakingMetaPromise, exchangeRatePromise, substrateApi.api.query.vtokenMinting.minimumRedeem(_getTokenOnChainInfo(derivativeTokenInfo)), substrateApi.api.query.vtokenMinting.minimumMint(_getTokenOnChainInfo(inputTokenInfo))]);
71
+ const minimumRedeem = _minimumRedeem.toString();
72
+ const minimumMint = _minimumMint.toString();
73
+ const stakingMeta = _stakingMeta;
74
+ const exchangeRate = _exchangeRate;
75
+ const vDOTStats = stakingMeta.vDOT;
76
+ const assetInfo = this.state.getAssetBySlug(this.inputAsset);
77
+ const assetDecimals = 10 ** _getAssetDecimals(assetInfo);
78
+ const rate = parseFloat(exchangeRate.data.slp_polkadot_ratio[0].ratio);
79
+ this.updateExchangeRate(rate);
80
+ return {
81
+ ...this.baseInfo,
82
+ type: this.type,
83
+ metadata: {
84
+ ...this.metadataInfo,
85
+ description: this.getDescription()
86
+ },
87
+ statistic: {
88
+ assetEarning: [{
89
+ slug: this.rewardAssets[0],
90
+ apy: parseFloat(vDOTStats.apyBase),
91
+ exchangeRate: rate
92
+ }],
93
+ unstakingPeriod: 24 * 28,
94
+ maxCandidatePerFarmer: 1,
95
+ maxWithdrawalRequestPerFarmer: 1,
96
+ earningThreshold: {
97
+ join: minimumMint,
98
+ defaultUnstake: minimumRedeem,
99
+ fastUnstake: '0'
100
+ },
101
+ totalApy: parseFloat(vDOTStats.apyBase),
102
+ tvl: (vDOTStats.tvm * assetDecimals).toString()
103
+ }
104
+ };
105
+ }
106
+
107
+ /* Subscribe pool info */
108
+
109
+ /* Subscribe pool position */
110
+
111
+ async subscribePoolPosition(useAddresses, resultCallback) {
112
+ let cancel = false;
113
+ const substrateApi = this.substrateApi;
114
+ await substrateApi.isReady;
115
+
116
+ // @ts-ignore
117
+ const derivativeTokenSlug = this.derivativeAssets[0];
118
+ const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
119
+ const inputTokenSlug = this.inputAsset;
120
+ const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
121
+ const unsub = await substrateApi.api.query.tokens.accounts.multi(useAddresses.map(address => [address, _getTokenOnChainInfo(derivativeTokenInfo)]), async _balance => {
122
+ if (cancel) {
123
+ unsub();
124
+ return;
125
+ }
126
+ const balances = _balance;
127
+ const [_unlockLedgerList, _currentRelayEra, rate] = await Promise.all([substrateApi.api.query.vtokenMinting.userUnlockLedger.multi(useAddresses.map(address => [address, _getTokenOnChainInfo(inputTokenInfo)])), substrateApi.api.query.vtokenMinting.ongoingTimeUnit(_getTokenOnChainInfo(inputTokenInfo)), this.getExchangeRate()]);
128
+ const exchangeRate = new BigNumber(rate);
129
+ const currentRelayEraObj = _currentRelayEra.toPrimitive();
130
+ const currentRelayEra = currentRelayEraObj.Era;
131
+ const unlockLedgerList = [];
132
+ const activeBalanceMap = {};
133
+ for (let i = 0; i < balances.length; i++) {
134
+ const balanceItem = balances[i];
135
+ const address = useAddresses[i];
136
+ const formattedAddress = reformatAddress(address);
137
+ activeBalanceMap[formattedAddress] = balanceItem.free || BN_ZERO;
138
+ const _unlockLedger = _unlockLedgerList[i];
139
+ const unlockLedger = _unlockLedger.toPrimitive();
140
+ if (unlockLedger) {
141
+ // @ts-ignore
142
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
143
+ const unstakingLedgerIds = unlockLedger[1];
144
+ unstakingLedgerIds.forEach(ledgerId => {
145
+ unlockLedgerList.push({
146
+ address: formattedAddress,
147
+ ledgerId
148
+ });
149
+ });
150
+ }
151
+
152
+ // const bnTotalBalance = bnActiveBalance.add(bnUnstakingBalance);
153
+ }
154
+
155
+ const unlockingMap = {};
156
+
157
+ // TODO: review unstaking info vtokenMinting.userUnlockLedger
158
+ const _unlockInfoList = await substrateApi.api.query.vtokenMinting.tokenUnlockLedger.multi(unlockLedgerList.map(({
159
+ ledgerId
160
+ }) => [_getTokenOnChainInfo(inputTokenInfo), ledgerId]));
161
+ for (let i = 0; i < _unlockInfoList.length; i++) {
162
+ const unlockInfo = _unlockInfoList[i].toPrimitive();
163
+ const owner = reformatAddress(unlockInfo[0]);
164
+ const amount = unlockInfo[1].toString();
165
+ // @ts-ignore
166
+ const withdrawalEra = unlockInfo[2].era;
167
+ if (owner in unlockingMap) {
168
+ unlockingMap[owner].push({
169
+ balance: amount,
170
+ era: withdrawalEra
171
+ });
172
+ } else {
173
+ unlockingMap[owner] = [{
174
+ balance: amount,
175
+ era: withdrawalEra
176
+ }];
177
+ }
178
+ }
179
+ const unstakingList = [];
180
+ useAddresses.forEach(address => {
181
+ const formattedAddress = reformatAddress(address);
182
+ const bnActiveBalance = activeBalanceMap[formattedAddress];
183
+ const unlockings = unlockingMap[formattedAddress];
184
+ let unlockBalance = BN_ZERO;
185
+ if (unlockings) {
186
+ unlockings.forEach(unlocking => {
187
+ const isClaimable = unlocking.era - currentRelayEra < 0;
188
+ const remainingEra = unlocking.era - currentRelayEra;
189
+ const waitingTime = remainingEra * _STAKING_ERA_LENGTH_MAP[this.chain];
190
+ unlockBalance = unlockBalance.add(new BN(unlocking.balance));
191
+ unstakingList.push({
192
+ chain: this.chain,
193
+ status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
194
+ claimable: unlocking.balance,
195
+ waitingTime: waitingTime
196
+ });
197
+ });
198
+ }
199
+ const activeToTotalBalance = exchangeRate.multipliedBy(bnActiveBalance.toString());
200
+ const totalBalance = activeToTotalBalance.plus(unlockBalance.toString());
201
+ const result = {
202
+ ...this.baseInfo,
203
+ type: this.type,
204
+ address,
205
+ balanceToken: this.inputAsset,
206
+ derivativeToken: derivativeTokenSlug,
207
+ totalStake: totalBalance.toString(),
208
+ activeStake: bnActiveBalance.toString(),
209
+ unstakeBalance: unlockBalance.toString(),
210
+ status: bnActiveBalance.gt(BN_ZERO) ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING,
211
+ isBondedBefore: totalBalance.gt(BN_ZERO.toString()),
212
+ nominations: [],
213
+ unstakings: unstakingList
214
+ };
215
+ resultCallback(result);
216
+ });
217
+ });
218
+ return () => {
219
+ cancel = true;
220
+ unsub();
221
+ };
222
+ }
223
+
224
+ /* Subscribe pool position */
225
+
226
+ /* Join pool action */
227
+
228
+ get submitJoinStepInfo() {
229
+ return {
230
+ name: 'Mint vDOT',
231
+ type: YieldStepType.MINT_VDOT
232
+ };
233
+ }
234
+ async getSubmitStepFee(params) {
235
+ const poolOriginSubstrateApi = await this.substrateApi.isReady;
236
+ const inputTokenSlug = this.inputAsset;
237
+ const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
238
+ const defaultFeeTokenSlug = this.feeAssets[0];
239
+ if (new BN(params.amount).gt(BN_ZERO)) {
240
+ const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), params.amount, undefined, undefined).paymentInfo(fakeAddress);
241
+ const mintFeeInfo = _mintFeeInfo.toPrimitive();
242
+ return {
243
+ amount: mintFeeInfo.partialFee.toString(),
244
+ slug: defaultFeeTokenSlug
245
+ };
246
+ } else {
247
+ return {
248
+ amount: '0',
249
+ slug: defaultFeeTokenSlug
250
+ };
251
+ }
252
+ }
253
+ async handleSubmitStep(data, path) {
254
+ const substrateApi = await this.substrateApi.isReady;
255
+ const inputTokenSlug = this.inputAsset;
256
+ const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
257
+ const extrinsic = substrateApi.api.tx.vtokenMinting.mint(_getTokenOnChainInfo(inputTokenInfo), data.amount, undefined, undefined);
258
+ return {
259
+ txChain: this.chain,
260
+ extrinsicType: ExtrinsicType.MINT_VDOT,
261
+ extrinsic,
262
+ txData: data,
263
+ transferNativeAmount: '0',
264
+ chainType: ChainType.SUBSTRATE
265
+ };
266
+ }
267
+
268
+ /* Join pool action */
269
+
270
+ /* Leave pool action */
271
+
272
+ async handleYieldRedeem(amount, address, selectedTarget) {
273
+ const substrateApi = await this.substrateApi.isReady;
274
+ const weightedMinAmount = await this.createParamToRedeem(amount, address);
275
+ const extrinsic = substrateApi.api.tx.stablePool.swap(0, 1, 0, amount, weightedMinAmount);
276
+ return [ExtrinsicType.REDEEM_VDOT, extrinsic];
277
+ }
278
+ async handleYieldUnstake(amount, address, selectedTarget) {
279
+ const chainApi = await this.substrateApi.isReady;
280
+ const derivativeTokenSlug = this.derivativeAssets[0];
281
+ const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
282
+ const extrinsic = chainApi.api.tx.vtokenMinting.redeem(_getTokenOnChainInfo(derivativeTokenInfo), amount);
283
+ return [ExtrinsicType.UNSTAKE_VDOT, extrinsic];
284
+ }
285
+
286
+ /* Leave pool action */
287
+ }
@@ -0,0 +1,4 @@
1
+ export { default as AcalaLiquidStakingPoolHandler } from './acala';
2
+ export { default as BifrostLiquidStakingPoolHandler } from './bifrost';
3
+ export { default as ParallelLiquidStakingPoolHandler } from './parallel';
4
+ export { default as StellaSwapLiquidStakingPoolHandler } from './stella-swap';
@@ -0,0 +1,7 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { default as AcalaLiquidStakingPoolHandler } from "./acala.js";
5
+ export { default as BifrostLiquidStakingPoolHandler } from "./bifrost.js";
6
+ export { default as ParallelLiquidStakingPoolHandler } from "./parallel.js";
7
+ export { default as StellaSwapLiquidStakingPoolHandler } from "./stella-swap.js";
@@ -0,0 +1,26 @@
1
+ import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
2
+ import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
3
+ import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPoolMethodInfo, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
4
+ import BaseLiquidStakingPoolHandler from './base';
5
+ export default class ParallelLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
6
+ slug: string;
7
+ protected readonly name: string;
8
+ protected readonly shortName: string;
9
+ protected readonly altInputAsset: string;
10
+ protected readonly derivativeAssets: string[];
11
+ protected readonly inputAsset: string;
12
+ protected readonly rewardAssets: string[];
13
+ protected readonly feeAssets: string[];
14
+ readonly minAmountPercent = 0.97;
15
+ protected readonly rateDecimals = 18;
16
+ protected readonly availableMethod: YieldPoolMethodInfo;
17
+ constructor(state: KoniState, chain: string);
18
+ protected getDescription(): string;
19
+ getPoolStat(): Promise<LiquidYieldPoolInfo>;
20
+ subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
21
+ get submitJoinStepInfo(): BaseYieldStepDetail;
22
+ getSubmitStepFee(params: OptimalYieldPathParams): Promise<YieldTokenBaseInfo>;
23
+ handleSubmitStep(data: SubmitYieldJoinData, path: OptimalYieldPath): Promise<HandleYieldStepData>;
24
+ handleYieldRedeem(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
25
+ handleYieldUnstake(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
26
+ }
@@ -0,0 +1,219 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
5
+ import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
6
+ import { _getTokenOnChainAssetId } from '@subwallet/extension-base/services/chain-service/utils';
7
+ import { fakeAddress } from '@subwallet/extension-base/services/earning-service/constants';
8
+ import { EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
9
+ import { BN, BN_TEN, BN_ZERO } from '@polkadot/util';
10
+ import BaseLiquidStakingPoolHandler from "./base.js";
11
+ export default class ParallelLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
12
+ altInputAsset = 'polkadot-NATIVE-DOT';
13
+ derivativeAssets = ['parallel-LOCAL-sDOT'];
14
+ inputAsset = 'parallel-LOCAL-DOT';
15
+ rewardAssets = ['parallel-LOCAL-DOT'];
16
+ feeAssets = ['parallel-NATIVE-PARA'];
17
+ minAmountPercent = 0.97;
18
+ rateDecimals = 18;
19
+ availableMethod = {
20
+ join: true,
21
+ defaultUnstake: true,
22
+ fastUnstake: true,
23
+ cancelUnstake: false,
24
+ withdraw: false,
25
+ claimReward: false
26
+ };
27
+ constructor(state, chain) {
28
+ super(state, chain);
29
+ const chainInfo = this.chainInfo;
30
+ this.slug = `DOT___liquid_staking___${chain}`;
31
+ this.name = `${chainInfo.name} Liquid Staking`;
32
+ this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
33
+ }
34
+ getDescription() {
35
+ return 'Stake DOT to earn yield on sDOT';
36
+ }
37
+
38
+ /* Subscribe pool info */
39
+
40
+ async getPoolStat() {
41
+ const substrateApi = await this.substrateApi.isReady;
42
+ 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()]);
43
+ let tvl = BN_ZERO;
44
+ for (const _stakingLedger of _stakingLedgers) {
45
+ const _ledger = _stakingLedger[1];
46
+ const ledger = _ledger.toPrimitive();
47
+ tvl = tvl.add(new BN(ledger.total.toString()));
48
+ }
49
+ const exchangeRate = _exchangeRate.toPrimitive();
50
+ const currentBlockHeader = _currentBlockHeader.toPrimitive();
51
+ const currentTimestamp = _currentTimestamp.toPrimitive();
52
+ const beginBlock = currentBlockHeader.number - 24 * 60 * 60 / 6 * 14;
53
+ const _beginBlockHash = await substrateApi.api.rpc.chain.getBlockHash(beginBlock);
54
+ const beginBlockHash = _beginBlockHash.toString();
55
+ const [_beginTimestamp, _beginExchangeRate] = await Promise.all([substrateApi.api.query.timestamp.now.at(beginBlockHash), substrateApi.api.query.liquidStaking.exchangeRate.at(beginBlockHash)]);
56
+ const beginTimestamp = _beginTimestamp.toPrimitive();
57
+ const beginExchangeRate = _beginExchangeRate.toPrimitive();
58
+ const decimals = 10 ** this.rateDecimals;
59
+ const apy = (exchangeRate / beginExchangeRate) ** (365 * 24 * 60 * 60000 / (currentTimestamp - beginTimestamp)) - 1;
60
+ const minStake = substrateApi.api.consts.liquidStaking.minStake.toString();
61
+ const minUnstake = substrateApi.api.consts.liquidStaking.minUnstake.toString();
62
+ this.updateExchangeRate(exchangeRate);
63
+ return {
64
+ ...this.baseInfo,
65
+ type: this.type,
66
+ metadata: {
67
+ ...this.metadataInfo,
68
+ description: this.getDescription()
69
+ },
70
+ statistic: {
71
+ assetEarning: [{
72
+ slug: this.rewardAssets[0],
73
+ apy: apy * 100,
74
+ exchangeRate: exchangeRate / decimals
75
+ }],
76
+ unstakingPeriod: 24 * 28,
77
+ maxCandidatePerFarmer: 1,
78
+ maxWithdrawalRequestPerFarmer: 1,
79
+ earningThreshold: {
80
+ join: minStake,
81
+ defaultUnstake: minUnstake,
82
+ fastUnstake: '0'
83
+ },
84
+ totalApy: apy * 100,
85
+ tvl: tvl.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.assets.account.multi(useAddresses.map(address => [_getTokenOnChainAssetId(derivativeTokenInfo), address]), async balances => {
101
+ if (cancel) {
102
+ unsub();
103
+ return;
104
+ }
105
+ const [unlockingChunks, _currentEra, exchangeRate] = await Promise.all([substrateApi.api.query.liquidStaking.unlockings.multi(useAddresses), substrateApi.api.query.liquidStaking.currentEra(), this.getExchangeRate()]);
106
+ const currentEra = _currentEra.toPrimitive();
107
+ const decimals = BN_TEN.pow(new BN(this.rateDecimals));
108
+ for (let i = 0; i < balances.length; i++) {
109
+ const b = balances[i];
110
+ const address = useAddresses[i];
111
+ // @ts-ignore
112
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment
113
+ const bdata = b === null || b === void 0 ? void 0 : b.toHuman();
114
+ const chunks = unlockingChunks[i].toPrimitive();
115
+
116
+ // @ts-ignore
117
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument
118
+ const activeBalance = bdata && bdata.balance ? new BN(String(bdata === null || bdata === void 0 ? void 0 : bdata.balance).replaceAll(',', '') || '0') : BN_ZERO;
119
+ let totalBalance = activeBalance.mul(new BN(exchangeRate)).div(decimals);
120
+ let unlockingBalance = BN_ZERO;
121
+ const unstakings = [];
122
+ if (chunks) {
123
+ for (const chunk of chunks) {
124
+ const amount = new BN(chunk.value);
125
+ const isClaimable = chunk.era - currentEra < 0;
126
+ const remainingEra = chunk.era - currentEra;
127
+ const eraTime = _STAKING_ERA_LENGTH_MAP[this.chain] || _STAKING_ERA_LENGTH_MAP.default;
128
+ const waitingTime = remainingEra * eraTime;
129
+ totalBalance = totalBalance.add(amount);
130
+ unlockingBalance = unlockingBalance.add(amount);
131
+ unstakings.push({
132
+ chain: this.chain,
133
+ status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
134
+ claimable: amount.toString(),
135
+ waitingTime: waitingTime
136
+ });
137
+ }
138
+ }
139
+ const result = {
140
+ ...this.baseInfo,
141
+ type: this.type,
142
+ address,
143
+ balanceToken: this.inputAsset,
144
+ totalStake: totalBalance.toString(),
145
+ activeStake: activeBalance.toString(),
146
+ unstakeBalance: unlockingBalance.toString(),
147
+ status: activeBalance.gt(BN_ZERO) ? EarningStatus.EARNING_REWARD : EarningStatus.NOT_EARNING,
148
+ derivativeToken: derivativeTokenSlug,
149
+ isBondedBefore: totalBalance.gt(BN_ZERO),
150
+ nominations: [],
151
+ unstakings: unstakings
152
+ };
153
+ resultCallback(result);
154
+ }
155
+ });
156
+ return () => {
157
+ cancel = true;
158
+ unsub();
159
+ };
160
+ }
161
+
162
+ /* Subscribe pool position */
163
+
164
+ /* Join pool action */
165
+
166
+ get submitJoinStepInfo() {
167
+ return {
168
+ name: 'Mint sDOT',
169
+ type: YieldStepType.MINT_SDOT
170
+ };
171
+ }
172
+ async getSubmitStepFee(params) {
173
+ const poolOriginSubstrateApi = await this.substrateApi.isReady;
174
+ const defaultFeeTokenSlug = this.feeAssets[0];
175
+ if (new BN(params.amount).gt(BN_ZERO)) {
176
+ const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.liquidStaking.stake(params.amount).paymentInfo(fakeAddress);
177
+ const mintFeeInfo = _mintFeeInfo.toPrimitive();
178
+ return {
179
+ amount: mintFeeInfo.partialFee.toString(),
180
+ slug: defaultFeeTokenSlug
181
+ };
182
+ } else {
183
+ return {
184
+ amount: '0',
185
+ slug: defaultFeeTokenSlug
186
+ };
187
+ }
188
+ }
189
+ async handleSubmitStep(data, path) {
190
+ const substrateApi = await this.substrateApi.isReady;
191
+ const extrinsic = substrateApi.api.tx.liquidStaking.stake(data.amount);
192
+ return {
193
+ txChain: this.chain,
194
+ extrinsicType: ExtrinsicType.MINT_SDOT,
195
+ extrinsic,
196
+ txData: data,
197
+ transferNativeAmount: '0',
198
+ chainType: ChainType.SUBSTRATE
199
+ };
200
+ }
201
+
202
+ /* Join pool action */
203
+
204
+ /* Leave pool action */
205
+
206
+ async handleYieldRedeem(amount, address, selectedTarget) {
207
+ const substrateApi = await this.substrateApi.isReady;
208
+ const weightedMinAmount = await this.createParamToRedeem(amount, address);
209
+ const extrinsic = substrateApi.api.tx.ammRoute.swapExactTokensForTokens(['1001', '101'], amount, weightedMinAmount);
210
+ return [ExtrinsicType.REDEEM_SDOT, extrinsic];
211
+ }
212
+ async handleYieldUnstake(amount, address, selectedTarget) {
213
+ const chainApi = await this.substrateApi.isReady;
214
+ const extrinsic = chainApi.api.tx.liquidStaking.unstake(amount, 'RelayChain');
215
+ return [ExtrinsicType.UNSTAKE_SDOT, extrinsic];
216
+ }
217
+
218
+ /* Leave pool action */
219
+ }
@@ -0,0 +1,34 @@
1
+ import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
2
+ import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
3
+ import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
4
+ import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
5
+ import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, UnstakingInfo, YieldPoolMethodInfo, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
6
+ import { Contract } from 'web3-eth-contract';
7
+ import BaseLiquidStakingPoolHandler from './base';
8
+ export declare const getStellaswapLiquidStakingContract: (networkKey: string, assetAddress: string, evmApi: _EvmApi, options?: {}) => Contract;
9
+ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
10
+ slug: string;
11
+ protected readonly name: string;
12
+ protected readonly shortName: string;
13
+ protected readonly inputAsset: string;
14
+ protected readonly altInputAsset: string;
15
+ protected readonly derivativeAssets: string[];
16
+ protected readonly rewardAssets: string[];
17
+ protected readonly feeAssets: string[];
18
+ transactionChainType: ChainType;
19
+ protected readonly rateDecimals = 10;
20
+ protected readonly availableMethod: YieldPoolMethodInfo;
21
+ constructor(state: KoniState, chain: string);
22
+ protected getDescription(): string;
23
+ getPoolStat(): Promise<LiquidYieldPoolInfo>;
24
+ subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
25
+ get submitJoinStepInfo(): BaseYieldStepDetail;
26
+ getTokenApproveStep(params: OptimalYieldPathParams): Promise<[BaseYieldStepDetail, YieldTokenBaseInfo] | undefined>;
27
+ getSubmitStepFee(params: OptimalYieldPathParams): Promise<YieldTokenBaseInfo>;
28
+ protected validateTokenApproveStep(params: OptimalYieldPathParams, path: OptimalYieldPath): Promise<TransactionError[]>;
29
+ protected handleTokenApproveStep(data: SubmitYieldJoinData, path: OptimalYieldPath): Promise<HandleYieldStepData>;
30
+ handleSubmitStep(data: SubmitYieldJoinData, path: OptimalYieldPath): Promise<HandleYieldStepData>;
31
+ handleYieldRedeem(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
32
+ handleYieldUnstake(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
33
+ handleYieldWithdraw(address: string, unstakingInfo: UnstakingInfo): Promise<TransactionData>;
34
+ }