@cubee_ee/sdk 0.1.8 → 0.2.1

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.
Files changed (44) hide show
  1. package/README.md +50 -0
  2. package/dist/clients/CubicPoolClient.d.ts.map +1 -1
  3. package/dist/clients/CubicPoolClient.js +1 -0
  4. package/dist/clients/CubicPoolClient.js.map +1 -1
  5. package/dist/clients/index.d.ts +1 -0
  6. package/dist/clients/index.d.ts.map +1 -1
  7. package/dist/clients/index.js +1 -0
  8. package/dist/clients/index.js.map +1 -1
  9. package/dist/clients/tx-builders.d.ts +44 -0
  10. package/dist/clients/tx-builders.d.ts.map +1 -1
  11. package/dist/clients/tx-builders.js +59 -0
  12. package/dist/clients/tx-builders.js.map +1 -1
  13. package/dist/clients/versioned.d.ts +34 -0
  14. package/dist/clients/versioned.d.ts.map +1 -0
  15. package/dist/clients/versioned.js +55 -0
  16. package/dist/clients/versioned.js.map +1 -0
  17. package/dist/idl/cubic_pool.json +1101 -114
  18. package/dist/idl/index.d.ts +380 -16
  19. package/dist/idl/index.d.ts.map +1 -1
  20. package/dist/idl/protocol_admin.json +513 -2
  21. package/dist/index.d.ts +3 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +7 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/parsers/poolAccount.d.ts +42 -11
  26. package/dist/parsers/poolAccount.d.ts.map +1 -1
  27. package/dist/parsers/poolAccount.js +96 -37
  28. package/dist/parsers/poolAccount.js.map +1 -1
  29. package/dist/types/pool.d.ts +6 -0
  30. package/dist/types/pool.d.ts.map +1 -1
  31. package/dist/types/result.d.ts +1 -1
  32. package/dist/types/result.d.ts.map +1 -1
  33. package/dist/types/result.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/clients/CubicPoolClient.ts +1 -0
  36. package/src/clients/index.ts +1 -0
  37. package/src/clients/tx-builders.ts +100 -0
  38. package/src/clients/versioned.ts +80 -0
  39. package/src/idl/cubic_pool.json +1101 -114
  40. package/src/idl/protocol_admin.json +513 -2
  41. package/src/index.ts +5 -0
  42. package/src/parsers/poolAccount.ts +151 -48
  43. package/src/types/pool.ts +6 -0
  44. package/src/types/result.ts +1 -0
@@ -1,32 +1,63 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import BN from "bn.js";
3
3
  /**
4
- * Raw binary layout of CubicPool (see
5
- * `contracts/programs/cubic-pool/src/state/cubic_pool.rs`). Borsh-serialised.
4
+ * Raw binary layout of CubicPool **v4** (see
5
+ * `contracts/programs/cubic-pool/src/state/cubic_pool.rs`).
6
6
  *
7
- * We decode manually to avoid bundling an Anchor Program instance into the
8
- * SDK: the SDK is consumed by both frontend and backend, where dragging a
9
- * full Anchor runtime is heavy. The on-chain layout is stable (reserved[128]
10
- * at the tail).
7
+ * v4 reorganised per-token data from six parallel arrays into a single
8
+ * `tokens: [TokenSlot; 10]` array (each slot = `AssetConfig` +
9
+ * `AssetDynamics`). For backwards compatibility with downstream
10
+ * consumers (`CubicPoolClient.sync()` and similar), this decoder still
11
+ * exposes the parallel-array shape, plus the new max-selloff and admin
12
+ * fields.
13
+ *
14
+ * We decode manually to avoid bundling an Anchor `Program` instance into
15
+ * the SDK — both frontend and backend consume the SDK, and pulling the
16
+ * full Anchor runtime is heavy. The on-chain layout is stable (trailing
17
+ * `reserved[64]` blob keeps room for forward extensions).
11
18
  */
