@0xtorch/core 0.0.1

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 (241) hide show
  1. package/README.md +15 -0
  2. package/dist/import/accounts/index.d.ts +2 -0
  3. package/dist/import/accounts/index.d.ts.map +1 -0
  4. package/dist/import/accounts/types/account.d.ts +6 -0
  5. package/dist/import/accounts/types/account.d.ts.map +1 -0
  6. package/dist/import/accounts/types/index.d.ts +2 -0
  7. package/dist/import/accounts/types/index.d.ts.map +1 -0
  8. package/dist/import/actions/index.d.ts +2 -0
  9. package/dist/import/actions/index.d.ts.map +1 -0
  10. package/dist/import/actions/types/addLiquidity.d.ts +7 -0
  11. package/dist/import/actions/types/addLiquidity.d.ts.map +1 -0
  12. package/dist/import/actions/types/atomicArbitrage.d.ts +5 -0
  13. package/dist/import/actions/types/atomicArbitrage.d.ts.map +1 -0
  14. package/dist/import/actions/types/bridgeFrom.d.ts +6 -0
  15. package/dist/import/actions/types/bridgeFrom.d.ts.map +1 -0
  16. package/dist/import/actions/types/bridgeTo.d.ts +6 -0
  17. package/dist/import/actions/types/bridgeTo.d.ts.map +1 -0
  18. package/dist/import/actions/types/buyNft.d.ts +7 -0
  19. package/dist/import/actions/types/buyNft.d.ts.map +1 -0
  20. package/dist/import/actions/types/common.d.ts +50 -0
  21. package/dist/import/actions/types/common.d.ts.map +1 -0
  22. package/dist/import/actions/types/deposit.d.ts +6 -0
  23. package/dist/import/actions/types/deposit.d.ts.map +1 -0
  24. package/dist/import/actions/types/depositWithBond.d.ts +7 -0
  25. package/dist/import/actions/types/depositWithBond.d.ts.map +1 -0
  26. package/dist/import/actions/types/freeMintNft.d.ts +8 -0
  27. package/dist/import/actions/types/freeMintNft.d.ts.map +1 -0
  28. package/dist/import/actions/types/income.d.ts +5 -0
  29. package/dist/import/actions/types/income.d.ts.map +1 -0
  30. package/dist/import/actions/types/index.d.ts +24 -0
  31. package/dist/import/actions/types/index.d.ts.map +1 -0
  32. package/dist/import/actions/types/move.d.ts +5 -0
  33. package/dist/import/actions/types/move.d.ts.map +1 -0
  34. package/dist/import/actions/types/nftRoyalty.d.ts +7 -0
  35. package/dist/import/actions/types/nftRoyalty.d.ts.map +1 -0
  36. package/dist/import/actions/types/removeLiquidity.d.ts +7 -0
  37. package/dist/import/actions/types/removeLiquidity.d.ts.map +1 -0
  38. package/dist/import/actions/types/sellNft.d.ts +6 -0
  39. package/dist/import/actions/types/sellNft.d.ts.map +1 -0
  40. package/dist/import/actions/types/spam.d.ts +6 -0
  41. package/dist/import/actions/types/spam.d.ts.map +1 -0
  42. package/dist/import/actions/types/swapIncome.d.ts +4 -0
  43. package/dist/import/actions/types/swapIncome.d.ts.map +1 -0
  44. package/dist/import/actions/types/swapNft.d.ts +6 -0
  45. package/dist/import/actions/types/swapNft.d.ts.map +1 -0
  46. package/dist/import/actions/types/swapTransfer.d.ts +4 -0
  47. package/dist/import/actions/types/swapTransfer.d.ts.map +1 -0
  48. package/dist/import/actions/types/trade.d.ts +7 -0
  49. package/dist/import/actions/types/trade.d.ts.map +1 -0
  50. package/dist/import/actions/types/transactionFee.d.ts +7 -0
  51. package/dist/import/actions/types/transactionFee.d.ts.map +1 -0
  52. package/dist/import/actions/types/transfer.d.ts +8 -0
  53. package/dist/import/actions/types/transfer.d.ts.map +1 -0
  54. package/dist/import/actions/types/withdraw.d.ts +7 -0
  55. package/dist/import/actions/types/withdraw.d.ts.map +1 -0
  56. package/dist/import/actions/types/withdrawWithBond.d.ts +7 -0
  57. package/dist/import/actions/types/withdrawWithBond.d.ts.map +1 -0
  58. package/dist/import/apps/index.d.ts +3 -0
  59. package/dist/import/apps/index.d.ts.map +1 -0
  60. package/dist/import/apps/types.d.ts +11 -0
  61. package/dist/import/apps/types.d.ts.map +1 -0
  62. package/dist/import/assets/constants.d.ts +2 -0
  63. package/dist/import/assets/constants.d.ts.map +1 -0
  64. package/dist/import/assets/creates/createCryptoCurrency.d.ts +3 -0
  65. package/dist/import/assets/creates/createCryptoCurrency.d.ts.map +1 -0
  66. package/dist/import/assets/creates/createFiatCurrency.d.ts +3 -0
  67. package/dist/import/assets/creates/createFiatCurrency.d.ts.map +1 -0
  68. package/dist/import/assets/creates/index.d.ts +3 -0
  69. package/dist/import/assets/creates/index.d.ts.map +1 -0
  70. package/dist/import/assets/definitions/astar.d.ts +13 -0
  71. package/dist/import/assets/definitions/astar.d.ts.map +1 -0
  72. package/dist/import/assets/definitions/avalanche.d.ts +13 -0
  73. package/dist/import/assets/definitions/avalanche.d.ts.map +1 -0
  74. package/dist/import/assets/definitions/bnb.d.ts +13 -0
  75. package/dist/import/assets/definitions/bnb.d.ts.map +1 -0
  76. package/dist/import/assets/definitions/coingeckoCryptoCurrencyDataSource.d.ts +18 -0
  77. package/dist/import/assets/definitions/coingeckoCryptoCurrencyDataSource.d.ts.map +1 -0
  78. package/dist/import/assets/definitions/ethereum.d.ts +13 -0
  79. package/dist/import/assets/definitions/ethereum.d.ts.map +1 -0
  80. package/dist/import/assets/definitions/eur.d.ts +8 -0
  81. package/dist/import/assets/definitions/eur.d.ts.map +1 -0
  82. package/dist/import/assets/definitions/fantom.d.ts +13 -0
  83. package/dist/import/assets/definitions/fantom.d.ts.map +1 -0
  84. package/dist/import/assets/definitions/index.d.ts +17 -0
  85. package/dist/import/assets/definitions/index.d.ts.map +1 -0
  86. package/dist/import/assets/definitions/jpy.d.ts +8 -0
  87. package/dist/import/assets/definitions/jpy.d.ts.map +1 -0
  88. package/dist/import/assets/definitions/kava.d.ts +13 -0
  89. package/dist/import/assets/definitions/kava.d.ts.map +1 -0
  90. package/dist/import/assets/definitions/mantle.d.ts +13 -0
  91. package/dist/import/assets/definitions/mantle.d.ts.map +1 -0
  92. package/dist/import/assets/definitions/maticNetwork.d.ts +13 -0
  93. package/dist/import/assets/definitions/maticNetwork.d.ts.map +1 -0
  94. package/dist/import/assets/definitions/metis.d.ts +13 -0
  95. package/dist/import/assets/definitions/metis.d.ts.map +1 -0
  96. package/dist/import/assets/definitions/moonbeam.d.ts +13 -0
  97. package/dist/import/assets/definitions/moonbeam.d.ts.map +1 -0
  98. package/dist/import/assets/definitions/moonriver.d.ts +13 -0
  99. package/dist/import/assets/definitions/moonriver.d.ts.map +1 -0
  100. package/dist/import/assets/definitions/ronin.d.ts +13 -0
  101. package/dist/import/assets/definitions/ronin.d.ts.map +1 -0
  102. package/dist/import/assets/definitions/usd.d.ts +8 -0
  103. package/dist/import/assets/definitions/usd.d.ts.map +1 -0
  104. package/dist/import/assets/externals/coingecko/constants.d.ts +2 -0
  105. package/dist/import/assets/externals/coingecko/constants.d.ts.map +1 -0
  106. package/dist/import/assets/externals/coingecko/getAutoRetry.d.ts +4 -0
  107. package/dist/import/assets/externals/coingecko/getAutoRetry.d.ts.map +1 -0
  108. package/dist/import/assets/externals/coingecko/getCoinMarketChartRange.d.ts +49 -0
  109. package/dist/import/assets/externals/coingecko/getCoinMarketChartRange.d.ts.map +1 -0
  110. package/dist/import/assets/externals/coingecko/getCoinsMarkets.d.ts +58 -0
  111. package/dist/import/assets/externals/coingecko/getCoinsMarkets.d.ts.map +1 -0
  112. package/dist/import/assets/externals/coingecko/index.d.ts +3 -0
  113. package/dist/import/assets/externals/coingecko/index.d.ts.map +1 -0
  114. package/dist/import/assets/externals/index.d.ts +2 -0
  115. package/dist/import/assets/externals/index.d.ts.map +1 -0
  116. package/dist/import/assets/index.d.ts +5 -0
  117. package/dist/import/assets/index.d.ts.map +1 -0
  118. package/dist/import/assets/types/cryptoCurrency.d.ts +17 -0
  119. package/dist/import/assets/types/cryptoCurrency.d.ts.map +1 -0
  120. package/dist/import/assets/types/cryptoCurrencyPrice.d.ts +10 -0
  121. package/dist/import/assets/types/cryptoCurrencyPrice.d.ts.map +1 -0
  122. package/dist/import/assets/types/dataSource.d.ts +18 -0
  123. package/dist/import/assets/types/dataSource.d.ts.map +1 -0
  124. package/dist/import/assets/types/fiatCurrency.d.ts +12 -0
  125. package/dist/import/assets/types/fiatCurrency.d.ts.map +1 -0
  126. package/dist/import/assets/types/index.d.ts +6 -0
  127. package/dist/import/assets/types/index.d.ts.map +1 -0
  128. package/dist/import/assets/types/nft.d.ts +5 -0
  129. package/dist/import/assets/types/nft.d.ts.map +1 -0
  130. package/dist/import/index.d.mts +12 -0
  131. package/dist/import/index.d.mts.map +1 -0
  132. package/dist/import/index.mjs +2 -0
  133. package/dist/import/portfolios/createPortfolio.d.ts +2 -0
  134. package/dist/import/portfolios/createPortfolio.d.ts.map +1 -0
  135. package/dist/import/portfolios/index.d.ts +3 -0
  136. package/dist/import/portfolios/index.d.ts.map +1 -0
  137. package/dist/import/portfolios/type.d.ts +4 -0
  138. package/dist/import/portfolios/type.d.ts.map +1 -0
  139. package/dist/import/types.d.ts +11 -0
  140. package/dist/import/types.d.ts.map +1 -0
  141. package/dist/import/utils/errors.d.ts +48 -0
  142. package/dist/import/utils/errors.d.ts.map +1 -0
  143. package/dist/import/utils/index.d.ts +5 -0
  144. package/dist/import/utils/index.d.ts.map +1 -0
  145. package/dist/import/utils/rest.d.ts +14 -0
  146. package/dist/import/utils/rest.d.ts.map +1 -0
  147. package/dist/import/utils/stringify.d.ts +2 -0
  148. package/dist/import/utils/stringify.d.ts.map +1 -0
  149. package/dist/import/utils/types.d.ts +12 -0
  150. package/dist/import/utils/types.d.ts.map +1 -0
  151. package/dist/require/index.cjs +2 -0
  152. package/dist/require/index.d.cts +2 -0
  153. package/dist/require/index.d.cts.map +1 -0
  154. package/package.json +79 -0
  155. package/src/accounts/index.ts +1 -0
  156. package/src/accounts/types/account.ts +5 -0
  157. package/src/accounts/types/index.ts +1 -0
  158. package/src/actions/index.ts +44 -0
  159. package/src/actions/schemas/constants.ts +16 -0
  160. package/src/actions/schemas/swap.ts +7 -0
  161. package/src/actions/types/addLiquidity.ts +23 -0
  162. package/src/actions/types/atomicArbitrage.ts +30 -0
  163. package/src/actions/types/bridgeFrom.ts +23 -0
  164. package/src/actions/types/bridgeTo.ts +23 -0
  165. package/src/actions/types/buyNft.ts +34 -0
  166. package/src/actions/types/common.ts +142 -0
  167. package/src/actions/types/deposit.ts +23 -0
  168. package/src/actions/types/depositWithBond.ts +23 -0
  169. package/src/actions/types/freeMintNft.ts +20 -0
  170. package/src/actions/types/income.ts +21 -0
  171. package/src/actions/types/index.ts +53 -0
  172. package/src/actions/types/move.ts +21 -0
  173. package/src/actions/types/nftRoyalty.ts +19 -0
  174. package/src/actions/types/removeLiquidity.ts +23 -0
  175. package/src/actions/types/sellNft.ts +22 -0
  176. package/src/actions/types/spam.ts +23 -0
  177. package/src/actions/types/swapIncome.ts +12 -0
  178. package/src/actions/types/swapNft.ts +12 -0
  179. package/src/actions/types/swapTransfer.ts +12 -0
  180. package/src/actions/types/trade.ts +34 -0
  181. package/src/actions/types/transactionFee.ts +19 -0
  182. package/src/actions/types/transfer.ts +36 -0
  183. package/src/actions/types/withdraw.ts +23 -0
  184. package/src/actions/types/withdrawWithBond.ts +23 -0
  185. package/src/apps/index.ts +2 -0
  186. package/src/apps/types.ts +20 -0
  187. package/src/assets/constants.ts +1 -0
  188. package/src/assets/creates/createCryptoCurrency.ts +7 -0
  189. package/src/assets/creates/createFiatCurrency.ts +10 -0
  190. package/src/assets/creates/index.ts +2 -0
  191. package/src/assets/definitions/astar.ts +14 -0
  192. package/src/assets/definitions/avalanche.ts +14 -0
  193. package/src/assets/definitions/bnb.ts +14 -0
  194. package/src/assets/definitions/coingeckoCryptoCurrencyDataSource.test.ts +53 -0
  195. package/src/assets/definitions/coingeckoCryptoCurrencyDataSource.ts +169 -0
  196. package/src/assets/definitions/ethereum.ts +14 -0
  197. package/src/assets/definitions/eur.ts +9 -0
  198. package/src/assets/definitions/fantom.ts +14 -0
  199. package/src/assets/definitions/index.ts +16 -0
  200. package/src/assets/definitions/jpy.ts +9 -0
  201. package/src/assets/definitions/kava.ts +14 -0
  202. package/src/assets/definitions/mantle.ts +14 -0
  203. package/src/assets/definitions/maticNetwork.ts +14 -0
  204. package/src/assets/definitions/metis.ts +14 -0
  205. package/src/assets/definitions/moonbeam.ts +14 -0
  206. package/src/assets/definitions/moonriver.ts +14 -0
  207. package/src/assets/definitions/ronin.ts +14 -0
  208. package/src/assets/definitions/usd.ts +9 -0
  209. package/src/assets/externals/coingecko/constants.ts +1 -0
  210. package/src/assets/externals/coingecko/getAutoRetry.ts +35 -0
  211. package/src/assets/externals/coingecko/getCoinMarketChartRange.test.ts +28 -0
  212. package/src/assets/externals/coingecko/getCoinMarketChartRange.ts +88 -0
  213. package/src/assets/externals/coingecko/getCoinsMarkets.test.ts +11 -0
  214. package/src/assets/externals/coingecko/getCoinsMarkets.ts +106 -0
  215. package/src/assets/externals/coingecko/index.ts +2 -0
  216. package/src/assets/externals/index.ts +1 -0
  217. package/src/assets/index.ts +27 -0
  218. package/src/assets/types/cryptoCurrency.ts +17 -0
  219. package/src/assets/types/cryptoCurrencyPrice.ts +14 -0
  220. package/src/assets/types/dataSource.ts +26 -0
  221. package/src/assets/types/fiatCurrency.ts +21 -0
  222. package/src/assets/types/index.ts +9 -0
  223. package/src/assets/types/nft.ts +5 -0
  224. package/src/index.cts +1 -0
  225. package/src/index.mts +79 -0
  226. package/src/portfolios/createPortfolio.test.ts +7 -0
  227. package/src/portfolios/createPortfolio.ts +3 -0
  228. package/src/portfolios/index.ts +2 -0
  229. package/src/portfolios/type.ts +3 -0
  230. package/src/tests/constants.ts +1 -0
  231. package/src/tests/index.ts +2 -0
  232. package/src/tests/utils.ts +26 -0
  233. package/src/types.ts +11 -0
  234. package/src/utils/errors.ts +130 -0
  235. package/src/utils/index.ts +4 -0
  236. package/src/utils/rest.test.ts +19 -0
  237. package/src/utils/rest.ts +138 -0
  238. package/src/utils/stringify.test.ts +24 -0
  239. package/src/utils/stringify.ts +11 -0
  240. package/src/utils/types.ts +12 -0
  241. package/tsconfig.json +28 -0
