@alphafi/alphafi-sdk 0.0.12 → 0.0.13

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 (153) hide show
  1. package/dist/common/alphaTypes.d.ts +109 -0
  2. package/dist/common/cetus_mainnet_config.d.ts +2 -0
  3. package/dist/common/coins.d.ts +4 -0
  4. package/dist/common/constants.d.ts +401 -0
  5. package/dist/common/maps.d.ts +56 -0
  6. package/dist/common/pyth.d.ts +6 -0
  7. package/dist/common/types.d.ts +412 -0
  8. package/dist/example.d.ts +2 -0
  9. package/dist/getAirdropShare.d.ts +1 -0
  10. package/dist/getAllVaults.d.ts +3 -0
  11. package/dist/getAlphaUnlocks.d.ts +13 -0
  12. package/dist/getAprs.d.ts +5 -0
  13. package/dist/getHoldersFromTransactions.d.ts +8 -0
  14. package/dist/getLastAutoCompoundTime.d.ts +2 -0
  15. package/dist/getRebalanceHistory.d.ts +3 -0
  16. package/dist/getVaultBalances.d.ts +8 -0
  17. package/dist/getVaults.d.ts +4 -0
  18. package/dist/graphql/client.d.ts +3 -0
  19. package/dist/graphql/executeMutations.d.ts +3 -0
  20. package/dist/graphql/fetchAutoCompoundingEventsGql.d.ts +26 -0
  21. package/dist/graphql/fetchData.d.ts +10 -0
  22. package/dist/graphql/fetchNftHolders.d.ts +2 -0
  23. package/dist/graphql/fetchReceipts.d.ts +2 -0
  24. package/dist/graphql/mutations.d.ts +3 -0
  25. package/dist/graphql/parseData.d.ts +1 -0
  26. package/dist/graphql/parseLockedTableId.d.ts +6 -0
  27. package/dist/graphql/queries.d.ts +14 -0
  28. package/dist/graphql/types.d.ts +69 -0
  29. package/dist/index.d.ts +18 -0
  30. package/dist/sui-sdk/client.d.ts +3 -0
  31. package/dist/sui-sdk/events/fetchAutoCompoundingEvents.d.ts +5 -0
  32. package/dist/sui-sdk/events/fetchEvents.d.ts +2 -0
  33. package/dist/sui-sdk/events/fetchLiquidityChangeEvents.d.ts +2 -0
  34. package/dist/sui-sdk/events/fetchRebalanceEvents.d.ts +4 -0
  35. package/dist/sui-sdk/events/parseData.d.ts +3 -0
  36. package/dist/sui-sdk/events/types.d.ts +93 -0
  37. package/dist/sui-sdk/functions/fetchTableData.d.ts +49 -0
  38. package/dist/sui-sdk/functions/fetchUserVaultBalances.d.ts +2 -0
  39. package/dist/sui-sdk/functions/fetchUserVaults.d.ts +2 -0
  40. package/dist/sui-sdk/functions/getPortfolioAmounts.d.ts +32 -0
  41. package/dist/sui-sdk/functions/getReceipts.d.ts +8 -0
  42. package/dist/sui-sdk/transactions/constants.d.ts +3 -0
  43. package/dist/sui-sdk/transactions/fetchTransactions.d.ts +3 -0
  44. package/dist/sui-sdk/transactions/types.d.ts +7 -0
  45. package/dist/types.d.ts +212 -0
  46. package/dist/utils/clmm/prices.d.ts +19 -0
  47. package/dist/utils/clmm/tokenAmountFromLiquidity.d.ts +10 -0
  48. package/dist/utils/clmm/types.d.ts +24 -0
  49. package/dist/utils/constants.d.ts +2 -0
  50. package/dist/utils/getHoldersFromTransactionsUtils.d.ts +5 -0
  51. package/dist/utils/getReceipts.d.ts +3 -0
  52. package/dist/utils/hop.d.ts +15 -0
  53. package/dist/utils/prices.d.ts +6 -0
  54. package/dist/utils/simpleCache.d.ts +9 -0
  55. package/dist/utils/types.d.ts +4 -0
  56. package/dist/utils/userHoldings.d.ts +5 -0
  57. package/dist/vaultFunctions.d.ts +4 -0
  58. package/package.json +4 -1
  59. package/.envrc +0 -1
  60. package/.eslintrc.json +0 -21
  61. package/.github/workflows/static.yml +0 -51
  62. package/.prettierrc.json +0 -27
  63. package/.prettierrc.json~ +0 -30
  64. package/__tests__/getAprs.test.ts~ +0 -9
  65. package/__tests__/getRebalanceHistory.test.ts~ +0 -19
  66. package/apr.org +0 -11
  67. package/babel.config.json +0 -11
  68. package/docs/.nojekyll +0 -1
  69. package/docs/assets/highlight.css +0 -78
  70. package/docs/assets/icons.js +0 -18
  71. package/docs/assets/icons.svg +0 -1
  72. package/docs/assets/main.js +0 -60
  73. package/docs/assets/navigation.js +0 -1
  74. package/docs/assets/search.js +0 -1
  75. package/docs/assets/style.css +0 -1448
  76. package/docs/functions/alphaLpBreakdown.html +0 -1
  77. package/docs/functions/cetusLpBreakdown.html +0 -1
  78. package/docs/functions/collectRewards.html +0 -1
  79. package/docs/functions/deposit.html +0 -1
  80. package/docs/functions/fetchAutoCompoundingEventsGql.html +0 -1
  81. package/docs/functions/fetchCetusPools.html +0 -1
  82. package/docs/functions/fetchChainIdentifier.html +0 -1
  83. package/docs/functions/fetchNftHolders.html +0 -1
  84. package/docs/functions/fetchPools.html +0 -1
  85. package/docs/functions/fetchPortfolioData.html +0 -1
  86. package/docs/functions/fetchProtocolData.html +0 -1
  87. package/docs/functions/fetchUserVaultBalances.html +0 -1
  88. package/docs/functions/fetchUserVaults.html +0 -1
  89. package/docs/functions/fetchUserWalletData.html +0 -1
  90. package/docs/functions/getAirdropShare.html +0 -1
  91. package/docs/functions/getAllDoubleAssetVaults.html +0 -1
  92. package/docs/functions/getAllSingleAssetVaults.html +0 -1
  93. package/docs/functions/getAllVaults.html +0 -1
  94. package/docs/functions/getAlphaVaultBalance.html +0 -1
  95. package/docs/functions/getApr.html +0 -1
  96. package/docs/functions/getAprs.html +0 -1
  97. package/docs/functions/getApy.html +0 -1
  98. package/docs/functions/getApys.html +0 -1
  99. package/docs/functions/getDoubleAssetVaultBalance.html +0 -1
  100. package/docs/functions/getDoubleAssetVaults.html +0 -1
  101. package/docs/functions/getRebalanceHistories.html +0 -1
  102. package/docs/functions/getRebalanceHistory.html +0 -1
  103. package/docs/functions/getSingleAssetVaultBalance.html +0 -1
  104. package/docs/functions/getSingleAssetVaults.html +0 -1
  105. package/docs/functions/getVaultBalance.html +0 -1
  106. package/docs/functions/getVaults.html +0 -1
  107. package/docs/functions/lastAutocompoundTime.html +0 -1
  108. package/docs/functions/parseUserWalletData.html +0 -1
  109. package/docs/functions/withdraw.html +0 -1
  110. package/docs/index.html +0 -40
  111. package/docs/interfaces/Coin.html +0 -5
  112. package/docs/interfaces/CoinPair.html +0 -3
  113. package/docs/interfaces/RebalanceHistoryType.html +0 -5
  114. package/docs/modules.html +0 -66
  115. package/docs/types/AlphaFiDoubleAssetVault.html +0 -1
  116. package/docs/types/AlphaFiSingleAssetVault.html +0 -1
  117. package/docs/types/AlphaFiVault.html +0 -1
  118. package/docs/types/AlphaFiVaultBalance.html +0 -1
  119. package/docs/types/AlphaPoolType.html +0 -1
  120. package/docs/types/AlphaReceipt.html +0 -1
  121. package/docs/types/AlphaVaultBalance.html +0 -1
  122. package/docs/types/AutoCompoundingEventNode.html +0 -1
  123. package/docs/types/CetusInvestor.html +0 -1
  124. package/docs/types/CetusPoolType.html +0 -1
  125. package/docs/types/CetusSwapOptions.html +0 -1
  126. package/docs/types/CoinAmounts.html +0 -1
  127. package/docs/types/CoinName.html +0 -1
  128. package/docs/types/CoinType.html +0 -1
  129. package/docs/types/CreatePoolOptions.html +0 -1
  130. package/docs/types/DoubleAssetVaultBalance.html +0 -1
  131. package/docs/types/Icon.html +0 -1
  132. package/docs/types/LpBreakdownType.html +0 -1
  133. package/docs/types/ParentProtocolName.html +0 -1
  134. package/docs/types/PoolName.html +0 -1
  135. package/docs/types/PoolReceipt.html +0 -1
  136. package/docs/types/PoolType.html +0 -1
  137. package/docs/types/Receipt.html +0 -1
  138. package/docs/types/SingleAssetVaultBalance.html +0 -1
  139. package/docs/types/SuiNetwork.html +0 -1
  140. package/docs/types/SwapOptions.html +0 -1
  141. package/docs/types/TickSpacing.html +0 -1
  142. package/docs/types/TransactionBlockType.html +0 -1
  143. package/events.csv +0 -61
  144. package/events.csv~ +0 -71
  145. package/jest.config.js +0 -5
  146. package/package.json~ +0 -56
  147. package/tsconfig.json~ +0 -16
  148. package/tsconfig.test.json~ +0 -17
  149. package/typedoc.json +0 -8
  150. package/webpack.config.cjs~ +0 -63
  151. package/webpack.config.js +0 -54
  152. package/webpack.config.js~ +0 -50
  153. package/webpack.config.ts~ +0 -64