12
19
  export interface RawPoolAccount {
13
20
  config: PublicKey;
14
21
  bump: number;
15
22
  tokenCount: number;
16
23
  poolId: BN;
24
+ swapFeeRate: number;
25
+ protocolFeeRate: number;
26
+ createdAt: BN;
27
+ poolEnabled: boolean;
28
+ swapsEnabled: boolean;
29
+ poolAdmin: PublicKey;
30
+ pendingPoolAdmin: PublicKey;
31
+ rangeManager: PublicKey;
32
+ rangeManagerEnabled: boolean;
33
+ rangeManagerMaxVbChangeBps: number;
34
+ rangeManagerMaxWeightChangeBps: number;
35
+ rangeManagerMinUpdateIntervalSecs: number;
36
+ rangeManagerLastUpdated: BN;
17
37
  tokenMints: PublicKey[];
18
38
  tokenPrograms: PublicKey[];
19
39
  normalizedWeights: BN[];
40
+ maxSelloff: BN[];
41
+ maxSelloffPeriodLength: number[];
20
42
  virtualBalances: BN[];
21
43
  actualBalances: BN[];
22
- swapFeeRate: number;
23
- protocolFeeRate: number;
24
44
  protocolFeesOwed: BN[];
25
- createdAt: BN;
26
- poolEnabled: boolean;
27
- swapsEnabled: boolean;
45
+ previousSelloff: BN[];
46
+ currentSelloff: BN[];
47
+ windowStartTimestamp: BN[];
48
+ /**
49
+ * Per-pool Address Lookup Table. `PublicKey.default` means the pool's
50
+ * ALT has not been provisioned yet (`initialize_pool_alt` not called).
51
+ * SDK uses this to choose between v0 (with ALT) and legacy tx-building
52
+ * paths.
53
+ */
54
+ lookupTable: PublicKey;
28
55
  }
29
56
  /** 8-byte anchor discriminator for CubicPool. */
30
57
  export declare const POOL_DISCRIMINATOR_LEN = 8;
58
+ /** Total on-chain size of a v4 CubicPool (includes the 8-byte discriminator). */
59
+ export declare const POOL_V4_LEN = 1683;
60
+ /** Pre-v4 size — accounts at this size still need `migrate_pool_v4`. */
61
+ export declare const POOL_V3_LEN = 1154;
31
62
  export declare function decodePoolAccount(data: Buffer): RawPoolAccount;
32
63
  //# sourceMappingURL=poolAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"poolAccount.d.ts","sourceRoot":"","sources":["../../src/parsers/poolAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,EAAE,CAAC;IACX,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,aAAa,EAAE,SAAS,EAAE,CAA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E,SAAS,EAAE,CAAC;IAC3B,iBAAiB,EAAE,EAAE,EAAE,CAAC;IACxB,UAAU,EAAE,EAAE,EAAE,CAAC;IACjB,sBAAsB,EAAE,MAAM,EAAE,CAAC;IAEjC,eAAe,EAAE,EAAE,EAAE,CAAC;IACtB,cAAc,EAAE,EAAE,EAAE,CAAC;IACrB,gBAAgB,EAAE,EAAE,EAAE,CAAC;IACvB,eAAe,EAAE,EAAE,EAAE,CAAC;IACtB,cAAc,EAAE,EAAE,EAAE,CAAC;IACrB,oBAAoB,EAAE,EAAE,EAAE,CAAC;IAE3B;;;;;OAKG;IACH,WAAW,EAAE,SAAS,CAAC;CACxB;AAED,iDAAiD;AACjD,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,iFAAiF;AACjF,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,wEAAwE;AACxE,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAmI9D"}
@@ -3,19 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.POOL_DISCRIMINATOR_LEN = void 0;
6
+ exports.POOL_V3_LEN = exports.POOL_V4_LEN = exports.POOL_DISCRIMINATOR_LEN = void 0;
7
7
  exports.decodePoolAccount = decodePoolAccount;
8
8
  const web3_js_1 = require("@solana/web3.js");
9
9
  const bn_js_1 = __importDefault(require("bn.js"));
10
10
  /** 8-byte anchor discriminator for CubicPool. */
11
11
  exports.POOL_DISCRIMINATOR_LEN = 8;
12
12
  const MAX_TOKENS = 10;
