@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.
- package/CHANGELOG.md +16 -0
- package/build/common.d.ts +27 -0
- package/build/common.js +3 -0
- package/build/common.js.map +1 -0
- package/build/cpi.d.ts +37 -0
- package/build/cpi.js +3 -0
- package/build/cpi.js.map +1 -0
- package/build/flavor.d.ts +122 -0
- package/build/flavor.js +3 -0
- package/build/flavor.js.map +1 -0
- package/build/generic.d.ts +89 -0
- package/build/generic.js +26 -0
- package/build/generic.js.map +1 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +27 -0
- package/build/index.js.map +1 -0
- package/build/jito-restaking.d.ts +57 -0
- package/build/jito-restaking.js +18 -0
- package/build/jito-restaking.js.map +1 -0
- package/build/kamino.d.ts +72 -0
- package/build/kamino.js +3 -0
- package/build/kamino.js.map +1 -0
- package/build/liquidity.d.ts +10 -0
- package/build/liquidity.js +3 -0
- package/build/liquidity.js.map +1 -0
- package/build/marginfi.d.ts +77 -0
- package/build/marginfi.js +3 -0
- package/build/marginfi.js.map +1 -0
- package/build/perena.d.ts +50 -0
- package/build/perena.js +17 -0
- package/build/perena.js.map +1 -0
- package/build/trade.d.ts +32 -0
- package/build/trade.js +3 -0
- package/build/trade.js.map +1 -0
- package/build/vault.d.ts +131 -0
- package/build/vault.js +3 -0
- package/build/vault.js.map +1 -0
- package/package.json +18 -0
- package/src/common.ts +26 -0
- package/src/cpi.ts +44 -0
- package/src/flavor.ts +141 -0
- package/src/generic.ts +121 -0
- package/src/index.ts +11 -0
- package/src/jito-restaking.ts +78 -0
- package/src/kamino.ts +76 -0
- package/src/liquidity.ts +17 -0
- package/src/marginfi.ts +81 -0
- package/src/perena.ts +67 -0
- package/src/trade.ts +37 -0
- package/src/vault.ts +191 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BN, web3 } from "@coral-xyz/anchor";
|
|
2
|
+
import { SyEmissionRaw, SyEmissionJson } from "./common";
|
|
3
|
+
export interface PerenaSyState {
|
|
4
|
+
selfAddress: web3.PublicKey;
|
|
5
|
+
account: PerenaSyMetaAccount;
|
|
6
|
+
/** The value of SY tokens in terms of the base asset */
|
|
7
|
+
syRate: string;
|
|
8
|
+
tokenProgramBase: web3.PublicKey;
|
|
9
|
+
lpMint: web3.PublicKey;
|
|
10
|
+
}
|
|
11
|
+
export interface PerenaSyMetaAccountRaw {
|
|
12
|
+
perenaStablePool: web3.PublicKey;
|
|
13
|
+
mintSy: web3.PublicKey;
|
|
14
|
+
tokenSyEscrow: web3.PublicKey;
|
|
15
|
+
maxSySupply: BN;
|
|
16
|
+
minMintSize: BN;
|
|
17
|
+
minRedeemSize: BN;
|
|
18
|
+
selfAddressBump: number[];
|
|
19
|
+
emissions: SyEmissionRaw[];
|
|
20
|
+
interfaceAccounts: web3.PublicKey[];
|
|
21
|
+
}
|
|
22
|
+
export interface PerenaSyMetaAccount {
|
|
23
|
+
perenaStablePool: web3.PublicKey;
|
|
24
|
+
mintSy: web3.PublicKey;
|
|
25
|
+
tokenSyEscrow: web3.PublicKey;
|
|
26
|
+
interfaceAccounts: web3.PublicKey[];
|
|
27
|
+
maxSySupply: BN;
|
|
28
|
+
minMintSize: BN;
|
|
29
|
+
minRedeemSize: BN;
|
|
30
|
+
emissions: SyEmissionRaw[];
|
|
31
|
+
}
|
|
32
|
+
export interface PerenaSyMetaAccountJson {
|
|
33
|
+
perenaStablePool: string;
|
|
34
|
+
mintSy: string;
|
|
35
|
+
tokenSyEscrow: string;
|
|
36
|
+
interfaceAccounts: string[];
|
|
37
|
+
maxSySupply: string;
|
|
38
|
+
minMintSize: string;
|
|
39
|
+
minRedeemSize: string;
|
|
40
|
+
emissions: SyEmissionJson[];
|
|
41
|
+
}
|
|
42
|
+
export declare function deserializePerenaSyMetaAccountRaw(raw: PerenaSyMetaAccountRaw): PerenaSyMetaAccount;
|
|
43
|
+
export interface PerenaSyStateJson {
|
|
44
|
+
selfAddress: string;
|
|
45
|
+
account: PerenaSyMetaAccountJson;
|
|
46
|
+
syRate: string;
|
|
47
|
+
underlyingExchangeRate: number;
|
|
48
|
+
mintBase: string;
|
|
49
|
+
tokenProgramBase: string;
|
|
50
|
+
}
|
package/build/perena.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializePerenaSyMetaAccountRaw = void 0;
|
|
4
|
+
function deserializePerenaSyMetaAccountRaw(raw) {
|
|
5
|
+
return {
|
|
6
|
+
perenaStablePool: raw.perenaStablePool,
|
|
7
|
+
mintSy: raw.mintSy,
|
|
8
|
+
tokenSyEscrow: raw.tokenSyEscrow,
|
|
9
|
+
interfaceAccounts: raw.interfaceAccounts,
|
|
10
|
+
maxSySupply: raw.maxSySupply,
|
|
11
|
+
minMintSize: raw.minMintSize,
|
|
12
|
+
minRedeemSize: raw.minRedeemSize,
|
|
13
|
+
emissions: raw.emissions,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.deserializePerenaSyMetaAccountRaw = deserializePerenaSyMetaAccountRaw;
|
|
17
|
+
//# sourceMappingURL=perena.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perena.js","sourceRoot":"","sources":["../src/perena.ts"],"names":[],"mappings":";;;AA8CA,SAAgB,iCAAiC,CAAC,GAA2B;IAC3E,OAAO;QACL,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;QACtC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;QACxC,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,SAAS,EAAE,GAAG,CAAC,SAAS;KACzB,CAAA;AACH,CAAC;AAXD,8EAWC"}
|
package/build/trade.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
export type Trade = {
|
|
11
|
+
marketAddress: MarketAddress;
|
|
12
|
+
amountInTokens: number;
|
|
13
|
+
amountOutTokens: number;
|
|
14
|
+
amountUsd: number;
|
|
15
|
+
price: number;
|
|
16
|
+
date: number;
|
|
17
|
+
kind: "buy" | "sell";
|
|
18
|
+
annualizedYield: number;
|
|
19
|
+
txHash: string;
|
|
20
|
+
decimals: number;
|
|
21
|
+
mint: string;
|
|
22
|
+
created_at: string;
|
|
23
|
+
};
|
|
24
|
+
export type MarketAddress = string;
|
|
25
|
+
export type AllTrades = {
|
|
26
|
+
ytTrades: Trade[];
|
|
27
|
+
ptTrades: Trade[];
|
|
28
|
+
};
|
|
29
|
+
export type TradeHistory = Record<MarketAddress, AllTrades>;
|
|
30
|
+
export type ApiReturnData = {
|
|
31
|
+
tradeHistory: TradeHistory;
|
|
32
|
+
};
|
package/build/trade.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trade.js","sourceRoot":"","sources":["../src/trade.ts"],"names":[],"mappings":""}
|
package/build/vault.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { BN, web3 } from "@coral-xyz/anchor";
|
|
2
|
+
import { IFlavorStateJson, Flavor } from "./flavor";
|
|
3
|
+
import { CpiAccountsRaw, CpiAccountsRawJson } from "./cpi";
|
|
4
|
+
import { AnchorizedPNum, AnchorizedPNumJson } from "./common";
|
|
5
|
+
export type VaultJson = {
|
|
6
|
+
/** When does the vault start, as a UNIX timestamp */
|
|
7
|
+
startTs: number;
|
|
8
|
+
/** For how long is the vault active */
|
|
9
|
+
duration: number;
|
|
10
|
+
/** When does the vault start, formatted as YYYY-MM-DD */
|
|
11
|
+
startDateString: string;
|
|
12
|
+
/** Vault signer for token accounts, mints, SY position etc */
|
|
13
|
+
authority: string;
|
|
14
|
+
/** SY balance of the vault in the SY program */
|
|
15
|
+
syBalance: string;
|
|
16
|
+
/** Address of the address lookup table */
|
|
17
|
+
addressLookupTable: string;
|
|
18
|
+
/** Last seen SY exchange rate, according to the Vault state */
|
|
19
|
+
lastSeenSyExchangeRate: number;
|
|
20
|
+
/** Current SY exchange rate, according to underlying program */
|
|
21
|
+
currentSyExchangeRate: number;
|
|
22
|
+
/** Address of the vault */
|
|
23
|
+
selfAddress: string;
|
|
24
|
+
/** SY program address */
|
|
25
|
+
syProgram: string;
|
|
26
|
+
/** PT mint */
|
|
27
|
+
mintPt: string;
|
|
28
|
+
/** YT mint */
|
|
29
|
+
mintYt: string;
|
|
30
|
+
/** SY mint */
|
|
31
|
+
mintSy: string;
|
|
32
|
+
/** Escrow SY token account */
|
|
33
|
+
escrowSy: string;
|
|
34
|
+
/** Escrow YT token account */
|
|
35
|
+
escrowYt: string;
|
|
36
|
+
/** Treasury SY token account */
|
|
37
|
+
treasurySyTokenAccount: string;
|
|
38
|
+
/** All time high SY exchange rate */
|
|
39
|
+
allTimeHighSyExchangeRate: number;
|
|
40
|
+
/** Exchange rate for SY when the vault expires */
|
|
41
|
+
finalSyExchangeRate: number;
|
|
42
|
+
/** Supply of PT */
|
|
43
|
+
ptSupply: string;
|
|
44
|
+
/** SY in escrow */
|
|
45
|
+
totalSyInEscrow: string;
|
|
46
|
+
/** SY for PT */
|
|
47
|
+
syForPt: string;
|
|
48
|
+
status: number;
|
|
49
|
+
syPosition: SyPositionJson;
|
|
50
|
+
minOperationSizeStrip: string;
|
|
51
|
+
minOperationSizeMerge: string;
|
|
52
|
+
yieldPositonAddress: string;
|
|
53
|
+
interestFeeBps: number;
|
|
54
|
+
cpiAccounts: CpiAccountsRawJson;
|
|
55
|
+
flavor: IFlavorStateJson;
|
|
56
|
+
emissions: VaultEmissionJson[];
|
|
57
|
+
maxPySupply: string;
|
|
58
|
+
};
|
|
59
|
+
export interface VaultState {
|
|
60
|
+
/** supply of PT */
|
|
61
|
+
ptSupply: bigint;
|
|
62
|
+
syForPt: bigint;
|
|
63
|
+
/** When does the vault start, as a UNIX timestamp */
|
|
64
|
+
startTs: number;
|
|
65
|
+
/** For how long is the vault active */
|
|
66
|
+
durationSeconds: number;
|
|
67
|
+
/** Vault signer for token accounts, mints, SY position etc */
|
|
68
|
+
authority: web3.PublicKey;
|
|
69
|
+
addressLookupTable: web3.PublicKey;
|
|
70
|
+
lastSeenSyExchangeRate: number;
|
|
71
|
+
allTimeHighSyExchangeRate: number;
|
|
72
|
+
/** Vault-owned account for passing SY between SY program and user */
|
|
73
|
+
escrowSy: web3.PublicKey;
|
|
74
|
+
/** Escrow account for holding deposited YT */
|
|
75
|
+
escrowYt: web3.PublicKey;
|
|
76
|
+
/** Key to SY Program */
|
|
77
|
+
syProgram: web3.PublicKey;
|
|
78
|
+
syPosition: SyPosition;
|
|
79
|
+
cpiAccounts: CpiAccountsRaw;
|
|
80
|
+
mintPt: web3.PublicKey;
|
|
81
|
+
status: number;
|
|
82
|
+
minOperationSizeStrip: bigint;
|
|
83
|
+
minOperationSizeMerge: bigint;
|
|
84
|
+
mintYt: web3.PublicKey;
|
|
85
|
+
mintSy: web3.PublicKey;
|
|
86
|
+
yieldPositonAddress: web3.PublicKey;
|
|
87
|
+
treasurySyTokenAccount: web3.PublicKey;
|
|
88
|
+
interestBpsFee: number;
|
|
89
|
+
totalSyInEscrow: bigint;
|
|
90
|
+
flavor: Flavor;
|
|
91
|
+
finalSyExchangeRate: number;
|
|
92
|
+
emissions: VaultEmission[];
|
|
93
|
+
maxPySupply: bigint;
|
|
94
|
+
}
|
|
95
|
+
export interface SyPositionJson {
|
|
96
|
+
balanceSy: string;
|
|
97
|
+
owner: string;
|
|
98
|
+
emissions: {
|
|
99
|
+
lastSeenIndex: number;
|
|
100
|
+
mint: string;
|
|
101
|
+
staged: string;
|
|
102
|
+
}[];
|
|
103
|
+
}
|
|
104
|
+
export interface SyPosition {
|
|
105
|
+
balanceSy: bigint;
|
|
106
|
+
owner: web3.PublicKey;
|
|
107
|
+
emissions: {
|
|
108
|
+
/** Last seen index for SY-to-emission exchange rate */
|
|
109
|
+
lastSeenIndex: number;
|
|
110
|
+
/** mint of emission token */
|
|
111
|
+
mint: web3.PublicKey;
|
|
112
|
+
/** How many emissions are staged to claim */
|
|
113
|
+
staged: bigint;
|
|
114
|
+
}[];
|
|
115
|
+
}
|
|
116
|
+
export interface VaultEmission {
|
|
117
|
+
tokenAccount: web3.PublicKey;
|
|
118
|
+
initialIndex: AnchorizedPNum;
|
|
119
|
+
lastSeenIndex: AnchorizedPNum;
|
|
120
|
+
treasuryTokenAccount: web3.PublicKey;
|
|
121
|
+
feeBps: number;
|
|
122
|
+
treasuryEmission: BN;
|
|
123
|
+
}
|
|
124
|
+
export interface VaultEmissionJson {
|
|
125
|
+
tokenAccount: string;
|
|
126
|
+
initialIndex: AnchorizedPNumJson;
|
|
127
|
+
lastSeenIndex: AnchorizedPNumJson;
|
|
128
|
+
treasuryTokenAccount: string;
|
|
129
|
+
feeBps: number;
|
|
130
|
+
treasuryEmission: string;
|
|
131
|
+
}
|
package/build/vault.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@exponent-labs/exponent-types",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"main": "build/index.js",
|
|
5
|
+
"types": "build/index.d.ts",
|
|
6
|
+
"license": "AGPL-3.0",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc --build"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@coral-xyz/anchor": "0.30.1",
|
|
12
|
+
"@exponent-labs/precise-number": "^0.0.3"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"typescript": "5.4.5"
|
|
16
|
+
},
|
|
17
|
+
"gitHead": "209b8847e9a0fadb5b5ec96b9b47f0ace4a3bf9d"
|
|
18
|
+
}
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BN, web3 } from "@coral-xyz/anchor"
|
|
2
|
+
|
|
3
|
+
export interface SyEmissionRaw {
|
|
4
|
+
mint: web3.PublicKey
|
|
5
|
+
index: AnchorizedPNum
|
|
6
|
+
lastSeenTotalAccruedEmissions: BN
|
|
7
|
+
totalClaimedEmissions: BN
|
|
8
|
+
tokenProgram: web3.PublicKey
|
|
9
|
+
escrowAccount: web3.PublicKey
|
|
10
|
+
treasuryEmission: BN
|
|
11
|
+
lastSeenIndex: AnchorizedPNum
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SyEmissionJson {
|
|
15
|
+
mint: string
|
|
16
|
+
tokenProgram: string
|
|
17
|
+
escrowAccount: string
|
|
18
|
+
index: number
|
|
19
|
+
lastSeenIndex: number
|
|
20
|
+
lastSeenTotalAccruedEmissions: string
|
|
21
|
+
totalClaimedEmissions: string
|
|
22
|
+
treasuryEmission: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type AnchorizedPNum = { 0: BN[] }
|
|
26
|
+
export type AnchorizedPNumJson = { 0: string[] }
|
package/src/cpi.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { web3 } from "@coral-xyz/anchor"
|
|
2
|
+
|
|
3
|
+
export interface AccountInfo {
|
|
4
|
+
pubkey: web3.PublicKey
|
|
5
|
+
isSigner: boolean
|
|
6
|
+
isWritable: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Generic container for CPI account lists */
|
|
10
|
+
export interface CpiMeta<T> {
|
|
11
|
+
getSyState: T[]
|
|
12
|
+
withdrawSy: T[]
|
|
13
|
+
depositSy: T[]
|
|
14
|
+
claimEmission: T[][]
|
|
15
|
+
getPositionState: T[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The on-chain storage for CPI accounts, which references an ALT */
|
|
19
|
+
export interface CpiAccountIndex {
|
|
20
|
+
/** Index in the Address Lookup Table */
|
|
21
|
+
altIndex: number
|
|
22
|
+
isSigner: boolean
|
|
23
|
+
isWritable: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Raw account infos for CPI that include the Pubkey */
|
|
27
|
+
export type CpiAccountsRaw = CpiMeta<AccountInfo>
|
|
28
|
+
|
|
29
|
+
/** This account is stored in state on the vault/market to track indexes in the ALT */
|
|
30
|
+
export type CpiAccountIndexes = CpiMeta<CpiAccountIndex>
|
|
31
|
+
|
|
32
|
+
export interface CpiAccountsRawJson {
|
|
33
|
+
getSyState: AccountInfoJson[]
|
|
34
|
+
withdrawSy: AccountInfoJson[]
|
|
35
|
+
depositSy: AccountInfoJson[]
|
|
36
|
+
claimEmission: AccountInfoJson[][]
|
|
37
|
+
getPositionState: AccountInfoJson[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type AccountInfoJson = {
|
|
41
|
+
pubkey: string
|
|
42
|
+
isSigner: boolean
|
|
43
|
+
isWritable: boolean
|
|
44
|
+
}
|
package/src/flavor.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { web3 } from "@coral-xyz/anchor"
|
|
2
|
+
import { MfiSyStateJson, MfiSyState } from "./marginfi"
|
|
3
|
+
import { KaminoSyState, KaminoSyStateJson } from "./kamino"
|
|
4
|
+
import { JitoRestakingSyState, JitoRestakingSyStateJson } from "./jito-restaking"
|
|
5
|
+
import { AnchorizedPNum } from "./common"
|
|
6
|
+
import { PerenaSyState, PerenaSyStateJson } from "./perena"
|
|
7
|
+
import { GenericSyState, GenericSyStateJson } from "./generic"
|
|
8
|
+
|
|
9
|
+
export type FlavorDiscriminator = "marginfi" | "kamino" | "jitoRestaking" | "perena" | "generic"
|
|
10
|
+
|
|
11
|
+
export type MintSyArgs = {
|
|
12
|
+
amountBase: string
|
|
13
|
+
depositor: web3.PublicKey
|
|
14
|
+
depositorBaseTokenAccount: web3.PublicKey
|
|
15
|
+
depositorSyTokenAccount: web3.PublicKey
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type RedeemSyArgs = {
|
|
19
|
+
amountSy: string
|
|
20
|
+
redeemer: web3.PublicKey
|
|
21
|
+
redeemerBaseTokenAccount: web3.PublicKey
|
|
22
|
+
redeemerSyTokenAccount: web3.PublicKey
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type InterfaceInstructionArgs = {
|
|
26
|
+
signer: web3.PublicKey
|
|
27
|
+
amountBase: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type BaseFlavorState = {
|
|
31
|
+
flavor: FlavorDiscriminator
|
|
32
|
+
currentSyExchangeRate: number
|
|
33
|
+
mintBase: web3.PublicKey
|
|
34
|
+
baseTokenProgram: web3.PublicKey
|
|
35
|
+
emissions: {
|
|
36
|
+
exchangeRate: AnchorizedPNum
|
|
37
|
+
mint: web3.PublicKey
|
|
38
|
+
tokenProgram: web3.PublicKey
|
|
39
|
+
}[]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type BaseFlavorStateJson = {
|
|
43
|
+
flavor: FlavorDiscriminator
|
|
44
|
+
currentSyExchangeRate: number
|
|
45
|
+
mintBase: string
|
|
46
|
+
baseTokenProgram: string
|
|
47
|
+
emissions: {
|
|
48
|
+
exchangeRate: number
|
|
49
|
+
mint: string
|
|
50
|
+
tokenProgram: string
|
|
51
|
+
}[]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface BaseFlavorTrait {
|
|
55
|
+
ixMintSy: (args: MintSyArgs) => Promise<web3.TransactionInstruction>
|
|
56
|
+
ixRedeemSy: (args: RedeemSyArgs) => Promise<web3.TransactionInstruction>
|
|
57
|
+
preIxs: (args: { signer: web3.PublicKey }) => Promise<web3.TransactionInstruction[]>
|
|
58
|
+
postIxs: (args: { signer: web3.PublicKey }) => Promise<web3.TransactionInstruction[]>
|
|
59
|
+
preMintSyIx?: (args: InterfaceInstructionArgs) => Promise<web3.TransactionInstruction[]>
|
|
60
|
+
postRedeemSyIx?: (args: InterfaceInstructionArgs) => Promise<web3.TransactionInstruction[]>
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface FlavorKaminoState extends BaseFlavorState {
|
|
64
|
+
flavor: "kamino"
|
|
65
|
+
kaminoSyState: KaminoSyState
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface FlavorMarginfiState extends BaseFlavorState {
|
|
69
|
+
flavor: "marginfi"
|
|
70
|
+
bank: web3.PublicKey
|
|
71
|
+
emissionMint?: web3.PublicKey
|
|
72
|
+
emissionTokenProgram?: web3.PublicKey
|
|
73
|
+
mfiSyState: MfiSyState
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface FlavorJitoRestakingState extends BaseFlavorState {
|
|
77
|
+
flavor: "jitoRestaking"
|
|
78
|
+
jitoSyState: JitoRestakingSyState
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface FlavorPerenaState extends BaseFlavorState {
|
|
82
|
+
flavor: "perena"
|
|
83
|
+
perenaSyState: PerenaSyState
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface FlavorGenericState extends BaseFlavorState {
|
|
87
|
+
flavor: "generic"
|
|
88
|
+
genericSyState: GenericSyState
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface FlavorJitoRestakingStateJson extends BaseFlavorStateJson {
|
|
92
|
+
flavor: "jitoRestaking"
|
|
93
|
+
jitoSyState: JitoRestakingSyStateJson
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface FlavorPerenaStateJson extends BaseFlavorStateJson {
|
|
97
|
+
flavor: "perena"
|
|
98
|
+
perenaSyState: PerenaSyStateJson
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface FlavorMarginfiStateJson extends BaseFlavorStateJson {
|
|
102
|
+
flavor: "marginfi"
|
|
103
|
+
bank: string
|
|
104
|
+
emissionMint?: string
|
|
105
|
+
emissionTokenProgram?: string
|
|
106
|
+
mfiSyState: MfiSyStateJson
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface FlavorKaminoStateJson extends BaseFlavorStateJson {
|
|
110
|
+
flavor: "kamino"
|
|
111
|
+
kaminoSyState: KaminoSyStateJson
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface FlavorJitoRestakingStateJson extends BaseFlavorStateJson {
|
|
115
|
+
flavor: "jitoRestaking"
|
|
116
|
+
jitoSyState: JitoRestakingSyStateJson
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface FlavorGenericStateJson extends BaseFlavorStateJson {
|
|
120
|
+
flavor: "generic"
|
|
121
|
+
genericSyState: GenericSyStateJson
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface FlavorKamino extends BaseFlavorTrait, FlavorKaminoState {}
|
|
125
|
+
export interface FlavorMarginfi extends BaseFlavorTrait, FlavorMarginfiState {}
|
|
126
|
+
export interface FlavorJitoRestaking extends BaseFlavorTrait, FlavorJitoRestakingState {}
|
|
127
|
+
export interface FlavorPerena extends BaseFlavorTrait, FlavorPerenaState {}
|
|
128
|
+
export interface FlavorGeneric extends BaseFlavorTrait, FlavorGenericState {}
|
|
129
|
+
export type IFlavorState =
|
|
130
|
+
| FlavorMarginfiState
|
|
131
|
+
| FlavorKaminoState
|
|
132
|
+
| FlavorJitoRestakingState
|
|
133
|
+
| FlavorPerenaState
|
|
134
|
+
| FlavorGenericState
|
|
135
|
+
export type IFlavorStateJson =
|
|
136
|
+
| FlavorMarginfiStateJson
|
|
137
|
+
| FlavorKaminoStateJson
|
|
138
|
+
| FlavorJitoRestakingStateJson
|
|
139
|
+
| FlavorPerenaStateJson
|
|
140
|
+
| FlavorGenericStateJson
|
|
141
|
+
export type Flavor = FlavorMarginfi | FlavorKamino | FlavorJitoRestaking | FlavorPerena | FlavorGeneric
|
package/src/generic.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { BN, web3 } from "@coral-xyz/anchor"
|
|
2
|
+
import { AnchorizedPNum, SyEmissionRaw, SyEmissionJson } from "./common"
|
|
3
|
+
|
|
4
|
+
export type InterfaceTypeGeneric =
|
|
5
|
+
| {
|
|
6
|
+
pyth: {
|
|
7
|
+
lastSlot: BN
|
|
8
|
+
maximumAgeSeconds: BN
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
splStakePool: Record<string, never>
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
one: Record<string, never>
|
|
16
|
+
}
|
|
17
|
+
| {
|
|
18
|
+
fragmetric: Record<string, never>
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
meteora: Record<string, never>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Hook {
|
|
25
|
+
enabled: boolean
|
|
26
|
+
interfaceEmissionsAccountsUntil: number
|
|
27
|
+
preMintHookDiscriminator: number[]
|
|
28
|
+
postRedeemHookDiscriminator: number[]
|
|
29
|
+
programId: web3.PublicKey
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HookRaw {
|
|
33
|
+
enabled: boolean
|
|
34
|
+
interfaceEmissionsAccountsUntil: number
|
|
35
|
+
preMintHookDiscriminator: Buffer
|
|
36
|
+
postRedeemHookDiscriminator: Buffer
|
|
37
|
+
programId: web3.PublicKey
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface GenericSyState {
|
|
41
|
+
selfAddress: web3.PublicKey
|
|
42
|
+
account: GenericSyMetaAccount
|
|
43
|
+
tokenProgramBase: web3.PublicKey
|
|
44
|
+
syRate: number
|
|
45
|
+
fragmetricData?: {
|
|
46
|
+
receiptTokenMint: web3.PublicKey
|
|
47
|
+
wrappedTokenMint: web3.PublicKey
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface GenericSyStateJson {
|
|
52
|
+
selfAddress: string
|
|
53
|
+
account: GenericSyMetaAccountJson
|
|
54
|
+
tokenProgramBase: string
|
|
55
|
+
syRate: number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface GenericSyMetaAccountJson {
|
|
59
|
+
mintSy: string
|
|
60
|
+
yieldBearingMint: string
|
|
61
|
+
tokenSyEscrow: string
|
|
62
|
+
interfaceAccounts: string[]
|
|
63
|
+
interfaceType: InterfaceTypeGeneric
|
|
64
|
+
maxSySupply: string
|
|
65
|
+
minMintSize: string
|
|
66
|
+
minRedeemSize: string
|
|
67
|
+
hook: HookRaw
|
|
68
|
+
emissions: SyEmissionJson[]
|
|
69
|
+
index: number
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface GenericSyMetaAccount {
|
|
73
|
+
mintSy: web3.PublicKey
|
|
74
|
+
yieldBearingMint: web3.PublicKey
|
|
75
|
+
tokenSyEscrow: web3.PublicKey
|
|
76
|
+
interfaceAccounts: web3.PublicKey[]
|
|
77
|
+
interfaceType: InterfaceTypeGeneric
|
|
78
|
+
maxSySupply: BN
|
|
79
|
+
minMintSize: BN
|
|
80
|
+
minRedeemSize: BN
|
|
81
|
+
hook: Hook
|
|
82
|
+
emissions: SyEmissionRaw[]
|
|
83
|
+
index: AnchorizedPNum
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface GenericSyMetaAccountRaw {
|
|
87
|
+
mintSy: web3.PublicKey
|
|
88
|
+
yieldBearingMint: web3.PublicKey
|
|
89
|
+
tokenSyEscrow: web3.PublicKey
|
|
90
|
+
maxSySupply: BN
|
|
91
|
+
minMintSize: BN
|
|
92
|
+
minRedeemSize: BN
|
|
93
|
+
selfAddressBump: number[]
|
|
94
|
+
emissions: SyEmissionRaw[]
|
|
95
|
+
interfaceAccounts: web3.PublicKey[]
|
|
96
|
+
interfaceType: InterfaceTypeGeneric
|
|
97
|
+
index: AnchorizedPNum
|
|
98
|
+
hook: HookRaw
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function deserializeGenericSyMetaAccountRaw(raw: GenericSyMetaAccountRaw): GenericSyMetaAccount {
|
|
102
|
+
return {
|
|
103
|
+
mintSy: raw.mintSy,
|
|
104
|
+
yieldBearingMint: raw.yieldBearingMint,
|
|
105
|
+
tokenSyEscrow: raw.tokenSyEscrow,
|
|
106
|
+
interfaceAccounts: raw.interfaceAccounts,
|
|
107
|
+
interfaceType: raw.interfaceType,
|
|
108
|
+
index: raw.index,
|
|
109
|
+
maxSySupply: raw.maxSySupply,
|
|
110
|
+
minMintSize: raw.minMintSize,
|
|
111
|
+
minRedeemSize: raw.minRedeemSize,
|
|
112
|
+
emissions: raw.emissions,
|
|
113
|
+
hook: {
|
|
114
|
+
enabled: raw.hook.enabled,
|
|
115
|
+
interfaceEmissionsAccountsUntil: raw.hook.interfaceEmissionsAccountsUntil,
|
|
116
|
+
preMintHookDiscriminator: Array.from(raw.hook.preMintHookDiscriminator),
|
|
117
|
+
postRedeemHookDiscriminator: Array.from(raw.hook.postRedeemHookDiscriminator),
|
|
118
|
+
programId: raw.hook.programId,
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { SyEmissionRaw, SyEmissionJson } from "./common"
|
|
2
|
+
export * from "./flavor"
|
|
3
|
+
export * from "./jito-restaking"
|
|
4
|
+
export * from "./kamino"
|
|
5
|
+
export * from "./marginfi"
|
|
6
|
+
export * from "./perena"
|
|
7
|
+
export * from "./vault"
|
|
8
|
+
export * from "./cpi"
|
|
9
|
+
export * from "./trade"
|
|
10
|
+
export * from "./liquidity"
|
|
11
|
+
export * from "./generic"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { BN, web3 } from "@coral-xyz/anchor"
|
|
2
|
+
import { AnchorizedPNum, AnchorizedPNumJson, SyEmissionRaw, SyEmissionJson } from "./common"
|
|
3
|
+
|
|
4
|
+
export interface InterfaceType {
|
|
5
|
+
splStakePool: {}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface JitoRestakingSyState {
|
|
9
|
+
selfAddress: web3.PublicKey
|
|
10
|
+
account: JitoRestakingSyMetaAccount
|
|
11
|
+
/** The value of SY tokens in terms of the base asset */
|
|
12
|
+
syRate: string
|
|
13
|
+
underlyingExchangeRate: number
|
|
14
|
+
mintBase: web3.PublicKey
|
|
15
|
+
tokenProgramBase: web3.PublicKey
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface JitoRestakingSyMetaAccountRaw {
|
|
19
|
+
jitoVault: web3.PublicKey
|
|
20
|
+
mintSy: web3.PublicKey
|
|
21
|
+
tokenSyEscrow: web3.PublicKey
|
|
22
|
+
maxSySupply: BN
|
|
23
|
+
minMintSize: BN
|
|
24
|
+
minRedeemSize: BN
|
|
25
|
+
selfAddressBump: number[]
|
|
26
|
+
emissions: SyEmissionRaw[]
|
|
27
|
+
interfaceAccounts: web3.PublicKey[]
|
|
28
|
+
interfaceType: InterfaceType
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface JitoRestakingSyMetaAccount {
|
|
32
|
+
jitoVault: web3.PublicKey
|
|
33
|
+
mintSy: web3.PublicKey
|
|
34
|
+
tokenSyEscrow: web3.PublicKey
|
|
35
|
+
interfaceAccounts: web3.PublicKey[]
|
|
36
|
+
interfaceType: InterfaceType
|
|
37
|
+
maxSySupply: BN
|
|
38
|
+
minMintSize: BN
|
|
39
|
+
minRedeemSize: BN
|
|
40
|
+
emissions: SyEmissionRaw[]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface JitoRestakingSyMetaAccountJson {
|
|
44
|
+
jitoVault: string
|
|
45
|
+
mintSy: string
|
|
46
|
+
tokenSyEscrow: string
|
|
47
|
+
interfaceAccounts: string[]
|
|
48
|
+
interfaceType: InterfaceType
|
|
49
|
+
maxSySupply: string
|
|
50
|
+
minMintSize: string
|
|
51
|
+
minRedeemSize: string
|
|
52
|
+
emissions: SyEmissionJson[]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function deserializeJitoRestakingSyMetaAccountRaw(
|
|
56
|
+
raw: JitoRestakingSyMetaAccountRaw,
|
|
57
|
+
): JitoRestakingSyMetaAccount {
|
|
58
|
+
return {
|
|
59
|
+
jitoVault: raw.jitoVault,
|
|
60
|
+
mintSy: raw.mintSy,
|
|
61
|
+
tokenSyEscrow: raw.tokenSyEscrow,
|
|
62
|
+
interfaceAccounts: raw.interfaceAccounts,
|
|
63
|
+
interfaceType: raw.interfaceType,
|
|
64
|
+
maxSySupply: raw.maxSySupply,
|
|
65
|
+
minMintSize: raw.minMintSize,
|
|
66
|
+
minRedeemSize: raw.minRedeemSize,
|
|
67
|
+
emissions: raw.emissions,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface JitoRestakingSyStateJson {
|
|
72
|
+
selfAddress: string
|
|
73
|
+
account: JitoRestakingSyMetaAccountJson
|
|
74
|
+
syRate: string
|
|
75
|
+
underlyingExchangeRate: number
|
|
76
|
+
mintBase: string
|
|
77
|
+
tokenProgramBase: string
|
|
78
|
+
}
|