@liquid-af/sdk 0.5.4 → 0.5.5
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/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lut.d.ts +50 -0
- package/dist/lut.d.ts.map +1 -0
- package/dist/lut.js +140 -0
- package/dist/lut.js.map +1 -0
- package/package.json +1 -1
- package/src/config.ts +16 -0
- package/src/index.ts +2 -0
- package/src/lut.ts +195 -0
package/dist/config.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export interface LiquidConfig {
|
|
|
13
13
|
liquidStateProgramId: PublicKey;
|
|
14
14
|
/** Program ID for the events program */
|
|
15
15
|
liquidEventsProgramId: PublicKey;
|
|
16
|
+
/** Address lookup table for liquid-swap transactions */
|
|
17
|
+
swapLut: PublicKey;
|
|
18
|
+
/** Address lookup table for liquid (bonding curve) transactions */
|
|
19
|
+
liquidLut: PublicKey;
|
|
16
20
|
}
|
|
17
21
|
/** Mainnet program IDs */
|
|
18
22
|
export declare const MAINNET_CONFIG: LiquidConfig;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,+CAA+C;IAC/C,eAAe,EAAE,SAAS,CAAC;IAC3B,0CAA0C;IAC1C,mBAAmB,EAAE,SAAS,CAAC;IAC/B,mDAAmD;IACnD,mBAAmB,EAAE,SAAS,CAAC;IAC/B,4CAA4C;IAC5C,oBAAoB,EAAE,SAAS,CAAC;IAChC,wCAAwC;IACxC,qBA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;AAEzC,+BAA+B;AAC/B,eAAO,MAAM,MAAM;;;;;;;;;;;;;CAIT,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -6,6 +6,8 @@ export const MAINNET_CONFIG = {
|
|
|
6
6
|
liquidFeesProgramId: new PublicKey("FeesZQLb1xTeZbvaFRGnqzrZYzzmQtwhTYKQphbNGQru"),
|
|
7
7
|
liquidStateProgramId: new PublicKey("State3HtEfi7cXdsTpAtRoBvrij8zSFCiGTAVWmYH2d"),
|
|
8
8
|
liquidEventsProgramId: new PublicKey("EventsQeXA43nLKR69DhHwNsJ6aM512AweMCgG3wG8zG"),
|
|
9
|
+
swapLut: new PublicKey("KeNubFgNenQVUQe1Z2Rmov4vEAsjk3mUKaR3jvhL4CG"),
|
|
10
|
+
liquidLut: new PublicKey("3R3hdXsDiYcJqoy5rkFGwj5YzxT3yaWF9BxeaDgjVBd7"),
|
|
9
11
|
};
|
|
10
12
|
/** Devnet program IDs (liquid differs, others same as mainnet) */
|
|
11
13
|
export const DEVNET_CONFIG = {
|
|
@@ -14,6 +16,8 @@ export const DEVNET_CONFIG = {
|
|
|
14
16
|
liquidFeesProgramId: new PublicKey("3iFrDQxt6ZQT5eTyoHSpdq9hpyj9QmXDjTNEopGYpvTh"),
|
|
15
17
|
liquidStateProgramId: new PublicKey("9ZcKPa3HAEVEKxwFX8fYD56ZJCKPEQgqjgr9rfUvtwKJ"),
|
|
16
18
|
liquidEventsProgramId: new PublicKey("Bast7hBDiqSsxiwEmqazwvPvXC3N4z8UQR5ZmkqXnCiY"),
|
|
19
|
+
swapLut: new PublicKey("6gzZxE1Ww89bnzZ5VQJm4XCxxkfqzQ1SHPVPzatirSvm"),
|
|
20
|
+
liquidLut: new PublicKey("oeNEhk9xzeXBPYEdtD6RZxotQP55Y63vpLH2zbdWyYu"),
|
|
17
21
|
};
|
|
18
22
|
/** Localnet program IDs (same as mainnet per Anchor.toml) */
|
|
19
23
|
export const LOCALNET_CONFIG = { ...MAINNET_CONFIG };
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAsB5C,0BAA0B;AAC1B,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC3C,eAAe,EAAE,IAAI,SAAS,CAC7B,6CAA6C,CAC7C;IACD,mBAAmB,EAAE,IAAI,SAAS,CACjC,6CAA6C,CAC7C;IACD,mBAAmB,EAAE,IAAI,SAAS,CACjC,8CAA8C,CAC9C;IACD,oBAAoB,EAAE,IAAI,SAAS,CAClC,6CAA6C,CAC7C;IACD,qBAAqB,EAAE,IAAI,SAAS,CACnC,8CAA8C,CAC9C;IACD,OAAO,EAAE,IAAI,SAAS,CACrB,6CAA6C,CAC7C;IACD,SAAS,EAAE,IAAI,SAAS,CACvB,8CAA8C,CAC9C;CACQ,CAAC;AAEX,kEAAkE;AAClE,MAAM,CAAC,MAAM,aAAa,GAAiB;IAC1C,eAAe,EAAE,IAAI,SAAS,CAC7B,8CAA8C,CAC9C;IACD,mBAAmB,EAAE,IAAI,SAAS,CACjC,8CAA8C,CAC9C;IACD,mBAAmB,EAAE,IAAI,SAAS,CACjC,8CAA8C,CAC9C;IACD,oBAAoB,EAAE,IAAI,SAAS,CAClC,8CAA8C,CAC9C;IACD,qBAAqB,EAAE,IAAI,SAAS,CACnC,8CAA8C,CAC9C;IACD,OAAO,EAAE,IAAI,SAAS,CACrB,8CAA8C,CAC9C;IACD,SAAS,EAAE,IAAI,SAAS,CACvB,6CAA6C,CAC7C;CACQ,CAAC;AAEX,6DAA6D;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAiB,EAAE,GAAG,cAAc,EAAW,CAAC;AAE5E,wBAAwB;AACxB,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,SAAS,CACrC,6CAA6C,CAC7C,CAAC;AAEF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,SAAS,CACpD,6CAA6C,CAC7C,CAAC;AAEF,+CAA+C;AAC/C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAM,CAAC;AAEtC,sCAAsC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,sCAAsC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC,mCAAmC;AACnC,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,uCAAuC;AACvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAEzC,uCAAuC;AACvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAEzC,uDAAuD;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAO,CAAC;AAEzC,+BAA+B;AAC/B,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IACzB,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAC3B,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE;CACjB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./helpers/index.js";
|
|
|
14
14
|
export * from "./events/index.js";
|
|
15
15
|
export * from "./transaction/index.js";
|
|
16
16
|
export * from "./oracle.js";
|
|
17
|
+
export * from "./lut.js";
|
|
17
18
|
export type { Liquid, LiquidSwap, LiquidFees, LiquidState, LiquidEvents, } from "./idl/index.js";
|
|
18
19
|
export { getLiquidProgram, getLiquidSwapProgram, getLiquidFeesProgram, getLiquidStateProgram, getLiquidEventsProgram, liquidIdl, liquidSwapIdl, liquidFeesIdl, liquidStateIdl, liquidEventsIdl, patchIdl, } from "./idl/index.js";
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE3D,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACN,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,GACN,MAAM,aAAa,CAAC;AAErB,YAAY,EACX,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,GACjB,MAAM,YAAY,CAAC;AAEpB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,yBAAyB,CAAC;AAExC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mBAAmB,CAAC;AAElC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,aAAa,CAAC;AAE5B,YAAY,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,QAAQ,GACR,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE3D,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACN,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,GACN,MAAM,aAAa,CAAC;AAErB,YAAY,EACX,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,GACjB,MAAM,YAAY,CAAC;AAEpB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,yBAAyB,CAAC;AAExC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mBAAmB,CAAC;AAElC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,aAAa,CAAC;AAE5B,cAAc,UAAU,CAAC;AAEzB,YAAY,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,QAAQ,GACR,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,5 +11,6 @@ export * from "./helpers/index.js";
|
|
|
11
11
|
export * from "./events/index.js";
|
|
12
12
|
export * from "./transaction/index.js";
|
|
13
13
|
export * from "./oracle.js";
|
|
14
|
+
export * from "./lut.js";
|
|
14
15
|
export { getLiquidProgram, getLiquidSwapProgram, getLiquidFeesProgram, getLiquidStateProgram, getLiquidEventsProgram, liquidIdl, liquidSwapIdl, liquidFeesIdl, liquidStateIdl, liquidEventsIdl, patchIdl, } from "./idl/index.js";
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG3D,OAAO,EACN,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,GACN,MAAM,aAAa,CAAC;AAqCrB,OAAO,EACN,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,GACjB,MAAM,YAAY,CAAC;AAEpB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,yBAAyB,CAAC;AAExC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mBAAmB,CAAC;AAElC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG3D,OAAO,EACN,cAAc,EACd,aAAa,EACb,eAAe,EACf,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,GACN,MAAM,aAAa,CAAC;AAqCrB,OAAO,EACN,OAAO,EACP,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,GACjB,MAAM,YAAY,CAAC;AAEpB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,yBAAyB,CAAC;AAExC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mBAAmB,CAAC;AAElC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,aAAa,CAAC;AAE5B,cAAc,UAAU,CAAC;AASzB,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,QAAQ,GACR,MAAM,gBAAgB,CAAC"}
|
package/dist/lut.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PublicKey, type Connection, type AddressLookupTableAccount } from "@solana/web3.js";
|
|
2
|
+
import { type LiquidConfig } from "./config.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the 15 account addresses for the liquid-swap global LUT.
|
|
5
|
+
*
|
|
6
|
+
* Programs (7): System, SPL Token, Token-2022, ATA, ComputeBudget, State, Events
|
|
7
|
+
* Swap PDAs (3): authority, global_config, cpi_authority
|
|
8
|
+
* State PDAs (3): global_amm_volume, cashback_config, state_events_cpi_authority
|
|
9
|
+
* Constants (2): WSOL mint, oracle price feed
|
|
10
|
+
*
|
|
11
|
+
* @param config - Liquid protocol configuration
|
|
12
|
+
* @param connection - Solana RPC connection (for fetching oracle price feed)
|
|
13
|
+
* @returns Array of 15 public keys to populate the LUT
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSwapLutAccounts(config: LiquidConfig, connection: Connection): Promise<PublicKey[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the 18 account addresses for the liquid (bonding curve) global LUT.
|
|
18
|
+
*
|
|
19
|
+
* Programs (9): System, SPL Token, Token-2022, ATA, ComputeBudget, State, Events, Fees, Swap
|
|
20
|
+
* Liquid PDAs (2): global_config, cpi_authority
|
|
21
|
+
* State PDAs (3): global_curve_volume, cashback_config, state_events_cpi_authority
|
|
22
|
+
* Swap PDAs for migration (3): amm_global_config, amm_authority, swap_cpi_authority
|
|
23
|
+
* Constants (1): WSOL mint
|
|
24
|
+
*
|
|
25
|
+
* @param config - Liquid protocol configuration
|
|
26
|
+
* @returns Array of 18 public keys to populate the LUT
|
|
27
|
+
*/
|
|
28
|
+
export declare function getLiquidLutAccounts(config: LiquidConfig): PublicKey[];
|
|
29
|
+
/**
|
|
30
|
+
* Fetches an Address Lookup Table account from the chain.
|
|
31
|
+
*
|
|
32
|
+
* @param connection - Solana RPC connection
|
|
33
|
+
* @param lutAddress - Address of the lookup table
|
|
34
|
+
* @returns The AddressLookupTableAccount, or null if not found
|
|
35
|
+
*/
|
|
36
|
+
export declare function fetchLut(connection: Connection, lutAddress: PublicKey): Promise<AddressLookupTableAccount | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates instructions to create and extend an Address Lookup Table.
|
|
39
|
+
*
|
|
40
|
+
* @param authority - The LUT authority (usually admin keypair)
|
|
41
|
+
* @param payer - The rent payer
|
|
42
|
+
* @param accounts - The accounts to add to the LUT
|
|
43
|
+
* @param recentSlot - A recent slot for LUT derivation
|
|
44
|
+
* @returns The LUT address and the create + extend instructions
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildCreateLutInstructions(authority: PublicKey, payer: PublicKey, accounts: PublicKey[], recentSlot: number): {
|
|
47
|
+
lutAddress: PublicKey;
|
|
48
|
+
instructions: import("@solana/web3.js").TransactionInstruction[];
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=lut.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lut.d.ts","sourceRoot":"","sources":["../src/lut.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,SAAS,EAET,KAAK,UAAU,EACf,KAAK,yBAAyB,EAC9B,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,aAAa,CAAC;AA0B3D;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqCtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,EAAE,CA2CtE;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC7B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,SAAS,GACnB,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAG3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACzC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,SAAS,EAAE,EACrB,UAAU,EAAE,MAAM;;;EAgBlB"}
|
package/dist/lut.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { AddressLookupTableProgram, ComputeBudgetProgram, PublicKey, SystemProgram, } from "@solana/web3.js";
|
|
2
|
+
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, } from "@solana/spl-token";
|
|
3
|
+
import { WSOL_MINT } from "./config.js";
|
|
4
|
+
import { getSwapAuthorityPDA, getSwapGlobalConfigPDA, } from "./pda/liquid-swap.js";
|
|
5
|
+
import { getGlobalAmmVolumePDA, getGlobalCurveVolumePDA, getCashbackConfigPDA, } from "./pda/liquid-state.js";
|
|
6
|
+
import { getLiquidGlobalConfigPDA } from "./pda/liquid.js";
|
|
7
|
+
import { fetchAmmConfig } from "./accounts/liquid-swap.js";
|
|
8
|
+
const SEED_CPI_AUTHORITY = Buffer.from("cpi_authority");
|
|
9
|
+
/**
|
|
10
|
+
* Derives the CPI authority PDA for a given program.
|
|
11
|
+
*/
|
|
12
|
+
function getCpiAuthorityPDA(programId) {
|
|
13
|
+
const [pda] = PublicKey.findProgramAddressSync([SEED_CPI_AUTHORITY], programId);
|
|
14
|
+
return pda;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the 15 account addresses for the liquid-swap global LUT.
|
|
18
|
+
*
|
|
19
|
+
* Programs (7): System, SPL Token, Token-2022, ATA, ComputeBudget, State, Events
|
|
20
|
+
* Swap PDAs (3): authority, global_config, cpi_authority
|
|
21
|
+
* State PDAs (3): global_amm_volume, cashback_config, state_events_cpi_authority
|
|
22
|
+
* Constants (2): WSOL mint, oracle price feed
|
|
23
|
+
*
|
|
24
|
+
* @param config - Liquid protocol configuration
|
|
25
|
+
* @param connection - Solana RPC connection (for fetching oracle price feed)
|
|
26
|
+
* @returns Array of 15 public keys to populate the LUT
|
|
27
|
+
*/
|
|
28
|
+
export async function getSwapLutAccounts(config, connection) {
|
|
29
|
+
const ammConfig = await fetchAmmConfig(connection, config);
|
|
30
|
+
const oraclePriceFeed = ammConfig.oraclePriceFeed;
|
|
31
|
+
const [swapAuthority] = getSwapAuthorityPDA(config.liquidSwapProgramId);
|
|
32
|
+
const [swapGlobalConfig] = getSwapGlobalConfigPDA(config.liquidSwapProgramId);
|
|
33
|
+
const swapCpiAuthority = getCpiAuthorityPDA(config.liquidSwapProgramId);
|
|
34
|
+
const [globalAmmVolume] = getGlobalAmmVolumePDA(config.liquidStateProgramId);
|
|
35
|
+
const [cashbackConfig] = getCashbackConfigPDA(config.liquidStateProgramId);
|
|
36
|
+
const stateCpiAuthority = getCpiAuthorityPDA(config.liquidStateProgramId);
|
|
37
|
+
return [
|
|
38
|
+
// Programs
|
|
39
|
+
SystemProgram.programId,
|
|
40
|
+
TOKEN_PROGRAM_ID,
|
|
41
|
+
TOKEN_2022_PROGRAM_ID,
|
|
42
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
43
|
+
ComputeBudgetProgram.programId,
|
|
44
|
+
config.liquidStateProgramId,
|
|
45
|
+
config.liquidEventsProgramId,
|
|
46
|
+
// Swap global PDAs
|
|
47
|
+
swapAuthority,
|
|
48
|
+
swapGlobalConfig,
|
|
49
|
+
swapCpiAuthority,
|
|
50
|
+
// State global PDAs
|
|
51
|
+
globalAmmVolume,
|
|
52
|
+
cashbackConfig,
|
|
53
|
+
stateCpiAuthority,
|
|
54
|
+
// Constants
|
|
55
|
+
WSOL_MINT,
|
|
56
|
+
oraclePriceFeed,
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the 18 account addresses for the liquid (bonding curve) global LUT.
|
|
61
|
+
*
|
|
62
|
+
* Programs (9): System, SPL Token, Token-2022, ATA, ComputeBudget, State, Events, Fees, Swap
|
|
63
|
+
* Liquid PDAs (2): global_config, cpi_authority
|
|
64
|
+
* State PDAs (3): global_curve_volume, cashback_config, state_events_cpi_authority
|
|
65
|
+
* Swap PDAs for migration (3): amm_global_config, amm_authority, swap_cpi_authority
|
|
66
|
+
* Constants (1): WSOL mint
|
|
67
|
+
*
|
|
68
|
+
* @param config - Liquid protocol configuration
|
|
69
|
+
* @returns Array of 18 public keys to populate the LUT
|
|
70
|
+
*/
|
|
71
|
+
export function getLiquidLutAccounts(config) {
|
|
72
|
+
const [liquidGlobalConfig] = getLiquidGlobalConfigPDA(config.liquidProgramId);
|
|
73
|
+
const liquidCpiAuthority = getCpiAuthorityPDA(config.liquidProgramId);
|
|
74
|
+
const [globalCurveVolume] = getGlobalCurveVolumePDA(config.liquidStateProgramId);
|
|
75
|
+
const [cashbackConfig] = getCashbackConfigPDA(config.liquidStateProgramId);
|
|
76
|
+
const stateCpiAuthority = getCpiAuthorityPDA(config.liquidStateProgramId);
|
|
77
|
+
const [swapGlobalConfig] = getSwapGlobalConfigPDA(config.liquidSwapProgramId);
|
|
78
|
+
const [swapAuthority] = getSwapAuthorityPDA(config.liquidSwapProgramId);
|
|
79
|
+
const swapCpiAuthority = getCpiAuthorityPDA(config.liquidSwapProgramId);
|
|
80
|
+
return [
|
|
81
|
+
// Programs
|
|
82
|
+
SystemProgram.programId,
|
|
83
|
+
TOKEN_PROGRAM_ID,
|
|
84
|
+
TOKEN_2022_PROGRAM_ID,
|
|
85
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
86
|
+
ComputeBudgetProgram.programId,
|
|
87
|
+
config.liquidStateProgramId,
|
|
88
|
+
config.liquidEventsProgramId,
|
|
89
|
+
config.liquidFeesProgramId,
|
|
90
|
+
config.liquidSwapProgramId,
|
|
91
|
+
// Liquid global PDAs
|
|
92
|
+
liquidGlobalConfig,
|
|
93
|
+
liquidCpiAuthority,
|
|
94
|
+
// State global PDAs
|
|
95
|
+
globalCurveVolume,
|
|
96
|
+
cashbackConfig,
|
|
97
|
+
stateCpiAuthority,
|
|
98
|
+
// Swap PDAs (for migration CPI)
|
|
99
|
+
swapGlobalConfig,
|
|
100
|
+
swapAuthority,
|
|
101
|
+
swapCpiAuthority,
|
|
102
|
+
// Constants
|
|
103
|
+
WSOL_MINT,
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Fetches an Address Lookup Table account from the chain.
|
|
108
|
+
*
|
|
109
|
+
* @param connection - Solana RPC connection
|
|
110
|
+
* @param lutAddress - Address of the lookup table
|
|
111
|
+
* @returns The AddressLookupTableAccount, or null if not found
|
|
112
|
+
*/
|
|
113
|
+
export async function fetchLut(connection, lutAddress) {
|
|
114
|
+
const result = await connection.getAddressLookupTable(lutAddress);
|
|
115
|
+
return result.value;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Creates instructions to create and extend an Address Lookup Table.
|
|
119
|
+
*
|
|
120
|
+
* @param authority - The LUT authority (usually admin keypair)
|
|
121
|
+
* @param payer - The rent payer
|
|
122
|
+
* @param accounts - The accounts to add to the LUT
|
|
123
|
+
* @param recentSlot - A recent slot for LUT derivation
|
|
124
|
+
* @returns The LUT address and the create + extend instructions
|
|
125
|
+
*/
|
|
126
|
+
export function buildCreateLutInstructions(authority, payer, accounts, recentSlot) {
|
|
127
|
+
const [createIx, lutAddress] = AddressLookupTableProgram.createLookupTable({
|
|
128
|
+
authority,
|
|
129
|
+
payer,
|
|
130
|
+
recentSlot,
|
|
131
|
+
});
|
|
132
|
+
const extendIx = AddressLookupTableProgram.extendLookupTable({
|
|
133
|
+
payer,
|
|
134
|
+
authority,
|
|
135
|
+
lookupTable: lutAddress,
|
|
136
|
+
addresses: accounts,
|
|
137
|
+
});
|
|
138
|
+
return { lutAddress, instructions: [createIx, extendIx] };
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=lut.js.map
|
package/dist/lut.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lut.js","sourceRoot":"","sources":["../src/lut.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,yBAAyB,EACzB,oBAAoB,EACpB,SAAS,EACT,aAAa,GAGb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,2BAA2B,EAC3B,qBAAqB,EACrB,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAqB,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACN,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAExD;;GAEG;AACH,S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,UAAU,CAAC,CAAC;IAClE,OAAO,MAAM,CAAC,KAAK,CAAC;AACrB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACzC,SAAoB,EACpB,KAAgB,EAChB,QAAqB,EACrB,UAAkB;IAElB,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,yBAAyB,CAAC,iBAAiB,CAAC;QAC1E,SAAS;QACT,KAAK;QACL,UAAU;KACV,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,yBAAyB,CAAC,iBAAiB,CAAC;QAC5D,KAAK;QACL,SAAS;QACT,WAAW,EAAE,UAAU;QACvB,SAAS,EAAE,QAAQ;KACnB,CAAC,CAAC;IAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;AAC3D,CAAC"}
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -14,6 +14,10 @@ export interface LiquidConfig {
|
|
|
14
14
|
liquidStateProgramId: PublicKey;
|
|
15
15
|
/** Program ID for the events program */
|
|
16
16
|
liquidEventsProgramId: PublicKey;
|
|
17
|
+
/** Address lookup table for liquid-swap transactions */
|
|
18
|
+
swapLut: PublicKey;
|
|
19
|
+
/** Address lookup table for liquid (bonding curve) transactions */
|
|
20
|
+
liquidLut: PublicKey;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
/** Mainnet program IDs */
|
|
@@ -33,6 +37,12 @@ export const MAINNET_CONFIG: LiquidConfig = {
|
|
|
33
37
|
liquidEventsProgramId: new PublicKey(
|
|
34
38
|
"EventsQeXA43nLKR69DhHwNsJ6aM512AweMCgG3wG8zG",
|
|
35
39
|
),
|
|
40
|
+
swapLut: new PublicKey(
|
|
41
|
+
"KeNubFgNenQVUQe1Z2Rmov4vEAsjk3mUKaR3jvhL4CG"
|
|
42
|
+
),
|
|
43
|
+
liquidLut: new PublicKey(
|
|
44
|
+
"3R3hdXsDiYcJqoy5rkFGwj5YzxT3yaWF9BxeaDgjVBd7"
|
|
45
|
+
),
|
|
36
46
|
} as const;
|
|
37
47
|
|
|
38
48
|
/** Devnet program IDs (liquid differs, others same as mainnet) */
|
|
@@ -52,6 +62,12 @@ export const DEVNET_CONFIG: LiquidConfig = {
|
|
|
52
62
|
liquidEventsProgramId: new PublicKey(
|
|
53
63
|
"Bast7hBDiqSsxiwEmqazwvPvXC3N4z8UQR5ZmkqXnCiY",
|
|
54
64
|
),
|
|
65
|
+
swapLut: new PublicKey(
|
|
66
|
+
"6gzZxE1Ww89bnzZ5VQJm4XCxxkfqzQ1SHPVPzatirSvm"
|
|
67
|
+
),
|
|
68
|
+
liquidLut: new PublicKey(
|
|
69
|
+
"oeNEhk9xzeXBPYEdtD6RZxotQP55Y63vpLH2zbdWyYu"
|
|
70
|
+
),
|
|
55
71
|
} as const;
|
|
56
72
|
|
|
57
73
|
/** Localnet program IDs (same as mainnet per Anchor.toml) */
|
package/src/index.ts
CHANGED
package/src/lut.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddressLookupTableProgram,
|
|
3
|
+
ComputeBudgetProgram,
|
|
4
|
+
PublicKey,
|
|
5
|
+
SystemProgram,
|
|
6
|
+
type Connection,
|
|
7
|
+
type AddressLookupTableAccount,
|
|
8
|
+
} from "@solana/web3.js";
|
|
9
|
+
import {
|
|
10
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
11
|
+
TOKEN_2022_PROGRAM_ID,
|
|
12
|
+
TOKEN_PROGRAM_ID,
|
|
13
|
+
} from "@solana/spl-token";
|
|
14
|
+
import { type LiquidConfig, WSOL_MINT } from "./config.js";
|
|
15
|
+
import {
|
|
16
|
+
getSwapAuthorityPDA,
|
|
17
|
+
getSwapGlobalConfigPDA,
|
|
18
|
+
} from "./pda/liquid-swap.js";
|
|
19
|
+
import {
|
|
20
|
+
getGlobalAmmVolumePDA,
|
|
21
|
+
getGlobalCurveVolumePDA,
|
|
22
|
+
getCashbackConfigPDA,
|
|
23
|
+
} from "./pda/liquid-state.js";
|
|
24
|
+
import { getLiquidGlobalConfigPDA } from "./pda/liquid.js";
|
|
25
|
+
import { fetchAmmConfig } from "./accounts/liquid-swap.js";
|
|
26
|
+
|
|
27
|
+
const SEED_CPI_AUTHORITY = Buffer.from("cpi_authority");
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Derives the CPI authority PDA for a given program.
|
|
31
|
+
*/
|
|
32
|
+
function getCpiAuthorityPDA(programId: PublicKey): PublicKey {
|
|
33
|
+
const [pda] = PublicKey.findProgramAddressSync(
|
|
34
|
+
[SEED_CPI_AUTHORITY],
|
|
35
|
+
programId,
|
|
36
|
+
);
|
|
37
|
+
return pda;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the 15 account addresses for the liquid-swap global LUT.
|
|
42
|
+
*
|
|
43
|
+
* Programs (7): System, SPL Token, Token-2022, ATA, ComputeBudget, State, Events
|
|
44
|
+
* Swap PDAs (3): authority, global_config, cpi_authority
|
|
45
|
+
* State PDAs (3): global_amm_volume, cashback_config, state_events_cpi_authority
|
|
46
|
+
* Constants (2): WSOL mint, oracle price feed
|
|
47
|
+
*
|
|
48
|
+
* @param config - Liquid protocol configuration
|
|
49
|
+
* @param connection - Solana RPC connection (for fetching oracle price feed)
|
|
50
|
+
* @returns Array of 15 public keys to populate the LUT
|
|
51
|
+
*/
|
|
52
|
+
export async function getSwapLutAccounts(
|
|
53
|
+
config: LiquidConfig,
|
|
54
|
+
connection: Connection,
|
|
55
|
+
): Promise<PublicKey[]> {
|
|
56
|
+
const ammConfig = await fetchAmmConfig(connection, config);
|
|
57
|
+
const oraclePriceFeed = ammConfig.oraclePriceFeed as PublicKey;
|
|
58
|
+
|
|
59
|
+
const [swapAuthority] = getSwapAuthorityPDA(config.liquidSwapProgramId);
|
|
60
|
+
const [swapGlobalConfig] = getSwapGlobalConfigPDA(
|
|
61
|
+
config.liquidSwapProgramId,
|
|
62
|
+
);
|
|
63
|
+
const swapCpiAuthority = getCpiAuthorityPDA(config.liquidSwapProgramId);
|
|
64
|
+
|
|
65
|
+
const [globalAmmVolume] = getGlobalAmmVolumePDA(
|
|
66
|
+
config.liquidStateProgramId,
|
|
67
|
+
);
|
|
68
|
+
const [cashbackConfig] = getCashbackConfigPDA(config.liquidStateProgramId);
|
|
69
|
+
const stateCpiAuthority = getCpiAuthorityPDA(config.liquidStateProgramId);
|
|
70
|
+
|
|
71
|
+
return [
|
|
72
|
+
// Programs
|
|
73
|
+
SystemProgram.programId,
|
|
74
|
+
TOKEN_PROGRAM_ID,
|
|
75
|
+
TOKEN_2022_PROGRAM_ID,
|
|
76
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
77
|
+
ComputeBudgetProgram.programId,
|
|
78
|
+
config.liquidStateProgramId,
|
|
79
|
+
config.liquidEventsProgramId,
|
|
80
|
+
// Swap global PDAs
|
|
81
|
+
swapAuthority,
|
|
82
|
+
swapGlobalConfig,
|
|
83
|
+
swapCpiAuthority,
|
|
84
|
+
// State global PDAs
|
|
85
|
+
globalAmmVolume,
|
|
86
|
+
cashbackConfig,
|
|
87
|
+
stateCpiAuthority,
|
|
88
|
+
// Constants
|
|
89
|
+
WSOL_MINT,
|
|
90
|
+
oraclePriceFeed,
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Returns the 18 account addresses for the liquid (bonding curve) global LUT.
|
|
96
|
+
*
|
|
97
|
+
* Programs (9): System, SPL Token, Token-2022, ATA, ComputeBudget, State, Events, Fees, Swap
|
|
98
|
+
* Liquid PDAs (2): global_config, cpi_authority
|
|
99
|
+
* State PDAs (3): global_curve_volume, cashback_config, state_events_cpi_authority
|
|
100
|
+
* Swap PDAs for migration (3): amm_global_config, amm_authority, swap_cpi_authority
|
|
101
|
+
* Constants (1): WSOL mint
|
|
102
|
+
*
|
|
103
|
+
* @param config - Liquid protocol configuration
|
|
104
|
+
* @returns Array of 18 public keys to populate the LUT
|
|
105
|
+
*/
|
|
106
|
+
export function getLiquidLutAccounts(config: LiquidConfig): PublicKey[] {
|
|
107
|
+
const [liquidGlobalConfig] = getLiquidGlobalConfigPDA(
|
|
108
|
+
config.liquidProgramId,
|
|
109
|
+
);
|
|
110
|
+
const liquidCpiAuthority = getCpiAuthorityPDA(config.liquidProgramId);
|
|
111
|
+
|
|
112
|
+
const [globalCurveVolume] = getGlobalCurveVolumePDA(
|
|
113
|
+
config.liquidStateProgramId,
|
|
114
|
+
);
|
|
115
|
+
const [cashbackConfig] = getCashbackConfigPDA(config.liquidStateProgramId);
|
|
116
|
+
const stateCpiAuthority = getCpiAuthorityPDA(config.liquidStateProgramId);
|
|
117
|
+
|
|
118
|
+
const [swapGlobalConfig] = getSwapGlobalConfigPDA(
|
|
119
|
+
config.liquidSwapProgramId,
|
|
120
|
+
);
|
|
121
|
+
const [swapAuthority] = getSwapAuthorityPDA(config.liquidSwapProgramId);
|
|
122
|
+
const swapCpiAuthority = getCpiAuthorityPDA(config.liquidSwapProgramId);
|
|
123
|
+
|
|
124
|
+
return [
|
|
125
|
+
// Programs
|
|
126
|
+
SystemProgram.programId,
|
|
127
|
+
TOKEN_PROGRAM_ID,
|
|
128
|
+
TOKEN_2022_PROGRAM_ID,
|
|
129
|
+
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
130
|
+
ComputeBudgetProgram.programId,
|
|
131
|
+
config.liquidStateProgramId,
|
|
132
|
+
config.liquidEventsProgramId,
|
|
133
|
+
config.liquidFeesProgramId,
|
|
134
|
+
config.liquidSwapProgramId,
|
|
135
|
+
// Liquid global PDAs
|
|
136
|
+
liquidGlobalConfig,
|
|
137
|
+
liquidCpiAuthority,
|
|
138
|
+
// State global PDAs
|
|
139
|
+
globalCurveVolume,
|
|
140
|
+
cashbackConfig,
|
|
141
|
+
stateCpiAuthority,
|
|
142
|
+
// Swap PDAs (for migration CPI)
|
|
143
|
+
swapGlobalConfig,
|
|
144
|
+
swapAuthority,
|
|
145
|
+
swapCpiAuthority,
|
|
146
|
+
// Constants
|
|
147
|
+
WSOL_MINT,
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Fetches an Address Lookup Table account from the chain.
|
|
153
|
+
*
|
|
154
|
+
* @param connection - Solana RPC connection
|
|
155
|
+
* @param lutAddress - Address of the lookup table
|
|
156
|
+
* @returns The AddressLookupTableAccount, or null if not found
|
|
157
|
+
*/
|
|
158
|
+
export async function fetchLut(
|
|
159
|
+
connection: Connection,
|
|
160
|
+
lutAddress: PublicKey,
|
|
161
|
+
): Promise<AddressLookupTableAccount | null> {
|
|
162
|
+
const result = await connection.getAddressLookupTable(lutAddress);
|
|
163
|
+
return result.value;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Creates instructions to create and extend an Address Lookup Table.
|
|
168
|
+
*
|
|
169
|
+
* @param authority - The LUT authority (usually admin keypair)
|
|
170
|
+
* @param payer - The rent payer
|
|
171
|
+
* @param accounts - The accounts to add to the LUT
|
|
172
|
+
* @param recentSlot - A recent slot for LUT derivation
|
|
173
|
+
* @returns The LUT address and the create + extend instructions
|
|
174
|
+
*/
|
|
175
|
+
export function buildCreateLutInstructions(
|
|
176
|
+
authority: PublicKey,
|
|
177
|
+
payer: PublicKey,
|
|
178
|
+
accounts: PublicKey[],
|
|
179
|
+
recentSlot: number,
|
|
180
|
+
) {
|
|
181
|
+
const [createIx, lutAddress] = AddressLookupTableProgram.createLookupTable({
|
|
182
|
+
authority,
|
|
183
|
+
payer,
|
|
184
|
+
recentSlot,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const extendIx = AddressLookupTableProgram.extendLookupTable({
|
|
188
|
+
payer,
|
|
189
|
+
authority,
|
|
190
|
+
lookupTable: lutAddress,
|
|
191
|
+
addresses: accounts,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return { lutAddress, instructions: [createIx, extendIx] };
|
|
195
|
+
}
|