@swapkit/helpers 2.4.3 → 3.0.0-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 (106) hide show
  1. package/dist/api/index.cjs +3 -0
  2. package/dist/api/index.cjs.map +16 -0
  3. package/dist/api/index.js +3 -0
  4. package/dist/api/index.js.map +16 -0
  5. package/dist/chunk-fazw0jvt.js +3 -0
  6. package/dist/chunk-fazw0jvt.js.map +9 -0
  7. package/dist/chunk-nm00d52v.js +4 -0
  8. package/dist/chunk-nm00d52v.js.map +9 -0
  9. package/dist/contracts/index.cjs +3 -0
  10. package/dist/contracts/index.cjs.map +38 -0
  11. package/dist/contracts/index.js +3 -0
  12. package/dist/contracts/index.js.map +38 -0
  13. package/dist/index.cjs +6 -0
  14. package/dist/index.cjs.map +29 -0
  15. package/dist/index.js +3 -3
  16. package/dist/index.js.map +19 -20
  17. package/dist/tokens/index.cjs +3 -0
  18. package/dist/tokens/index.cjs.map +23 -0
  19. package/dist/tokens/index.js +3 -0
  20. package/dist/tokens/index.js.map +23 -0
  21. package/package.json +31 -15
  22. package/src/api/index.ts +19 -0
  23. package/src/api/microgard/endpoints.ts +83 -0
  24. package/src/api/microgard/types.ts +60 -0
  25. package/src/api/midgard/endpoints.ts +166 -0
  26. package/src/api/midgard/types.ts +155 -0
  27. package/src/api/swapkitApi/endpoints.ts +266 -0
  28. package/src/api/swapkitApi/types.ts +772 -0
  29. package/src/api/thornode/endpoints.ts +78 -0
  30. package/src/api/thornode/types.ts +241 -0
  31. package/src/api/thorswapStatic/endpoints.ts +30 -0
  32. package/src/api/thorswapStatic/types.ts +18 -0
  33. package/src/contracts/abis/avaxGeneric.ts +92 -0
  34. package/src/contracts/abis/avaxWoofi.ts +145 -0
  35. package/src/contracts/abis/bscGeneric.ts +106 -0
  36. package/src/contracts/abis/chainflipGateway.ts +330 -0
  37. package/src/contracts/abis/erc20.ts +99 -0
  38. package/src/contracts/abis/ethGeneric.ts +92 -0
  39. package/src/contracts/abis/mayaEvmVaults.ts +331 -0
  40. package/src/contracts/abis/pancakeV2.ts +145 -0
  41. package/src/contracts/abis/pangolin.ts +120 -0
  42. package/src/contracts/abis/sushiswap.ts +120 -0
  43. package/src/contracts/abis/tcEthVault.ts +650 -0
  44. package/src/contracts/abis/traderJoe.ts +120 -0
  45. package/src/contracts/abis/uniswapV2.ts +120 -0
  46. package/src/contracts/abis/uniswapV2Leg.ts +128 -0
  47. package/src/contracts/abis/uniswapV3_100.ts +128 -0
  48. package/src/contracts/abis/uniswapV3_10000.ts +128 -0
  49. package/src/contracts/abis/uniswapV3_3000.ts +128 -0
  50. package/src/contracts/abis/uniswapV3_500.ts +128 -0
  51. package/src/contracts/index.ts +95 -0
  52. package/src/contracts/routers/index.ts +58 -0
  53. package/src/contracts/routers/kyber.ts +402 -0
  54. package/src/contracts/routers/oneinch.ts +2188 -0
  55. package/src/contracts/routers/pancakeswap.ts +340 -0
  56. package/src/contracts/routers/pangolin.ts +340 -0
  57. package/src/contracts/routers/sushiswap.ts +340 -0
  58. package/src/contracts/routers/traderJoe.ts +340 -0
  59. package/src/contracts/routers/uniswapv2.ts +340 -0
  60. package/src/contracts/routers/uniswapv3.ts +254 -0
  61. package/src/contracts/routers/woofi.ts +171 -0
  62. package/src/index.ts +11 -12
  63. package/src/modules/__tests__/assetValue.test.ts +0 -2
  64. package/src/modules/__tests__/swapKitConfig.test.ts +37 -0
  65. package/src/modules/assetValue.ts +26 -92
  66. package/src/modules/bigIntArithmetics.ts +6 -2
  67. package/src/modules/requestClient.ts +26 -35
  68. package/src/modules/swapKitConfig.ts +131 -0
  69. package/src/modules/swapKitError.ts +6 -6
  70. package/src/tokens/index.ts +15 -0
  71. package/src/tokens/lists/camelot_v3.ts +15920 -0
  72. package/src/tokens/lists/caviar_v1.ts +1694 -0
  73. package/src/tokens/lists/chainflip.ts +104 -0
  74. package/src/tokens/lists/index.ts +13 -0
  75. package/src/tokens/lists/jupiter.ts +29606 -0
  76. package/src/tokens/lists/mayachain.ts +513 -0
  77. package/src/tokens/lists/oneinch.ts +14238 -0
  78. package/src/tokens/lists/openocean_v2.ts +11514 -0
  79. package/src/tokens/lists/pancakeswap.ts +4296 -0
  80. package/src/tokens/lists/pangolin_v1.ts +175 -0
  81. package/src/tokens/lists/sushiswap_v2.ts +965 -0
  82. package/src/tokens/lists/thorchain.ts +669 -0
  83. package/src/tokens/lists/traderjoe_v2.ts +1384 -0
  84. package/src/tokens/lists/uniswap_v2.ts +5596 -0
  85. package/src/tokens/lists/uniswap_v3.ts +5946 -0
  86. package/src/types/chains.ts +26 -46
  87. package/src/types/commonTypes.ts +3 -90
  88. package/src/types/index.ts +3 -4
  89. package/src/types/sdk.ts +0 -24
  90. package/src/types/tokens.ts +1 -1
  91. package/src/types/wallet.ts +37 -21
  92. package/src/{helpers → utils}/asset.ts +49 -19
  93. package/src/{helpers → utils}/derivationPath.ts +7 -2
  94. package/src/{helpers → utils}/memo.ts +0 -65
  95. package/src/{helpers → utils}/others.ts +12 -5
  96. package/src/utils/plugin.ts +13 -0
  97. package/src/{helpers/web3wallets.ts → utils/wallets.ts} +175 -148
  98. package/src/modules/walletUtils.ts +0 -30
  99. package/src/types/network.ts +0 -49
  100. /package/src/{helpers → utils}/__tests__/asset.test.ts +0 -0
  101. /package/src/{helpers/__tests__/derivationPath.ts → utils/__tests__/derivationPath.test.ts} +0 -0
  102. /package/src/{helpers → utils}/__tests__/memo.test.ts +0 -0
  103. /package/src/{helpers → utils}/__tests__/others.test.ts +0 -0
  104. /package/src/{helpers → utils}/__tests__/validators.test.ts +0 -0
  105. /package/src/{helpers → utils}/liquidity.ts +0 -0
  106. /package/src/{helpers → utils}/validators.ts +0 -0
