@elemental-stv-core/sdk 0.7.0 → 0.8.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/dist/common/ata.d.ts +13 -1
- package/dist/common/ata.js +27 -0
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +2 -1
- package/dist/p-stv-core/accounts.d.ts +1 -1
- package/dist/p-stv-core/accounts.js +2 -2
- package/dist/p-stv-core/sol-wrap.js +1 -21
- package/dist/p-stv-core/types.d.ts +3 -1
- package/package.json +1 -1
package/dist/common/ata.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
1
|
+
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
2
|
/**
|
|
3
3
|
* Derive an Associated Token Account (ATA) address.
|
|
4
4
|
*
|
|
@@ -12,3 +12,15 @@ import { PublicKey } from "@solana/web3.js";
|
|
|
12
12
|
* @param tokenProgram - Token program ID (SPL Token or Token-2022)
|
|
13
13
|
*/
|
|
14
14
|
export declare function findAta(mint: PublicKey, owner: PublicKey, tokenProgram: PublicKey): PublicKey;
|
|
15
|
+
/**
|
|
16
|
+
* Build an Associated Token Account `CreateIdempotent` instruction.
|
|
17
|
+
*
|
|
18
|
+
* Idempotent — safe to include on every tx; the ATA program no-ops if the
|
|
19
|
+
* account already exists. Works for both SPL Token and Token-2022.
|
|
20
|
+
*
|
|
21
|
+
* @param payer - Wallet paying rent + signing the tx
|
|
22
|
+
* @param mint - Token mint the ATA will hold
|
|
23
|
+
* @param owner - ATA owner (wallet or PDA)
|
|
24
|
+
* @param tokenProgram - SPL Token or Token-2022 program id
|
|
25
|
+
*/
|
|
26
|
+
export declare function createIdempotentAtaIx(payer: PublicKey, mint: PublicKey, owner: PublicKey, tokenProgram: PublicKey): TransactionInstruction;
|
package/dist/common/ata.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findAta = findAta;
|
|
4
|
+
exports.createIdempotentAtaIx = createIdempotentAtaIx;
|
|
4
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
6
|
const spl_token_1 = require("@solana/spl-token");
|
|
6
7
|
/**
|
|
@@ -19,3 +20,29 @@ function findAta(mint, owner, tokenProgram) {
|
|
|
19
20
|
const [ata] = web3_js_1.PublicKey.findProgramAddressSync([owner.toBuffer(), tokenProgram.toBuffer(), mint.toBuffer()], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
20
21
|
return ata;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Build an Associated Token Account `CreateIdempotent` instruction.
|
|
25
|
+
*
|
|
26
|
+
* Idempotent — safe to include on every tx; the ATA program no-ops if the
|
|
27
|
+
* account already exists. Works for both SPL Token and Token-2022.
|
|
28
|
+
*
|
|
29
|
+
* @param payer - Wallet paying rent + signing the tx
|
|
30
|
+
* @param mint - Token mint the ATA will hold
|
|
31
|
+
* @param owner - ATA owner (wallet or PDA)
|
|
32
|
+
* @param tokenProgram - SPL Token or Token-2022 program id
|
|
33
|
+
*/
|
|
34
|
+
function createIdempotentAtaIx(payer, mint, owner, tokenProgram) {
|
|
35
|
+
const ata = findAta(mint, owner, tokenProgram);
|
|
36
|
+
return new web3_js_1.TransactionInstruction({
|
|
37
|
+
keys: [
|
|
38
|
+
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
39
|
+
{ pubkey: ata, isSigner: false, isWritable: true },
|
|
40
|
+
{ pubkey: owner, isSigner: false, isWritable: false },
|
|
41
|
+
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
42
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
43
|
+
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
44
|
+
],
|
|
45
|
+
programId: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
46
|
+
data: Buffer.from([1]), // CreateIdempotent
|
|
47
|
+
});
|
|
48
|
+
}
|
package/dist/common/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export { PPS_DECIMALS, BPS_DENOMINATOR, SECONDS_PER_YEAR, STALENESS_THRESHOLD, D
|
|
|
3
3
|
export type { SolanaConnection } from "./connection";
|
|
4
4
|
export type { StrategyStateHeader, StvPosition, } from "./strategy-interface";
|
|
5
5
|
export { deserializeStrategyStateHeader, deserializeStvPosition, } from "./strategy-interface";
|
|
6
|
-
export { findAta } from "./ata";
|
|
6
|
+
export { findAta, createIdempotentAtaIx } from "./ata";
|
package/dist/common/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findAta = exports.deserializeStvPosition = exports.deserializeStrategyStateHeader = exports.DISC_MANAGER_ROLE = exports.DISC_STV_POSITION = exports.DISC_STRATEGY_STATE = exports.STALENESS_THRESHOLD = exports.SECONDS_PER_YEAR = exports.BPS_DENOMINATOR = exports.PPS_DECIMALS = exports.writeOptionalU16 = exports.writeOptionalU32 = exports.writeOptionalU64 = exports.writeOptionalPubkey = exports.writeU64 = exports.readU8 = exports.readU16 = exports.readU32 = exports.readU64 = exports.readPubkey = void 0;
|
|
3
|
+
exports.createIdempotentAtaIx = exports.findAta = exports.deserializeStvPosition = exports.deserializeStrategyStateHeader = exports.DISC_MANAGER_ROLE = exports.DISC_STV_POSITION = exports.DISC_STRATEGY_STATE = exports.STALENESS_THRESHOLD = exports.SECONDS_PER_YEAR = exports.BPS_DENOMINATOR = exports.PPS_DECIMALS = exports.writeOptionalU16 = exports.writeOptionalU32 = exports.writeOptionalU64 = exports.writeOptionalPubkey = exports.writeU64 = exports.readU8 = exports.readU16 = exports.readU32 = exports.readU64 = exports.readPubkey = void 0;
|
|
4
4
|
var buffer_1 = require("./buffer");
|
|
5
5
|
Object.defineProperty(exports, "readPubkey", { enumerable: true, get: function () { return buffer_1.readPubkey; } });
|
|
6
6
|
Object.defineProperty(exports, "readU64", { enumerable: true, get: function () { return buffer_1.readU64; } });
|
|
@@ -25,3 +25,4 @@ Object.defineProperty(exports, "deserializeStrategyStateHeader", { enumerable: t
|
|
|
25
25
|
Object.defineProperty(exports, "deserializeStvPosition", { enumerable: true, get: function () { return strategy_interface_1.deserializeStvPosition; } });
|
|
26
26
|
var ata_1 = require("./ata");
|
|
27
27
|
Object.defineProperty(exports, "findAta", { enumerable: true, get: function () { return ata_1.findAta; } });
|
|
28
|
+
Object.defineProperty(exports, "createIdempotentAtaIx", { enumerable: true, get: function () { return ata_1.createIdempotentAtaIx; } });
|
|
@@ -28,7 +28,7 @@ export declare function deserializeGlobalConfig(data: Buffer): GlobalConfig;
|
|
|
28
28
|
* [168..248] childVaults[10] [u64; 10] (allocator child vault IDs)
|
|
29
29
|
* [248..256] vaultId u64
|
|
30
30
|
* [256..264] reservedBase u64 (base reserved for pending claims)
|
|
31
|
-
* [264..272]
|
|
31
|
+
* [264..272] requestedShares u64 (shares pending in escrow — multiply × PPS to estimate base)
|
|
32
32
|
* [272..280] vaultCapacity u64 (0 = uncapped)
|
|
33
33
|
* [280..288] minDeposit u64
|
|
34
34
|
* [288..296] hwm u64 (high-water mark for perf fees)
|
|
@@ -66,7 +66,7 @@ function deserializeGlobalConfig(data) {
|
|
|
66
66
|
* [168..248] childVaults[10] [u64; 10] (allocator child vault IDs)
|
|
67
67
|
* [248..256] vaultId u64
|
|
68
68
|
* [256..264] reservedBase u64 (base reserved for pending claims)
|
|
69
|
-
* [264..272]
|
|
69
|
+
* [264..272] requestedShares u64 (shares pending in escrow — multiply × PPS to estimate base)
|
|
70
70
|
* [272..280] vaultCapacity u64 (0 = uncapped)
|
|
71
71
|
* [280..288] minDeposit u64
|
|
72
72
|
* [288..296] hwm u64 (high-water mark for perf fees)
|
|
@@ -110,7 +110,7 @@ function deserializeStv(data) {
|
|
|
110
110
|
childVaults,
|
|
111
111
|
vaultId: (0, buffer_1.readU64)(data, 248),
|
|
112
112
|
reservedBase: (0, buffer_1.readU64)(data, 256),
|
|
113
|
-
|
|
113
|
+
requestedShares: (0, buffer_1.readU64)(data, 264),
|
|
114
114
|
vaultCapacity: (0, buffer_1.readU64)(data, 272),
|
|
115
115
|
minDeposit: (0, buffer_1.readU64)(data, 280),
|
|
116
116
|
hwm: (0, buffer_1.readU64)(data, 288),
|
|
@@ -12,7 +12,6 @@ exports.findWsolAta = findWsolAta;
|
|
|
12
12
|
exports.buildWrapSolIxs = buildWrapSolIxs;
|
|
13
13
|
exports.buildUnwrapSolIx = buildUnwrapSolIx;
|
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
|
15
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
16
15
|
const ata_1 = require("../common/ata");
|
|
17
16
|
/** Native SOL mint (wrapped SOL) */
|
|
18
17
|
exports.NATIVE_SOL_MINT = new web3_js_1.PublicKey("So11111111111111111111111111111111111111112");
|
|
@@ -39,15 +38,12 @@ function findWsolAta(owner) {
|
|
|
39
38
|
function buildWrapSolIxs(payer, lamports) {
|
|
40
39
|
const wsolAta = findWsolAta(payer);
|
|
41
40
|
return [
|
|
42
|
-
|
|
43
|
-
createAtaIxInternal(payer, exports.NATIVE_SOL_MINT, payer),
|
|
44
|
-
// Transfer SOL to wSOL ATA
|
|
41
|
+
(0, ata_1.createIdempotentAtaIx)(payer, exports.NATIVE_SOL_MINT, payer, SPL_TOKEN_PROGRAM),
|
|
45
42
|
web3_js_1.SystemProgram.transfer({
|
|
46
43
|
fromPubkey: payer,
|
|
47
44
|
toPubkey: wsolAta,
|
|
48
45
|
lamports: BigInt(lamports),
|
|
49
46
|
}),
|
|
50
|
-
// Sync native balance
|
|
51
47
|
new web3_js_1.TransactionInstruction({
|
|
52
48
|
programId: SPL_TOKEN_PROGRAM,
|
|
53
49
|
keys: [{ pubkey: wsolAta, isSigner: false, isWritable: true }],
|
|
@@ -76,19 +72,3 @@ function buildUnwrapSolIx(owner) {
|
|
|
76
72
|
data: Buffer.from([9]),
|
|
77
73
|
});
|
|
78
74
|
}
|
|
79
|
-
/** Internal: create ATA (idempotent) */
|
|
80
|
-
function createAtaIxInternal(payer, mint, owner) {
|
|
81
|
-
const ata = (0, ata_1.findAta)(mint, owner, SPL_TOKEN_PROGRAM);
|
|
82
|
-
return new web3_js_1.TransactionInstruction({
|
|
83
|
-
keys: [
|
|
84
|
-
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
85
|
-
{ pubkey: ata, isSigner: false, isWritable: true },
|
|
86
|
-
{ pubkey: owner, isSigner: false, isWritable: false },
|
|
87
|
-
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
88
|
-
{ pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
89
|
-
{ pubkey: SPL_TOKEN_PROGRAM, isSigner: false, isWritable: false },
|
|
90
|
-
],
|
|
91
|
-
programId: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
92
|
-
data: Buffer.from([1]), // CreateIdempotent
|
|
93
|
-
});
|
|
94
|
-
}
|
|
@@ -16,7 +16,9 @@ export interface Stv {
|
|
|
16
16
|
childVaults: BN[];
|
|
17
17
|
vaultId: BN;
|
|
18
18
|
reservedBase: BN;
|
|
19
|
-
|
|
19
|
+
/** Pending withdrawal shares (sum across unprocessed WithdrawRequests).
|
|
20
|
+
* Display value: requestedShares × currentPps / PPS_DECIMALS. */
|
|
21
|
+
requestedShares: BN;
|
|
20
22
|
vaultCapacity: BN;
|
|
21
23
|
minDeposit: BN;
|
|
22
24
|
hwm: BN;
|