@exponent-labs/exponent-types 0.0.3

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 (51) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/common.d.ts +27 -0
  3. package/build/common.js +3 -0
  4. package/build/common.js.map +1 -0
  5. package/build/cpi.d.ts +37 -0
  6. package/build/cpi.js +3 -0
  7. package/build/cpi.js.map +1 -0
  8. package/build/flavor.d.ts +122 -0
  9. package/build/flavor.js +3 -0
  10. package/build/flavor.js.map +1 -0
  11. package/build/generic.d.ts +89 -0
  12. package/build/generic.js +26 -0
  13. package/build/generic.js.map +1 -0
  14. package/build/index.d.ts +11 -0
  15. package/build/index.js +27 -0
  16. package/build/index.js.map +1 -0
  17. package/build/jito-restaking.d.ts +57 -0
  18. package/build/jito-restaking.js +18 -0
  19. package/build/jito-restaking.js.map +1 -0
  20. package/build/kamino.d.ts +72 -0
  21. package/build/kamino.js +3 -0
  22. package/build/kamino.js.map +1 -0
  23. package/build/liquidity.d.ts +10 -0
  24. package/build/liquidity.js +3 -0
  25. package/build/liquidity.js.map +1 -0
  26. package/build/marginfi.d.ts +77 -0
  27. package/build/marginfi.js +3 -0
  28. package/build/marginfi.js.map +1 -0
  29. package/build/perena.d.ts +50 -0
  30. package/build/perena.js +17 -0
  31. package/build/perena.js.map +1 -0
  32. package/build/trade.d.ts +32 -0
  33. package/build/trade.js +3 -0
  34. package/build/trade.js.map +1 -0
  35. package/build/vault.d.ts +131 -0
  36. package/build/vault.js +3 -0
  37. package/build/vault.js.map +1 -0
  38. package/package.json +18 -0
  39. package/src/common.ts +26 -0
  40. package/src/cpi.ts +44 -0
  41. package/src/flavor.ts +141 -0
  42. package/src/generic.ts +121 -0
  43. package/src/index.ts +11 -0
  44. package/src/jito-restaking.ts +78 -0
  45. package/src/kamino.ts +76 -0
  46. package/src/liquidity.ts +17 -0
  47. package/src/marginfi.ts +81 -0
  48. package/src/perena.ts +67 -0
  49. package/src/trade.ts +37 -0
  50. package/src/vault.ts +191 -0
  51. package/tsconfig.json +23 -0