package/package.json CHANGED
@@ -1,17 +1,34 @@
1
1
  {
2
2
  "author": "swapkit-oss",
3
- "description": "SwapKit - Helpers",
4
3
  "dependencies": {
5
- "@swapkit/contracts": "1.1.0",
6
- "@swapkit/tokens": "2.2.2"
4
+ "zod": "3.24.2",
5
+ "zustand": "5.0.3"
7
6
  },
7
+ "description": "SwapKit - Helpers",
8
8
  "devDependencies": {
9
- "@swapkit/toolbox-cosmos": "1.8.5",
10
- "@swapkit/toolbox-evm": "1.8.7",
11
- "@swapkit/toolbox-radix": "1.2.33",
12
- "@swapkit/toolbox-solana": "1.4.5",
13
- "@swapkit/toolbox-substrate": "1.3.17",
14
- "@swapkit/toolbox-utxo": "1.2.17"
9
+ "@swapkit/toolboxes": "1.0.0-beta.0"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "default": "./dist/index.js",
14
+ "require": "./dist/index.cjs",
15
+ "types": "./src/index.ts"
16
+ },
17
+ "./api": {
18
+ "default": "./dist/api/index.js",
19
+ "require": "./dist/api/index.cjs",
20
+ "types": "./src/api/index.ts"
21
+ },
22
+ "./contracts": {
23
+ "default": "./dist/contracts/index.js",
24
+ "require": "./dist/contracts/index.cjs",
25
+ "types": "./src/contracts/index.ts"
26
+ },
27
+ "./tokens": {
28
+ "default": "./dist/tokens/index.js",
29
+ "require": "./dist/tokens/index.cjs",
30
+ "types": "./src/tokens/index.ts"
31
+ }
15
32
  },