13
+ /** Total on-chain size of a v4 CubicPool (includes the 8-byte discriminator). */
14
+ exports.POOL_V4_LEN = 1683;
15
+ /** Pre-v4 size — accounts at this size still need `migrate_pool_v4`. */
16
+ exports.POOL_V3_LEN = 1154;
13
17
  function decodePoolAccount(data) {
14
- if (data.length < exports.POOL_DISCRIMINATOR_LEN + 1000) {
15
- throw new Error(`decodePoolAccount: data too short (${data.length} bytes)`);
18
+ if (data.length === exports.POOL_V3_LEN) {
19
+ throw new Error(`decodePoolAccount: account is at v3 size (${exports.POOL_V3_LEN}). ` +
20
+ `Run migrate_pool_v4 against it before calling this decoder.`);
21
+ }
22
+ if (data.length !== exports.POOL_V4_LEN) {
23
+ throw new Error(`decodePoolAccount: unexpected data length ${data.length} ` +
24
+ `(expected ${exports.POOL_V4_LEN} for v4).`);
16
25
  }
17
26
  let off = exports.POOL_DISCRIMINATOR_LEN;
18
- const config = new web3_js_1.PublicKey(data.slice(off, off + 32));
27
+ const config = readPubkey(data, off);
19
28
  off += 32;
20
29
  const bump = data.readUInt8(off);
21
30
  off += 1;
@@ -23,66 +32,116 @@ function decodePoolAccount(data) {
23
32
  off += 1;
24
33
  const poolId = readU64LE(data, off);
25
34
  off += 8;
35
+ const swapFeeRate = data.readUInt32LE(off);
36
+ off += 4;
37
+ const protocolFeeRate = data.readUInt16LE(off);
38
+ off += 2;
39
+ const createdAt = readI64LE(data, off);
40
+ off += 8;
41
+ const poolEnabled = data.readUInt8(off) !== 0;
42
+ off += 1;
43
+ const swapsEnabled = data.readUInt8(off) !== 0;
44
+ off += 1;
45
+ const poolAdmin = readPubkey(data, off);
46
+ off += 32;
47
+ const pendingPoolAdmin = readPubkey(data, off);
48
+ off += 32;
49
+ const rangeManager = readPubkey(data, off);
50
+ off += 32;
51
+ const rangeManagerEnabled = data.readUInt8(off) !== 0;
52
+ off += 1;
53
+ const rangeManagerMaxVbChangeBps = data.readUInt16LE(off);
54
+ off += 2;
55
+ const rangeManagerMaxWeightChangeBps = data.readUInt16LE(off);
56
+ off += 2;
57
+ const rangeManagerMinUpdateIntervalSecs = data.readUInt32LE(off);
58
+ off += 4;
59
+ const rangeManagerLastUpdated = readI64LE(data, off);
60
+ off += 8;
61
+ // Per-token AoS — 10 slots, each 144 bytes.
26
62
  const tokenMints = [];
27
- for (let i = 0; i < MAX_TOKENS; i++) {
28
- tokenMints.push(new web3_js_1.PublicKey(data.slice(off, off + 32)));
29
- off += 32;
30
- }
31
63
  const tokenPrograms = [];
32
- for (let i = 0; i < MAX_TOKENS; i++) {
33
- tokenPrograms.push(new web3_js_1.PublicKey(data.slice(off, off + 32)));
34
- off += 32;
35
- }
36
64
  const normalizedWeights = [];
65
+ const maxSelloff = [];
66
+ const maxSelloffPeriodLength = [];
67
+ const virtualBalances = [];
68
+ const actualBalances = [];
69
+ const protocolFeesOwed = [];
70
+ const previousSelloff = [];
71
+ const currentSelloff = [];
72
+ const windowStartTimestamp = [];
37
73
  for (let i = 0; i < MAX_TOKENS; i++) {
74
+ // AssetConfig — 88 bytes
75
+ tokenMints.push(readPubkey(data, off));
76
+ off += 32;
77
+ tokenPrograms.push(readPubkey(data, off));
78
+ off += 32;
38
79
  normalizedWeights.push(readU64LE(data, off));
39
80
  off += 8;
40
- }
41
- const virtualBalances = [];
42
- for (let i = 0; i < MAX_TOKENS; i++) {
81
+ maxSelloff.push(readU64LE(data, off));
82
+ off += 8;
83
+ maxSelloffPeriodLength.push(data.readUInt32LE(off));
84
+ off += 4;
85
+ off += 4; // AssetConfig.reserved
86
+ // AssetDynamics — 56 bytes
43
87
  virtualBalances.push(readU64LE(data, off));
44
88
  off += 8;
45
- }
46
- const actualBalances = [];
47
- for (let i = 0; i < MAX_TOKENS; i++) {
48
89
  actualBalances.push(readU64LE(data, off));
49
90
  off += 8;
50
- }
51
- const swapFeeRate = data.readUInt32LE(off);
52
- off += 4;
53
- const protocolFeeRate = data.readUInt16LE(off);
54
- off += 2;
55
- const protocolFeesOwed = [];
56
- for (let i = 0; i < MAX_TOKENS; i++) {
57
91
  protocolFeesOwed.push(readU64LE(data, off));
58
92
  off += 8;
93
+ previousSelloff.push(readU64LE(data, off));
94
+ off += 8;
95
+ currentSelloff.push(readU64LE(data, off));
96
+ off += 8;
97
+ windowStartTimestamp.push(readI64LE(data, off));
98
+ off += 8;
99
+ off += 8; // AssetDynamics.reserved
59
100
  }
60
- const createdAt = readU64LE(data, off); // i64 — but Solana ts ≥ 0
61
- off += 8;
62
- const poolEnabled = data.readUInt8(off) !== 0;
63
- off += 1;
64
- const swapsEnabled = data.readUInt8(off) !== 0;
65
- off += 1;
66
- // reserved[128] trails — ignored.
101
+ const lookupTable = readPubkey(data, off);
102
+ off += 32;
103
+ // Trailing `reserved[32]` ignored.
67
104
  return {
68
105
  config,
69
106
  bump,
70
107
  tokenCount,
71
108
  poolId,
109
+ swapFeeRate,
110
+ protocolFeeRate,
111
+ createdAt,
112
+ poolEnabled,
113
+ swapsEnabled,
114
+ poolAdmin,
115
+ pendingPoolAdmin,
116
+ rangeManager,
117
+ rangeManagerEnabled,
118
+ rangeManagerMaxVbChangeBps,
119
+ rangeManagerMaxWeightChangeBps,
120
+ rangeManagerMinUpdateIntervalSecs,
121
+ rangeManagerLastUpdated,
72
122
  tokenMints,
73
123
  tokenPrograms,
74
124
  normalizedWeights,
125
+ maxSelloff,
126
+ maxSelloffPeriodLength,
75
127
  virtualBalances,
76
128
  actualBalances,
77
- swapFeeRate,
78
- protocolFeeRate,
79
129
  protocolFeesOwed,
80
- createdAt,
81
- poolEnabled,
82
- swapsEnabled,
130
+ previousSelloff,
131
+ currentSelloff,
132
+ windowStartTimestamp,
133
+ lookupTable,
83
134
  };
84
135
  }
136
+ function readPubkey(data, off) {
137
+ return new web3_js_1.PublicKey(data.slice(off, off + 32));
138
+ }
85
139
  function readU64LE(data, off) {
86
140
  return new bn_js_1.default(data.slice(off, off + 8), "le");
87
141
  }
142
+ function readI64LE(data, off) {
143
+ // i64 LE — for our timestamps (always ≥ 0 in practice) BN+LE matches.
144
+ // Returning BN keeps callers free to interpret signedness if needed.
145
+ return new bn_js_1.default(data.slice(off, off + 8), "le");
146
+ }
88
147
  //# sourceMappingURL=poolAccount.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"poolAccount.js","sourceRoot":"","sources":["../../src/parsers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48
  poolEnabled: boolean;
49
49
  swapsEnabled: boolean;
50
50
  createdAt: number;
51
+ /**
52
+ * Per-pool Address Lookup Table. `PublicKey.default` ⇒ no ALT provisioned
53
+ * yet (call `initialize_pool_alt` to bootstrap). When set and non-default,
54
+ * v0-tx builders compress per-token accounts via this ALT.
55
+ */
56
+ lookupTable: PublicKey;
51
57
  /** Unix timestamp (ms) when sync() ran. Useful for staleness checks. */
52
58
  syncedAt: number;
53
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/types/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;IAChB,YAAY,EAAE,SAAS,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,cAAc,EAAE,EAAE,CAAC;IACnB,aAAa,EAAE,EAAE,CAAC;IAClB,gBAAgB,EAAE,EAAE,CAAC;IACrB,0CAA0C;IAC1C,KAAK,EAAE,SAAS,CAAC;IACjB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,wBAAwB;IACxB,OAAO,EAAE,SAAS,CAAC;IACnB,kDAAkD;IAClD,MAAM,EAAE,SAAS,CAAC;IAClB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,MAAM,EAAE,EAAE,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,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CAAC;IACjB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,wBAAwB;IACxB,OAAO,EAAE,SAAS,CAAC;IACnB,kDAAkD;IAClD,MAAM,EAAE,SAAS,CAAC;IAClB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,MAAM,EAAE,EAAE,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,EAAE,SAAS,CAAC;IACnB,mDAAmD;IACnD,cAAc,EAAE,EAAE,CAAC;IACnB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,WAAW,EAAE,SAAS,CAAC;IACvB,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrE"}
@@ -17,7 +17,7 @@ export interface SdkError {
17
17
  /** Original error for debugging; never render this to end users. */
18
18
  cause?: unknown;
19
19
  }
20
- export type SdkErrorCode = "rpc_unavailable" | "rpc_timeout" | "rpc_rate_limited" | "account_not_found" | "invalid_input" | "math_overflow" | "parse_failure" | "backend_unavailable" | "backend_invalid_response" | "insufficient_funds" | "pool_disabled" | "swaps_disabled" | "unsupported_pool_state" | "slippage_exceeded" | "simulation_failed" | "tx_build_failed" | "unknown";
20
+ export type SdkErrorCode = "rpc_unavailable" | "rpc_timeout" | "rpc_rate_limited" | "account_not_found" | "invalid_input" | "math_overflow" | "parse_failure" | "backend_unavailable" | "backend_invalid_response" | "insufficient_funds" | "pool_disabled" | "swaps_disabled" | "unsupported_pool_state" | "slippage_exceeded" | "simulation_failed" | "tx_build_failed" | "alt_fetch_failed" | "unknown";
21
21
  export declare const ok: <T>(data: T) => SdkResult<T>;
22
22
  export declare const err: (code: SdkErrorCode, humanMessage: string, cause?: unknown) => SdkResult<never>;
23
23
  //# sourceMappingURL=result.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/types/result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACrB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEnC,MAAM,WAAW,QAAQ;IACvB,oCAAoC;IACpC,IAAI,EAAE,YAAY,CAAC;IACnB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,aAAa,GACb,kBAAkB,GAClB,mBAAmB,GACnB,eAAe,GACf,eAAe,GACf,eAAe,GACf,qBAAqB,GACrB,0BAA0B,GAC1B,oBAAoB,GACpB,eAAe,GACf,gBAAgB,GAChB,wBAAwB,GACxB,mBAAmB,GACnB,mBAAmB,GACnB,iBAAiB,GACjB,SAAS,CAAC;AAEd,eAAO,MAAM,EAAE,GAAI,CAAC,EAAE,MAAM,CAAC,KAAG,SAAS,CAAC,CAAC,CAAyB,CAAC;AACrE,eAAO,MAAM,GAAG,GACd,MAAM,YAAY,EAClB,cAAc,MAAM,EACpB,QAAQ,OAAO,KACd,SAAS,CAAC,KAAK,CAGhB,CAAC"}
1
+ {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/types/result.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACrB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEnC,MAAM,WAAW,QAAQ;IACvB,oCAAoC;IACpC,IAAI,EAAE,YAAY,CAAC;IACnB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,YAAY,GACpB,iBAAiB,GACjB,aAAa,GACb,kBAAkB,GAClB,mBAAmB,GACnB,eAAe,GACf,eAAe,GACf,eAAe,GACf,qBAAqB,GACrB,0BAA0B,GAC1B,oBAAoB,GACpB,eAAe,GACf,gBAAgB,GAChB,wBAAwB,GACxB,mBAAmB,GACnB,mBAAmB,GACnB,iBAAiB,GACjB,kBAAkB,GAClB,SAAS,CAAC;AAEd,eAAO,MAAM,EAAE,GAAI,CAAC,EAAE,MAAM,CAAC,KAAG,SAAS,CAAC,CAAC,CAAyB,CAAC;AACrE,eAAO,MAAM,GAAG,GACd,MAAM,YAAY,EAClB,cAAc,MAAM,EACpB,QAAQ,OAAO,KACd,SAAS,CAAC,KAAK,CAGhB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/types/result.ts"],"names":[],"mappings":";;;AAoCO,MAAM,EAAE,GAAG,CAAI,IAAO,EAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAAxD,QAAA,EAAE,MAAsD;AAC9D,MAAM,GAAG,GAAG,CACjB,IAAkB,EAClB,YAAoB,EACpB,KAAe,EACG,EAAE,CAAC,CAAC;IACtB,EAAE,EAAE,KAAK;IACT,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE;CACrC,CAAC,CAAC;AAPU,QAAA,GAAG,OAOb"}
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/types/result.ts"],"names":[],"mappings":";;;AAqCO,MAAM,EAAE,GAAG,CAAI,IAAO,EAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAAxD,QAAA,EAAE,MAAsD;AAC9D,MAAM,GAAG,GAAG,CACjB,IAAkB,EAClB,YAAoB,EACpB,KAAe,EACG,EAAE,CAAC,CAAC;IACtB,EAAE,EAAE,KAAK;IACT,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE;CACrC,CAAC,CAAC;AAPU,QAAA,GAAG,OAOb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubee_ee/sdk",
3
- "version": "0.1.8",
3
+ "version": "0.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -160,6 +160,7 @@ export class CubicPoolClient {
160
160
  poolEnabled: raw.poolEnabled,
161
161
  swapsEnabled: raw.swapsEnabled,
162
162
  createdAt: raw.createdAt.toNumber(),
163
+ lookupTable: raw.lookupTable,
163
164
  syncedAt: Date.now(),
164
165
  };
165
166
  this.cache = info;
@@ -2,6 +2,7 @@ export * from "./RpcClient";
2
2
  export * from "./CubeBackendClient";
3
3
  export * from "./CubicPoolClient";
4
4
  export * from "./tx-builders";
5
+ export * from "./versioned";
5
6
  export * from "./SingleTokenDepositClient";
6
7
  export * from "./PoolFactoryClient";
7
8
  export * from "./AdminClient";
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  AccountMeta,
3
+ AddressLookupTableProgram,
3
4
  ComputeBudgetProgram,
4
5
  PublicKey,
5
6
  SystemProgram,
@@ -34,6 +35,7 @@ const CUBIC_POOL_DISC = {
34
35
  addLiquidity: computeDiscriminator("add_liquidity"),
35
36
  removeLiquidity: computeDiscriminator("remove_liquidity"),
36
37
  initializeCubicPool: computeDiscriminator("initialize_cubic_pool"),
38
+ initializePoolAlt: computeDiscriminator("initialize_pool_alt"),
37
39
  };
38
40
 
39
41
  const STLD_DISC = {
@@ -62,6 +64,7 @@ function computeDiscriminator(ixName: string): Buffer {
62
64
  add_liquidity: "b59d59438fb63448",
63
65
  remove_liquidity: "5055d14818ceb16c",
64
66
  initialize_cubic_pool: "d79474cf79686f83",
67
+ initialize_pool_alt: "fb874202f4490c90",
65
68
  deposit_single_token: "a688a62fc7c056a9",
66
69
  initialize_config: "d07f1501c2bec446",
67
70
  };
@@ -504,6 +507,103 @@ export function buildDeployPoolTx(cfg: CubeConfig, params: DeployPoolParams): Bu
504
507
  };
505
508
  }
506
509
 
510
+ // ============================================================
511
+ // initialize_pool_alt — per-pool Address Lookup Table
512
+ // ============================================================
513
+
514
+ export interface InitializePoolAltParams {
515
+ /** Pool PDA. */
516
+ pool: PublicKey;
517
+ /** `CubicPoolConfig` account this pool is pinned to. Read by the
518
+ * program to gate the alternative-authority path (`config.protocol_admin`). */
519
+ config: PublicKey;
520
+ /** Authority. Must equal either `pool.pool_admin` (per-pool owner
521
+ * path) or `config.protocol_admin` (Treasury PDA via the
522
+ * protocol-admin CPI wrapper). The ALT address is derived from
523
+ * `[authority, recent_slot]`. */
524
+ authority: PublicKey;
525
+ /** Rent payer. Decoupled from `authority` so the wrapper path can
526
+ * pay from a regular wallet while Treasury PDA acts as authority.
527
+ * In the pool-admin path pass the same key for both. */
528
+ payer: PublicKey;
529
+ /**
530
+ * Recent slot. Used by the upstream ALT program to derive the table
531
+ * address as `[authority, recent_slot]`. Must be a slot the runtime
532
+ * still has in slot-hashes — caller should pass
533
+ * `await connection.getSlot('finalized')`.
534
+ */
535
+ recentSlot: BN;
536
+ }
537
+
538
+ /**
539
+ * Re-derives the Address Lookup Table address from `(authority, recent_slot)`
540
+ * the same way the upstream ALT program does.
541
+ *
542
+ * `@solana/web3.js` v1 doesn't expose `deriveLookupTableAddress` as a static,
543
+ * so we inline the seed derivation.
544
+ */
545
+ export function deriveAltAddress(authority: PublicKey, recentSlot: BN): PublicKey {
546
+ const slotBuf = recentSlot.toArrayLike(Buffer, "le", 8);
547
+ const [addr] = PublicKey.findProgramAddressSync(
548
+ [authority.toBuffer(), slotBuf],
549
+ AddressLookupTableProgram.programId,
550
+ );
551
+ return addr;
552
+ }
553
+
554
+ /**
555
+ * Build the on-chain `initialize_pool_alt` instruction. Performs three
556
+ * upstream CPIs inside the program: create + extend + freeze. After
557
+ * this ix lands, the ALT is immutable and the pool's `lookup_table`
558
+ * field points at it.
559
+ *
560
+ * Caller must NOT use the ALT in the same slot (warmup) — wait at
561
+ * least one slot before sending any v0 tx that references it.
562
+ */
563
+ export function buildInitializePoolAltIx(
564
+ cfg: CubeConfig,
565
+ params: InitializePoolAltParams,
566
+ ): TransactionInstruction {
567
+ const altAddr = deriveAltAddress(params.authority, params.recentSlot);
568
+
569
+ const data = Buffer.concat([
570
+ CUBIC_POOL_DISC.initializePoolAlt,
571
+ encodeU64(params.recentSlot),
572
+ ]);
573
+
574
+ // Account order MUST match cubic-pool's InitializePoolAlt context:
575
+ // pool, config, authority, payer, lookup_table, system_program, alt_program.
576
+ const keys: AccountMeta[] = [
577
+ { pubkey: params.pool, isSigner: false, isWritable: true },
578
+ { pubkey: params.config, isSigner: false, isWritable: false },
579
+ { pubkey: params.authority, isSigner: true, isWritable: false },
580
+ { pubkey: params.payer, isSigner: true, isWritable: true },
581
+ { pubkey: altAddr, isSigner: false, isWritable: true },
582
+ { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
583
+ { pubkey: AddressLookupTableProgram.programId, isSigner: false, isWritable: false },
584
+ ];
585
+
586
+ return new TransactionInstruction({
587
+ programId: cfg.programs.cubicPool,
588
+ keys,
589
+ data,
590
+ });
591
+ }
592
+
593
+ export function buildInitializePoolAltTx(
594
+ cfg: CubeConfig,
595
+ params: InitializePoolAltParams,
596
+ ): BuiltTx & { lookupTable: PublicKey } {
597
+ return {
598
+ instructions: [
599
+ ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }),
600
+ buildInitializePoolAltIx(cfg, params),
601
+ ],
602
+ suggestedCuLimit: 200_000,
603
+ lookupTable: deriveAltAddress(params.authority, params.recentSlot),
604
+ };
605
+ }
606
+
507
607
  // ============================================================
