@glamsystems/glam-sdk 1.0.13 → 1.0.14-alpha.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/README.md +1 -1
- package/index.cjs.js +14542 -21898
- package/index.esm.js +14521 -21841
- package/package.json +2 -2
- package/src/assets.d.ts +6 -15
- package/src/client/base.d.ts +24 -5
- package/src/client/bridge.d.ts +184 -0
- package/src/client/bridgeRegistry.d.ts +32 -0
- package/src/client/epi.d.ts +78 -0
- package/src/client/fees.d.ts +1 -0
- package/src/client/jupiter.d.ts +22 -18
- package/src/client/price.d.ts +13 -37
- package/src/client.d.ts +6 -5
- package/src/constants.d.ts +5 -7
- package/src/deser/index.d.ts +0 -1
- package/src/deser/integrationPolicies.d.ts +23 -20
- package/src/error.d.ts +2 -1
- package/src/glamExports.d.ts +2423 -1787
- package/src/globalConfig.d.ts +22 -0
- package/src/index.d.ts +3 -1
- package/src/react/glam.d.ts +0 -4
- package/src/react/query-keys.d.ts +1 -3
- package/src/utils/accounts.d.ts +4 -1
- package/src/utils/common.d.ts +2 -0
- package/src/utils/index.d.ts +0 -1
- package/src/utils/positionCategorizer.d.ts +3 -21
- package/target/idl/ext_cctp.json +1 -1
- package/target/idl/ext_kamino-staging.json +1 -1
- package/target/idl/ext_kamino.json +109 -1
- package/target/idl/ext_spl-staging.json +1 -1
- package/target/idl/ext_spl.json +1 -1
- package/target/idl/glam_config.json +75 -9
- package/target/idl/glam_mint.json +205 -11
- package/target/idl/glam_policies.json +2 -7
- package/target/idl/glam_protocol-staging.json +118 -522
- package/target/idl/glam_protocol.json +204 -121
- package/target/types/ext_bridge.d.ts +2397 -0
- package/target/types/ext_cctp.d.ts +1 -1
- package/target/types/ext_cctp.ts +1 -1
- package/target/types/ext_epi.d.ts +2175 -0
- package/target/types/ext_kamino-staging.ts +1 -1
- package/target/types/ext_kamino.d.ts +109 -1
- package/target/types/ext_kamino.ts +109 -1
- package/target/types/ext_spl-staging.ts +1 -1
- package/target/types/ext_spl.d.ts +1 -1
- package/target/types/ext_spl.ts +1 -1
- package/target/types/glam_config.d.ts +75 -9
- package/target/types/glam_config.ts +75 -9
- package/target/types/glam_mint.d.ts +205 -11
- package/target/types/glam_mint.ts +205 -11
- package/target/types/glam_policies.ts +2 -7
- package/target/types/glam_protocol-staging.ts +118 -522
- package/target/types/glam_protocol.d.ts +204 -121
- package/target/types/glam_protocol.ts +204 -121
- package/src/client/drift/index.d.ts +0 -2
- package/src/client/drift/protocol-v2.d.ts +0 -130
- package/src/client/drift/vaults.d.ts +0 -60
- package/src/deser/driftLayouts.d.ts +0 -217
- package/src/utils/drift/index.d.ts +0 -2
- package/src/utils/drift/orderParams.d.ts +0 -28
- package/src/utils/drift/types.d.ts +0 -522
- package/target/idl/ext_drift-staging.json +0 -5442
- package/target/idl/ext_drift.json +0 -4962
- package/target/types/ext_drift-staging.ts +0 -5448
- package/target/types/ext_drift.d.ts +0 -4968
- package/target/types/ext_drift.ts +0 -4968
- package/target/types/ext_offchain.d.ts +0 -1074
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glamsystems/glam-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14-alpha.0",
|
|
4
4
|
"description": "TypeScript SDK for the GLAM Protocol",
|
|
5
5
|
"main": "./index.cjs.js",
|
|
6
6
|
"module": "./index.esm.js",
|
|
7
7
|
"homepage": "https://www.glam.systems",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git@github.com:glamsystems/glam-sdk.git"
|
|
10
|
+
"url": "git@github.com:glamsystems/glam-sdk-ts.git"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
13
13
|
"glam",
|
package/src/assets.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { ClusterNetwork } from "./clientConfig";
|
|
3
2
|
export declare const STAKE_POOLS: {
|
|
4
3
|
name: string;
|
|
5
4
|
symbol: string;
|
|
@@ -24,26 +23,18 @@ export declare const STAKE_POOLS_MAP: Map<string, {
|
|
|
24
23
|
* Metadata for an asset for pricing
|
|
25
24
|
*/
|
|
26
25
|
export interface AssetMeta {
|
|
26
|
+
asset: PublicKey;
|
|
27
27
|
decimals: number;
|
|
28
28
|
oracle: PublicKey;
|
|
29
|
-
programId
|
|
30
|
-
aggIndex?: number;
|
|
29
|
+
programId: PublicKey;
|
|
31
30
|
oracleSource?: string;
|
|
32
31
|
}
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
33
|
+
* Legacy asset metadata snapshot retained for backward compatibility.
|
|
35
34
|
*
|
|
36
|
-
*
|
|
35
|
+
* Runtime consumers should prefer the onchain-backed helpers in `globalConfig.ts`.
|
|
36
|
+
* Note that we use functional prices for LSTs, and the oracle pubkey of a LST
|
|
37
|
+
* asset is the pool state.
|
|
37
38
|
*/
|
|
38
39
|
export declare const ASSETS_MAINNET: Map<string, AssetMeta>;
|
|
39
40
|
export declare const ASSETS_TESTS: Map<string, AssetMeta>;
|
|
40
|
-
export declare const SOL_ORACLE: PublicKey;
|
|
41
|
-
export declare const USDC_ORACLE: PublicKey;
|
|
42
|
-
/**
|
|
43
|
-
* Get metadata of an asset for pricing
|
|
44
|
-
*
|
|
45
|
-
* @param assetMint Token mint of the asset
|
|
46
|
-
* @param cluster The cluster network (defaults to mainnet)
|
|
47
|
-
* @returns Metadata of the asset
|
|
48
|
-
*/
|
|
49
|
-
export declare function getAssetMeta(assetMint: string | PublicKey, cluster?: ClusterNetwork): AssetMeta;
|
package/src/client/base.d.ts
CHANGED
|
@@ -2,11 +2,13 @@ import * as anchor from "@coral-xyz/anchor";
|
|
|
2
2
|
import { BN } from "@coral-xyz/anchor";
|
|
3
3
|
import { Wallet } from "@coral-xyz/anchor";
|
|
4
4
|
import { AddressLookupTableAccount, Connection, Keypair, PublicKey, Transaction, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ExtBridgeProgram, ExtEpiProgram, ExtCctpProgram, ExtKaminoProgram, ExtMarinadeProgram, ExtSplProgram, ExtStakePoolProgram, GlamMintProgram, GlamProtocolProgram } from "../glamExports";
|
|
6
6
|
import { ClusterNetwork, GlamClientConfig } from "../clientConfig";
|
|
7
|
+
import type { GlobalConfigAccount } from "../globalConfig";
|
|
7
8
|
import { RequestQueue, StateAccount, StateModel } from "../models";
|
|
8
9
|
import { BlockhashWithCache } from "../utils/blockhash";
|
|
9
10
|
import { JupiterApiClient } from "../utils";
|
|
11
|
+
import { AssetMeta } from "../assets";
|
|
10
12
|
export type TxOptions = {
|
|
11
13
|
signer?: PublicKey;
|
|
12
14
|
computeUnitLimit?: number;
|
|
@@ -39,23 +41,27 @@ export declare class BaseClient {
|
|
|
39
41
|
private _protocolProgram?;
|
|
40
42
|
private _mintProgram?;
|
|
41
43
|
private _extSplProgram?;
|
|
42
|
-
private _extDriftProgram?;
|
|
43
44
|
private _extKaminoProgram?;
|
|
44
45
|
private _extMarinadeProgram?;
|
|
45
46
|
private _extStakePoolProgram?;
|
|
46
47
|
private _extCctpProgram?;
|
|
47
|
-
private
|
|
48
|
+
private _extBridgeProgram?;
|
|
49
|
+
private _extEpiProgram?;
|
|
48
50
|
private _statePda?;
|
|
51
|
+
private _globalConfig?;
|
|
52
|
+
private _globalConfigPromise?;
|
|
53
|
+
private _assetMetas?;
|
|
54
|
+
private _assetMetasPromise?;
|
|
49
55
|
constructor(config?: GlamClientConfig);
|
|
50
56
|
get protocolProgram(): GlamProtocolProgram;
|
|
51
57
|
get mintProgram(): GlamMintProgram;
|
|
52
58
|
get extSplProgram(): ExtSplProgram;
|
|
53
|
-
get extDriftProgram(): ExtDriftProgram;
|
|
54
59
|
get extKaminoProgram(): ExtKaminoProgram;
|
|
55
60
|
get extMarinadeProgram(): ExtMarinadeProgram;
|
|
56
61
|
get extStakePoolProgram(): ExtStakePoolProgram;
|
|
57
62
|
get extCctpProgram(): ExtCctpProgram;
|
|
58
|
-
get
|
|
63
|
+
get extBridgeProgram(): ExtBridgeProgram;
|
|
64
|
+
get extEpiProgram(): ExtEpiProgram;
|
|
59
65
|
get isVaultConnected(): boolean;
|
|
60
66
|
get statePda(): PublicKey;
|
|
61
67
|
set statePda(statePda: PublicKey);
|
|
@@ -117,6 +123,19 @@ export declare class BaseClient {
|
|
|
117
123
|
uiAmount: number;
|
|
118
124
|
}>;
|
|
119
125
|
isLockupEnabled(): Promise<boolean>;
|
|
126
|
+
fetchGlobalConfig(options?: {
|
|
127
|
+
refresh?: boolean;
|
|
128
|
+
}): Promise<GlobalConfigAccount>;
|
|
129
|
+
fetchAssetMetas(options?: {
|
|
130
|
+
refresh?: boolean;
|
|
131
|
+
}): Promise<Map<string, AssetMeta>>;
|
|
132
|
+
refreshAssetMetaCache(): Promise<Map<string, AssetMeta>>;
|
|
133
|
+
getAssetMeta(assetMint: string | PublicKey, options?: {
|
|
134
|
+
refresh?: boolean;
|
|
135
|
+
}): Promise<AssetMeta>;
|
|
136
|
+
getSolOracle(options?: {
|
|
137
|
+
refresh?: boolean;
|
|
138
|
+
}): Promise<PublicKey>;
|
|
120
139
|
fetchStateAccount(statePda?: PublicKey): Promise<StateAccount>;
|
|
121
140
|
private getMintProgramIdForStateAccount;
|
|
122
141
|
private getMintProgramForStateAccount;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
2
|
+
import { AccountMeta, Keypair, PublicKey, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
|
|
3
|
+
import { BaseClient, BaseTxBuilder, TxOptions } from "./base";
|
|
4
|
+
import { LayerzeroOftRouteProfile } from "./bridgeRegistry";
|
|
5
|
+
import { LayerzeroOftPolicy, LayerzeroOftRoute, RouteManagementMode } from "../deser/integrationPolicies";
|
|
6
|
+
type BufferLike32 = Uint8Array | number[] | Buffer;
|
|
7
|
+
type BufferLike = Uint8Array | number[] | Buffer;
|
|
8
|
+
type RouteManagementModeArg = RouteManagementMode | number | {
|
|
9
|
+
unmanagedOnly: Record<string, never>;
|
|
10
|
+
} | {
|
|
11
|
+
managedOnly: Record<string, never>;
|
|
12
|
+
} | {
|
|
13
|
+
either: Record<string, never>;
|
|
14
|
+
};
|
|
15
|
+
export type LayerzeroOftRouteInput = Omit<LayerzeroOftRoute, "managementMode"> & {
|
|
16
|
+
managementMode: RouteManagementModeArg;
|
|
17
|
+
};
|
|
18
|
+
export type OftTransferParams = {
|
|
19
|
+
transferId: BufferLike32;
|
|
20
|
+
sourceMint: PublicKey;
|
|
21
|
+
sourceAmount: BN;
|
|
22
|
+
providerInstructions: TransactionInstruction[];
|
|
23
|
+
providerReceipt: PublicKey;
|
|
24
|
+
sourceTokenAccount?: PublicKey;
|
|
25
|
+
managed?: boolean;
|
|
26
|
+
providerSigners?: Keypair[];
|
|
27
|
+
prepareRemainingAccounts?: AccountMeta[];
|
|
28
|
+
commitRemainingAccounts?: AccountMeta[];
|
|
29
|
+
};
|
|
30
|
+
export type LayerzeroOftSendParams = {
|
|
31
|
+
transferId?: BufferLike32;
|
|
32
|
+
sourceMint: PublicKey;
|
|
33
|
+
sourceAmount: BN;
|
|
34
|
+
destinationChain: number;
|
|
35
|
+
destinationRecipient: PublicKey;
|
|
36
|
+
nativeFee: BN;
|
|
37
|
+
minAmountLd?: BN;
|
|
38
|
+
lzTokenFee?: BN;
|
|
39
|
+
options?: BufferLike;
|
|
40
|
+
composeMsg?: BufferLike | null;
|
|
41
|
+
sourceTokenAccount?: PublicKey;
|
|
42
|
+
nonceAccount?: PublicKey;
|
|
43
|
+
managed?: boolean;
|
|
44
|
+
providerProgram?: PublicKey;
|
|
45
|
+
};
|
|
46
|
+
export declare function deriveLayerzeroNoncePda(endpointProgram: PublicKey, sender: PublicKey, destinationChain: number, destinationRecipient: PublicKey): PublicKey;
|
|
47
|
+
export declare function deriveOftAuxiliaryAccountSeed(glamState: PublicKey, transferId: BufferLike32): Promise<string>;
|
|
48
|
+
export declare function deriveOftAuxiliaryAccount(glamSigner: PublicKey, glamState: PublicKey, transferId: BufferLike32, tokenProgram: PublicKey): Promise<{
|
|
49
|
+
address: PublicKey;
|
|
50
|
+
seed: string;
|
|
51
|
+
}>;
|
|
52
|
+
declare class TxBuilder extends BaseTxBuilder<BridgeClient> {
|
|
53
|
+
addLayerzeroOftRouteIx(route: LayerzeroOftRouteInput, signer?: PublicKey): Promise<TransactionInstruction>;
|
|
54
|
+
updateLayerzeroOftRouteIx(route: LayerzeroOftRouteInput, signer?: PublicKey): Promise<TransactionInstruction>;
|
|
55
|
+
deleteLayerzeroOftRouteIx(route: LayerzeroOftRouteInput, signer?: PublicKey): Promise<TransactionInstruction>;
|
|
56
|
+
buildOftTransferTx(params: OftTransferParams, txOptions?: TxOptions): Promise<{
|
|
57
|
+
tx: VersionedTransaction;
|
|
58
|
+
additionalSigners: Keypair[];
|
|
59
|
+
sessionPda: PublicKey;
|
|
60
|
+
transferRecordPda: PublicKey;
|
|
61
|
+
auxiliaryTokenAccount: PublicKey;
|
|
62
|
+
sourceTokenAccount: PublicKey;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
declare class LayerzeroOftBridgeProtocolClient {
|
|
66
|
+
readonly bridge: BridgeClient;
|
|
67
|
+
constructor(bridge: BridgeClient);
|
|
68
|
+
buildSendTx(params: LayerzeroOftSendParams, txOptions?: TxOptions): Promise<{
|
|
69
|
+
auxiliaryTokenAccount: PublicKey;
|
|
70
|
+
nonceAccount: PublicKey;
|
|
71
|
+
routeProfile: LayerzeroOftRouteProfile;
|
|
72
|
+
sendInstruction: TransactionInstruction;
|
|
73
|
+
tx: VersionedTransaction;
|
|
74
|
+
additionalSigners: Keypair[];
|
|
75
|
+
sessionPda: PublicKey;
|
|
76
|
+
transferRecordPda: PublicKey;
|
|
77
|
+
sourceTokenAccount: PublicKey;
|
|
78
|
+
}>;
|
|
79
|
+
send(params: LayerzeroOftSendParams, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
80
|
+
}
|
|
81
|
+
export declare class BridgeClient {
|
|
82
|
+
readonly base: BaseClient;
|
|
83
|
+
readonly txBuilder: TxBuilder;
|
|
84
|
+
readonly oft: LayerzeroOftBridgeProtocolClient;
|
|
85
|
+
constructor(base: BaseClient);
|
|
86
|
+
getRegistryPda(): PublicKey;
|
|
87
|
+
getSessionPda(transferId: BufferLike32): PublicKey;
|
|
88
|
+
getTransferRecordPda(transferId: BufferLike32): PublicKey;
|
|
89
|
+
getLayerzeroNoncePda(endpointProgram: PublicKey, sender: PublicKey, destinationChain: number, destinationRecipient: PublicKey): PublicKey;
|
|
90
|
+
deriveOftAuxiliaryTokenAccount(transferId: BufferLike32, sourceMint: PublicKey, signer?: PublicKey): Promise<{
|
|
91
|
+
tokenProgram: PublicKey;
|
|
92
|
+
address: PublicKey;
|
|
93
|
+
seed: string;
|
|
94
|
+
}>;
|
|
95
|
+
private resolveLayerzeroOftRouteProfile;
|
|
96
|
+
private resolveLayerzeroOftNonceAccount;
|
|
97
|
+
private materializeLayerzeroOftRemainingAccounts;
|
|
98
|
+
private buildLayerzeroOftInstructionBaseAccounts;
|
|
99
|
+
private buildLayerzeroOftSendInstruction;
|
|
100
|
+
fetchLayerzeroOftPolicy(): Promise<LayerzeroOftPolicy | null>;
|
|
101
|
+
fetchRegistry(): Promise<{
|
|
102
|
+
glamState: PublicKey;
|
|
103
|
+
managedTransferCount: BN;
|
|
104
|
+
bump: number;
|
|
105
|
+
} | null>;
|
|
106
|
+
fetchSession(transferId: BufferLike32): Promise<{
|
|
107
|
+
glamState: PublicKey;
|
|
108
|
+
signer: PublicKey;
|
|
109
|
+
transferId: number[];
|
|
110
|
+
protocol: number;
|
|
111
|
+
managed: boolean;
|
|
112
|
+
sourceMint: PublicKey;
|
|
113
|
+
sourceTokenAccount: PublicKey;
|
|
114
|
+
providerProgram: PublicKey;
|
|
115
|
+
providerConfig: PublicKey;
|
|
116
|
+
providerSender: PublicKey;
|
|
117
|
+
providerDelegate: PublicKey;
|
|
118
|
+
providerReceipt: PublicKey;
|
|
119
|
+
providerInstructionHash: number[];
|
|
120
|
+
providerInstructionCount: number;
|
|
121
|
+
sourceAmount: BN;
|
|
122
|
+
quotedOutAmount: BN;
|
|
123
|
+
initialSourceBalance: BN;
|
|
124
|
+
initialProviderSequence: BN;
|
|
125
|
+
destinationChain: number;
|
|
126
|
+
destinationRecipient: PublicKey;
|
|
127
|
+
quoteExpiresAt: BN;
|
|
128
|
+
preparedSlot: BN;
|
|
129
|
+
bump: number;
|
|
130
|
+
} | null>;
|
|
131
|
+
fetchTransferRecord(transferId: BufferLike32): Promise<{
|
|
132
|
+
glamState: PublicKey;
|
|
133
|
+
transferId: number[];
|
|
134
|
+
protocol: number;
|
|
135
|
+
status: any;
|
|
136
|
+
managed: boolean;
|
|
137
|
+
receiptVerified: boolean;
|
|
138
|
+
sourceMint: PublicKey;
|
|
139
|
+
sourceTokenAccount: PublicKey;
|
|
140
|
+
providerProgram: PublicKey;
|
|
141
|
+
providerConfig: PublicKey;
|
|
142
|
+
sourceAmount: BN;
|
|
143
|
+
quotedOutAmount: BN;
|
|
144
|
+
destinationChain: number;
|
|
145
|
+
destinationRecipient: PublicKey;
|
|
146
|
+
providerTransferId: number[];
|
|
147
|
+
providerEmitter: PublicKey;
|
|
148
|
+
providerSequence: BN;
|
|
149
|
+
committedSlot: BN;
|
|
150
|
+
settledSlot: BN;
|
|
151
|
+
reconciledSlot: BN;
|
|
152
|
+
failureReason: number;
|
|
153
|
+
bump: number;
|
|
154
|
+
}>;
|
|
155
|
+
addLayerzeroOftRoute(route: LayerzeroOftRouteInput, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
156
|
+
updateLayerzeroOftRoute(route: LayerzeroOftRouteInput, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
157
|
+
deleteLayerzeroOftRoute(route: LayerzeroOftRouteInput, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
158
|
+
buildOftTransferTx(params: OftTransferParams, txOptions?: TxOptions): Promise<{
|
|
159
|
+
tx: VersionedTransaction;
|
|
160
|
+
additionalSigners: Keypair[];
|
|
161
|
+
sessionPda: PublicKey;
|
|
162
|
+
transferRecordPda: PublicKey;
|
|
163
|
+
auxiliaryTokenAccount: PublicKey;
|
|
164
|
+
sourceTokenAccount: PublicKey;
|
|
165
|
+
}>;
|
|
166
|
+
buildLayerzeroOftSendTx(params: LayerzeroOftSendParams, txOptions?: TxOptions): Promise<{
|
|
167
|
+
auxiliaryTokenAccount: PublicKey;
|
|
168
|
+
nonceAccount: PublicKey;
|
|
169
|
+
routeProfile: LayerzeroOftRouteProfile;
|
|
170
|
+
sendInstruction: TransactionInstruction;
|
|
171
|
+
tx: VersionedTransaction;
|
|
172
|
+
additionalSigners: Keypair[];
|
|
173
|
+
sessionPda: PublicKey;
|
|
174
|
+
transferRecordPda: PublicKey;
|
|
175
|
+
sourceTokenAccount: PublicKey;
|
|
176
|
+
}>;
|
|
177
|
+
sendOft(params: OftTransferParams, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
178
|
+
private extendLookupTables;
|
|
179
|
+
settleManagedTransfer(transferId: BufferLike32, txOptions?: TxOptions): Promise<string>;
|
|
180
|
+
reconcileManagedTransfer(transferId: BufferLike32, txOptions?: TxOptions): Promise<string>;
|
|
181
|
+
failManagedTransfer(transferId: BufferLike32, failureReason: number, txOptions?: TxOptions): Promise<string>;
|
|
182
|
+
cleanupTransferRecord(transferId: BufferLike32, txOptions?: TxOptions): Promise<string>;
|
|
183
|
+
}
|
|
184
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { ClusterNetwork } from "../clientConfig";
|
|
3
|
+
export type RouteAccountPlaceholder = "payer" | "nonce";
|
|
4
|
+
export type SerializableRouteAccountMeta = {
|
|
5
|
+
pubkey?: PublicKey;
|
|
6
|
+
placeholder?: RouteAccountPlaceholder;
|
|
7
|
+
isSigner: boolean;
|
|
8
|
+
isWritable: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type LayerzeroOftRouteProfile = {
|
|
11
|
+
sourceMint: PublicKey;
|
|
12
|
+
destinationChain: number;
|
|
13
|
+
providerProgram: PublicKey;
|
|
14
|
+
providerConfig: PublicKey;
|
|
15
|
+
nonceAccount?: PublicKey;
|
|
16
|
+
peerConfig: PublicKey;
|
|
17
|
+
providerSender: PublicKey;
|
|
18
|
+
enforcedOptions: PublicKey;
|
|
19
|
+
tokenEscrow: PublicKey;
|
|
20
|
+
eventAuthority: PublicKey;
|
|
21
|
+
lookupTables?: PublicKey[];
|
|
22
|
+
defaultOptions?: Uint8Array | number[] | Buffer;
|
|
23
|
+
defaultMinAmountBps?: number;
|
|
24
|
+
remainingAccounts: SerializableRouteAccountMeta[];
|
|
25
|
+
quoteRemainingAccounts?: SerializableRouteAccountMeta[];
|
|
26
|
+
};
|
|
27
|
+
export declare function resolveCanonicalLayerzeroOftRouteProfile(params: {
|
|
28
|
+
sourceMint: PublicKey;
|
|
29
|
+
destinationChain: number;
|
|
30
|
+
cluster: ClusterNetwork;
|
|
31
|
+
providerProgram?: PublicKey;
|
|
32
|
+
}): LayerzeroOftRouteProfile | null;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { BN } from "@coral-xyz/anchor";
|
|
2
|
+
import { PublicKey, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js";
|
|
3
|
+
import { BaseClient, BaseTxBuilder, TxOptions } from "./base";
|
|
4
|
+
type BufferLike32 = Uint8Array | number[] | Buffer;
|
|
5
|
+
export type EpiDenominationKindInput = {
|
|
6
|
+
usd: Record<string, never>;
|
|
7
|
+
} | {
|
|
8
|
+
mint: Record<string, never>;
|
|
9
|
+
};
|
|
10
|
+
export type EpiDenominationSpecInput = {
|
|
11
|
+
denom: EpiDenominationKindInput;
|
|
12
|
+
mint: PublicKey;
|
|
13
|
+
};
|
|
14
|
+
export type EpiExternalPositionTypeInput = {
|
|
15
|
+
valued: Record<string, never>;
|
|
16
|
+
} | {
|
|
17
|
+
tokenized: Record<string, never>;
|
|
18
|
+
};
|
|
19
|
+
export type EpiExternalSourceTypeInput = {
|
|
20
|
+
trusted: Record<string, never>;
|
|
21
|
+
} | {
|
|
22
|
+
native: Record<string, never>;
|
|
23
|
+
};
|
|
24
|
+
export type EpiNativeCustodyKindInput = {
|
|
25
|
+
splToken: Record<string, never>;
|
|
26
|
+
} | {
|
|
27
|
+
nativeSol: Record<string, never>;
|
|
28
|
+
};
|
|
29
|
+
export type UpsertExternalPositionParams = {
|
|
30
|
+
positionId: BufferLike32;
|
|
31
|
+
positionType: EpiExternalPositionTypeInput;
|
|
32
|
+
sourceType: EpiExternalSourceTypeInput;
|
|
33
|
+
denomination: EpiDenominationSpecInput;
|
|
34
|
+
nativeCustodyAccount?: PublicKey;
|
|
35
|
+
nativeCustodyKind?: EpiNativeCustodyKindInput;
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
freshnessOverrideSecs?: number;
|
|
38
|
+
submitAllowlist?: PublicKey[];
|
|
39
|
+
validateAllowlist?: PublicKey[];
|
|
40
|
+
configureAllowlist?: PublicKey[];
|
|
41
|
+
};
|
|
42
|
+
export type SubmitExternalObservationParams = {
|
|
43
|
+
positionId: BufferLike32;
|
|
44
|
+
amount: BN;
|
|
45
|
+
denomination: EpiDenominationSpecInput;
|
|
46
|
+
observationTimestamp: BN;
|
|
47
|
+
externalShares?: BN;
|
|
48
|
+
reserved?: Uint8Array | number[] | Buffer;
|
|
49
|
+
};
|
|
50
|
+
declare class TxBuilder extends BaseTxBuilder<EpiClient> {
|
|
51
|
+
upsertExternalPositionIx(params: UpsertExternalPositionParams, signer?: PublicKey): Promise<TransactionInstruction>;
|
|
52
|
+
submitExternalObservationIx(params: SubmitExternalObservationParams, signer?: PublicKey): Promise<TransactionInstruction>;
|
|
53
|
+
validateExternalObservationIx(positionId: BufferLike32, normalizedBaseAssetAmount: BN | null, signer?: PublicKey): Promise<TransactionInstruction>;
|
|
54
|
+
refreshPricedProtocolIx(signer?: PublicKey): Promise<TransactionInstruction>;
|
|
55
|
+
submitExternalObservationTx(params: SubmitExternalObservationParams, txOptions?: TxOptions): Promise<VersionedTransaction>;
|
|
56
|
+
upsertExternalPositionTx(params: UpsertExternalPositionParams, txOptions?: TxOptions): Promise<VersionedTransaction>;
|
|
57
|
+
validateExternalObservationTx(positionId: BufferLike32, normalizedBaseAssetAmount: BN | null, txOptions?: TxOptions): Promise<VersionedTransaction>;
|
|
58
|
+
refreshPricedProtocolTx(txOptions?: TxOptions): Promise<VersionedTransaction>;
|
|
59
|
+
}
|
|
60
|
+
export declare class EpiClient {
|
|
61
|
+
readonly base: BaseClient;
|
|
62
|
+
readonly txBuilder: TxBuilder;
|
|
63
|
+
constructor(base: BaseClient);
|
|
64
|
+
getObservationStatePda(): PublicKey;
|
|
65
|
+
getIntegrationAuthorityPda(): PublicKey;
|
|
66
|
+
fetchObservationState(): Promise<{
|
|
67
|
+
glamState: PublicKey;
|
|
68
|
+
bump: number;
|
|
69
|
+
positionsLen: number;
|
|
70
|
+
reserved: number[];
|
|
71
|
+
positions: any[];
|
|
72
|
+
} | null>;
|
|
73
|
+
submitExternalObservation(params: SubmitExternalObservationParams, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
74
|
+
upsertExternalPosition(params: UpsertExternalPositionParams, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
75
|
+
validateExternalObservation(positionId: BufferLike32, normalizedBaseAssetAmount: BN | null, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
76
|
+
refreshPricedProtocol(txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
package/src/client/fees.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare class FeesClient {
|
|
|
27
27
|
crystallizeFees(txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
28
28
|
claimFees(txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
29
29
|
chargeProtocolFee(protocolFeeAuthority: PublicKey, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
30
|
+
setProtocolFeesIx(baseFeeBps: number, flowFeeBps: number, signer?: PublicKey): Promise<TransactionInstruction>;
|
|
30
31
|
setProtocolFees(baseFeeBps: number, flowFeeBps: number, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
31
32
|
}
|
|
32
33
|
export {};
|
package/src/client/jupiter.d.ts
CHANGED
|
@@ -3,22 +3,30 @@ import { PublicKey, TransactionInstruction, TransactionSignature, VersionedTrans
|
|
|
3
3
|
import { BaseClient, BaseTxBuilder, TxOptions } from "./base";
|
|
4
4
|
import { VaultClient } from "./vault";
|
|
5
5
|
import { JupiterApiClient, JupiterInstruction, QuoteParams, QuoteResponse, SwapInstructions } from "../utils/jupiterApi";
|
|
6
|
+
export type JupiterSwapOptions = {
|
|
7
|
+
quoteParams?: QuoteParams;
|
|
8
|
+
quoteResponse?: QuoteResponse;
|
|
9
|
+
swapInstructions?: SwapInstructions;
|
|
10
|
+
trackingAccount?: PublicKey;
|
|
11
|
+
};
|
|
12
|
+
export type JupiterSwapV2OracleAccounts = {
|
|
13
|
+
solUsdOracle?: PublicKey;
|
|
14
|
+
inputTokenOracle?: PublicKey;
|
|
15
|
+
outputTokenOracle?: PublicKey;
|
|
16
|
+
};
|
|
17
|
+
export type JupiterSwapV2Options = JupiterSwapOptions & {
|
|
18
|
+
skipQuotePriceCheck?: boolean;
|
|
19
|
+
oracleAccounts?: JupiterSwapV2OracleAccounts;
|
|
20
|
+
};
|
|
6
21
|
declare class TxBuilder extends BaseTxBuilder<JupiterSwapClient> {
|
|
22
|
+
private resolveSwapInstructionContext;
|
|
7
23
|
/**
|
|
8
24
|
* Returns the instructions for a Jupiter swap and the lookup tables
|
|
9
25
|
*/
|
|
10
|
-
swapIxs(options:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
trackingAccount?: PublicKey;
|
|
15
|
-
}, glamSigner: PublicKey): Promise<[TransactionInstruction[], PublicKey[]]>;
|
|
16
|
-
swapTx(options: {
|
|
17
|
-
quoteParams?: QuoteParams;
|
|
18
|
-
quoteResponse?: QuoteResponse;
|
|
19
|
-
swapInstructions?: SwapInstructions;
|
|
20
|
-
trackingAccount?: PublicKey;
|
|
21
|
-
}, txOptions?: TxOptions): Promise<VersionedTransaction>;
|
|
26
|
+
swapIxs(options: JupiterSwapOptions, glamSigner: PublicKey): Promise<[TransactionInstruction[], PublicKey[]]>;
|
|
27
|
+
swapV2Ixs(options: JupiterSwapV2Options, glamSigner: PublicKey): Promise<[TransactionInstruction[], PublicKey[]]>;
|
|
28
|
+
swapTx(options: JupiterSwapOptions, txOptions?: TxOptions): Promise<VersionedTransaction>;
|
|
29
|
+
swapV2Tx(options: JupiterSwapV2Options, txOptions?: TxOptions): Promise<VersionedTransaction>;
|
|
22
30
|
getPreInstructions: (signer: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, outputTokenProgram?: PublicKey) => Promise<TransactionInstruction[]>;
|
|
23
31
|
toTransactionInstruction: (ix: JupiterInstruction) => TransactionInstruction;
|
|
24
32
|
}
|
|
@@ -28,11 +36,7 @@ export declare class JupiterSwapClient {
|
|
|
28
36
|
readonly txBuilder: TxBuilder;
|
|
29
37
|
readonly jupApi: JupiterApiClient;
|
|
30
38
|
constructor(base: BaseClient, vault: VaultClient);
|
|
31
|
-
swap(options:
|
|
32
|
-
|
|
33
|
-
quoteResponse?: QuoteResponse;
|
|
34
|
-
swapInstructions?: SwapInstructions;
|
|
35
|
-
trackingAccount?: PublicKey;
|
|
36
|
-
}, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
39
|
+
swap(options: JupiterSwapOptions, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
40
|
+
swapV2(options: JupiterSwapV2Options, txOptions?: TxOptions): Promise<TransactionSignature>;
|
|
37
41
|
}
|
|
38
42
|
export {};
|
package/src/client/price.d.ts
CHANGED
|
@@ -3,9 +3,8 @@ import { BN } from "@coral-xyz/anchor";
|
|
|
3
3
|
import { KaminoLendingClient, KaminoVaultsClient } from "./kamino";
|
|
4
4
|
import { BaseClient } from "./base";
|
|
5
5
|
import { StateModel } from "../models";
|
|
6
|
-
import { DriftProtocolClient, DriftVaultsClient } from "./drift";
|
|
7
6
|
import { PkMap, PkSet } from "../utils";
|
|
8
|
-
import {
|
|
7
|
+
import { KVaultState, Reserve } from "../deser";
|
|
9
8
|
import { JupiterApiClient, TokenListItem } from "../utils/jupiterApi";
|
|
10
9
|
/**
|
|
11
10
|
* Represents a single asset holding within a vault.
|
|
@@ -31,7 +30,7 @@ export declare class Holding {
|
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Aggregates all holdings for a GLAM vault.
|
|
34
|
-
* Includes token balances
|
|
33
|
+
* Includes token balances and supported DeFi positions.
|
|
35
34
|
*
|
|
36
35
|
* @param vaultState - The vault's state account address (stores vault configuration)
|
|
37
36
|
* @param vaultPda - The vault's PDA that holds tokens and positions
|
|
@@ -56,13 +55,12 @@ export declare class PriceClient {
|
|
|
56
55
|
readonly base: BaseClient;
|
|
57
56
|
readonly klend: KaminoLendingClient;
|
|
58
57
|
readonly kvaults: KaminoVaultsClient;
|
|
59
|
-
readonly drift: DriftProtocolClient;
|
|
60
|
-
readonly dvaults: DriftVaultsClient;
|
|
61
58
|
private readonly getJupiterApi;
|
|
62
59
|
private _stateModel;
|
|
63
60
|
private _lookupTables;
|
|
64
61
|
private _kaminoVaults;
|
|
65
|
-
|
|
62
|
+
private _priceVaultIxsQueue;
|
|
63
|
+
constructor(base: BaseClient, klend: KaminoLendingClient, kvaults: KaminoVaultsClient, getJupiterApi: () => JupiterApiClient);
|
|
66
64
|
get jupiterApi(): JupiterApiClient;
|
|
67
65
|
get cachedStateModel(): StateModel | null;
|
|
68
66
|
set cachedStateModel(stateModel: StateModel);
|
|
@@ -73,8 +71,6 @@ export declare class PriceClient {
|
|
|
73
71
|
*
|
|
74
72
|
* The source of truth for external positions is the `externalPositions` array
|
|
75
73
|
* from the state account, which tracks:
|
|
76
|
-
* - Drift user PDAs (direct trading positions)
|
|
77
|
-
* - Drift vault depositor accounts (shares in drift vaults)
|
|
78
74
|
* - Kamino obligation accounts (lending positions)
|
|
79
75
|
* - Kamino vault share ATAs (shares in kamino vaults)
|
|
80
76
|
*
|
|
@@ -85,12 +81,6 @@ export declare class PriceClient {
|
|
|
85
81
|
*/
|
|
86
82
|
getVaultHoldings(commitment: Commitment, priceBaseAssetMint?: PublicKey): Promise<VaultHoldings>;
|
|
87
83
|
getPubkeysForTokenHoldings(externalPositionsSet: PkSet, commitment?: Commitment): Promise<PublicKey[]>;
|
|
88
|
-
getPubkeysForSpotHoldings(driftUserPdas: PublicKey[], commitment?: Commitment): Promise<PkMap<PkSet>>;
|
|
89
|
-
getPubkeysForPerpHoldings(driftUserPdas: PublicKey[], commitment?: Commitment): Promise<PkMap<PkSet>>;
|
|
90
|
-
/**
|
|
91
|
-
* Parses drift vault depositors from known pubkeys.
|
|
92
|
-
*/
|
|
93
|
-
getDepositorsAndDriftVaults(depositorPubkeys: PublicKey[], commitment?: Commitment): Promise<PkMap<DriftVault>>;
|
|
94
84
|
/**
|
|
95
85
|
* Gets kamino obligation reserves from known obligation pubkeys.
|
|
96
86
|
*/
|
|
@@ -106,8 +96,6 @@ export declare class PriceClient {
|
|
|
106
96
|
*/
|
|
107
97
|
private getTokenPrice;
|
|
108
98
|
getTokenHoldings(tokenAccountPubkeys: PublicKey[], accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Promise<Holding[]>;
|
|
109
|
-
getDriftHoldings(userPubkeys: Iterable<PublicKey>, spotMarketsMap: PkMap<DriftSpotMarket>, perpMarketsMap: PkMap<DriftPerpMarket>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Promise<Holding[]>;
|
|
110
|
-
getDriftVaultsHoldings(dvaultDepositorsAndVaults: PkMap<DriftVault>, dvaultDepositorsMap: PkMap<DriftVaultDepositor>, spotMarketsMap: PkMap<DriftSpotMarket>, perpMarketsMap: PkMap<DriftPerpMarket>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Promise<Holding[]>;
|
|
111
99
|
getKaminoLendHoldings(obligationPubkeys: Iterable<PublicKey>, reservesMap: PkMap<Reserve>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Promise<Holding[]>;
|
|
112
100
|
getKaminoVaultsHoldings(kvaultAtasAndStates: PkMap<KVaultState>, reservesMap: PkMap<Reserve>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Promise<Holding[]>;
|
|
113
101
|
/**
|
|
@@ -116,35 +104,23 @@ export declare class PriceClient {
|
|
|
116
104
|
*/
|
|
117
105
|
priceKaminoObligationsIxs(): Promise<TransactionInstruction[]>;
|
|
118
106
|
priceKaminoVaultSharesIx(): Promise<TransactionInstruction[] | null>;
|
|
119
|
-
/**
|
|
120
|
-
* Returns an instruction that prices all Drift users (aka sub-accounts) controlled by the GLAM vault.
|
|
121
|
-
*/
|
|
122
|
-
priceDriftUsersIx(): Promise<TransactionInstruction | null>;
|
|
123
|
-
/**
|
|
124
|
-
* Returns an instruction that prices a drift vault depositor.
|
|
125
|
-
* If there are no vault depositor accounts, returns null.
|
|
126
|
-
*/
|
|
127
|
-
priceDriftVaultDepositorsIx(): Promise<TransactionInstruction | null>;
|
|
128
107
|
/**
|
|
129
108
|
* Returns an instruction that prices vault balance and tokens
|
|
130
109
|
*/
|
|
131
|
-
priceVaultTokensIx(): Promise<TransactionInstruction>;
|
|
110
|
+
priceVaultTokensIx(): Promise<TransactionInstruction[]>;
|
|
132
111
|
/**
|
|
133
112
|
* Returns an instruction that prices stake accounts.
|
|
134
113
|
* If there are no stake accounts, returns null.
|
|
135
114
|
*/
|
|
136
115
|
priceStakeAccountsIx(): Promise<TransactionInstruction | null>;
|
|
137
116
|
priceVaultIxs(): Promise<TransactionInstruction[]>;
|
|
117
|
+
private enqueuePriceVaultIxs;
|
|
118
|
+
private priceEpiValidatedPositionsIx;
|
|
119
|
+
private _priceVaultIxsImpl;
|
|
138
120
|
validateAumIx(): Promise<TransactionInstruction>;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}[]): Promise<{
|
|
145
|
-
remainingAccounts: AccountMeta[];
|
|
146
|
-
numSpotMarkets: number;
|
|
147
|
-
numPerpMarkets: number;
|
|
148
|
-
}>;
|
|
149
|
-
remainingAccountsForPricingVaultAssets(): Promise<AccountMeta[]>;
|
|
121
|
+
getBaseAssetOracle(): Promise<PublicKey>;
|
|
122
|
+
remainingAccountsForPricingVaultAssets(): Promise<[
|
|
123
|
+
AccountMeta[],
|
|
124
|
+
PublicKey[]
|
|
125
|
+
]>;
|
|
150
126
|
}
|
package/src/client.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GlamClientConfig } from "./clientConfig";
|
|
2
2
|
import { BaseClient } from "./client/base";
|
|
3
|
-
import { DriftProtocolClient, DriftVaultsClient } from "./client/drift";
|
|
4
3
|
import { JupiterSwapClient } from "./client/jupiter";
|
|
5
4
|
import { MarinadeClient } from "./client/marinade";
|
|
6
5
|
import { VaultClient } from "./client/vault";
|
|
@@ -15,14 +14,14 @@ import { TimelockClient } from "./client/timelock";
|
|
|
15
14
|
import { StakeClient } from "./client/stake";
|
|
16
15
|
import { StakePoolClient } from "./client/stake-pool";
|
|
17
16
|
import { CctpClient } from "./client/cctp";
|
|
17
|
+
import { BridgeClient } from "./client/bridge";
|
|
18
|
+
import { EpiClient } from "./client/epi";
|
|
18
19
|
/**
|
|
19
20
|
* Main entrypoint for the GLAM SDK
|
|
20
21
|
*
|
|
21
22
|
* Lazy loads each client/module at first use
|
|
22
23
|
*/
|
|
23
24
|
export declare class GlamClient extends BaseClient {
|
|
24
|
-
private _drift?;
|
|
25
|
-
private _driftVaults?;
|
|
26
25
|
private _invest?;
|
|
27
26
|
private _jupiterSwap?;
|
|
28
27
|
private _marinade?;
|
|
@@ -39,9 +38,9 @@ export declare class GlamClient extends BaseClient {
|
|
|
39
38
|
private _fees?;
|
|
40
39
|
private _timelock?;
|
|
41
40
|
private _cctp?;
|
|
41
|
+
private _bridge?;
|
|
42
|
+
private _epi?;
|
|
42
43
|
constructor(config?: GlamClientConfig);
|
|
43
|
-
get drift(): DriftProtocolClient;
|
|
44
|
-
get driftVaults(): DriftVaultsClient;
|
|
45
44
|
get invest(): InvestClient;
|
|
46
45
|
get fees(): FeesClient;
|
|
47
46
|
get jupiterSwap(): JupiterSwapClient;
|
|
@@ -58,4 +57,6 @@ export declare class GlamClient extends BaseClient {
|
|
|
58
57
|
get kaminoVaults(): KaminoVaultsClient;
|
|
59
58
|
get timelock(): TimelockClient;
|
|
60
59
|
get cctp(): CctpClient;
|
|
60
|
+
get bridge(): BridgeClient;
|
|
61
|
+
get epi(): EpiClient;
|
|
61
62
|
}
|