16
33
  "files": [
17
34
  "src/",
@@ -19,7 +36,6 @@
19
36
  ],
20
37
  "homepage": "https://github.com/thorswap/SwapKit",
21
38
  "license": "Apache-2.0",
22
- "main": "./dist/index.js",
23
39
  "name": "@swapkit/helpers",
24
40
  "repository": {
25
41
  "type": "git",
@@ -28,12 +44,12 @@
28
44
  "scripts": {
29
45
  "build": "bun run ./build.ts",
30
46
  "clean": "rm -rf dist node_modules *.tsbuildinfo",
31
- "lint": "biome check --diagnostic-level=error --write ./src",
47
+ "lint": "biome check --write ./src",
48
+ "generate-tokens": "bun --bun ./fetchTokenLists.ts",
32
49
  "test": "bun test",
33
- "test:coverage": "bun test --coverage",
50
+ "test:ci": "bun test --coverage",
34
51
  "type-check": "tsc --noEmit"
35
52
  },
36
53
  "type": "module",
37
- "types": "./src/index.ts",
38
- "version": "2.4.3"
39
- }
54
+ "version": "3.0.0-beta.0"
55
+ }
@@ -0,0 +1,19 @@
1
+ import * as microgard from "./microgard/endpoints";
2
+ import { mayachainMidgard, thorchainMidgard } from "./midgard/endpoints";
3
+ import * as swapkit from "./swapkitApi/endpoints";
4
+ import * as thornode from "./thornode/endpoints";
5
+ import * as tsStatic from "./thorswapStatic/endpoints";
6
+
7
+ export * from "./microgard/types";
8
+ export * from "./thorswapStatic/types";
9
+ export * from "./thornode/types";
10
+ export * from "./swapkitApi/types";
11
+
12
+ export const SwapKitApi = {
13
+ ...swapkit,
14
+ ...tsStatic,
15
+ mayachainMidgard,
16
+ microgard,
17
+ thorchainMidgard,
18
+ thornode,
19
+ };
@@ -0,0 +1,83 @@
1
+ import {
2
+ AssetValue,
3
+ BaseDecimal,
4
+ type Chain,
5
+ RequestClient,
6
+ SwapKitNumber,
7
+ } from "@swapkit/helpers";
8
+ import type { LiquidityPositionRaw, PoolDetail, PoolPeriod, THORNameDetails } from "./types";
9
+
10
+ /**
11
+ * TODO: Move to SKConfig under midgardUrls.microgard
12
+ */
13
+ const baseUrl = "https://mu.thorswap.net";
14
+
15
+ export function getTHORNameDetails(thorname: string) {
16
+ return RequestClient.get<THORNameDetails>(`${baseUrl}/thorname/lookup/${thorname}`);
17
+ }
18
+
19
+ export function getTHORNamesByOwner(owner: string) {
20
+ return RequestClient.get<string[]>(`${baseUrl}/thorname/owner/${owner}`);
21
+ }
22
+
23
+ export function getTHORNamesByAddress(address: string) {
24
+ return RequestClient.get<string[]>(`${baseUrl}/thorname/address/${address}`);
25
+ }
26
+
27
+ export function getTHORChainPools(period: PoolPeriod) {
28
+ return RequestClient.get<PoolDetail[]>(`${baseUrl}/pools`, { searchParams: { period } });
29
+ }
30
+
31
+ export function getLiquidityPositionsRaw(addresses: string[]) {
32
+ return RequestClient.get<LiquidityPositionRaw[]>(
33
+ `${baseUrl}/fullmember?address=${addresses.join(",")}`,
34
+ );
35
+ }
36
+
37
+ export async function getTNSChainAddress({ chain, tns }: { chain: Chain; tns: string }) {
38
+ const tnsDetails = await getTHORNameDetails(tns);
39
+
40
+ return tnsDetails?.entries?.find((e) => e.chain.toLowerCase() === chain.toLowerCase())?.address;
41
+ }
42
+
43
+ export async function getLiquidityPositions(addresses: string[]) {
44
+ const rawLiquidityPositions = await getLiquidityPositionsRaw(addresses);
45
+
46
+ return rawLiquidityPositions.map((p) => ({
47
+ assetRegisteredAddress: p.assetAddress,
48
+ asset: AssetValue.from({
49
+ asset: p.pool,
50
+ value: p.assetAdded,
51
+ fromBaseDecimal: BaseDecimal.THOR,
52
+ }),
53
+ assetPending: AssetValue.from({
54
+ asset: p.pool,
55
+ value: p.assetPending,
56
+ fromBaseDecimal: BaseDecimal.THOR,
57
+ }),
58
+ assetWithdrawn: AssetValue.from({
59
+ asset: p.pool,
60
+ value: p.assetWithdrawn,
61
+ fromBaseDecimal: BaseDecimal.THOR,
62
+ }),
63
+ runeRegisteredAddress: p.runeAddress,
64
+ rune: AssetValue.from({
65
+ asset: "THOR.RUNE",
66
+ value: p.runeAdded,
67
+ fromBaseDecimal: BaseDecimal.THOR,
68
+ }),
69
+ runePending: AssetValue.from({
70
+ asset: "THOR.RUNE",
71
+ value: p.runePending,
72
+ fromBaseDecimal: BaseDecimal.THOR,
73
+ }),
74
+ runeWithdrawn: AssetValue.from({
75
+ asset: "THOR.RUNE",
76
+ value: p.runeWithdrawn,
77
+ fromBaseDecimal: BaseDecimal.THOR,
78
+ }),
79
+ poolShare: new SwapKitNumber(p.sharedUnits).div(p.poolUnits),
80
+ dateLastAdded: p.dateLastAdded,
81
+ dateFirstAdded: p.dateFirstAdded,
82
+ }));
83
+ }
@@ -0,0 +1,60 @@
1
+ import type { AssetValue, SwapKitNumber } from "@swapkit/helpers";
2
+
3
+ export type THORNameDetails = {
4
+ entries: Array<{ address: string; chain: string }>;
5
+ owner: string;
6
+ expire: string;
7
+ };
8
+
9
+ export type PoolPeriod = "1h" | "24h" | "7d" | "30d" | "90d" | "100d" | "180d" | "365d";
10
+
11
+ export type PoolDetail = {
12
+ annualPercentageRate: string;
13
+ asset: string;
14
+ assetDepth: string;
15
+ assetPrice: string;
16
+ assetPriceUSD: string;
17
+ liquidityUnits: string;
18
+ poolAPY: string;
19
+ runeDepth: string;
20
+ saversAPR: string;
21
+ saversDepth: string;
22
+ saversUnits: string;
23
+ status: string;
24
+ synthSupply: string;
25
+ synthUnits: string;
26
+ units: string;
27
+ volume24h: string;
28
+ };
29
+
30
+ export type LiquidityPositionRaw = {
31
+ assetAdded: string;
32
+ assetAddress: string;
33
+ assetPending: string;
34
+ assetWithdrawn: string;
35
+ dateFirstAdded: string;
36
+ dateLastAdded: string;
37
+ pool: string;
38
+ poolAssetDepth: string;
39
+ poolRuneDepth: string;
40
+ poolUnits: string;
41
+ runeAdded: string;
42
+ runeAddress: string;
43
+ runePending: string;
44
+ runeWithdrawn: string;
45
+ sharedUnits: string;
46
+ };
47
+
48
+ export type LiquidityPosition = {
49
+ asset: AssetValue;
50
+ assetPending: AssetValue;
51
+ assetWithdrawn: AssetValue;
52
+ assetAddress: string;
53
+ native: AssetValue;
54
+ nativeAddress: string;
55
+ nativePending: AssetValue;
56
+ nativeWithdrawn: AssetValue;
57
+ dateFirstAdded: string;
58
+ dateLastAdded: string;
59
+ poolShare: SwapKitNumber;
60
+ };
@@ -0,0 +1,166 @@
1
+ import { AssetValue, BaseDecimal, Chain, RequestClient, SwapKitNumber } from "@swapkit/helpers";
2
+ import type {
3
+ BorrowerDetails,
4
+ MemberDetailsMayachain,
5
+ MemberDetailsThorchain,
6
+ SaverDetails,
7
+ THORNameDetails,
8
+ } from "./types";
9
+
10
+ // TODO: question: Move to SKConfig under midgardUrls
11
+ // also - shouldn't that be named `isThorchain`?
12
+ // As we default to TC and this is the only place that checks for opposite
13
+ function getMidgardBaseUrl(isMayachain = false) {
14
+ return isMayachain ? "https://midgard.mayachain.info" : "https://midgard.ninerealms.com";
15
+ }
16
+
17
+ function getNameServiceBaseUrl(isMayachain = false) {
18
+ return isMayachain
19
+ ? `${getMidgardBaseUrl(isMayachain)}/v2/mayaname`
20
+ : `${getMidgardBaseUrl(isMayachain)}/v2/thorname`;
21
+ }
22
+
23
+ export function getBorrowerDetailRaw(address: string, isMayachain = false) {
24
+ return RequestClient.get<BorrowerDetails>(
25
+ `${getMidgardBaseUrl(isMayachain)}/v2/borrower/${address}`,
26
+ );
27
+ }
28
+
29
+ export function getSaverDetailRaw(address: string, isMayachain = false) {
30
+ return RequestClient.get<SaverDetails>(`${getMidgardBaseUrl(isMayachain)}/v2/saver/${address}`);
31
+ }
32
+
33
+ export function getLiquidityPositionRaw<T extends boolean = false>(
34
+ address: string,
35
+ isMayachain?: T,
36
+ ) {
37
+ return RequestClient.get<T extends true ? MemberDetailsMayachain : MemberDetailsThorchain>(
38
+ `${getMidgardBaseUrl(isMayachain)}/v2/member/${address}`,
39
+ );
40
+ }
41
+
42
+ export function getNameDetails(name: string, isMayachain = false) {
43
+ return RequestClient.get<THORNameDetails>(`${getNameServiceBaseUrl(isMayachain)}/lookup/${name}`);
44
+ }
45
+
46
+ export function getNamesByAddress(address: string, isMayachain = false) {
47
+ return RequestClient.get<THORNameDetails>(
48
+ `${getNameServiceBaseUrl(isMayachain)}/rlookup/${address}`,
49
+ );
50
+ }
51
+
52
+ export function getNamesByOwner(address: string, isMayachain = false) {
53
+ return RequestClient.get<THORNameDetails>(
54
+ `${getNameServiceBaseUrl(isMayachain)}/owner/${address}`,
55
+ );
56
+ }
57
+
58
+ export async function getBorrowerDetail(address: string, isMayachain = false) {
59
+ const rawBorrowerDetail = await getBorrowerDetailRaw(address, isMayachain);
60
+
61
+ return rawBorrowerDetail.pools.map((p) => ({
62
+ collateral_deposited: AssetValue.from({
63
+ asset: p.collateral_asset,
64
+ value: p.collateral_deposited,
65
+ fromBaseDecimal: BaseDecimal.THOR,
66
+ }),
67
+ collateral_withdrawn: AssetValue.from({
68
+ asset: p.collateral_asset,
69
+ value: p.collateral_withdrawn,
70
+ fromBaseDecimal: BaseDecimal.THOR,
71
+ }),
72
+ debt_issued_tor: SwapKitNumber.fromBigInt(BigInt(p.debt_issued_tor), BaseDecimal.THOR),
73
+ debt_repaid_tor: SwapKitNumber.fromBigInt(BigInt(p.debt_repaid_tor), BaseDecimal.THOR),
74
+ last_open_loan_timestamp: p.last_open_loan_timestamp,
75
+ last_repay_loan_timestamp: p.last_repay_loan_timestamp,
76
+ target_assets: p.target_assets.map((asset) => AssetValue.from({ asset })),
77
+ }));
78
+ }
79
+
80
+ export async function getSaverDetail(address: string, isMayachain = false) {
81
+ const rawSaverPositions = await getSaverDetailRaw(address, isMayachain);
82
+
83
+ return rawSaverPositions.pools.map((p) => ({
84
+ assetRegisteredAddress: p.assetAddress,
85
+ assetAdded: AssetValue.from({
86
+ asset: p.pool,
87
+ value: p.assetAdded,
88
+ fromBaseDecimal: BaseDecimal.THOR,
89
+ }),
90
+ assetDeposit: AssetValue.from({
91
+ asset: p.pool,
92
+ value: p.assetDeposit,
93
+ fromBaseDecimal: BaseDecimal.THOR,
94
+ }),
95
+ assetRedeem: AssetValue.from({
96
+ asset: p.pool,
97
+ value: p.assetRedeem,
98
+ fromBaseDecimal: BaseDecimal.THOR,
99
+ }),
100
+ assetWithdrawn: AssetValue.from({
101
+ asset: p.pool,
102
+ value: p.assetWithdrawn,
103
+ fromBaseDecimal: BaseDecimal.THOR,
104
+ }),
105
+ dateLastAdded: p.dateLastAdded,
106
+ dateFirstAdded: p.dateFirstAdded,
107
+ }));
108
+ }
109
+
110
+ export async function getLiquidityPosition(address: string, isMayachain = false) {
111
+ const rawLiquidityPositions = await getLiquidityPositionRaw(address, isMayachain);
112
+
113
+ return rawLiquidityPositions.pools.map((p) => ({
114
+ assetRegisteredAddress: p.assetAddress,
115
+ asset: AssetValue.from({
116
+ asset: p.pool,
117
+ value: p.assetAdded,
118
+ fromBaseDecimal: BaseDecimal.THOR,
119
+ }),
120
+ assetPending: AssetValue.from({
121
+ asset: p.pool,
122
+ value: p.assetPending,
123
+ fromBaseDecimal: BaseDecimal.THOR,
124
+ }),
125
+ assetWithdrawn: AssetValue.from({
126
+ asset: p.pool,
127
+ value: p.assetWithdrawn,
128
+ fromBaseDecimal: BaseDecimal.THOR,
129
+ }),
130
+ [`${isMayachain ? "cacao" : "rune"}RegisteredAddress`]: p.runeAddress,
131
+ [`${isMayachain ? "cacao" : "rune"}`]: AssetValue.from({
132
+ asset: "THOR.RUNE",
133
+ value: p.runeAdded,
134
+ fromBaseDecimal: BaseDecimal.THOR,
135
+ }),
136
+ [`${isMayachain ? "cacao" : "rune"}Pending`]: AssetValue.from({
137
+ asset: "THOR.RUNE",
138
+ value: p.runePending,
139
+ fromBaseDecimal: BaseDecimal.THOR,
140
+ }),
141
+ [`${isMayachain ? "cacao" : "rune"}Withdrawn`]: AssetValue.from({
142
+ asset: "THOR.RUNE",
143
+ value: p.runeWithdrawn,
144
+ fromBaseDecimal: BaseDecimal.THOR,
145
+ }),
146
+ poolShare: new SwapKitNumber(p.liquidityUnits).div(p.pool),
147
+ dateLastAdded: p.dateLastAdded,
148
+ dateFirstAdded: p.dateFirstAdded,
149
+ }));
150
+ }
151
+
152
+ const getMidgardMethodsForProtocol = (chain: Chain.THORChain | Chain.Maya) => ({
153
+ getBorrowerDetail: (address: string) => getBorrowerDetail(address, chain === Chain.Maya),
154
+ getBorrowerDetailRaw: (address: string) => getBorrowerDetailRaw(address, chain === Chain.Maya),
155
+ getSaversDetail: (address: string) => getSaverDetail(address, chain === Chain.Maya),
156
+ getSaverDetailRaw: (address: string) => getSaverDetailRaw(address, chain === Chain.Maya),
157
+ getLiquidityPosition: (address: string) => getLiquidityPosition(address, chain === Chain.Maya),
158
+ getLiquidityPositionRaw: (address: string) =>
159
+ getLiquidityPositionRaw(address, chain === Chain.Maya),
160
+ getNameDetails: (name: string) => getNameDetails(name, chain === Chain.Maya),
161
+ getNamesByAddress: (address: string) => getNamesByAddress(address, chain === Chain.Maya),
162
+ getNamesByOwner: (address: string) => getNamesByOwner(address, chain === Chain.Maya),
163
+ });
164
+
165
+ export const thorchainMidgard = getMidgardMethodsForProtocol(Chain.THORChain);
166
+ export const mayachainMidgard = getMidgardMethodsForProtocol(Chain.Maya);
@@ -0,0 +1,155 @@
1
+ export type BorrowerDetails = {
2
+ /** @description List details of all the loans identified with the given address */
3
+ pools: BorrowerPool[];
4
+ };
5
+
6
+ export type BorrowerPool = {
7
+ /** @description The asset that the borrower used as collateral */
8
+ collateral_asset: string;
9
+ /** @description Int64(e8), The total amount of collateral that user deposited */
10
+ collateral_deposited: string;
11
+ /** @description Int64(e8), The total amount of collateral the system paid back to the user */
12
+ collateral_withdrawn: string;
13
+ /** @description Int64(e8), The total amount of debt issued as debt for user. denominated in TOR. */
14
+ debt_issued_tor: string;
15
+ /** @description Int64(e8), The total amount of debt that the user paid back. denominated in TOR. */
16
+ debt_repaid_tor: string;
17
+ /** @description Int64, Unix timestamp for the last time borrower opened a loan */
18
+ last_open_loan_timestamp: string;
19
+ /** @description Int64, Unix timestamp for the last time borrower repayment occurred */
20
+ last_repay_loan_timestamp: string;
21
+ target_assets: string[];
22
+ };
23
+
24
+ export type SaverDetails = {
25
+ /** @description List details of all the savers identified with the given address */
26
+ pools: SaverPool[];
27
+ };
28
+
29
+ export type SaverPool = {
30
+ /** @description Int64(e8), total asset added in the saver pool by member */
31
+ assetAdded: string;
32
+ /** @description saver address used by the member */
33
+ assetAddress: string;
34
+ /** @description Int64(e8), total asset that is currently deposited by the member */
35
+ assetDeposit: string;
36
+ /** @description Int64(e8), total asset can be redeemed from the saver pool by member */
37
+ assetRedeem: string;
38
+ /** @description Int64(e8), total asset withdrawn from the saver pool by member */
39
+ assetWithdrawn: string;
40
+ /** @description Int64, Unix timestamp for the first time member deposited into the saver pool */
41
+ dateFirstAdded: string;
42
+ /** @description Int64, Unix timestamp for the last time member deposited into the saver pool */
43
+ dateLastAdded: string;
44
+ /** @description The Pool rest of the data are refering to (only those pools can show up which have a corresponding saver pool) */
45
+ pool: string;
46
+ /** @description Int64, saver liquidity units that belong the the member */
47
+ saverUnits: string;
48
+ };
49
+
50
+ export type MemberDetailsMayachain = {
51
+ /** @MemberPool List details of all the liquidity providers identified with the given address */
52
+ pools: MemberPoolMayachain[];
53
+ };
54
+
55
+ export type MemberPoolMayachain = {
56
+ /** @description Int64(e8), total asset added to the pool by member */
57
+ assetAdded: string;
58
+ /** @description asset address used by the member */
59
+ assetAddress: string;
60
+ /** @description Int64(e8), total asset that is currently deposited to the pool by member.
61
+ * This field is same as the `asset_deposit_value` field in thornode. Mainly can be used
62
+ * for tracking, mainly Growth Percentage
63
+ * */
64
+ assetDeposit: string;
65
+ /** @description Int64(e8), asset sent but not added yet, it will be added when the rune pair arrives
66
+ * */
67
+ assetPending: string;
68
+ /** @description Int64(e8), total asset withdrawn from the pool by member */
69
+ assetWithdrawn: string;
70
+ /** @description Int64(e8), total Cacao that is currently deposited to the pool by member.
71
+ * This field is same as the `rune_deposit_value` field in thornode. Mainly can be used
72
+ * for tracking, mainly Growth Percentage
73
+ * */
74
+ cacaoDeposit: string;
75
+ /** @description Int64, Unix timestamp for the first time member deposited into the pool */
76
+ dateFirstAdded: string;
77
+ /** @description Int64, Unix timestamp for the last time member deposited into the pool */
78
+ dateLastAdded: string;
79
+ /** @description Int64, pool liquidity units that belong the the member */
80
+ liquidityUnits: string;
81
+ /** @description Pool rest of the data refers to */
82
+ pool: string;
83
+ /** @description Int64(e8), total Rune added to the pool by member */
84
+ runeAdded: string;
85
+ /** @description Rune address used by the member */
86
+ runeAddress: string;
87
+ /** @description Int64(e8), Rune sent but not added yet, it will be added when the asset pair arrives
88
+ * */
89
+ runePending: string;
90
+ /** @description Int64(e8), total Rune withdrawn from the pool by member */
91
+ runeWithdrawn: string;
92
+ };
93
+
94
+ export type MemberDetailsThorchain = {
95
+ /** @MemberPool List details of all the liquidity providers identified with the given address */
96
+ pools: MemberPoolThorchain[];
97
+ };
98
+
99
+ export type MemberPoolThorchain = {
100
+ /** @description Int64(e8), total asset added to the pool by member */
101
+ assetAdded: string;
102
+ /** @description asset address used by the member */
103
+ assetAddress: string;
104
+ /** @description Int64(e8), total asset that is currently deposited to the pool by member.
105
+ * This field is same as the `asset_deposit_value` field in thornode. Mainly can be used
106
+ * for tracking, mainly Growth Percentage
107
+ * */
108
+ assetDeposit: string;
109
+ /** @description Int64(e8), asset sent but not added yet, it will be added when the rune pair arrives
110
+ * */
111
+ assetPending: string;
112
+ /** @description Int64(e8), total asset withdrawn from the pool by member */
113
+ assetWithdrawn: string;
114
+ /** @description Int64(e8), total Rune that is currently deposited to the pool by member.
115
+ * This field is same as the `rune_deposit_value` field in thornode. Mainly can be used
116
+ * for tracking, mainly Growth Percentage
117
+ * */
118
+ runeDeposit: string;
119
+ /** @description Int64, Unix timestamp for the first time member deposited into the pool */
120
+ dateFirstAdded: string;
121
+ /** @description Int64, Unix timestamp for the last time member deposited into the pool */
122
+ dateLastAdded: string;
123
+ /** @description Int64, pool liquidity units that belong the the member */
124
+ liquidityUnits: string;
125
+ /** @description Pool rest of the data refers to */
126
+ pool: string;
127
+ /** @description Int64(e8), total Rune added to the pool by member */
128
+ runeAdded: string;
129
+ /** @description Rune address used by the member */
130
+ runeAddress: string;
131
+ /** @description Int64(e8), Rune sent but not added yet, it will be added when the asset pair arrives
132
+ * */
133
+ runePending: string;
134
+ /** @description Int64(e8), total Rune withdrawn from the pool by member */
135
+ runeWithdrawn: string;
136
+ };
137
+
138
+ export type THORNameDetails = {
139
+ /** @description List details of all chains and their addresses for a given THORName */
140
+ entries: THORNameEntry[];
141
+ /** @description Int64, THORChain block height in which THORName expires */
142
+ expire: string;
143
+ /**
144
+ * @description owner's THOR address
145
+ * @example thor102y0m3uptg0vvudeyh00r2fnz70wq7d8y7mu2g
146
+ */
147
+ owner: string;
148
+ };
149
+
150
+ export type THORNameEntry = {
151
+ /** @description address on blockchain */
152
+ address: string;
153
+ /** @description blockchain */
154
+ chain: string;
155
+ };