package/src/kamino.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { BN } from "@coral-xyz/anchor"
2
+ import { web3 } from "@coral-xyz/anchor"
3
+ import { SyEmissionRaw, SyEmissionJson } from "./common"
4
+
5
+ export interface KaminoSyState {
6
+ selfAddress: web3.PublicKey
7
+ account: KaminoSyMetaAccount
8
+ klendSyProgramId: web3.PublicKey
9
+ /** The value of SY tokens in terms of the base asset */
10
+ syRate: string
11
+ mintBase: web3.PublicKey
12
+ tokenProgramBase: web3.PublicKey
13
+ klendProgramId: web3.PublicKey
14
+ klendMarketId: web3.PublicKey
15
+ }
16
+
17
+ export interface KaminoSyStateJson {
18
+ selfAddress: string
19
+ account: KaminoSyMetaAccountJson
20
+ klendSyProgramId: string
21
+ syRate: string
22
+ mintBase: string
23
+ tokenProgramBase: string
24
+ klendProgramId: string
25
+ klendMarketId: string
26
+ }
27
+
28
+ export interface KaminoSyMetaAccount {
29
+ kaminoReserve: web3.PublicKey
30
+ kaminoObligation: web3.PublicKey
31
+ kaminoFarm: web3.PublicKey
32
+ kaminoUserMetadata: web3.PublicKey
33
+ mintSy: web3.PublicKey
34
+ /** Where deposited SY tokens reside */
35
+ tokenSyEscrow: web3.PublicKey
36
+ userState: web3.PublicKey
37
+ maxSySupply: string
38
+ minMintSize: string
39
+ minRedeemSize: string
40
+ emissions: SyEmissionRaw[]
41
+ }
42
+
43
+ interface KaminoSyMetaAccountJson {
44
+ kaminoReserve: string
45
+ kaminoObligation: string
46
+ kaminoFarm: string
47
+ kaminoUserMetadata: string
48
+ mintSy: string
49
+ tokenSyEscrow: string
50
+ userState: string
51
+ maxSySupply: string
52
+ minMintSize: string
53
+ minRedeemSize: string
54
+ emissions: SyEmissionJson[]
55
+ }
56
+
57
+ export interface KaminoSyMetaAccountRaw {
58
+ kamino_reserve: web3.PublicKey
59
+ kamino_obligation: web3.PublicKey
60
+ kamino_farm: web3.PublicKey
61
+ kamino_user_metadata: web3.PublicKey
62
+ mint_sy: web3.PublicKey
63
+ /** Where deposited SY tokens reside */
64
+ token_sy_escrow: web3.PublicKey
65
+ /** Robot authority over the Mfi Account */
66
+ authority_klend_account: web3.PublicKey
67
+ /** Authority over the SY token escrow account */
68
+ authority_escrow: web3.PublicKey
69
+ /** Authority over the sy mint */
70
+ mint_authority: web3.PublicKey
71
+ user_state: web3.PublicKey
72
+ max_sy_supply: BN
73
+ min_mint_size: BN
74
+ min_redeem_size: BN
75
+ emissions: SyEmissionRaw[]
76
+ }
@@ -0,0 +1,17 @@
1
+ export type LiquidityHistory = {
2
+ deposits: LiquidityAddEvent[]
3
+ // TODO: add withdraws
4
+ // withdraws: todo[]
5
+ }
6
+
7
+ type LiquidityAddEvent = {
8
+ timestamp: Date
9
+ // raw amount of base tokens
10
+ baseTokensIn: string
11
+
12
+ // raw amount of LP tokens
13
+ lpTokensOut: string
14
+
15
+ // raw amount of YT minted as a side-effect
16
+ yieldTokensMinted: string
17
+ }
@@ -0,0 +1,81 @@
1
+ import { BN, web3 } from "@coral-xyz/anchor"
2
+ import { SyEmissionRaw, SyEmissionJson } from "./common"
3
+
4
+ export interface MfiSyState {
5
+ selfAddress: web3.PublicKey
6
+ account: MarginfiSyMeta
7
+ marginfiSyProgramId: web3.PublicKey
8
+
9
+ /** The value of SY tokens in terms of the base asset taken directly from the bank */
10
+ syRate: string
11
+ mintBase: web3.PublicKey
12
+ tokenProgramBase: web3.PublicKey
13
+ marginfiProgramId: web3.PublicKey
14
+ marginfiGroupId: web3.PublicKey
15
+ emissionsMint: web3.PublicKey | null
16
+ emissionsTokenProgram: web3.PublicKey | null
17
+ }
18
+
19
+ export interface MfiSyStateJson {
20
+ selfAddress: string
21
+ account: MarginfiSyMetaJson
22
+ marginfiSyProgramId: string
23
+ syRate: string
24
+ mintBase: string
25
+ tokenProgramBase: string
26
+ marginfiProgramId: string
27
+ marginfiGroupId: string
28
+ emissionsMint: string | null
29
+ emissionsTokenProgram: string | null
30
+ }
31
+
32
+ export interface SyMetaJson {
33
+ selfAddress: string
34
+ marginfiBank: string
35
+ marginfiAccount: string
36
+ mintSy: string
37
+ tokenSyEscrow: string
38
+ emissions: SyEmissionJson[]
39
+ maxSySupply: string
40
+ minMintSize: string
41
+ minRedeemSize: string
42
+ syRate: string
43
+ }
44
+
45
+ export interface MarginfiSyMeta {
46
+ marginfiBank: web3.PublicKey
47
+ marginfiAccount: web3.PublicKey
48
+ mintSy: web3.PublicKey
49
+ /** Where the SY tokens get deposited */
50
+ tokenSyEscrow: web3.PublicKey
51
+ maxSySupply: bigint
52
+ minMintSize: bigint
53
+ minRedeemSize: bigint
54
+ emissions: SyEmissionRaw[]
55
+ }
56
+
57
+ export interface MarginfiSyMetaJson {
58
+ marginfiBank: string
59
+ marginfiAccount: string
60
+ mintSy: string
61
+ tokenSyEscrow: string
62
+ maxSySupply: string
63
+ minMintSize: string
64
+ minRedeemSize: string
65
+ emissions: SyEmissionJson[]
66
+ }
67
+
68
+ export interface MarginfiSyMetaRaw {
69
+ marginfiBank: web3.PublicKey
70
+ marginfiAccount: web3.PublicKey
71
+ mintSy: web3.PublicKey
72
+ maxSySupply: BN
73
+ minMintSize: BN
74
+ minRedeemSize: BN
75
+ /** Where the SY tokens get deposited */
76
+ tokenSyEscrow: web3.PublicKey
77
+ emissions: SyEmissionRaw[]
78
+ }
79
+
80
+ export type AnchorizedPNum = { 0: BN[] }
81
+ export type AnchorizedPNumJson = { 0: string[] }
package/src/perena.ts ADDED
@@ -0,0 +1,67 @@
1
+ import { BN, web3 } from "@coral-xyz/anchor"
2
+ import { AnchorizedPNum, AnchorizedPNumJson, SyEmissionRaw, SyEmissionJson } from "./common"
3
+
4
+ export interface PerenaSyState {
5
+ selfAddress: web3.PublicKey
6
+ account: PerenaSyMetaAccount
7
+ /** The value of SY tokens in terms of the base asset */
8
+ syRate: string
9
+ tokenProgramBase: web3.PublicKey
10
+ lpMint: web3.PublicKey
11
+ }
12
+
13
+ export interface PerenaSyMetaAccountRaw {
14
+ perenaStablePool: web3.PublicKey
15
+ mintSy: web3.PublicKey
16
+ tokenSyEscrow: web3.PublicKey
17
+ maxSySupply: BN
18
+ minMintSize: BN
19
+ minRedeemSize: BN
20
+ selfAddressBump: number[]
21
+ emissions: SyEmissionRaw[]
22
+ interfaceAccounts: web3.PublicKey[]
23
+ }
24
+
25
+ export interface PerenaSyMetaAccount {
26
+ perenaStablePool: web3.PublicKey
27
+ mintSy: web3.PublicKey
28
+ tokenSyEscrow: web3.PublicKey
29
+ interfaceAccounts: web3.PublicKey[]
30
+ maxSySupply: BN
31
+ minMintSize: BN
32
+ minRedeemSize: BN
33
+ emissions: SyEmissionRaw[]
34
+ }
35
+
36
+ export interface PerenaSyMetaAccountJson {
37
+ perenaStablePool: string
38
+ mintSy: string
39
+ tokenSyEscrow: string
40
+ interfaceAccounts: string[]
41
+ maxSySupply: string
42
+ minMintSize: string
43
+ minRedeemSize: string
44
+ emissions: SyEmissionJson[]
45
+ }
46
+
47
+ export function deserializePerenaSyMetaAccountRaw(raw: PerenaSyMetaAccountRaw): PerenaSyMetaAccount {
48
+ return {
49
+ perenaStablePool: raw.perenaStablePool,
50
+ mintSy: raw.mintSy,
51
+ tokenSyEscrow: raw.tokenSyEscrow,
52
+ interfaceAccounts: raw.interfaceAccounts,
53
+ maxSySupply: raw.maxSySupply,
54
+ minMintSize: raw.minMintSize,
55
+ minRedeemSize: raw.minRedeemSize,
56
+ emissions: raw.emissions,
57
+ }
58
+ }
59
+
60
+ export interface PerenaSyStateJson {
61
+ selfAddress: string
62
+ account: PerenaSyMetaAccountJson
63
+ syRate: string
64
+ underlyingExchangeRate: number
65
+ mintBase: string
66
+ tokenProgramBase: string
67
+ }
package/src/trade.ts ADDED
@@ -0,0 +1,37 @@
1
+ export type UserTrade = {
2
+ user_address: string
3
+ market: string
4
+ is_buy: boolean
5
+ in_amount: string
6
+ out_amount: string
7
+ created_at: Date
8
+ tx_signature: string
9
+ }
10
+
11
+ export type Trade = {
12
+ marketAddress: MarketAddress
13
+ amountInTokens: number
14
+ amountOutTokens: number
15
+ amountUsd: number
16
+ price: number
17
+ date: number
18
+ kind: "buy" | "sell"
19
+ annualizedYield: number
20
+ txHash: string
21
+ decimals: number
22
+ mint: string
23
+ created_at: string
24
+ }
25
+
26
+ export type MarketAddress = string
27
+
28
+ export type AllTrades = {
29
+ ytTrades: Trade[]
30
+ ptTrades: Trade[]
31
+ }
32
+
33
+ export type TradeHistory = Record<MarketAddress, AllTrades>
34
+
35
+ export type ApiReturnData = {
36
+ tradeHistory: TradeHistory
37
+ }
package/src/vault.ts ADDED
@@ -0,0 +1,191 @@
1
+ import { BN, web3 } from "@coral-xyz/anchor"
2
+ import { IFlavorState, IFlavorStateJson, Flavor } from "./flavor"
3
+ import { CpiAccountsRaw, CpiAccountsRawJson } from "./cpi"
4
+ import { AnchorizedPNum, AnchorizedPNumJson } from "./common"
5
+
6
+ export type VaultJson = {
7
+ /** When does the vault start, as a UNIX timestamp */
8
+ startTs: number
9
+ /** For how long is the vault active */
10
+ duration: number
11
+ /** When does the vault start, formatted as YYYY-MM-DD */
12
+ startDateString: string
13
+
14
+ /** Vault signer for token accounts, mints, SY position etc */
15
+ authority: string
16
+
17
+ /** SY balance of the vault in the SY program */
18
+ syBalance: string
19
+
20
+ /** Address of the address lookup table */
21
+ addressLookupTable: string
22
+
23
+ /** Last seen SY exchange rate, according to the Vault state */
24
+ lastSeenSyExchangeRate: number
25
+
26
+ /** Current SY exchange rate, according to underlying program */
27
+ currentSyExchangeRate: number
28
+
29
+ /** Address of the vault */
30
+ selfAddress: string
31
+
32
+ /** SY program address */
33
+ syProgram: string
34
+
35
+ /** PT mint */
36
+ mintPt: string
37
+ /** YT mint */
38
+ mintYt: string
39
+
40
+ /** SY mint */
41
+ mintSy: string
42
+
43
+ /** Escrow SY token account */
44
+ escrowSy: string
45
+
46
+ /** Escrow YT token account */
47
+ escrowYt: string
48
+
49
+ /** Treasury SY token account */
50
+ treasurySyTokenAccount: string
51
+
52
+ /** All time high SY exchange rate */
53
+ allTimeHighSyExchangeRate: number
54
+
55
+ /** Exchange rate for SY when the vault expires */
56
+ finalSyExchangeRate: number
57
+
58
+ /** Supply of PT */
59
+ ptSupply: string
60
+
61
+ /** SY in escrow */
62
+ totalSyInEscrow: string
63
+
64
+ /** SY for PT */
65
+ syForPt: string
66
+
67
+ status: number
68
+
69
+ syPosition: SyPositionJson
70
+
71
+ minOperationSizeStrip: string
72
+
73
+ minOperationSizeMerge: string
74
+
75
+ yieldPositonAddress: string
76
+
77
+ interestFeeBps: number
78
+
79
+ cpiAccounts: CpiAccountsRawJson
80
+
81
+ flavor: IFlavorStateJson
82
+
83
+ emissions: VaultEmissionJson[]
84
+
85
+ maxPySupply: string
86
+ }
87
+ export interface VaultState {
88
+ /** supply of PT */
89
+ ptSupply: bigint
90
+
91
+ syForPt: bigint
92
+
93
+ /** When does the vault start, as a UNIX timestamp */
94
+ startTs: number
95
+
96
+ /** For how long is the vault active */
97
+ durationSeconds: number
98
+
99
+ /** Vault signer for token accounts, mints, SY position etc */
100
+ authority: web3.PublicKey
101
+
102
+ addressLookupTable: web3.PublicKey
103
+
104
+ lastSeenSyExchangeRate: number
105
+
106
+ allTimeHighSyExchangeRate: number
107
+
108
+ /** Vault-owned account for passing SY between SY program and user */
109
+ escrowSy: web3.PublicKey
110
+
111
+ /** Escrow account for holding deposited YT */
112
+ escrowYt: web3.PublicKey
113
+
114
+ /** Key to SY Program */
115
+ syProgram: web3.PublicKey
116
+
117
+ syPosition: SyPosition
118
+
119
+ cpiAccounts: CpiAccountsRaw
120
+
121
+ mintPt: web3.PublicKey
122
+
123
+ status: number
124
+
125
+ minOperationSizeStrip: bigint
126
+
127
+ minOperationSizeMerge: bigint
128
+
129
+ mintYt: web3.PublicKey
130
+
131
+ mintSy: web3.PublicKey
132
+
133
+ yieldPositonAddress: web3.PublicKey
134
+
135
+ // yieldPosition: YtPosition
136
+
137
+ treasurySyTokenAccount: web3.PublicKey
138
+
139
+ interestBpsFee: number
140
+
141
+ totalSyInEscrow: bigint
142
+
143
+ flavor: Flavor
144
+
145
+ finalSyExchangeRate: number
146
+
147
+ emissions: VaultEmission[]
148
+
149
+ maxPySupply: bigint
150
+ }
151
+
152
+ export interface SyPositionJson {
153
+ balanceSy: string
154
+ owner: string
155
+ emissions: {
156
+ lastSeenIndex: number
157
+ mint: string
158
+ staged: string
159
+ }[]
160
+ }
161
+
162
+ export interface SyPosition {
163
+ balanceSy: bigint
164
+ owner: web3.PublicKey
165
+ emissions: {
166
+ /** Last seen index for SY-to-emission exchange rate */
167
+ lastSeenIndex: number
168
+ /** mint of emission token */
169
+ mint: web3.PublicKey
170
+ /** How many emissions are staged to claim */
171
+ staged: bigint
172
+ }[]
173
+ }
174
+
175
+ export interface VaultEmission {
176
+ tokenAccount: web3.PublicKey
177
+ initialIndex: AnchorizedPNum
178
+ lastSeenIndex: AnchorizedPNum
179
+ treasuryTokenAccount: web3.PublicKey
180
+ feeBps: number
181
+ treasuryEmission: BN
182
+ }
183
+
184
+ export interface VaultEmissionJson {
185
+ tokenAccount: string
186
+ initialIndex: AnchorizedPNumJson
187
+ lastSeenIndex: AnchorizedPNumJson
188
+ treasuryTokenAccount: string
189
+ feeBps: number
190
+ treasuryEmission: string
191
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "sourceMap": true,
5
+ "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
6
+ "composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */,
7
+ "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
8
+ "module": "CommonJS" /* Specify what module code is generated. */,
9
+ "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
10
+ "outDir": "./build" /* Specify an output folder for all emitted files. */,
11
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
12
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
13
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */,
14
+ "types": ["jest"]
15
+ },
16
+ "references": [
17
+ {
18
+ "path": "../precise-number"
19
+ }
20
+ ],
21
+ "include": ["src"],
22
+ "exclude": ["build"]
23
+ }