@@ -0,0 +1,5 @@
1
+ import { PoolName } from "../../common/types";
2
+ import { AutoCompoundingEventNode, FetchAutoCompoundingEventsParams } from "./types";
3
+ export declare function fetchAutoCompoundingEvents(params: FetchAutoCompoundingEventsParams): Promise<AutoCompoundingEventNode[]>;
4
+ export declare function calculateAprForInvestor(events: AutoCompoundingEventNode[]): Promise<number>;
5
+ export declare function calculateAprForPools(events: AutoCompoundingEventNode[]): Promise<Record<PoolName, number>>;
@@ -0,0 +1,2 @@
1
+ import { EventNode, FetchEventsParams } from "./types";
2
+ export declare function fetchEvents(params: FetchEventsParams): Promise<EventNode[]>;
@@ -0,0 +1,2 @@
1
+ import { FetchLiquidityChangeEventsParams, LiquidityChangeEventNode } from "./types";
2
+ export declare function fetchLiquidityChangeEvents(params: FetchLiquidityChangeEventsParams): Promise<LiquidityChangeEventNode[]>;
@@ -0,0 +1,4 @@
1
+ import { PoolName, RebalanceHistoryType } from "../../common/types";
2
+ import { FetchRebalanceEventsParams, RebalanceEventNode } from "./types";
3
+ export declare function fetchRebalanceEvents(params: FetchRebalanceEventsParams): Promise<RebalanceEventNode[]>;
4
+ export declare function calculateRebalanceHistoryFromEvents(events: RebalanceEventNode[]): Promise<Record<PoolName, RebalanceHistoryType[]>>;
@@ -0,0 +1,3 @@
1
+ import { LiquidityChangeEventNode } from "./types";
2
+ export declare function parseHoldersFromLCEvents(events: LiquidityChangeEventNode[]): string[];
3
+ export declare function parseXTokensFromLCEvent(events: LiquidityChangeEventNode[]): [string, string, string][];
@@ -0,0 +1,93 @@
1
+ import { PoolName } from "../../common/types";
2
+ interface CommonEventAttributes {
3
+ type: string;
4
+ timestamp: number;
5
+ }
6
+ export interface CetusAutoCompoundingEvent {
7
+ compound_amount_a: bigint;
8
+ compound_amount_b: bigint;
9
+ current_liquidity: bigint;
10
+ fee_collected_a: bigint;
11
+ fee_collected_b: bigint;
12
+ free_balance_a: bigint;
13
+ free_balance_b: bigint;
14
+ investor_id: string;
15
+ total_amount_a: bigint;
16
+ total_amount_b: bigint;
17
+ }
18
+ export interface NaviAutoCompoundingEvent {
19
+ compound_amount: bigint;
20
+ fee_collected: bigint;
21
+ investor_id: string;
22
+ location: number;
23
+ total_amount: bigint;
24
+ }
25
+ export interface NaviLoopAutoCompoundingEvent extends NaviAutoCompoundingEvent {
26
+ cur_total_debt: bigint;
27
+ accrued_interest: bigint;
28
+ }
29
+ export interface RebalanceEvent {
30
+ investor_id: string;
31
+ lower_tick_after: string;
32
+ upper_tick_after: string;
33
+ sqrt_price_after: string;
34
+ amount_a_before: string;
35
+ amount_b_before: string;
36
+ amount_a_after: string;
37
+ amount_b_after: string;
38
+ }
39
+ export interface AlphaAutoCompoundingEvent {
40
+ amount: string;
41
+ investor_id: string;
42
+ }
43
+ export interface CetusLiquidityChangeEvent {
44
+ amount_a: string;
45
+ amount_b: string;
46
+ event_type: number;
47
+ fee_collected_a: string;
48
+ fee_collected_b: string;
49
+ pool_id: string;
50
+ sender: string;
51
+ tokens_invested: string;
52
+ total_amount_a: string;
53
+ total_amount_b: string;
54
+ user_total_x_token_balance: string;
55
+ x_token_supply: string;
56
+ }
57
+ export interface NaviLiquidityChangeEvent {
58
+ amount: string;
59
+ event_type: number;
60
+ fee_collected: string;
61
+ pool_id: string;
62
+ sender: string;
63
+ tokens_invested: string;
64
+ user_total_x_token_balance: string;
65
+ x_token_supply: string;
66
+ }
67
+ export interface AlphaLiquidityChangeEvent {
68
+ amount: string;
69
+ event_type: number;
70
+ fee_collected: string;
71
+ pool_id: string;
72
+ sender: string;
73
+ tokens_invested: string;
74
+ user_total_x_token_balance: string;
75
+ x_token_supply: string;
76
+ }
77
+ export type AutoCompoundingEventNode = (CetusAutoCompoundingEvent & CommonEventAttributes) | (NaviAutoCompoundingEvent & CommonEventAttributes) | (NaviLoopAutoCompoundingEvent & CommonEventAttributes) | (AlphaAutoCompoundingEvent & CommonEventAttributes);
78
+ export type RebalanceEventNode = RebalanceEvent & CommonEventAttributes;
79
+ export type LiquidityChangeEventNode = (CetusLiquidityChangeEvent & CommonEventAttributes) | (NaviLiquidityChangeEvent & CommonEventAttributes) | (AlphaLiquidityChangeEvent & CommonEventAttributes);
80
+ export type EventNode = AutoCompoundingEventNode | RebalanceEventNode | LiquidityChangeEventNode;
81
+ export type FetchAutoCompoundingEventsParams = {
82
+ startTime?: number;
83
+ endTime?: number;
84
+ poolNames?: PoolName[];
85
+ };
86
+ export type FetchRebalanceEventsParams = FetchAutoCompoundingEventsParams;
87
+ export type FetchLiquidityChangeEventsParams = FetchAutoCompoundingEventsParams;
88
+ export type FetchEventsParams = {
89
+ eventTypes: string[];
90
+ startTime?: number;
91
+ endTime?: number;
92
+ };
93
+ export {};
@@ -0,0 +1,49 @@
1
+ export interface LockedAlphaObject {
2
+ name: {
3
+ type: string;
4
+ value: string;
5
+ };
6
+ bcsName: string;
7
+ type: string;
8
+ objectType: string;
9
+ objectId: string;
10
+ version: string;
11
+ digest: string;
12
+ }
13
+ export interface LockedAlphaItem {
14
+ objectId: string;
15
+ version: string;
16
+ digest: string;
17
+ type: string;
18
+ owner: {
19
+ ObjectOwner: string;
20
+ };
21
+ previousTransaction: string;
22
+ storageRebate: string;
23
+ content: {
24
+ dataType: string;
25
+ type: string;
26
+ hasPublicTransfer: boolean;
27
+ fields: {
28
+ id: {
29
+ id: string;
30
+ };
31
+ name: string;
32
+ value: {
33
+ type: string;
34
+ fields: {
35
+ next: string;
36
+ prev: string;
37
+ value: string;
38
+ };
39
+ };
40
+ };
41
+ };
42
+ }
43
+ export type AlphaUnlocks = {
44
+ address: string;
45
+ tokens: string;
46
+ timestampMs: number;
47
+ };
48
+ export declare function getTableDataXtokens(owner: string, table: string): Promise<AlphaUnlocks[] | undefined>;
49
+ export declare function getUnlocksData(owner_table: [string, string][]): Promise<AlphaUnlocks[]>;
@@ -0,0 +1,2 @@
1
+ import { AlphaFiVaultBalance, PoolName } from "../../common/types";
2
+ export declare function fetchUserVaultBalances(address: string, poolName: PoolName): Promise<AlphaFiVaultBalance | undefined>;
@@ -0,0 +1,2 @@
1
+ import { AlphaFiVault } from "../..";
2
+ export declare function fetchUserVaults(address: string): Promise<AlphaFiVault[]>;
@@ -0,0 +1,32 @@
1
+ import { SuiClient } from "@mysten/sui/client";
2
+ import { PoolName } from "../..";
3
+ export declare function getAlphaPortfolioAmount(poolName: PoolName, options: {
4
+ suiClient: SuiClient;
5
+ address: string;
6
+ isLocked?: boolean;
7
+ }): Promise<string | undefined>;
8
+ export declare function getAlphaPortfolioAmountInUSD(poolName: PoolName, options: {
9
+ suiClient: SuiClient;
10
+ address: string;
11
+ isLocked?: boolean;
12
+ }): Promise<string | undefined>;
13
+ export declare function getPortfolioAmount(poolName: PoolName, options: {
14
+ suiClient: SuiClient;
15
+ address: string;
16
+ isLocked?: boolean;
17
+ }, ignoreCache?: boolean): Promise<[number, number] | undefined>;
18
+ export declare function getDoubleAssetPortfolioAmountInUSD(poolName: PoolName, options: {
19
+ suiClient: SuiClient;
20
+ address: string;
21
+ isLocked?: boolean;
22
+ }, ignoreCache?: boolean): Promise<string | undefined>;
23
+ export declare function getSingleAssetPortfolioAmount(poolName: PoolName, options: {
24
+ suiClient: SuiClient;
25
+ address: string;
26
+ isLocked?: boolean;
27
+ }, ignoreCache?: boolean): Promise<number>;
28
+ export declare function getSingleAssetPortfolioAmountInUSD(poolName: PoolName, options: {
29
+ suiClient: SuiClient;
30
+ address: string;
31
+ isLocked?: boolean;
32
+ }, ignoreCache?: boolean): Promise<string | undefined>;
@@ -0,0 +1,8 @@
1
+ import { AlphaPoolType, CetusInvestor, CetusPoolType, PoolName, PoolType, Receipt } from "../..";
2
+ import Decimal from "decimal.js";
3
+ export declare function getReceipts(poolName: string, address: string, ignoreCache?: boolean): Promise<Receipt[]>;
4
+ export declare function getPoolExchangeRate(poolName: PoolName, ignoreCache?: boolean): Promise<Decimal | undefined>;
5
+ export declare function getCoinAmountsFromLiquidity(poolName: PoolName, liquidity: number): Promise<[number, number]>;
6
+ export declare function getPool(poolName: string, ignoreCache?: boolean): Promise<PoolType | AlphaPoolType | undefined>;
7
+ export declare function getCetusPool(poolName: string, ignoreCache?: boolean): Promise<CetusPoolType | undefined>;
8
+ export declare function getCetusInvestor(poolName: PoolName, ignoreCache?: boolean): Promise<CetusInvestor | undefined>;
@@ -0,0 +1,3 @@
1
+ import { TransactionFilter } from "@mysten/sui/dist/cjs/client";
2
+ export declare const nonAlphaDepositFilters: TransactionFilter[];
3
+ export declare const alphaDepositFilters: TransactionFilter[];
@@ -0,0 +1,3 @@
1
+ import { SuiTransactionBlockResponse } from "@mysten/sui/client";
2
+ import { FetchTransactionParams } from "./types";
3
+ export declare function fetchTransactions(params: FetchTransactionParams): Promise<SuiTransactionBlockResponse[]>;
@@ -0,0 +1,7 @@
1
+ import { TransactionFilter } from "@mysten/sui/client";
2
+ export type FetchTransactionParams = {
3
+ startTime: number;
4
+ endTime: number;
5
+ filter: TransactionFilter[];
6
+ sort: "ascending" | "descending";
7
+ };
@@ -0,0 +1,212 @@
1
+ import { CoinName, DoubleAssetPoolNames, PoolName, SingleAssetPoolNames, AlphaFiVaultBalance } from "./common/types";
2
+ export type GetUserTokensFromTransactionsParams = {
3
+ poolNames?: string[];
4
+ startTime?: number;
5
+ endTime?: number;
6
+ owners?: string[];
7
+ };
8
+ export type GetUserTokensInUsdFromTransactionsParams = {
9
+ poolNames?: string[];
10
+ startTime?: number;
11
+ endTime?: number;
12
+ owners?: string[];
13
+ userTokensHoldings?: [string, string, string][];
14
+ };
15
+ export type AlphaReceiptFields = {
16
+ id: {
17
+ id: string;
18
+ };
19
+ image_url: string;
20
+ last_acc_reward_per_xtoken: {
21
+ type: string;
22
+ fields: {
23
+ contents: [
24
+ {
25
+ type: string;
26
+ fields: {
27
+ key: {
28
+ type: string;
29
+ fields: {
30
+ name: string;
31
+ };
32
+ };
33
+ value: string;
34
+ };
35
+ }
36
+ ];
37
+ };
38
+ };
39
+ locked_balance: {
40
+ type: string;
41
+ fields: {
42
+ head: string;
43
+ id: {
44
+ id: string;
45
+ };
46
+ size: string;
47
+ tail: string;
48
+ };
49
+ };
50
+ name: string;
51
+ owner: string;
52
+ pending_rewards: {
53
+ type: string;
54
+ fields: {
55
+ contents: [
56
+ {
57
+ type: string;
58
+ fields: {
59
+ key: {
60
+ type: string;
61
+ fields: {
62
+ name: string;
63
+ };
64
+ };
65
+ value: string;
66
+ };
67
+ }
68
+ ];
69
+ };
70
+ };
71
+ pool_id: string;
72
+ unlocked_xtokens: string;
73
+ xTokenBalance: string;
74
+ };
75
+ export type OtherReceiptFields = {
76
+ id: {
77
+ id: string;
78
+ };
79
+ image_url: string;
80
+ last_acc_reward_per_xtoken: {
81
+ fields: {
82
+ contents: [
83
+ {
84
+ fields: {
85
+ key: {
86
+ fields: {
87
+ name: string;
88
+ };
89
+ type: string;
90
+ };
91
+ value: string;
92
+ };
93
+ type: string;
94
+ }
95
+ ];
96
+ };
97
+ type: string;
98
+ };
99
+ name: string;
100
+ owner: string;
101
+ pending_rewards: {
102
+ fields: {
103
+ contents: [
104
+ {
105
+ fields: {
106
+ key: {
107
+ fields: {
108
+ name: string;
109
+ };
110
+ type: string;
111
+ };
112
+ value: string;
113
+ };
114
+ type: string;
115
+ }
116
+ ];
117
+ };
118
+ type: string;
119
+ };
120
+ pool_id: string;
121
+ xTokenBalance: string;
122
+ };
123
+ export type GetHoldersParams = {
124
+ poolNames?: string[];
125
+ startTime?: number;
126
+ endTime?: number;
127
+ };
128
+ export type GetTokenHoldingsParams = {
129
+ poolNames?: PoolName[];
130
+ startTime?: number;
131
+ endTime?: number;
132
+ };
133
+ export type LiquidityToUsdParams = {
134
+ liquidity: string;
135
+ poolName: string;
136
+ ticksCetusMap: {
137
+ [pool: string]: {
138
+ lower: string;
139
+ upper: string;
140
+ };
141
+ };
142
+ sqrtPriceCetusMap: Map<PoolName, string>;
143
+ tokenPriceMap: Map<CoinName, string>;
144
+ };
145
+ export type LiquidityToTokensParams = {
146
+ liquidity: string;
147
+ poolName: string;
148
+ ticksCetusMap: {
149
+ [pool: string]: {
150
+ lower: string;
151
+ upper: string;
152
+ };
153
+ };
154
+ sqrtPriceCetusMap: Map<PoolName, string>;
155
+ };
156
+ export type UserUsdHoldings = {
157
+ user: string;
158
+ poolName: PoolName;
159
+ usdHoldings: string;
160
+ };
161
+ export type UserPoolLiquidity = {
162
+ user: string;
163
+ poolName: string;
164
+ liquidity: string;
165
+ };
166
+ export type UserPoolTokenHoldings = SingleAssetTokenHoldings | DoubleAssetTokenHoldings;
167
+ export type SingleAssetTokenHoldings = {
168
+ user: string;
169
+ poolName: SingleAssetPoolNames;
170
+ tokens: string;
171
+ };
172
+ export type DoubleAssetTokenHoldings = {
173
+ user: string;
174
+ poolName: DoubleAssetPoolNames;
175
+ tokenAmountA: string;
176
+ tokenAmountB: string;
177
+ };
178
+ export type MultiGetVaultBalancesParams = {
179
+ poolNames?: PoolName[];
180
+ startTime?: number;
181
+ endTime?: number;
182
+ };
183
+ export type SingleGetVaultBalancesParams = {
184
+ address?: string;
185
+ poolName?: PoolName;
186
+ };
187
+ export type GetVaultBalanceParams = SingleGetVaultBalancesParams | MultiGetVaultBalancesParams;
188
+ export type HoldingsObj = {
189
+ owner: string;
190
+ poolName: PoolName;
191
+ holding: string;
192
+ };
193
+ export type VaultBalance = AlphaFiVaultBalance | undefined | AlphaFiMultiVaultBalance[];
194
+ export type AlphaFiMultiVaultBalance = SingleAssetMultiVaultBalance | DoubleAssetMultiVaultBalance;
195
+ export type SingleAssetMultiVaultBalance = {
196
+ owner: string;
197
+ poolName: PoolName;
198
+ tokens: string;
199
+ tokensInUsd: string;
200
+ };
201
+ export type DoubleAssetMultiVaultBalance = {
202
+ owner: string;
203
+ poolName: PoolName;
204
+ tokenA: string;
205
+ tokenB: string;
206
+ tokensInUsd: string;
207
+ };
208
+ export type GetVaultBalanceForActiveUsersParams = {
209
+ poolNames?: PoolName[];
210
+ startTime?: number;
211
+ endTime?: number;
212
+ };
@@ -0,0 +1,19 @@
1
+ import { SdkOptions, Pool, CalculateRatesResult } from "@cetusprotocol/cetus-sui-clmm-sdk";
2
+ import { Transaction } from "@mysten/sui/transactions";
3
+ import { Coin } from "../../common/types";
4
+ import { CetusSwapOptions, CreatePoolOptions } from "./types";
5
+ export declare function getAlphaPrice(ignoreCache?: boolean): Promise<number | undefined>;
6
+ export declare function getUSDYPrice(): Promise<number | undefined>;
7
+ export declare function getBUCKPrice(): Promise<number | undefined>;
8
+ export declare function getPriceFromCetus(coinType: string): Promise<string>;
9
+ export declare class CetusGateway {
10
+ private cetusSDK;
11
+ constructor(sdkOptions: SdkOptions);
12
+ getPools(pairs: {
13
+ coinA?: Coin;
14
+ coinB?: Coin;
15
+ }[]): Promise<Pool[]>;
16
+ getPrice(options: CetusSwapOptions): Promise<CalculateRatesResult>;
17
+ getTransaction(options: CetusSwapOptions): Promise<Transaction>;
18
+ createPoolTransactionBlock(options: CreatePoolOptions): Promise<Transaction>;
19
+ }
@@ -0,0 +1,10 @@
1
+ import BigNumber from "bignumber.js";
2
+ import BN from "bn.js";
3
+ export declare function signedShiftRight(n0: BN, shiftBy: number, bitWidth: number): BN;
4
+ export declare function tickIndexToSqrtPricePositive(tick: number): BigNumber;
5
+ export declare function tickIndexToSqrtPriceNegative(tickIndex: number): BigNumber;
6
+ export declare function tickIndexToSqrtPriceX64(tickIndex: number): BigNumber;
7
+ export declare function getTokenAmountsFromLiquidity(liquidity: BigNumber, tickCurrentIndex: number, tickLowerIndex: number, tickUpperIndex: number, roundUp: boolean): {
8
+ tokenAmountA: BigNumber;
9
+ tokenAmountB: BigNumber;
10
+ };
@@ -0,0 +1,24 @@
1
+ import { CoinName, CoinPair } from "../../common/types";
2
+ import BN from "bn.js";
3
+ export type CetusSwapOptions = SwapOptions;
4
+ export type TickSpacing = 2 | 10 | 60 | 200;
5
+ export type CreatePoolOptions = {
6
+ tickSpacing: TickSpacing;
7
+ initializePrice: number;
8
+ imageUrl: string;
9
+ coinNameA: CoinName;
10
+ coinNameB: CoinName;
11
+ amount: number;
12
+ isAmountA: boolean;
13
+ };
14
+ export type SwapOptions = {
15
+ pair: CoinPair;
16
+ senderAddress: string;
17
+ slippage: number;
18
+ } & ({
19
+ inAmount: BN;
20
+ outAmount?: never;
21
+ } | {
22
+ outAmount: BN;
23
+ inAmount?: never;
24
+ });
@@ -0,0 +1,2 @@
1
+ import { PythPriceFeed } from "../common/pyth";
2
+ export declare const pythPriceFeed: PythPriceFeed;
@@ -0,0 +1,5 @@
1
+ import { SuiObjectResponse } from "@mysten/sui/dist/cjs/client";
2
+ import { LiquidityToUsdParams } from "../types";
3
+ export declare function parseTokensFromReceipts(receipts: SuiObjectResponse[]): Promise<[string, string, string][]>;
4
+ export declare function liquidityToUsd(params: LiquidityToUsdParams): string | undefined;
5
+ export declare function mergeDuplicateHoldings(userTokens: [string, string, string][]): [string, string, string][];
@@ -0,0 +1,3 @@
1
+ import { SuiObjectResponse } from "@mysten/sui/client";
2
+ import { GetReceiptParams } from "./types";
3
+ export declare function getReceipts(params: GetReceiptParams): Promise<SuiObjectResponse[]>;
@@ -0,0 +1,15 @@
1
+ import { HopApiOptions } from "@hop.ag/sdk";
2
+ import { GetQuoteResponse } from "@hop.ag/sdk/dist/cjs/sdk/routes/quote";
3
+ import { SwapOptions } from "../common/types";
4
+ import { Transaction } from "@mysten/sui/transactions";
5
+ export type HopSwapOptions = SwapOptions;
6
+ export declare const hopSDKOptions: HopApiOptions;
7
+ export declare class HopGateway {
8
+ private hopAPI;
9
+ constructor(sdkOptions: HopApiOptions);
10
+ getQuote(options: HopSwapOptions, debug?: boolean): Promise<GetQuoteResponse>;
11
+ getTransactionBlock(options: HopSwapOptions, quote: GetQuoteResponse, debug?: boolean, transaction?: Transaction | undefined): Promise<Transaction>;
12
+ }
13
+ export declare function getBlubPrice(): Promise<number | undefined>;
14
+ export declare function getFudPrice(): Promise<number | undefined>;
15
+ export declare function getWsolPrice(): Promise<number | undefined>;
@@ -0,0 +1,6 @@
1
+ import { PythPriceIdPair } from "../common/pyth";
2
+ export declare function getLatestPrices(pairs: PythPriceIdPair[]): Promise<(string | undefined)[]>;
3
+ export declare function getLatestTokenPricePairs(pairs: PythPriceIdPair[]): Promise<{
4
+ [key: string]: string | undefined;
5
+ }>;
6
+ export declare function getLatestPrice(pair: PythPriceIdPair): Promise<string | undefined>;
@@ -0,0 +1,9 @@
1
+ export declare class SimpleCache<T> {
2
+ private cache;
3
+ private defaultTTL;
4
+ constructor(defaultTTL?: number);
5
+ get(key: string): T | null;
6
+ set(key: string, value: T, ttl?: number): void;
7
+ delete(key: string): void;
8
+ clear(): void;
9
+ }
@@ -0,0 +1,4 @@
1
+ export type GetReceiptParams = {
2
+ poolNames?: string[];
3
+ owners: string[];
4
+ };
@@ -0,0 +1,5 @@
1
+ import { DoubleAssetTokenHoldings, HoldingsObj, SingleAssetTokenHoldings, LiquidityToTokensParams } from "../types";
2
+ export declare function multiXTokensToLiquidity(xTokensHoldings: HoldingsObj[]): Promise<HoldingsObj[]>;
3
+ export declare function multiLiquidityToTokens(holdings: HoldingsObj[]): Promise<(SingleAssetTokenHoldings | DoubleAssetTokenHoldings)[]>;
4
+ export declare function liquidityToTokens(params: LiquidityToTokensParams): string | [string, string];
5
+ export declare function multiTokensToUsd(tokensHoldings: (SingleAssetTokenHoldings | DoubleAssetTokenHoldings)[]): Promise<HoldingsObj[]>;
@@ -0,0 +1,4 @@
1
+ import { LpBreakdownType, PoolName } from "./common/types";
2
+ export declare function alphaLpBreakdown(poolName: PoolName): Promise<LpBreakdownType>;
3
+ export declare function cetusLpBreakdown(poolName: PoolName): Promise<LpBreakdownType>;
4
+ export declare function lastAutocompoundTime(poolName: PoolName): Promise<string>;
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@alphafi/alphafi-sdk",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "AlphaFi SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*"
9
+ ],
7
10
  "scripts": {
8
11
  "buildNoPrettier": "npm run lint && webpack && npm link",
9
12
  "build": "npm run prettier && npm run lint && webpack && npm link",
package/.envrc DELETED
@@ -1 +0,0 @@
1
- export AWS_PROFILE=alphafi-mgmt-admin
package/.eslintrc.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "parser": "@typescript-eslint/parser",
3
- "extends": [
4
- "plugin:@typescript-eslint/recommended",
5
- "plugin:import/errors",
6
- "plugin:import/warnings",
7
- "plugin:import/typescript",
8
- "plugin:prettier/recommended" // Adds Prettier plugin recommendations at the end
9
- ],
10
- "parserOptions": {
11
- "ecmaVersion": 2020,
12
- "sourceType": "module"
13
- },
14
- "rules": {
15
- "@typescript-eslint/no-explicit-any": "off",
16
- "prettier/prettier": "error" // Ensures that Prettier mismatches are shown as errors
17
- },
18
- "plugins": [
19
- "prettier" // Ensure this plugin is installed and included
20
- ]
21
- }
@@ -1,51 +0,0 @@
1
- # Simple workflow for deploying docs to GitHub Pages
2
- name: Deploy Documentation to GitHub Pages
3
-
4
- on:
5
- # Runs on pushes targeting the default branch
6
- push:
7
- branches: ["main"]
8
-
9
- # Allows you to run this workflow manually from the Actions tab
10
- workflow_dispatch:
11
-
12
- # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13
- permissions:
14
- contents: read
15
- pages: write
16
- id-token: write
17
-
18
- # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19
- # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20
- concurrency:
21
- group: "pages"
22
- cancel-in-progress: false
23
-
24
- jobs:
25
- # Single deploy job since we're just deploying
26
- deploy:
27
- environment:
28
- name: github-pages
29
- url: ${{ steps.deployment.outputs.page_url }}
30
- runs-on: ubuntu-latest
31
- steps:
32
- - name: Checkout
33
- uses: actions/checkout@v4
34
- - name: Set up Node.js
35
- uses: actions/setup-node@v4
36
- with:
37
- node-version: 20
38
- - name: Install dependencies
39
- run: npm install
40
- - name: Generate Documentation
41
- run: npm run docs
42
- - name: Setup Pages
43
- uses: actions/configure-pages@v5
44
- - name: Upload artifact
45
- uses: actions/upload-pages-artifact@v3
46
- with:
47
- # Upload entire repository
48
- path: "./docs"
49
- - name: Deploy to GitHub Pages
50
- id: deployment
51
- uses: actions/deploy-pages@v4