@exponent-labs/exponent-types 0.1.7 → 0.9.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.
- package/build/common.d.ts +8 -7
- package/build/cpi.d.ts +34 -2
- package/build/cpi.js +2 -2
- package/build/cpi.js.map +1 -1
- package/build/exponent-vaults.d.ts +107 -0
- package/build/exponent-vaults.js +6 -0
- package/build/exponent-vaults.js.map +1 -0
- package/build/flavor.d.ts +23 -23
- package/build/generic.d.ts +94 -30
- package/build/generic.js +99 -9
- package/build/generic.js.map +1 -1
- package/build/index.d.ts +2 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/jito-restaking.d.ts +13 -12
- package/build/kamino.d.ts +27 -25
- package/build/marginfi.d.ts +18 -17
- package/build/orderbook.d.ts +151 -0
- package/build/orderbook.js +13 -0
- package/build/orderbook.js.map +1 -0
- package/build/perena.d.ts +13 -12
- package/build/vault.d.ts +53 -15
- package/package.json +4 -2
- package/src/common.ts +9 -8
- package/src/cpi.ts +43 -3
- package/src/flavor.ts +21 -22
- package/src/generic.ts +192 -35
- package/src/index.ts +3 -2
- package/src/jito-restaking.ts +14 -14
- package/src/kamino.ts +28 -26
- package/src/marginfi.ts +19 -19
- package/src/orderbook.ts +195 -0
- package/src/perena.ts +14 -14
- package/src/vault.ts +82 -17
package/src/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export { SyEmissionRaw, SyEmissionJson } from "./common"
|
|
1
|
+
export { SyEmissionRaw, SyEmissionJson, AnchorizedPNum, AnchorizedPNumJson } from "./common"
|
|
2
2
|
export * from "./flavor"
|
|
3
3
|
export * from "./jito-restaking"
|
|
4
4
|
export * from "./kamino"
|
|
5
5
|
export * from "./marginfi"
|
|
6
6
|
export * from "./perena"
|
|
7
7
|
export * from "./vault"
|
|
8
|
+
export * from "./orderbook"
|
|
8
9
|
export * from "./cpi"
|
|
9
10
|
export * from "./trade"
|
|
10
11
|
export * from "./liquidity"
|
|
11
|
-
export * from "./generic"
|
|
12
|
+
export * from "./generic"
|
package/src/jito-restaking.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { BN, web3 } from "@coral-xyz/anchor"
|
|
2
1
|
import { AnchorizedPNum, AnchorizedPNumJson, SyEmissionRaw, SyEmissionJson } from "./common"
|
|
3
|
-
|
|
2
|
+
import { PublicKey } from "@solana/web3.js"
|
|
3
|
+
import BN from 'bn.js'
|
|
4
4
|
export interface InterfaceType {
|
|
5
5
|
splStakePool: {}
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface JitoRestakingSyState {
|
|
9
|
-
selfAddress:
|
|
9
|
+
selfAddress: PublicKey
|
|
10
10
|
account: JitoRestakingSyMetaAccount
|
|
11
11
|
/** The value of SY tokens in terms of the base asset */
|
|
12
12
|
syRate: string
|
|
13
13
|
underlyingExchangeRate: number
|
|
14
|
-
mintBase:
|
|
15
|
-
tokenProgramBase:
|
|
14
|
+
mintBase: PublicKey
|
|
15
|
+
tokenProgramBase: PublicKey
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface JitoRestakingSyMetaAccountRaw {
|
|
19
|
-
jitoVault:
|
|
20
|
-
mintSy:
|
|
21
|
-
tokenSyEscrow:
|
|
19
|
+
jitoVault: PublicKey
|
|
20
|
+
mintSy: PublicKey
|
|
21
|
+
tokenSyEscrow: PublicKey
|
|
22
22
|
maxSySupply: BN
|
|
23
23
|
minMintSize: BN
|
|
24
24
|
minRedeemSize: BN
|
|
25
25
|
selfAddressBump: number[]
|
|
26
26
|
emissions: SyEmissionRaw[]
|
|
27
|
-
interfaceAccounts:
|
|
27
|
+
interfaceAccounts: PublicKey[]
|
|
28
28
|
interfaceType: InterfaceType
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface JitoRestakingSyMetaAccount {
|
|
32
|
-
jitoVault:
|
|
33
|
-
mintSy:
|
|
34
|
-
tokenSyEscrow:
|
|
35
|
-
interfaceAccounts:
|
|
32
|
+
jitoVault: PublicKey
|
|
33
|
+
mintSy: PublicKey
|
|
34
|
+
tokenSyEscrow: PublicKey
|
|
35
|
+
interfaceAccounts: PublicKey[]
|
|
36
36
|
interfaceType: InterfaceType
|
|
37
37
|
maxSySupply: BN
|
|
38
38
|
minMintSize: BN
|
|
@@ -75,4 +75,4 @@ export interface JitoRestakingSyStateJson {
|
|
|
75
75
|
underlyingExchangeRate: number
|
|
76
76
|
mintBase: string
|
|
77
77
|
tokenProgramBase: string
|
|
78
|
-
}
|
|
78
|
+
}
|
package/src/kamino.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { web3 } from "@coral-xyz/anchor"
|
|
1
|
+
import BN from "bn.js"
|
|
3
2
|
|
|
4
3
|
import { SyEmissionJson, SyEmissionRaw, SyEmissionRaw2 } from "./common"
|
|
4
|
+
import { PublicKey } from "@solana/web3.js"
|
|
5
5
|
|
|
6
6
|
export interface KaminoSyState {
|
|
7
|
-
selfAddress:
|
|
7
|
+
selfAddress: PublicKey
|
|
8
8
|
account: KaminoSyMetaAccount
|
|
9
|
-
klendSyProgramId:
|
|
9
|
+
klendSyProgramId: PublicKey
|
|
10
10
|
/** The value of SY tokens in terms of the base asset */
|
|
11
11
|
syRate: string
|
|
12
|
-
mintBase:
|
|
13
|
-
tokenProgramBase:
|
|
14
|
-
klendProgramId:
|
|
15
|
-
klendMarketId:
|
|
12
|
+
mintBase: PublicKey
|
|
13
|
+
tokenProgramBase: PublicKey
|
|
14
|
+
klendProgramId: PublicKey
|
|
15
|
+
klendMarketId: PublicKey
|
|
16
|
+
scopePriceFeed?: PublicKey
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export interface KaminoSyStateJson {
|
|
@@ -24,17 +25,18 @@ export interface KaminoSyStateJson {
|
|
|
24
25
|
tokenProgramBase: string
|
|
25
26
|
klendProgramId: string
|
|
26
27
|
klendMarketId: string
|
|
28
|
+
scopePriceFeed?: string
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export interface KaminoSyMetaAccount {
|
|
30
|
-
kaminoReserve:
|
|
31
|
-
kaminoObligation:
|
|
32
|
-
kaminoFarm:
|
|
33
|
-
kaminoUserMetadata:
|
|
34
|
-
mintSy:
|
|
32
|
+
kaminoReserve: PublicKey
|
|
33
|
+
kaminoObligation: PublicKey
|
|
34
|
+
kaminoFarm: PublicKey
|
|
35
|
+
kaminoUserMetadata: PublicKey
|
|
36
|
+
mintSy: PublicKey
|
|
35
37
|
/** Where deposited SY tokens reside */
|
|
36
|
-
tokenSyEscrow:
|
|
37
|
-
userState:
|
|
38
|
+
tokenSyEscrow: PublicKey
|
|
39
|
+
userState: PublicKey
|
|
38
40
|
maxSySupply: string
|
|
39
41
|
minMintSize: string
|
|
40
42
|
minRedeemSize: string
|
|
@@ -56,22 +58,22 @@ interface KaminoSyMetaAccountJson {
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
export interface KaminoSyMetaAccountRaw {
|
|
59
|
-
kamino_reserve:
|
|
60
|
-
kamino_obligation:
|
|
61
|
-
kamino_farm:
|
|
62
|
-
kamino_user_metadata:
|
|
63
|
-
mint_sy:
|
|
61
|
+
kamino_reserve: PublicKey
|
|
62
|
+
kamino_obligation: PublicKey
|
|
63
|
+
kamino_farm: PublicKey
|
|
64
|
+
kamino_user_metadata: PublicKey
|
|
65
|
+
mint_sy: PublicKey
|
|
64
66
|
/** Where deposited SY tokens reside */
|
|
65
|
-
token_sy_escrow:
|
|
67
|
+
token_sy_escrow: PublicKey
|
|
66
68
|
/** Robot authority over the Mfi Account */
|
|
67
|
-
authority_klend_account:
|
|
69
|
+
authority_klend_account: PublicKey
|
|
68
70
|
/** Authority over the SY token escrow account */
|
|
69
|
-
authority_escrow:
|
|
71
|
+
authority_escrow: PublicKey
|
|
70
72
|
/** Authority over the sy mint */
|
|
71
|
-
mint_authority:
|
|
72
|
-
user_state:
|
|
73
|
+
mint_authority: PublicKey
|
|
74
|
+
user_state: PublicKey
|
|
73
75
|
max_sy_supply: BN
|
|
74
76
|
min_mint_size: BN
|
|
75
77
|
min_redeem_size: BN
|
|
76
78
|
emissions: SyEmissionRaw2[]
|
|
77
|
-
}
|
|
79
|
+
}
|
package/src/marginfi.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from "@solana/web3.js"
|
|
2
2
|
import { SyEmissionRaw, SyEmissionJson } from "./common"
|
|
3
|
-
|
|
3
|
+
import BN from 'bn.js'
|
|
4
4
|
export interface MfiSyState {
|
|
5
|
-
selfAddress:
|
|
5
|
+
selfAddress: PublicKey
|
|
6
6
|
account: MarginfiSyMeta
|
|
7
|
-
marginfiSyProgramId:
|
|
7
|
+
marginfiSyProgramId: PublicKey
|
|
8
8
|
|
|
9
9
|
/** The value of SY tokens in terms of the base asset taken directly from the bank */
|
|
10
10
|
syRate: string
|
|
11
|
-
mintBase:
|
|
12
|
-
tokenProgramBase:
|
|
13
|
-
marginfiProgramId:
|
|
14
|
-
marginfiGroupId:
|
|
15
|
-
emissionsMint:
|
|
16
|
-
emissionsTokenProgram:
|
|
11
|
+
mintBase: PublicKey
|
|
12
|
+
tokenProgramBase: PublicKey
|
|
13
|
+
marginfiProgramId: PublicKey
|
|
14
|
+
marginfiGroupId: PublicKey
|
|
15
|
+
emissionsMint: PublicKey | null
|
|
16
|
+
emissionsTokenProgram: PublicKey | null
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface MfiSyStateJson {
|
|
@@ -43,11 +43,11 @@ export interface SyMetaJson {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export interface MarginfiSyMeta {
|
|
46
|
-
marginfiBank:
|
|
47
|
-
marginfiAccount:
|
|
48
|
-
mintSy:
|
|
46
|
+
marginfiBank: PublicKey
|
|
47
|
+
marginfiAccount: PublicKey
|
|
48
|
+
mintSy: PublicKey
|
|
49
49
|
/** Where the SY tokens get deposited */
|
|
50
|
-
tokenSyEscrow:
|
|
50
|
+
tokenSyEscrow: PublicKey
|
|
51
51
|
maxSySupply: bigint
|
|
52
52
|
minMintSize: bigint
|
|
53
53
|
minRedeemSize: bigint
|
|
@@ -66,16 +66,16 @@ export interface MarginfiSyMetaJson {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export interface MarginfiSyMetaRaw {
|
|
69
|
-
marginfiBank:
|
|
70
|
-
marginfiAccount:
|
|
71
|
-
mintSy:
|
|
69
|
+
marginfiBank: PublicKey
|
|
70
|
+
marginfiAccount: PublicKey
|
|
71
|
+
mintSy: PublicKey
|
|
72
72
|
maxSySupply: BN
|
|
73
73
|
minMintSize: BN
|
|
74
74
|
minRedeemSize: BN
|
|
75
75
|
/** Where the SY tokens get deposited */
|
|
76
|
-
tokenSyEscrow:
|
|
76
|
+
tokenSyEscrow: PublicKey
|
|
77
77
|
emissions: SyEmissionRaw[]
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export type AnchorizedPNum = { 0: BN[] }
|
|
81
|
-
export type AnchorizedPNumJson = { 0: string[] }
|
|
81
|
+
export type AnchorizedPNumJson = { 0: string[] }
|
package/src/orderbook.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
|
|
2
|
+
import { PublicKey } from "@solana/web3.js"
|
|
3
|
+
import { CpiAccountsRaw, ExponentCoreCpiAccountsRaw } from "./cpi"
|
|
4
|
+
import { Flavor } from "./flavor"
|
|
5
|
+
|
|
6
|
+
export const MAX_PRICE_NODES = 1000
|
|
7
|
+
export const MAX_OFFERS = 2500
|
|
8
|
+
export const MAX_USER_ESCROWS = 1500
|
|
9
|
+
// RedBlackTree uses 3 registers per node: parent, left, right
|
|
10
|
+
export const PRICE_NODE_REGISTERS = 3
|
|
11
|
+
// Offer allocator uses 1 register per node (free‐list pointer)
|
|
12
|
+
export const OFFER_REGISTERS = 1
|
|
13
|
+
// UserEscrow allocator uses 0 registers
|
|
14
|
+
export const ESCROW_REGISTERS = 0
|
|
15
|
+
|
|
16
|
+
/** ─── Orderbook Financials ─────────────────────────────────────────────────── */
|
|
17
|
+
export interface OrderbookFinancials {
|
|
18
|
+
/** Expiration timestamp (unix seconds) */
|
|
19
|
+
expirationTs: number
|
|
20
|
+
/** SY token balance */
|
|
21
|
+
syBalance: bigint
|
|
22
|
+
/** YT token balance */
|
|
23
|
+
ytBalance: bigint
|
|
24
|
+
/** PT token balance */
|
|
25
|
+
ptBalance: bigint
|
|
26
|
+
|
|
27
|
+
/// Balance of YT fee in the orderbook
|
|
28
|
+
/// This amount is tracked separately to prevent bugs from token transfers directly to the orderbook
|
|
29
|
+
ytFeeBalance: bigint
|
|
30
|
+
|
|
31
|
+
/// Balance of SY fee in the orderbook
|
|
32
|
+
/// This amount is tracked separately to prevent bugs from token transfers directly to the orderbook
|
|
33
|
+
syFeeBalance: bigint
|
|
34
|
+
|
|
35
|
+
/// Balance of PT fee in the orderbook
|
|
36
|
+
/// This amount is tracked separately to prevent bugs from token transfers directly to the orderbook
|
|
37
|
+
ptFeeBalance: bigint
|
|
38
|
+
|
|
39
|
+
/// Balance of staged SY in the orderbook
|
|
40
|
+
stagedSy: bigint
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** ─── Configuration Options ─────────────────────────────────────────────────── */
|
|
44
|
+
export interface ConfigurationOptions {
|
|
45
|
+
priceDecimals: number
|
|
46
|
+
thresholdAmount: bigint
|
|
47
|
+
lnMakerFeeRate: number
|
|
48
|
+
lnTakerFeeRate: number
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PriceTreeNode {
|
|
52
|
+
/** The price tick (key into the tree) */
|
|
53
|
+
key: number
|
|
54
|
+
/** Head indexes of the linked lists of offers at this price */
|
|
55
|
+
firstOfferSellYt: number
|
|
56
|
+
firstOfferBuyYt: number
|
|
57
|
+
lastOfferSellYt: number
|
|
58
|
+
lastOfferBuyYt: number
|
|
59
|
+
/** Index of this node’s parent in the price_nodes slab */
|
|
60
|
+
parent: number
|
|
61
|
+
/** Index of this node’s left child */
|
|
62
|
+
left: number
|
|
63
|
+
/** Index of this node’s right child */
|
|
64
|
+
right: number
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface OfferNode {
|
|
68
|
+
/** Actual NodeAllocator slot for this offer (0 is sentinel, live offers are 1-based) */
|
|
69
|
+
offerIndex: number
|
|
70
|
+
|
|
71
|
+
/** Internal register 1 (the free‐list link when unused) */
|
|
72
|
+
nextOfferPointer: number
|
|
73
|
+
|
|
74
|
+
/** Internal register 3 (the free‐list link when unused) */
|
|
75
|
+
pricePointer: number
|
|
76
|
+
|
|
77
|
+
/** SY/PT/YT amount deposited */
|
|
78
|
+
amount: bigint
|
|
79
|
+
/** Index of the user escrow that owns this offer */
|
|
80
|
+
userVaultPointer: number
|
|
81
|
+
/** Expiry timestamp (unix seconds) */
|
|
82
|
+
expiryAt: number
|
|
83
|
+
/** Creation timestamp (unix seconds) */
|
|
84
|
+
createdAt: number
|
|
85
|
+
/** True if this is a PT order */
|
|
86
|
+
virtualOffer: boolean
|
|
87
|
+
/** Offer‐type flag */
|
|
88
|
+
orderTypeFlag: number
|
|
89
|
+
/** Fill‐or‐kill flag */
|
|
90
|
+
fillOrKill: boolean
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface UserEscrowNode {
|
|
94
|
+
/** The user’s Pubkey */
|
|
95
|
+
user: PublicKey
|
|
96
|
+
/** Last seen SY exchange rate for this user escrow */
|
|
97
|
+
yieldIndex: number
|
|
98
|
+
/** Token amounts held */
|
|
99
|
+
ptAmount: bigint
|
|
100
|
+
syAmount: bigint
|
|
101
|
+
ytAmount: bigint
|
|
102
|
+
stakedYtAmount: bigint
|
|
103
|
+
/** When unused, the free‐list link */
|
|
104
|
+
staged: bigint
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** ─── Full On-chain Orderbook ───────────────────────────────────────────────── */
|
|
108
|
+
export interface Orderbook {
|
|
109
|
+
/** PDA link to vault */
|
|
110
|
+
vault: PublicKey
|
|
111
|
+
/** PDA link to a vault-owned YT position */
|
|
112
|
+
yieldPosition: PublicKey
|
|
113
|
+
/** Address Lookup Table key for the orderbook */
|
|
114
|
+
addressLookupTable: PublicKey
|
|
115
|
+
/** Address of the Exponent Core program */
|
|
116
|
+
exponentCoreProgram: PublicKey
|
|
117
|
+
/** Address of the Sy program */
|
|
118
|
+
syProgram: PublicKey
|
|
119
|
+
/** Orderbook-owned escrow for SY tokens */
|
|
120
|
+
tokenEscrowSy: PublicKey
|
|
121
|
+
/** Orderbook-owned escrow for YT tokens */
|
|
122
|
+
tokenEscrowYt: PublicKey
|
|
123
|
+
/** Orderbook-owned escrow for PT tokens */
|
|
124
|
+
tokenEscrowPt: PublicKey
|
|
125
|
+
|
|
126
|
+
/// Admin key
|
|
127
|
+
admin: PublicKey
|
|
128
|
+
|
|
129
|
+
/** CPI accounts storage key */
|
|
130
|
+
cpiAccountOrderbook: PublicKey
|
|
131
|
+
|
|
132
|
+
/** How many price nodes are currently in use */
|
|
133
|
+
nodeCount: number
|
|
134
|
+
|
|
135
|
+
financials: OrderbookFinancials
|
|
136
|
+
|
|
137
|
+
/** All PriceNode entries (fixed capacity) */
|
|
138
|
+
prices: PriceTreeNode[]
|
|
139
|
+
|
|
140
|
+
/** All Offer entries (fixed capacity) */
|
|
141
|
+
offers: OfferNode[]
|
|
142
|
+
|
|
143
|
+
/** All UserEscrow entries (fixed capacity) */
|
|
144
|
+
userEscrows: UserEscrowNode[]
|
|
145
|
+
|
|
146
|
+
/** PDA bump seed for the orderbook authority */
|
|
147
|
+
signerBump: number
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface OrderbookState {
|
|
151
|
+
/** PDA link to vault */
|
|
152
|
+
vault: PublicKey
|
|
153
|
+
/** PDA link to a vault-owned YT position */
|
|
154
|
+
yieldPosition: PublicKey
|
|
155
|
+
/** Address Lookup Table key for the orderbook */
|
|
156
|
+
addressLookupTable: PublicKey
|
|
157
|
+
/** Address of the Exponent Core program */
|
|
158
|
+
exponentCoreProgram: PublicKey
|
|
159
|
+
/** Address of the Exponent Core program */
|
|
160
|
+
syProgram: PublicKey
|
|
161
|
+
/** Orderbook-owned escrow for SY tokens */
|
|
162
|
+
tokenEscrowSy: PublicKey
|
|
163
|
+
/** Orderbook-owned escrow for YT tokens */
|
|
164
|
+
tokenEscrowYt: PublicKey
|
|
165
|
+
/** Orderbook-owned escrow for PT tokens */
|
|
166
|
+
tokenEscrowPt: PublicKey
|
|
167
|
+
/** CPI accounts storage key */
|
|
168
|
+
cpiAccountOrderbook: PublicKey
|
|
169
|
+
/** Admin key */
|
|
170
|
+
admin: PublicKey
|
|
171
|
+
|
|
172
|
+
configurationOptions: ConfigurationOptions
|
|
173
|
+
|
|
174
|
+
financials: OrderbookFinancials
|
|
175
|
+
|
|
176
|
+
/** All PriceNode entries (fixed capacity) */
|
|
177
|
+
prices: PriceTreeNode[]
|
|
178
|
+
|
|
179
|
+
/** All Offer entries (fixed capacity) */
|
|
180
|
+
offers: OfferNode[]
|
|
181
|
+
|
|
182
|
+
/** All UserEscrow entries (fixed capacity) */
|
|
183
|
+
userEscrows: UserEscrowNode[]
|
|
184
|
+
|
|
185
|
+
syCpiAccounts: CpiAccountsRaw
|
|
186
|
+
|
|
187
|
+
exponentCoreCpiAccounts: ExponentCoreCpiAccountsRaw
|
|
188
|
+
|
|
189
|
+
flavor: Flavor
|
|
190
|
+
|
|
191
|
+
/** Next offer index that will be allocated (from NodeAllocator free list) */
|
|
192
|
+
offersFreeListHead: number
|
|
193
|
+
/** Bump index boundary for offers allocator */
|
|
194
|
+
offersBumpIndex: number
|
|
195
|
+
}
|
package/src/perena.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from "@solana/web3.js"
|
|
2
2
|
import { AnchorizedPNum, AnchorizedPNumJson, SyEmissionRaw, SyEmissionJson } from "./common"
|
|
3
|
-
|
|
3
|
+
import BN from 'bn.js'
|
|
4
4
|
export interface PerenaSyState {
|
|
5
|
-
selfAddress:
|
|
5
|
+
selfAddress: PublicKey
|
|
6
6
|
account: PerenaSyMetaAccount
|
|
7
7
|
/** The value of SY tokens in terms of the base asset */
|
|
8
8
|
syRate: string
|
|
9
|
-
tokenProgramBase:
|
|
10
|
-
lpMint:
|
|
9
|
+
tokenProgramBase: PublicKey
|
|
10
|
+
lpMint: PublicKey
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface PerenaSyMetaAccountRaw {
|
|
14
|
-
perenaStablePool:
|
|
15
|
-
mintSy:
|
|
16
|
-
tokenSyEscrow:
|
|
14
|
+
perenaStablePool: PublicKey
|
|
15
|
+
mintSy: PublicKey
|
|
16
|
+
tokenSyEscrow: PublicKey
|
|
17
17
|
maxSySupply: BN
|
|
18
18
|
minMintSize: BN
|
|
19
19
|
minRedeemSize: BN
|
|
20
20
|
selfAddressBump: number[]
|
|
21
21
|
emissions: SyEmissionRaw[]
|
|
22
|
-
interfaceAccounts:
|
|
22
|
+
interfaceAccounts: PublicKey[]
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface PerenaSyMetaAccount {
|
|
26
|
-
perenaStablePool:
|
|
27
|
-
mintSy:
|
|
28
|
-
tokenSyEscrow:
|
|
29
|
-
interfaceAccounts:
|
|
26
|
+
perenaStablePool: PublicKey
|
|
27
|
+
mintSy: PublicKey
|
|
28
|
+
tokenSyEscrow: PublicKey
|
|
29
|
+
interfaceAccounts: PublicKey[]
|
|
30
30
|
maxSySupply: BN
|
|
31
31
|
minMintSize: BN
|
|
32
32
|
minRedeemSize: BN
|
|
@@ -64,4 +64,4 @@ export interface PerenaSyStateJson {
|
|
|
64
64
|
underlyingExchangeRate: number
|
|
65
65
|
mintBase: string
|
|
66
66
|
tokenProgramBase: string
|
|
67
|
-
}
|
|
67
|
+
}
|
package/src/vault.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BN, web3 } from "@coral-xyz/anchor"
|
|
2
1
|
import { IFlavorState, IFlavorStateJson, Flavor } from "./flavor"
|
|
3
2
|
import { CpiAccountsRaw, CpiAccountsRawJson } from "./cpi"
|
|
4
3
|
import { AnchorizedPNum, AnchorizedPNumJson } from "./common"
|
|
5
|
-
|
|
4
|
+
import { PublicKey } from "@solana/web3.js"
|
|
5
|
+
import BN from 'bn.js'
|
|
6
6
|
export type VaultJson = {
|
|
7
7
|
/** When does the vault start, as a UNIX timestamp */
|
|
8
8
|
startTs: number
|
|
@@ -83,6 +83,8 @@ export type VaultJson = {
|
|
|
83
83
|
emissions: VaultEmissionJson[]
|
|
84
84
|
|
|
85
85
|
maxPySupply: string
|
|
86
|
+
|
|
87
|
+
state: VaultStateJson
|
|
86
88
|
}
|
|
87
89
|
export interface VaultState {
|
|
88
90
|
/** supply of PT */
|
|
@@ -97,28 +99,28 @@ export interface VaultState {
|
|
|
97
99
|
durationSeconds: number
|
|
98
100
|
|
|
99
101
|
/** Vault signer for token accounts, mints, SY position etc */
|
|
100
|
-
authority:
|
|
102
|
+
authority: PublicKey
|
|
101
103
|
|
|
102
|
-
addressLookupTable:
|
|
104
|
+
addressLookupTable: PublicKey
|
|
103
105
|
|
|
104
106
|
lastSeenSyExchangeRate: number
|
|
105
107
|
|
|
106
108
|
allTimeHighSyExchangeRate: number
|
|
107
109
|
|
|
108
110
|
/** Vault-owned account for passing SY between SY program and user */
|
|
109
|
-
escrowSy:
|
|
111
|
+
escrowSy: PublicKey
|
|
110
112
|
|
|
111
113
|
/** Escrow account for holding deposited YT */
|
|
112
|
-
escrowYt:
|
|
114
|
+
escrowYt: PublicKey
|
|
113
115
|
|
|
114
116
|
/** Key to SY Program */
|
|
115
|
-
syProgram:
|
|
117
|
+
syProgram: PublicKey
|
|
116
118
|
|
|
117
119
|
syPosition: SyPosition
|
|
118
120
|
|
|
119
121
|
cpiAccounts: CpiAccountsRaw
|
|
120
122
|
|
|
121
|
-
mintPt:
|
|
123
|
+
mintPt: PublicKey
|
|
122
124
|
|
|
123
125
|
status: number
|
|
124
126
|
|
|
@@ -126,15 +128,15 @@ export interface VaultState {
|
|
|
126
128
|
|
|
127
129
|
minOperationSizeMerge: bigint
|
|
128
130
|
|
|
129
|
-
mintYt:
|
|
131
|
+
mintYt: PublicKey
|
|
130
132
|
|
|
131
|
-
mintSy:
|
|
133
|
+
mintSy: PublicKey
|
|
132
134
|
|
|
133
|
-
yieldPositonAddress:
|
|
135
|
+
yieldPositonAddress: PublicKey
|
|
134
136
|
|
|
135
137
|
// yieldPosition: YtPosition
|
|
136
138
|
|
|
137
|
-
treasurySyTokenAccount:
|
|
139
|
+
treasurySyTokenAccount: PublicKey
|
|
138
140
|
|
|
139
141
|
interestBpsFee: number
|
|
140
142
|
|
|
@@ -149,6 +151,69 @@ export interface VaultState {
|
|
|
149
151
|
maxPySupply: bigint
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
export interface VaultStateJson {
|
|
155
|
+
/** supply of PT */
|
|
156
|
+
ptSupply: string
|
|
157
|
+
|
|
158
|
+
syForPt: string
|
|
159
|
+
|
|
160
|
+
/** When does the vault start, as a UNIX timestamp */
|
|
161
|
+
startTs: number
|
|
162
|
+
|
|
163
|
+
/** For how long is the vault active */
|
|
164
|
+
durationSeconds: number
|
|
165
|
+
|
|
166
|
+
/** Vault signer for token accounts, mints, SY position etc */
|
|
167
|
+
authority: string
|
|
168
|
+
|
|
169
|
+
addressLookupTable: string
|
|
170
|
+
|
|
171
|
+
lastSeenSyExchangeRate: number
|
|
172
|
+
|
|
173
|
+
allTimeHighSyExchangeRate: number
|
|
174
|
+
|
|
175
|
+
/** Vault-owned account for passing SY between SY program and user */
|
|
176
|
+
escrowSy: string
|
|
177
|
+
|
|
178
|
+
/** Escrow account for holding deposited YT */
|
|
179
|
+
escrowYt: string
|
|
180
|
+
|
|
181
|
+
/** Key to SY Program */
|
|
182
|
+
syProgram: string
|
|
183
|
+
|
|
184
|
+
syPosition: SyPositionJson
|
|
185
|
+
|
|
186
|
+
cpiAccounts: CpiAccountsRawJson
|
|
187
|
+
|
|
188
|
+
mintPt: string
|
|
189
|
+
|
|
190
|
+
status: number
|
|
191
|
+
|
|
192
|
+
minOperationSizeStrip: string
|
|
193
|
+
|
|
194
|
+
minOperationSizeMerge: string
|
|
195
|
+
|
|
196
|
+
mintYt: string
|
|
197
|
+
|
|
198
|
+
mintSy: string
|
|
199
|
+
|
|
200
|
+
yieldPositonAddress: string
|
|
201
|
+
|
|
202
|
+
treasurySyTokenAccount: string
|
|
203
|
+
|
|
204
|
+
interestBpsFee: number
|
|
205
|
+
|
|
206
|
+
totalSyInEscrow: string
|
|
207
|
+
|
|
208
|
+
flavor: IFlavorStateJson
|
|
209
|
+
|
|
210
|
+
finalSyExchangeRate: number
|
|
211
|
+
|
|
212
|
+
emissions: VaultEmissionJson[]
|
|
213
|
+
|
|
214
|
+
maxPySupply: string
|
|
215
|
+
}
|
|
216
|
+
|
|
152
217
|
export interface SyPositionJson {
|
|
153
218
|
balanceSy: string
|
|
154
219
|
owner: string
|
|
@@ -161,23 +226,23 @@ export interface SyPositionJson {
|
|
|
161
226
|
|
|
162
227
|
export interface SyPosition {
|
|
163
228
|
balanceSy: bigint
|
|
164
|
-
owner:
|
|
229
|
+
owner: PublicKey
|
|
165
230
|
emissions: {
|
|
166
231
|
/** Last seen index for SY-to-emission exchange rate */
|
|
167
232
|
lastSeenIndex: number
|
|
168
233
|
/** mint of emission token */
|
|
169
|
-
mint:
|
|
234
|
+
mint: PublicKey
|
|
170
235
|
/** How many emissions are staged to claim */
|
|
171
236
|
staged: bigint
|
|
172
237
|
}[]
|
|
173
238
|
}
|
|
174
239
|
|
|
175
240
|
export interface VaultEmission {
|
|
176
|
-
tokenAccount:
|
|
241
|
+
tokenAccount: PublicKey
|
|
177
242
|
initialIndex: AnchorizedPNum
|
|
178
243
|
lastSeenIndex: AnchorizedPNum
|
|
179
244
|
finalIndex: AnchorizedPNum
|
|
180
|
-
treasuryTokenAccount:
|
|
245
|
+
treasuryTokenAccount: PublicKey
|
|
181
246
|
feeBps: number
|
|
182
247
|
treasuryEmission: BN
|
|
183
248
|
}
|
|
@@ -190,4 +255,4 @@ export interface VaultEmissionJson {
|
|
|
190
255
|
treasuryTokenAccount: string
|
|
191
256
|
feeBps: number
|
|
192
257
|
treasuryEmission: string
|
|
193
|
-
}
|
|
258
|
+
}
|