@glamsystems/glam-sdk 1.0.5 → 1.0.6
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/index.cjs.js +221 -206
- package/index.esm.js +221 -196
- package/package.json +1 -1
- package/src/client/base.d.ts +1 -0
- package/src/client/cctp.d.ts +1 -0
- package/src/client/drift/index.d.ts +0 -1
- package/src/client/drift/protocol-v2.d.ts +11 -1
- package/src/client/drift/vaults.d.ts +1 -2
- package/src/client/price.d.ts +1 -1
- package/src/clientConfig.d.ts +1 -0
- package/src/deser/driftLayouts.d.ts +43 -8
- package/src/models/state.d.ts +7 -0
- package/src/utils/drift/index.d.ts +0 -3
- package/src/utils/drift/types.d.ts +3 -947
- package/src/client/drift/types.d.ts +0 -13
package/package.json
CHANGED
package/src/client/base.d.ts
CHANGED
package/src/client/cctp.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class CctpBridgeEvent {
|
|
|
12
12
|
readonly status: string;
|
|
13
13
|
readonly txHash: string;
|
|
14
14
|
readonly uiAmount: number;
|
|
15
|
+
slot?: number;
|
|
15
16
|
constructor(amount: BN, sourceDomain: number, sourceAddress: string, destinationDomain: number, destinationAddress: string, attestation: string, nonce: string, status: string, txHash: string);
|
|
16
17
|
}
|
|
17
18
|
declare class TxBuilder extends BaseTxBuilder<CctpClient> {
|
|
@@ -4,7 +4,17 @@ import { MarketType, OrderParams, PositionDirection, ModifyOrderParams } from ".
|
|
|
4
4
|
import { DriftPerpMarket, DriftSpotMarket, DriftUser } from "../../deser/driftLayouts";
|
|
5
5
|
import { BaseClient, BaseTxBuilder, TxOptions } from "../base";
|
|
6
6
|
import { VaultClient } from "../vault";
|
|
7
|
-
|
|
7
|
+
export declare const DRIFT_SIGNER: anchor.web3.PublicKey;
|
|
8
|
+
export declare const DRIFT_MARGIN_PRECISION = 10000;
|
|
9
|
+
export interface OrderConstants {
|
|
10
|
+
perpBaseScale: number;
|
|
11
|
+
quoteScale: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DriftMarketConfigs {
|
|
14
|
+
orderConstants: OrderConstants;
|
|
15
|
+
perpMarkets: DriftPerpMarket[];
|
|
16
|
+
spotMarkets: DriftSpotMarket[];
|
|
17
|
+
}
|
|
8
18
|
declare class TxBuilder extends BaseTxBuilder<DriftProtocolClient> {
|
|
9
19
|
initializeUserStatsIx(glamSigner: PublicKey): Promise<TransactionInstruction>;
|
|
10
20
|
initializeUserIx(glamSigner: PublicKey, subAccountId: number): Promise<TransactionInstruction>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PublicKey, VersionedTransaction, TransactionSignature, AccountMeta, Commitment } from "@solana/web3.js";
|
|
2
|
-
import {
|
|
3
|
-
import { DriftVault } from "../../deser/driftLayouts";
|
|
2
|
+
import { DriftVault, PerpPosition, SpotPosition } from "../../deser/driftLayouts";
|
|
4
3
|
import { BaseClient, BaseTxBuilder, TxOptions } from "../base";
|
|
5
4
|
import { BN } from "@coral-xyz/anchor";
|
|
6
5
|
import { DriftProtocolClient } from "./protocol-v2";
|
package/src/client/price.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare class PriceClient {
|
|
|
60
60
|
getKaminoVaultStates(externalPositionsSet: PkSet, commitment?: Commitment): Promise<PkMap<KVaultState>>;
|
|
61
61
|
getPubkeysForKaminoHoldings(commitment?: Commitment): Promise<PkMap<PkSet>>;
|
|
62
62
|
getTokenHoldings(tokenAccountPubkeys: PublicKey[], accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
|
|
63
|
-
|
|
63
|
+
getDriftHoldings(userPubkeys: Iterable<PublicKey>, spotMarketsMap: PkMap<DriftSpotMarket>, perpMarketsMap: PkMap<DriftPerpMarket>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
|
|
64
64
|
getDriftVaultsHoldings(dvaultDepositorsAndVaults: PkMap<DriftVault>, dvaultDepositorsMap: PkMap<DriftVaultDepositor>, spotMarketsMap: PkMap<DriftSpotMarket>, perpMarketsMap: PkMap<DriftPerpMarket>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
|
|
65
65
|
getKaminoLendHoldings(obligationPubkeys: Iterable<PublicKey>, reservesMap: PkMap<Reserve>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
|
|
66
66
|
getKaminoVaultsHoldings(kvaultAtasAndStates: PkMap<KVaultState>, reservesMap: PkMap<Reserve>, accountsDataMap: PkMap<Buffer>, tokenPricesMap: PkMap<TokenListItem>, priceSource: string): Holding[];
|
package/src/clientConfig.d.ts
CHANGED
|
@@ -3,7 +3,48 @@ import { BN } from "@coral-xyz/anchor";
|
|
|
3
3
|
import { PublicKey } from "@solana/web3.js";
|
|
4
4
|
import { Decodable } from "./base";
|
|
5
5
|
import { PkMap } from "../utils";
|
|
6
|
-
import { MarginMode, MarketType, OracleSource, Order,
|
|
6
|
+
import { MarginMode, MarketType, OracleSource, Order, SpotBalanceType } from "../utils/drift/types";
|
|
7
|
+
export declare class SpotPosition {
|
|
8
|
+
marketIndex: number;
|
|
9
|
+
balanceType: SpotBalanceType;
|
|
10
|
+
scaledBalance: BN;
|
|
11
|
+
openOrders: number;
|
|
12
|
+
openBids: BN;
|
|
13
|
+
openAsks: BN;
|
|
14
|
+
cumulativeDeposits: BN;
|
|
15
|
+
constructor(data: any);
|
|
16
|
+
get marketPda(): PublicKey;
|
|
17
|
+
calcBalance(decimals: number, cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): {
|
|
18
|
+
amount: number;
|
|
19
|
+
uiAmount: number;
|
|
20
|
+
};
|
|
21
|
+
calcBalanceBn(decimals: number, cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): BN;
|
|
22
|
+
_interest(cumulativeDepositInterest: BN, cumulativeBorrowInterest: BN): BN;
|
|
23
|
+
get direction(): "borrow" | "deposit";
|
|
24
|
+
}
|
|
25
|
+
export declare class PerpPosition {
|
|
26
|
+
baseAssetAmount: BN;
|
|
27
|
+
lastCumulativeFundingRate: BN;
|
|
28
|
+
marketIndex: number;
|
|
29
|
+
quoteAssetAmount: BN;
|
|
30
|
+
quoteEntryAmount: BN;
|
|
31
|
+
quoteBreakEvenAmount: BN;
|
|
32
|
+
openOrders: number;
|
|
33
|
+
openBids: BN;
|
|
34
|
+
openAsks: BN;
|
|
35
|
+
settledPnl: BN;
|
|
36
|
+
lpShares: BN;
|
|
37
|
+
remainderBaseAssetAmount: number;
|
|
38
|
+
lastBaseAssetAmountPerLp: BN;
|
|
39
|
+
lastQuoteAssetAmountPerLp: BN;
|
|
40
|
+
perLpBase: number;
|
|
41
|
+
constructor(data: any);
|
|
42
|
+
get marketPda(): PublicKey;
|
|
43
|
+
baseAssetValue(oraclePrice: BN): BN;
|
|
44
|
+
unrealizedPnl(oraclePrice: BN): BN;
|
|
45
|
+
getUsdValueScaled(oraclePrice: BN, cumulativeFundingRateLong: BN, cumulativeFundingRateShort: BN): BN;
|
|
46
|
+
calcFundingPayment(cumulativeFundingRateLong: BN, cumulativeFundingRateShort: BN): BN;
|
|
47
|
+
}
|
|
7
48
|
export declare class DriftVaultDepositor extends Decodable {
|
|
8
49
|
discriminator: number[];
|
|
9
50
|
vault: PublicKey;
|
|
@@ -27,6 +68,7 @@ export declare class DriftVaultDepositor extends Decodable {
|
|
|
27
68
|
fuelAmount: BN;
|
|
28
69
|
padding: BN[];
|
|
29
70
|
static _layout: any;
|
|
71
|
+
get netShares(): BN;
|
|
30
72
|
}
|
|
31
73
|
export declare class DriftVault extends Decodable {
|
|
32
74
|
discriminator: number[];
|
|
@@ -145,12 +187,6 @@ export declare class DriftSpotMarket extends Decodable {
|
|
|
145
187
|
get name(): string;
|
|
146
188
|
get oracleSource(): OracleSource;
|
|
147
189
|
get tokenProgramId(): PublicKey;
|
|
148
|
-
calcSpotBalance(scaledBalance: BN, scaledBalanceType: SpotBalanceType): {
|
|
149
|
-
amount: number;
|
|
150
|
-
uiAmount: number;
|
|
151
|
-
};
|
|
152
|
-
calcSpotBalanceBn(scaledBalance: BN, scaledBalanceType: SpotBalanceType): BN;
|
|
153
|
-
_interest(balanceType: SpotBalanceType): BN;
|
|
154
190
|
}
|
|
155
191
|
export declare class DriftPerpMarket extends Decodable {
|
|
156
192
|
discriminator: number[];
|
|
@@ -174,5 +210,4 @@ export declare class DriftPerpMarket extends Decodable {
|
|
|
174
210
|
static _layout: any;
|
|
175
211
|
get name(): string;
|
|
176
212
|
get oracleSource(): OracleSource;
|
|
177
|
-
calcFundingPayment(perpPosition: PerpPosition): BN;
|
|
178
213
|
}
|
package/src/models/state.d.ts
CHANGED