508
608
  // Borsh encoding helpers (subset used above)
509
609
  // ============================================================
@@ -0,0 +1,80 @@
1
+ import {
2
+ AddressLookupTableAccount,
3
+ Connection,
4
+ PublicKey,
5
+ TransactionInstruction,
6
+ TransactionMessage,
7
+ VersionedTransaction,
8
+ } from "@solana/web3.js";
9
+ import { PoolInfo } from "../types/pool";
10
+ import { BuiltTx } from "../types/tx";
11
+ import { SdkResult, err, ok } from "../types/result";
12
+
13
+ /**
14
+ * Compile a set of instructions into a `VersionedTransaction` (v0),
15
+ * optionally using a per-pool Address Lookup Table to shrink the wire
16
+ * size below the 1232-byte legacy ceiling.
17
+ *
18
+ * ALT inclusion rules:
19
+ * - If `lookupTable` is `PublicKey.default` (or undefined) → no ALT
20
+ * is referenced; the tx is v0 but uses only static account keys.
21
+ * - Otherwise → fetch the ALT via `connection.getAddressLookupTable`
22
+ * and include it. If the fetch fails, the function returns an
23
+ * `alt_fetch_failed` error rather than silently falling back.
24
+ *
25
+ * Wallets supporting the standard `signTransaction(Transaction |
26
+ * VersionedTransaction)` overload (Phantom, Solflare, Backpack, Glow,
27
+ * the wallet-adapter set since 2023) sign these without changes.
28
+ */
29
+ export async function buildVersionedTx(
30
+ conn: Connection,
31
+ payer: PublicKey,
32
+ instructions: TransactionInstruction[],
33
+ lookupTable: PublicKey | undefined,
34
+ ): Promise<SdkResult<{ tx: VersionedTransaction; alts: AddressLookupTableAccount[] }>> {
35
+ const alts: AddressLookupTableAccount[] = [];
36
+
37
+ if (lookupTable && !lookupTable.equals(PublicKey.default)) {
38
+ try {
39
+ const res = await conn.getAddressLookupTable(lookupTable);
40
+ if (!res.value) {
41
+ return err(
42
+ "alt_fetch_failed",
43
+ `Lookup table ${lookupTable.toBase58()} not found on-chain. ` +
44
+ "The pool advertises an ALT but the account is missing — " +
45
+ "the ALT may have been closed or the RPC is stale.",
46
+ );
47
+ }
48
+ alts.push(res.value);
49
+ } catch (e) {
50
+ return err(
51
+ "alt_fetch_failed",
52
+ `Failed to fetch lookup table ${lookupTable.toBase58()}`,
53
+ e,
54
+ );
55
+ }
56
+ }
57
+
58
+ const { blockhash } = await conn.getLatestBlockhash("confirmed");
59
+ const msg = new TransactionMessage({
60
+ payerKey: payer,
61
+ recentBlockhash: blockhash,
62
+ instructions,
63
+ }).compileToV0Message(alts);
64
+
65
+ return ok({ tx: new VersionedTransaction(msg), alts });
66
+ }
67
+
68
+ /**
69
+ * Convenience: take a SDK-built `BuiltTx` and a pool snapshot, produce
70
+ * a signed-ready `VersionedTransaction`. Picks up `pool.lookupTable`
71
+ * automatically.
72
+ */
73
+ export async function compileBuiltTx(
74
+ conn: Connection,
75
+ payer: PublicKey,
76
+ built: BuiltTx,
77
+ pool: Pick<PoolInfo, "lookupTable">,
78
+ ): Promise<SdkResult<{ tx: VersionedTransaction; alts: AddressLookupTableAccount[] }>> {
79
+ return buildVersionedTx(conn, payer, built.instructions, pool.lookupTable);
80
+ }