@@ -0,0 +1,44 @@
1
+ export type {
2
+ AccountAction,
3
+ AccountActionAddLiquidity,
4
+ AccountActionAtomicArbitrage,
5
+ AccountActionBridgeFrom,
6
+ AccountActionBridgeTo,
7
+ AccountActionBuyNft,
8
+ AccountActionDeposit,
9
+ AccountActionDepositWithBond,
10
+ AccountActionFreeMintNft,
11
+ AccountActionIncome,
12
+ AccountActionMove,
13
+ AccountActionNftRoyalty,
14
+ AccountActionRemoveLiquidity,
15
+ AccountActionSellNft,
16
+ AccountActionSpam,
17
+ AccountActionSwapIncome,
18
+ AccountActionSwapNft,
19
+ AccountActionSwapTransfer,
20
+ AccountActionTrade,
21
+ AccountActionTransactionFee,
22
+ AccountActionTransfer,
23
+ AccountActionType,
24
+ AccountActionWithdraw,
25
+ AccountActionWithdrawWithBond,
26
+ ActionType,
27
+ Evidence,
28
+ NormalAction,
29
+ NormalActionAddLiquidity,
30
+ NormalActionAtomicArbitrage,
31
+ NormalActionBridgeFrom,
32
+ NormalActionBridgeTo,
33
+ NormalActionBuyNft,
34
+ NormalActionDeposit,
35
+ NormalActionDepositWithBond,
36
+ NormalActionFreeMintNft,
37
+ NormalActionRemoveLiquidity,
38
+ NormalActionSpam,
39
+ NormalActionTrade,
40
+ NormalActionTransactionFee,
41
+ NormalActionTransfer,
42
+ NormalActionWithdraw,
43
+ NormalActionWithdrawWithBond,
44
+ } from './types'
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod'
2
+
3
+ export const actionConstantsSchema = z.object({
4
+ type: z.string(),
5
+ evidence: z.union([
6
+ z.literal('contract'),
7
+ z.literal('system-rule'),
8
+ z.literal('user-rule'),
9
+ z.literal('manual-check'),
10
+ z.literal('none'),
11
+ ]),
12
+ timestamp: z.number().int(),
13
+ comment: z.string().optional(),
14
+ })
15
+
16
+ export const transferSchema = z.object({})
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod'
2
+
3
+ export const swapActionSchema = z.object({
4
+ type: z.literal('swap'),
5
+ })
6
+
7
+ // transfer の型定義がむず過ぎて読めない
@@ -0,0 +1,23 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ type Action = 'add-liquidity'
5
+
6
+ export type NormalActionAddLiquidity<
7
+ Account = unknown,
8
+ // TODO crypto 以外の価格にも対応させる
9
+ Price extends CryptoCurrencyPrice | undefined =
10
+ | CryptoCurrencyPrice
11
+ | undefined,
12
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
13
+ > = NormalAction<Action, Account, Price, Asset, 'in' | 'out'>
14
+
15
+ export type AccountActionAddLiquidity<
16
+ Account = unknown,
17
+ Source extends string = string,
18
+ // TODO crypto 以外の価格にも対応させる
19
+ Price extends CryptoCurrencyPrice | undefined =
20
+ | CryptoCurrencyPrice
21
+ | undefined,
22
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
23
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in' | 'out'>
@@ -0,0 +1,30 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ export type NormalActionAtomicArbitrage<
5
+ Account = unknown,
6
+ Price extends CryptoCurrencyPrice | undefined =
7
+ | CryptoCurrencyPrice
8
+ | undefined,
9
+ > = NormalAction<
10
+ 'atomic-arbitrage',
11
+ Account,
12
+ Price,
13
+ CryptoCurrency,
14
+ 'in' | 'out'
15
+ >
16
+
17
+ export type AccountActionAtomicArbitrage<
18
+ Account = unknown,
19
+ Source extends string = string,
20
+ Price extends CryptoCurrencyPrice | undefined =
21
+ | CryptoCurrencyPrice
22
+ | undefined,
23
+ > = AccountAction<
24
+ 'atomic-arbitrage',
25
+ Source,
26
+ Account,
27
+ Price,
28
+ CryptoCurrency,
29
+ 'in'
30
+ >
@@ -0,0 +1,23 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ export type Action = 'bridge-from'
5
+
6
+ export type NormalActionBridgeFrom<
7
+ Account = unknown,
8
+ // TODO crypto 以外の価格にも対応させる
9
+ Price extends CryptoCurrencyPrice | undefined =
10
+ | CryptoCurrencyPrice
11
+ | undefined,
12
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
13
+ > = NormalAction<Action, Account, Price, Asset, 'out'>
14
+
15
+ export type AccountActionBridgeFrom<
16
+ Account = unknown,
17
+ Source extends string = string,
18
+ // TODO crypto 以外の価格にも対応させる
19
+ Price extends CryptoCurrencyPrice | undefined =
20
+ | CryptoCurrencyPrice
21
+ | undefined,
22
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
23
+ > = AccountAction<Action, Source, Account, Price, Asset, 'out'>
@@ -0,0 +1,23 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ export type Action = 'bridge-to'
5
+
6
+ export type NormalActionBridgeTo<
7
+ Account = unknown,
8
+ // TODO crypto 以外の価格にも対応させる
9
+ Price extends CryptoCurrencyPrice | undefined =
10
+ | CryptoCurrencyPrice
11
+ | undefined,
12
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
13
+ > = NormalAction<Action, Account, Price, Asset, 'in'>
14
+
15
+ export type AccountActionBridgeTo<
16
+ Account = unknown,
17
+ Source extends string = string,
18
+ // TODO crypto 以外の価格にも対応させる
19
+ Price extends CryptoCurrencyPrice | undefined =
20
+ | CryptoCurrencyPrice
21
+ | undefined,
22
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
23
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in'>
@@ -0,0 +1,34 @@
1
+ import type {
2
+ CryptoCurrency,
3
+ CryptoCurrencyPrice,
4
+ FiatCurrency,
5
+ Nft,
6
+ } from '../../assets'
7
+ import type { AccountAction, NormalAction } from './common'
8
+
9
+ type Action = 'buy-nft'
10
+
11
+ export type NormalActionBuyNft<
12
+ Account = unknown,
13
+ // TODO crypto 以外の価格にも対応させる
14
+ Price extends CryptoCurrencyPrice | undefined =
15
+ | CryptoCurrencyPrice
16
+ | undefined,
17
+ Asset extends CryptoCurrency | FiatCurrency | Nft =
18
+ | CryptoCurrency
19
+ | FiatCurrency
20
+ | Nft,
21
+ > = NormalAction<Action, Account, Price, Asset, 'in' | 'out'>
22
+
23
+ export type AccountActionBuyNft<
24
+ Account = unknown,
25
+ Source extends string = string,
26
+ // TODO crypto 以外の価格にも対応させる
27
+ Price extends CryptoCurrencyPrice | undefined =
28
+ | CryptoCurrencyPrice
29
+ | undefined,
30
+ Asset extends CryptoCurrency | FiatCurrency | Nft =
31
+ | CryptoCurrency
32
+ | FiatCurrency
33
+ | Nft,
34
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in' | 'out'>
@@ -0,0 +1,142 @@
1
+ import type { BigDecimal } from '@0xtorch/big-decimal'
2
+ import type { App } from '../../apps'
3
+ import type {
4
+ CryptoCurrency,
5
+ CryptoCurrencyPrice,
6
+ FiatCurrency,
7
+ Nft,
8
+ } from '../../assets'
9
+
10
+ const actions = [
11
+ 'add-liquidity',
12
+ 'atomic-arbitrage',
13
+ 'bridge-from',
14
+ 'bridge-to',
15
+ 'buy-nft',
16
+ 'deposit',
17
+ 'deposit-with-bond',
18
+ 'free-mint-nft',
19
+ 'remove-liquidity',
20
+ 'spam',
21
+ 'trade',
22
+ 'transaction-fee',
23
+ 'transfer',
24
+ 'withdraw',
25
+ 'withdraw-with-bond',
26
+ ] as const
27
+ export type ActionType = (typeof actions)[number]
28
+
29
+ const accountActions = [
30
+ 'add-liquidity',
31
+ 'atomic-arbitrage',
32
+ 'bridge-from',
33
+ 'bridge-to',
34
+ 'buy-nft',
35
+ 'deposit',
36
+ 'deposit-with-bond',
37
+ 'free-mint-nft',
38
+ 'income',
39
+ 'move',
40
+ 'nft-royalty',
41
+ 'remove-liquidity',
42
+ 'sell-nft',
43
+ 'spam',
44
+ 'swap-income',
45
+ 'swap-nft',
46
+ 'swap-transfer',
47
+ 'trade',
48
+ 'transaction-fee',
49
+ 'transfer',
50
+ 'withdraw',
51
+ 'withdraw-with-bond',
52
+ ] as const
53
+ export type AccountActionType = (typeof accountActions)[number]
54
+
55
+ export type AccountAction<
56
+ Action extends AccountActionType = AccountActionType,
57
+ Source extends string = string,
58
+ Account = unknown,
59
+ // TODO crypto 以外の価格にも対応させる
60
+ Price extends CryptoCurrencyPrice | undefined =
61
+ | CryptoCurrencyPrice
62
+ | undefined,
63
+ Asset extends CryptoCurrency | FiatCurrency | Nft =
64
+ | CryptoCurrency
65
+ | FiatCurrency
66
+ | Nft,
67
+ Direction extends TransferDirection = TransferDirection,
68
+ > = {
69
+ readonly type: 'AccountAction'
70
+ readonly action: Action
71
+ readonly source: Source
72
+ readonly evidence: Evidence
73
+ readonly timestamp: number
74
+ readonly order: number
75
+ readonly comment: string | undefined
76
+ readonly app: App | undefined
77
+ readonly transfers: readonly Transfer<Account, Price, Asset, Direction>[]
78
+ }
79
+
80
+ export type NormalAction<
81
+ Action extends ActionType = ActionType,
82
+ Account = unknown,
83
+ // TODO crypto 以外の価格にも対応させる
84
+ Price extends CryptoCurrencyPrice | undefined =
85
+ | CryptoCurrencyPrice
86
+ | undefined,
87
+ Asset extends CryptoCurrency | FiatCurrency | Nft =
88
+ | CryptoCurrency
89
+ | FiatCurrency
90
+ | Nft,
91
+ Direction extends TransferDirection = TransferDirection,
92
+ > = {
93
+ readonly type: 'NormalAction'
94
+ readonly action: Action
95
+ readonly evidence: Evidence
96
+ readonly timestamp: number
97
+ readonly comment: string | undefined
98
+ readonly app: App | undefined
99
+ readonly transfers: readonly Transfer<Account, Price, Asset, Direction>[]
100
+ }
101
+
102
+ // TODO これで良いか再検討
103
+ const evidences = [
104
+ 'contract',
105
+ 'system-rule',
106
+ 'user-rule',
107
+ 'manual-check',
108
+ 'none',
109
+ ] as const
110
+ export type Evidence = (typeof evidences)[number]
111
+
112
+ /** action 内で発生している token transfer */
113
+ export type Transfer<
114
+ Account,
115
+ // TODO crypto 以外の価格にも対応させる
116
+ Price extends CryptoCurrencyPrice | undefined = undefined,
117
+ Asset extends CryptoCurrency | FiatCurrency | Nft =
118
+ | CryptoCurrency
119
+ | FiatCurrency
120
+ | Nft,
121
+ Direction extends TransferDirection = TransferDirection,
122
+ > = {
123
+ /** 誰視点なのか */
124
+ readonly target: string
125
+ /** target 視点からの移動方向 */
126
+ readonly direction: Direction
127
+ /** 移動元 account */
128
+ // TODO 適切な型を考える
129
+ readonly from: Account
130
+ /** 移動先 account */
131
+ // TODO 適切な型を考える
132
+ readonly to: Account
133
+ /** 移動した asset */
134
+ readonly asset: Asset
135
+ /** 移動したトークン量 */
136
+ readonly amount: BigDecimal
137
+ /** 移動したトークンの価格 */
138
+ readonly price: Price
139
+ }
140
+
141
+ const transferDirections = ['in', 'out', 'none'] as const
142
+ type TransferDirection = (typeof transferDirections)[number]
@@ -0,0 +1,23 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ export type Action = 'deposit'
5
+
6
+ export type NormalActionDeposit<
7
+ Account = unknown,
8
+ // TODO crypto 以外の価格にも対応させる
9
+ Price extends CryptoCurrencyPrice | undefined =
10
+ | CryptoCurrencyPrice
11
+ | undefined,
12
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
13
+ > = NormalAction<Action, Account, Price, Asset, 'out'>
14
+
15
+ export type AccountActionDeposit<
16
+ Account = unknown,
17
+ Source extends string = string,
18
+ // TODO crypto 以外の価格にも対応させる
19
+ Price extends CryptoCurrencyPrice | undefined =
20
+ | CryptoCurrencyPrice
21
+ | undefined,
22
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
23
+ > = AccountAction<Action, Source, Account, Price, Asset, 'out'>
@@ -0,0 +1,23 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ type Action = 'deposit-with-bond'
5
+
6
+ export type NormalActionDepositWithBond<
7
+ Account = unknown,
8
+ // TODO crypto 以外の価格にも対応させる
9
+ Price extends CryptoCurrencyPrice | undefined =
10
+ | CryptoCurrencyPrice
11
+ | undefined,
12
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
13
+ > = NormalAction<Action, Account, Price, Asset, 'in' | 'out'>
14
+
15
+ export type AccountActionDepositWithBond<
16
+ Account = unknown,
17
+ Source extends string = string,
18
+ // TODO crypto 以外の価格にも対応させる
19
+ Price extends CryptoCurrencyPrice | undefined =
20
+ | CryptoCurrencyPrice
21
+ | undefined,
22
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
23
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in' | 'out'>
@@ -0,0 +1,20 @@
1
+ import type { Nft } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ export type Action = 'free-mint-nft'
5
+
6
+ // TODO crypto 以外の価格にも対応させる
7
+ /** asset transfer */
8
+ export type NormalActionFreeMintNft<Account = unknown> = NormalAction<
9
+ Action,
10
+ Account,
11
+ undefined,
12
+ Nft
13
+ >
14
+
15
+ // TODO crypto 以外の価格にも対応させる
16
+ /** transfer from account to others */
17
+ export type AccountActionFreeMintNft<
18
+ Account = unknown,
19
+ Source extends string = string,
20
+ > = AccountAction<Action, Source, Account, undefined, Nft, 'in'>
@@ -0,0 +1,21 @@
1
+ import type {
2
+ CryptoCurrency,
3
+ CryptoCurrencyPrice,
4
+ FiatCurrency,
5
+ Nft,
6
+ } from '../../assets'
7
+ import type { AccountAction } from './common'
8
+
9
+ /** income */
10
+ export type AccountActionIncome<
11
+ Account = unknown,
12
+ Source extends string = string,
13
+ // TODO crypto 以外の価格にも対応させる
14
+ Price extends CryptoCurrencyPrice | undefined =
15
+ | CryptoCurrencyPrice
16
+ | undefined,
17
+ Asset extends CryptoCurrency | FiatCurrency | Nft =
18
+ | CryptoCurrency
19
+ | FiatCurrency
20
+ | Nft,
21
+ > = AccountAction<'income', Source, Account, Price, Asset, 'in'>
@@ -0,0 +1,53 @@
1
+ export type {
2
+ AccountActionAddLiquidity,
3
+ NormalActionAddLiquidity,
4
+ } from './addLiquidity'
5
+ export type {
6
+ AccountActionAtomicArbitrage,
7
+ NormalActionAtomicArbitrage,
8
+ } from './atomicArbitrage'
9
+ export type {
10
+ AccountActionBridgeFrom,
11
+ NormalActionBridgeFrom,
12
+ } from './bridgeFrom'
13
+ export type { AccountActionBridgeTo, NormalActionBridgeTo } from './bridgeTo'
14
+ export type { AccountActionBuyNft, NormalActionBuyNft } from './buyNft'
15
+ export type {
16
+ AccountAction,
17
+ AccountActionType,
18
+ ActionType,
19
+ Evidence,
20
+ NormalAction,
21
+ } from './common'
22
+ export type { AccountActionDeposit, NormalActionDeposit } from './deposit'
23
+ export type {
24
+ AccountActionDepositWithBond,
25
+ NormalActionDepositWithBond,
26
+ } from './depositWithBond'
27
+ export type {
28
+ AccountActionFreeMintNft,
29
+ NormalActionFreeMintNft,
30
+ } from './freeMintNft'
31
+ export type { AccountActionIncome } from './income'
32
+ export type { AccountActionMove } from './move'
33
+ export type { AccountActionNftRoyalty } from './nftRoyalty'
34
+ export type {
35
+ AccountActionRemoveLiquidity,
36
+ NormalActionRemoveLiquidity,
37
+ } from './removeLiquidity'
38
+ export type { AccountActionSellNft } from './sellNft'
39
+ export type { AccountActionSpam, NormalActionSpam } from './spam'
40
+ export type { AccountActionSwapIncome } from './swapIncome'
41
+ export type { AccountActionSwapNft } from './swapNft'
42
+ export type { AccountActionSwapTransfer } from './swapTransfer'
43
+ export type { AccountActionTrade, NormalActionTrade } from './trade'
44
+ export type {
45
+ AccountActionTransactionFee,
46
+ NormalActionTransactionFee,
47
+ } from './transactionFee'
48
+ export type { AccountActionTransfer, NormalActionTransfer } from './transfer'
49
+ export type { AccountActionWithdraw, NormalActionWithdraw } from './withdraw'
50
+ export type {
51
+ AccountActionWithdrawWithBond,
52
+ NormalActionWithdrawWithBond,
53
+ } from './withdrawWithBond'
@@ -0,0 +1,21 @@
1
+ import type {
2
+ CryptoCurrency,
3
+ CryptoCurrencyPrice,
4
+ FiatCurrency,
5
+ Nft,
6
+ } from '../../assets'
7
+ import type { AccountAction } from './common'
8
+
9
+ /** move asset between accounts */
10
+ export type AccountActionMove<
11
+ Account = unknown,
12
+ Source extends string = string,
13
+ // TODO crypto 以外の価格にも対応させる
14
+ Price extends CryptoCurrencyPrice | undefined =
15
+ | CryptoCurrencyPrice
16
+ | undefined,
17
+ Asset extends CryptoCurrency | FiatCurrency | Nft =
18
+ | CryptoCurrency
19
+ | FiatCurrency
20
+ | Nft,
21
+ > = AccountAction<'move', Source, Account, Price, Asset, 'none'>
@@ -0,0 +1,19 @@
1
+ import type {
2
+ CryptoCurrency,
3
+ CryptoCurrencyPrice,
4
+ FiatCurrency,
5
+ } from '../../assets'
6
+ import type { AccountAction } from './common'
7
+
8
+ type Action = 'nft-royalty'
9
+
10
+ /** nft-royalty */
11
+ export type AccountActionNftRoyalty<
12
+ Account = unknown,
13
+ Source extends string = string,
14
+ // TODO crypto 以外の価格にも対応させる
15
+ Price extends CryptoCurrencyPrice | undefined =
16
+ | CryptoCurrencyPrice
17
+ | undefined,
18
+ Asset extends CryptoCurrency | FiatCurrency = CryptoCurrency | FiatCurrency,
19
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in'>
@@ -0,0 +1,23 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ type Action = 'remove-liquidity'
5
+
6
+ export type NormalActionRemoveLiquidity<
7
+ Account = unknown,
8
+ // TODO crypto 以外の価格にも対応させる
9
+ Price extends CryptoCurrencyPrice | undefined =
10
+ | CryptoCurrencyPrice
11
+ | undefined,
12
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
13
+ > = NormalAction<Action, Account, Price, Asset, 'in' | 'out'>
14
+
15
+ export type AccountActionRemoveLiquidity<
16
+ Account = unknown,
17
+ Source extends string = string,
18
+ // TODO crypto 以外の価格にも対応させる
19
+ Price extends CryptoCurrencyPrice | undefined =
20
+ | CryptoCurrencyPrice
21
+ | undefined,
22
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
23
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in' | 'out'>
@@ -0,0 +1,22 @@
1
+ import type {
2
+ CryptoCurrency,
3
+ CryptoCurrencyPrice,
4
+ FiatCurrency,
5
+ Nft,
6
+ } from '../../assets'
7
+ import type { AccountAction } from './common'
8
+
9
+ type Action = 'sell-nft'
10
+
11
+ export type AccountActionSellNft<
12
+ Account = unknown,
13
+ Source extends string = string,
14
+ // TODO crypto 以外の価格にも対応させる
15
+ Price extends CryptoCurrencyPrice | undefined =
16
+ | CryptoCurrencyPrice
17
+ | undefined,
18
+ Asset extends CryptoCurrency | FiatCurrency | Nft =
19
+ | CryptoCurrency
20
+ | FiatCurrency
21
+ | Nft,
22
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in' | 'out'>
@@ -0,0 +1,23 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction, NormalAction } from './common'
3
+
4
+ export type Action = 'spam'
5
+
6
+ export type NormalActionSpam<
7
+ Account = unknown,
8
+ // TODO crypto 以外の価格にも対応させる
9
+ Price extends CryptoCurrencyPrice | undefined =
10
+ | CryptoCurrencyPrice
11
+ | undefined,
12
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
13
+ > = NormalAction<Action, Account, Price, Asset, 'none'>
14
+
15
+ export type AccountActionSpam<
16
+ Account = unknown,
17
+ Source extends string = string,
18
+ // TODO crypto 以外の価格にも対応させる
19
+ Price extends CryptoCurrencyPrice | undefined =
20
+ | CryptoCurrencyPrice
21
+ | undefined,
22
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
23
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in' | 'out'>
@@ -0,0 +1,12 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction } from './common'
3
+
4
+ export type AccountActionSwapIncome<
5
+ Account = unknown,
6
+ Source extends string = string,
7
+ // TODO crypto 以外の価格にも対応させる
8
+ Price extends CryptoCurrencyPrice | undefined =
9
+ | CryptoCurrencyPrice
10
+ | undefined,
11
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
12
+ > = AccountAction<'swap-income', Source, Account, Price, Asset, 'in'>
@@ -0,0 +1,12 @@
1
+ import type { Nft } from '../../assets'
2
+ import type { AccountAction } from './common'
3
+
4
+ type Action = 'swap-nft'
5
+
6
+ export type AccountActionSwapNft<
7
+ Account = unknown,
8
+ Source extends string = string,
9
+ // TODO crypto 以外の価格にも対応させる
10
+ Price extends undefined = undefined,
11
+ Asset extends Nft = Nft,
12
+ > = AccountAction<Action, Source, Account, Price, Asset, 'in' | 'out'>
@@ -0,0 +1,12 @@
1
+ import type { CryptoCurrency, CryptoCurrencyPrice, Nft } from '../../assets'
2
+ import type { AccountAction } from './common'
3
+
4
+ export type AccountActionSwapTransfer<
5
+ Account = unknown,
6
+ Source extends string = string,
7
+ // TODO crypto 以外の価格にも対応させる
8
+ Price extends CryptoCurrencyPrice | undefined =
9
+ | CryptoCurrencyPrice
10
+ | undefined,
11
+ Asset extends CryptoCurrency | Nft = CryptoCurrency | Nft,
12
+ > = AccountAction<'swap-transfer', Source, Account, Price, Asset, 'out'>