@liquid-af/sdk 0.2.0 → 0.3.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.
- package/dist/accounts/liquid-swap.d.ts +2 -0
- package/dist/accounts/liquid-swap.d.ts.map +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/helpers/preview.js.map +1 -1
- package/dist/idl/index.d.ts +1 -0
- package/dist/idl/index.d.ts.map +1 -1
- package/dist/idl/index.js +15 -4
- package/dist/idl/index.js.map +1 -1
- package/dist/idl/liquid.d.ts +1359 -1359
- package/dist/idl/liquid.d.ts.map +1 -1
- package/dist/idl/liquid.json +1359 -1359
- package/dist/idl/liquid_fees.d.ts +1 -1
- package/dist/idl/liquid_fees.json +1 -1
- package/dist/idl/liquid_state.d.ts +62 -62
- package/dist/idl/liquid_state.d.ts.map +1 -1
- package/dist/idl/liquid_state.json +62 -62
- package/dist/idl/liquid_swap.d.ts +597 -494
- package/dist/idl/liquid_swap.d.ts.map +1 -1
- package/dist/idl/liquid_swap.json +597 -494
- package/dist/idl/patch-idl.d.ts +10 -0
- package/dist/idl/patch-idl.d.ts.map +1 -0
- package/dist/idl/patch-idl.js +62 -0
- package/dist/idl/patch-idl.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/instructions/program-cache.d.ts.map +1 -1
- package/dist/instructions/program-cache.js +10 -6
- package/dist/instructions/program-cache.js.map +1 -1
- package/package.json +4 -4
- package/src/accounts/liquid-fees.ts +2 -2
- package/src/accounts/liquid-state.ts +7 -7
- package/src/accounts/liquid-swap.ts +4 -4
- package/src/accounts/liquid.ts +6 -6
- package/src/client.ts +31 -31
- package/src/config.ts +10 -10
- package/src/errors.ts +6 -6
- package/src/events/parser.ts +5 -5
- package/src/helpers/preview.ts +31 -31
- package/src/helpers/user.ts +1 -1
- package/src/idl/index.ts +31 -8
- package/src/idl/liquid.json +1359 -1359
- package/src/idl/liquid.ts +1359 -1359
- package/src/idl/liquid_fees.json +1 -1
- package/src/idl/liquid_fees.ts +1 -1
- package/src/idl/liquid_state.json +62 -62
- package/src/idl/liquid_state.ts +62 -62
- package/src/idl/liquid_swap.json +597 -494
- package/src/idl/liquid_swap.ts +597 -494
- package/src/idl/patch-idl.ts +80 -0
- package/src/index.ts +1 -0
- package/src/instructions/liquid-fees.ts +14 -14
- package/src/instructions/liquid-state.ts +4 -4
- package/src/instructions/liquid-swap.ts +18 -18
- package/src/instructions/liquid.ts +47 -47
- package/src/instructions/program-cache.ts +18 -9
- package/src/math/amm.ts +3 -3
- package/src/math/bonding-curve.ts +6 -6
- package/src/math/fees.ts +9 -9
- package/src/math/tiered-fees.ts +5 -5
- package/src/oracle.ts +3 -3
- package/src/pda/index.ts +27 -27
- package/src/pda/liquid-fees.ts +6 -6
- package/src/pda/liquid-state.ts +13 -13
- package/src/pda/liquid-swap.ts +16 -16
- package/src/pda/liquid.ts +15 -15
- package/src/provider.ts +2 -2
- package/src/transaction/builder.ts +4 -4
- package/src/transaction/send.ts +4 -4
- package/src/types.ts +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type LiquidConfig } from "../config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Deep-patches an Anchor IDL JSON object, replacing all embedded mainnet
|
|
4
|
+
* program addresses (both string and byte-array forms) with the addresses
|
|
5
|
+
* from the provided config.
|
|
6
|
+
*
|
|
7
|
+
* Returns the original IDL unchanged if config matches mainnet.
|
|
8
|
+
*/
|
|
9
|
+
export declare function patchIdl<T extends Record<string, unknown>>(idl: T, config: LiquidConfig): T;
|
|
10
|
+
//# sourceMappingURL=patch-idl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-idl.d.ts","sourceRoot":"","sources":["../../src/idl/patch-idl.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAwDjE;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,GAAG,EAAE,CAAC,EACN,MAAM,EAAE,YAAY,GAClB,CAAC,CAYH"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { MAINNET_CONFIG } from "../config.js";
|
|
2
|
+
function buildReplacementMap(config) {
|
|
3
|
+
const pairs = [
|
|
4
|
+
[MAINNET_CONFIG.liquidProgramId, config.liquidProgramId],
|
|
5
|
+
[MAINNET_CONFIG.liquidSwapProgramId, config.liquidSwapProgramId],
|
|
6
|
+
[MAINNET_CONFIG.liquidFeesProgramId, config.liquidFeesProgramId],
|
|
7
|
+
[MAINNET_CONFIG.liquidStateProgramId, config.liquidStateProgramId],
|
|
8
|
+
];
|
|
9
|
+
return pairs
|
|
10
|
+
.filter(([mainnet, target]) => !mainnet.equals(target))
|
|
11
|
+
.map(([mainnet, target]) => ({
|
|
12
|
+
mainnetAddress: mainnet.toBase58(),
|
|
13
|
+
mainnetBytes: Array.from(mainnet.toBytes()),
|
|
14
|
+
targetAddress: target.toBase58(),
|
|
15
|
+
targetBytes: Array.from(target.toBytes()),
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
function deepPatch(node, stringMap, byteMap) {
|
|
19
|
+
if (node === null || node === undefined)
|
|
20
|
+
return node;
|
|
21
|
+
if (typeof node !== "object")
|
|
22
|
+
return node;
|
|
23
|
+
if (Array.isArray(node)) {
|
|
24
|
+
if (node.length === 32 && typeof node[0] === "number") {
|
|
25
|
+
const key = JSON.stringify(node);
|
|
26
|
+
const replacement = byteMap.get(key);
|
|
27
|
+
if (replacement)
|
|
28
|
+
return replacement;
|
|
29
|
+
}
|
|
30
|
+
return node.map((item) => deepPatch(item, stringMap, byteMap));
|
|
31
|
+
}
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const [key, value] of Object.entries(node)) {
|
|
34
|
+
if (key === "address" && typeof value === "string") {
|
|
35
|
+
result[key] = stringMap.get(value) ?? value;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
result[key] = deepPatch(value, stringMap, byteMap);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Deep-patches an Anchor IDL JSON object, replacing all embedded mainnet
|
|
45
|
+
* program addresses (both string and byte-array forms) with the addresses
|
|
46
|
+
* from the provided config.
|
|
47
|
+
*
|
|
48
|
+
* Returns the original IDL unchanged if config matches mainnet.
|
|
49
|
+
*/
|
|
50
|
+
export function patchIdl(idl, config) {
|
|
51
|
+
const replacements = buildReplacementMap(config);
|
|
52
|
+
if (replacements.length === 0)
|
|
53
|
+
return idl;
|
|
54
|
+
const stringMap = new Map();
|
|
55
|
+
const byteMap = new Map();
|
|
56
|
+
for (const r of replacements) {
|
|
57
|
+
stringMap.set(r.mainnetAddress, r.targetAddress);
|
|
58
|
+
byteMap.set(JSON.stringify(r.mainnetBytes), r.targetBytes);
|
|
59
|
+
}
|
|
60
|
+
return deepPatch(idl, stringMap, byteMap);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=patch-idl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-idl.js","sourceRoot":"","sources":["../../src/idl/patch-idl.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ export * from "./events/index.js";
|
|
|
15
15
|
export * from "./transaction/index.js";
|
|
16
16
|
export * from "./oracle.js";
|
|
17
17
|
export type { Liquid, LiquidSwap, LiquidFees, LiquidState, } from "./idl/index.js";
|
|
18
|
-
export { getLiquidProgram, getLiquidSwapProgram, getLiquidFeesProgram, getLiquidStateProgram, liquidIdl, liquidSwapIdl, liquidFeesIdl, liquidStateIdl, } from "./idl/index.js";
|
|
18
|
+
export { getLiquidProgram, getLiquidSwapProgram, getLiquidFeesProgram, getLiquidStateProgram, liquidIdl, liquidSwapIdl, liquidFeesIdl, liquidStateIdl, patchIdl, } from "./idl/index.js";
|
|
19
19
|
//# 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,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,aAAa,EACb,aAAa,EACb,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,YAAY,EACX,MAAM,EACN,UAAU,EACV,UAAU,EACV,WAAW,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,QAAQ,GACR,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,5 +11,5 @@ 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 { getLiquidProgram, getLiquidSwapProgram, getLiquidFeesProgram, getLiquidStateProgram, liquidIdl, liquidSwapIdl, liquidFeesIdl, liquidStateIdl, } from "./idl/index.js";
|
|
14
|
+
export { getLiquidProgram, getLiquidSwapProgram, getLiquidFeesProgram, getLiquidStateProgram, liquidIdl, liquidSwapIdl, liquidFeesIdl, liquidStateIdl, patchIdl, } from "./idl/index.js";
|
|
15
15
|
//# 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;AAQ5B,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,aAAa,EACb,aAAa,EACb,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;AAQ5B,OAAO,EACN,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,QAAQ,GACR,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program-cache.d.ts","sourceRoot":"","sources":["../../src/instructions/program-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"program-cache.d.ts","sourceRoot":"","sources":["../../src/instructions/program-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AASjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAqC1D;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,UAAU,CAAC,CAOrB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,UAAU,CAAC,CAOrB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,WAAW,CAAC,CAOtB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Program } from "@coral-xyz/anchor";
|
|
2
2
|
import { createStubProvider } from "../provider.js";
|
|
3
|
+
import { patchIdl } from "../idl/patch-idl.js";
|
|
3
4
|
import liquidIdl from "../idl/liquid.json" with { type: "json" };
|
|
4
5
|
import liquidSwapIdl from "../idl/liquid_swap.json" with { type: "json" };
|
|
5
6
|
import liquidFeesIdl from "../idl/liquid_fees.json" with { type: "json" };
|
|
@@ -13,17 +14,20 @@ import liquidStateIdl from "../idl/liquid_state.json" with { type: "json" };
|
|
|
13
14
|
const cache = new Map();
|
|
14
15
|
/**
|
|
15
16
|
* Returns a cached Program instance or creates one if it doesn't exist.
|
|
17
|
+
* Deep-patches the IDL to replace all embedded mainnet program addresses
|
|
18
|
+
* with the addresses from the provided config.
|
|
16
19
|
*
|
|
17
20
|
* @param key - Cache key prefix (e.g., "liquid", "swap")
|
|
18
21
|
* @param idl - Raw IDL JSON object
|
|
19
22
|
* @param address - Program address as a base58 string
|
|
23
|
+
* @param config - Liquid protocol configuration
|
|
20
24
|
* @returns Cached or newly created Program instance
|
|
21
25
|
*/
|
|
22
|
-
function getOrCreate(key, idl, address) {
|
|
26
|
+
function getOrCreate(key, idl, address, config) {
|
|
23
27
|
const cacheKey = `${key}:${address}`;
|
|
24
28
|
let prog = cache.get(cacheKey);
|
|
25
29
|
if (!prog) {
|
|
26
|
-
const patchedIdl = { ...idl, address };
|
|
30
|
+
const patchedIdl = patchIdl({ ...idl, address }, config);
|
|
27
31
|
prog = new Program(patchedIdl, createStubProvider());
|
|
28
32
|
cache.set(cacheKey, prog);
|
|
29
33
|
}
|
|
@@ -36,7 +40,7 @@ function getOrCreate(key, idl, address) {
|
|
|
36
40
|
* @returns Cached Program instance typed as Liquid
|
|
37
41
|
*/
|
|
38
42
|
export function getCachedLiquidProgram(config) {
|
|
39
|
-
return getOrCreate("liquid", liquidIdl, config.liquidProgramId.toBase58());
|
|
43
|
+
return getOrCreate("liquid", liquidIdl, config.liquidProgramId.toBase58(), config);
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* Returns a cached Liquid Swap AMM program instance for instruction building.
|
|
@@ -45,7 +49,7 @@ export function getCachedLiquidProgram(config) {
|
|
|
45
49
|
* @returns Cached Program instance typed as LiquidSwap
|
|
46
50
|
*/
|
|
47
51
|
export function getCachedSwapProgram(config) {
|
|
48
|
-
return getOrCreate("swap", liquidSwapIdl, config.liquidSwapProgramId.toBase58());
|
|
52
|
+
return getOrCreate("swap", liquidSwapIdl, config.liquidSwapProgramId.toBase58(), config);
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Returns a cached Liquid Fees program instance for instruction building.
|
|
@@ -54,7 +58,7 @@ export function getCachedSwapProgram(config) {
|
|
|
54
58
|
* @returns Cached Program instance typed as LiquidFees
|
|
55
59
|
*/
|
|
56
60
|
export function getCachedFeesProgram(config) {
|
|
57
|
-
return getOrCreate("fees", liquidFeesIdl, config.liquidFeesProgramId.toBase58());
|
|
61
|
+
return getOrCreate("fees", liquidFeesIdl, config.liquidFeesProgramId.toBase58(), config);
|
|
58
62
|
}
|
|
59
63
|
/**
|
|
60
64
|
* Returns a cached Liquid State program instance for instruction building.
|
|
@@ -63,6 +67,6 @@ export function getCachedFeesProgram(config) {
|
|
|
63
67
|
* @returns Cached Program instance typed as LiquidState
|
|
64
68
|
*/
|
|
65
69
|
export function getCachedStateProgram(config) {
|
|
66
|
-
return getOrCreate("state", liquidStateIdl, config.liquidStateProgramId.toBase58());
|
|
70
|
+
return getOrCreate("state", liquidStateIdl, config.liquidStateProgramId.toBase58(), config);
|
|
67
71
|
}
|
|
68
72
|
//# sourceMappingURL=program-cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program-cache.js","sourceRoot":"","sources":["../../src/instructions/program-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"program-cache.js","sourceRoot":"","sources":["../../src/instructions/program-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,SAAS,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACjE,OAAO,aAAa,MAAM,yBAAyB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1E,OAAO,aAAa,MAAM,yBAAyB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1E,OAAO,cAAc,MAAM,0BAA0B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAO5E;;;;GAIG;AACH,8DAA8D;AAC9D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,SAAS,WAAW,CACnB,GAAW,EACX,GAA4B,EAC5B,OAAe,EACf,MAAoB;IAEpB,MAAM,QAAQ,GAAG,GAAG,GAAG,IAAI,OAAO,EAAE,CAAC;IACrC,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAA2B,CAAC;IACzD,IAAI,CAAC,IAAI,EAAE,CAAC;QACX,MAAM,UAAU,GAAG,QAAQ,CAAC,EAAE,GAAG,GAAG,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;QACzD,IAAI,GAAG,IAAI,OAAO,CAAC,UAAe,EAAE,kBAAkB,EAAE,CAAC,CAAC;QAC1D,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAoB;IAC1D,OAAO,WAAW,CACjB,QAAQ,EACR,SAAS,EACT,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,EACjC,MAAM,CACN,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CACnC,MAAoB;IAEpB,OAAO,WAAW,CACjB,MAAM,EACN,aAAa,EACb,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,EACrC,MAAM,CACN,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CACnC,MAAoB;IAEpB,OAAO,WAAW,CACjB,MAAM,EACN,aAAa,EACb,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,EACrC,MAAM,CACN,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACpC,MAAoB;IAEpB,OAAO,WAAW,CACjB,OAAO,EACP,cAAc,EACd,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EACtC,MAAM,CACN,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liquid-af/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "TypeScript SDK for the Liquid DeFi protocol on Solana",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
"prepack": "yarn build",
|
|
87
87
|
"prepublishOnly": "yarn test:build",
|
|
88
88
|
"test:build": "tsc --noEmit",
|
|
89
|
-
"version:patch": "
|
|
90
|
-
"version:minor": "
|
|
91
|
-
"version:major": "
|
|
89
|
+
"version:patch": "yarn version --patch --no-git-tag-version",
|
|
90
|
+
"version:minor": "yarn version --minor --no-git-tag-version",
|
|
91
|
+
"version:major": "yarn version --major --no-git-tag-version",
|
|
92
92
|
"docs": "typedoc",
|
|
93
93
|
"publish:test": "npm publish --dry-run",
|
|
94
94
|
"publish:prod": "npm publish"
|
|
@@ -14,7 +14,7 @@ import { getLiquidFeesProgram } from "../idl/index.js";
|
|
|
14
14
|
export async function fetchFeeConfig(
|
|
15
15
|
connection: Connection,
|
|
16
16
|
tokenMint: PublicKey,
|
|
17
|
-
config: LiquidConfig
|
|
17
|
+
config: LiquidConfig,
|
|
18
18
|
) {
|
|
19
19
|
const [pda] = getFeeConfigPDA(tokenMint, config.liquidFeesProgramId);
|
|
20
20
|
return fetchFeeConfigByAddress(connection, pda, config);
|
|
@@ -31,7 +31,7 @@ export async function fetchFeeConfig(
|
|
|
31
31
|
export async function fetchFeeConfigByAddress(
|
|
32
32
|
connection: Connection,
|
|
33
33
|
feeConfigAddress: PublicKey,
|
|
34
|
-
config: LiquidConfig
|
|
34
|
+
config: LiquidConfig,
|
|
35
35
|
) {
|
|
36
36
|
const program = getLiquidFeesProgram(connection, config);
|
|
37
37
|
return program.account.unifiedFeeConfiguration.fetch(feeConfigAddress);
|
|
@@ -22,7 +22,7 @@ import { getLiquidStateProgram } from "../idl/index.js";
|
|
|
22
22
|
export async function fetchUserProperties(
|
|
23
23
|
connection: Connection,
|
|
24
24
|
user: PublicKey,
|
|
25
|
-
config: LiquidConfig
|
|
25
|
+
config: LiquidConfig,
|
|
26
26
|
) {
|
|
27
27
|
const program = getLiquidStateProgram(connection, config);
|
|
28
28
|
const [pda] = getUserPropertiesPDA(user, config.liquidStateProgramId);
|
|
@@ -40,7 +40,7 @@ export async function fetchUserProperties(
|
|
|
40
40
|
export async function fetchTokenVolume(
|
|
41
41
|
connection: Connection,
|
|
42
42
|
mint: PublicKey,
|
|
43
|
-
config: LiquidConfig
|
|
43
|
+
config: LiquidConfig,
|
|
44
44
|
) {
|
|
45
45
|
const program = getLiquidStateProgram(connection, config);
|
|
46
46
|
const [pda] = getTokenVolumePDA(mint, config.liquidStateProgramId);
|
|
@@ -56,7 +56,7 @@ export async function fetchTokenVolume(
|
|
|
56
56
|
*/
|
|
57
57
|
export async function fetchGlobalCurveVolume(
|
|
58
58
|
connection: Connection,
|
|
59
|
-
config: LiquidConfig
|
|
59
|
+
config: LiquidConfig,
|
|
60
60
|
) {
|
|
61
61
|
const program = getLiquidStateProgram(connection, config);
|
|
62
62
|
const [pda] = getGlobalCurveVolumePDA(config.liquidStateProgramId);
|
|
@@ -72,7 +72,7 @@ export async function fetchGlobalCurveVolume(
|
|
|
72
72
|
*/
|
|
73
73
|
export async function fetchGlobalAmmVolume(
|
|
74
74
|
connection: Connection,
|
|
75
|
-
config: LiquidConfig
|
|
75
|
+
config: LiquidConfig,
|
|
76
76
|
) {
|
|
77
77
|
const program = getLiquidStateProgram(connection, config);
|
|
78
78
|
const [pda] = getGlobalAmmVolumePDA(config.liquidStateProgramId);
|
|
@@ -88,7 +88,7 @@ export async function fetchGlobalAmmVolume(
|
|
|
88
88
|
*/
|
|
89
89
|
export async function fetchCashbackConfig(
|
|
90
90
|
connection: Connection,
|
|
91
|
-
config: LiquidConfig
|
|
91
|
+
config: LiquidConfig,
|
|
92
92
|
) {
|
|
93
93
|
const program = getLiquidStateProgram(connection, config);
|
|
94
94
|
const [pda] = getCashbackConfigPDA(config.liquidStateProgramId);
|
|
@@ -108,7 +108,7 @@ export async function fetchUserSnapshot(
|
|
|
108
108
|
connection: Connection,
|
|
109
109
|
user: PublicKey,
|
|
110
110
|
index: number,
|
|
111
|
-
config: LiquidConfig
|
|
111
|
+
config: LiquidConfig,
|
|
112
112
|
) {
|
|
113
113
|
const program = getLiquidStateProgram(connection, config);
|
|
114
114
|
const [pda] = getUserSnapshotPDA(user, index, config.liquidStateProgramId);
|
|
@@ -126,7 +126,7 @@ export async function fetchUserSnapshot(
|
|
|
126
126
|
export async function fetchDeal(
|
|
127
127
|
connection: Connection,
|
|
128
128
|
owner: PublicKey,
|
|
129
|
-
config: LiquidConfig
|
|
129
|
+
config: LiquidConfig,
|
|
130
130
|
) {
|
|
131
131
|
const program = getLiquidStateProgram(connection, config);
|
|
132
132
|
const [pda] = getDealPDA(owner, config.liquidStateProgramId);
|
|
@@ -16,7 +16,7 @@ import { getLiquidSwapProgram } from "../idl/index.js";
|
|
|
16
16
|
*/
|
|
17
17
|
export async function fetchAmmConfig(
|
|
18
18
|
connection: Connection,
|
|
19
|
-
config: LiquidConfig
|
|
19
|
+
config: LiquidConfig,
|
|
20
20
|
) {
|
|
21
21
|
const program = getLiquidSwapProgram(connection, config);
|
|
22
22
|
const [pda] = getSwapGlobalConfigPDA(config.liquidSwapProgramId);
|
|
@@ -36,7 +36,7 @@ export async function fetchPoolState(
|
|
|
36
36
|
connection: Connection,
|
|
37
37
|
baseMint: PublicKey,
|
|
38
38
|
quoteMint: PublicKey,
|
|
39
|
-
config: LiquidConfig
|
|
39
|
+
config: LiquidConfig,
|
|
40
40
|
) {
|
|
41
41
|
const program = getLiquidSwapProgram(connection, config);
|
|
42
42
|
const [pda] = getPoolPDA(baseMint, quoteMint, config.liquidSwapProgramId);
|
|
@@ -54,7 +54,7 @@ export async function fetchPoolState(
|
|
|
54
54
|
export async function fetchPoolStateByAddress(
|
|
55
55
|
connection: Connection,
|
|
56
56
|
poolAddress: PublicKey,
|
|
57
|
-
config: LiquidConfig
|
|
57
|
+
config: LiquidConfig,
|
|
58
58
|
) {
|
|
59
59
|
const program = getLiquidSwapProgram(connection, config);
|
|
60
60
|
return program.account.poolState.fetch(poolAddress);
|
|
@@ -71,7 +71,7 @@ export async function fetchPoolStateByAddress(
|
|
|
71
71
|
export async function fetchObservationState(
|
|
72
72
|
connection: Connection,
|
|
73
73
|
poolAddress: PublicKey,
|
|
74
|
-
config: LiquidConfig
|
|
74
|
+
config: LiquidConfig,
|
|
75
75
|
) {
|
|
76
76
|
const program = getLiquidSwapProgram(connection, config);
|
|
77
77
|
const [pda] = getObservationPDA(poolAddress, config.liquidSwapProgramId);
|
package/src/accounts/liquid.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { getLiquidProgram } from "../idl/index.js";
|
|
|
16
16
|
*/
|
|
17
17
|
export async function fetchLiquidGlobalConfig(
|
|
18
18
|
connection: Connection,
|
|
19
|
-
config: LiquidConfig
|
|
19
|
+
config: LiquidConfig,
|
|
20
20
|
) {
|
|
21
21
|
const program = getLiquidProgram(connection, config);
|
|
22
22
|
const [pda] = getLiquidGlobalConfigPDA(config.liquidProgramId);
|
|
@@ -34,7 +34,7 @@ export async function fetchLiquidGlobalConfig(
|
|
|
34
34
|
export async function fetchNativeBondingCurve(
|
|
35
35
|
connection: Connection,
|
|
36
36
|
mint: PublicKey,
|
|
37
|
-
config: LiquidConfig
|
|
37
|
+
config: LiquidConfig,
|
|
38
38
|
) {
|
|
39
39
|
const program = getLiquidProgram(connection, config);
|
|
40
40
|
const [pda] = getBondingCurvePDA(mint, config.liquidProgramId);
|
|
@@ -52,7 +52,7 @@ export async function fetchNativeBondingCurve(
|
|
|
52
52
|
export async function fetchNativeBondingCurveByAddress(
|
|
53
53
|
connection: Connection,
|
|
54
54
|
bondingCurveAddress: PublicKey,
|
|
55
|
-
config: LiquidConfig
|
|
55
|
+
config: LiquidConfig,
|
|
56
56
|
) {
|
|
57
57
|
const program = getLiquidProgram(connection, config);
|
|
58
58
|
return program.account.nativeBondingCurve.fetch(bondingCurveAddress);
|
|
@@ -71,13 +71,13 @@ export async function fetchStableBondingCurve(
|
|
|
71
71
|
connection: Connection,
|
|
72
72
|
mint: PublicKey,
|
|
73
73
|
quoteMint: PublicKey,
|
|
74
|
-
config: LiquidConfig
|
|
74
|
+
config: LiquidConfig,
|
|
75
75
|
) {
|
|
76
76
|
const program = getLiquidProgram(connection, config);
|
|
77
77
|
const [pda] = getStableBondingCurvePDA(
|
|
78
78
|
mint,
|
|
79
79
|
quoteMint,
|
|
80
|
-
config.liquidProgramId
|
|
80
|
+
config.liquidProgramId,
|
|
81
81
|
);
|
|
82
82
|
return program.account.stableBondingCurve.fetch(pda);
|
|
83
83
|
}
|
|
@@ -93,7 +93,7 @@ export async function fetchStableBondingCurve(
|
|
|
93
93
|
export async function fetchStableBondingCurveByAddress(
|
|
94
94
|
connection: Connection,
|
|
95
95
|
stableBondingCurveAddress: PublicKey,
|
|
96
|
-
config: LiquidConfig
|
|
96
|
+
config: LiquidConfig,
|
|
97
97
|
) {
|
|
98
98
|
const program = getLiquidProgram(connection, config);
|
|
99
99
|
return program.account.stableBondingCurve.fetch(stableBondingCurveAddress);
|
package/src/client.ts
CHANGED
|
@@ -514,21 +514,21 @@ export class LiquidClient {
|
|
|
514
514
|
const [poolAddress] = getPoolPDA(
|
|
515
515
|
params.baseMint,
|
|
516
516
|
quoteMint,
|
|
517
|
-
this.config.liquidSwapProgramId
|
|
517
|
+
this.config.liquidSwapProgramId,
|
|
518
518
|
);
|
|
519
519
|
const [lpMint] = getPoolLpMintPDA(
|
|
520
520
|
poolAddress,
|
|
521
|
-
this.config.liquidSwapProgramId
|
|
521
|
+
this.config.liquidSwapProgramId,
|
|
522
522
|
);
|
|
523
523
|
const [baseVault] = getPoolVaultPDA(
|
|
524
524
|
poolAddress,
|
|
525
525
|
params.baseMint,
|
|
526
|
-
this.config.liquidSwapProgramId
|
|
526
|
+
this.config.liquidSwapProgramId,
|
|
527
527
|
);
|
|
528
528
|
const [quoteVault] = getPoolVaultPDA(
|
|
529
529
|
poolAddress,
|
|
530
530
|
quoteMint,
|
|
531
|
-
this.config.liquidSwapProgramId
|
|
531
|
+
this.config.liquidSwapProgramId,
|
|
532
532
|
);
|
|
533
533
|
|
|
534
534
|
const [baseTokenProgram, quoteTokenProgram] = await Promise.all([
|
|
@@ -576,21 +576,21 @@ export class LiquidClient {
|
|
|
576
576
|
const [poolAddress] = getPoolPDA(
|
|
577
577
|
params.baseMint,
|
|
578
578
|
quoteMint,
|
|
579
|
-
this.config.liquidSwapProgramId
|
|
579
|
+
this.config.liquidSwapProgramId,
|
|
580
580
|
);
|
|
581
581
|
const [lpMint] = getPoolLpMintPDA(
|
|
582
582
|
poolAddress,
|
|
583
|
-
this.config.liquidSwapProgramId
|
|
583
|
+
this.config.liquidSwapProgramId,
|
|
584
584
|
);
|
|
585
585
|
const [baseVault] = getPoolVaultPDA(
|
|
586
586
|
poolAddress,
|
|
587
587
|
params.baseMint,
|
|
588
|
-
this.config.liquidSwapProgramId
|
|
588
|
+
this.config.liquidSwapProgramId,
|
|
589
589
|
);
|
|
590
590
|
const [quoteVault] = getPoolVaultPDA(
|
|
591
591
|
poolAddress,
|
|
592
592
|
quoteMint,
|
|
593
|
-
this.config.liquidSwapProgramId
|
|
593
|
+
this.config.liquidSwapProgramId,
|
|
594
594
|
);
|
|
595
595
|
|
|
596
596
|
const [baseTokenProgram, quoteTokenProgram] = await Promise.all([
|
|
@@ -752,7 +752,7 @@ export class LiquidClient {
|
|
|
752
752
|
return fetchNativeBondingCurveByAddressFn(
|
|
753
753
|
this.connection,
|
|
754
754
|
address,
|
|
755
|
-
this.config
|
|
755
|
+
this.config,
|
|
756
756
|
);
|
|
757
757
|
}
|
|
758
758
|
|
|
@@ -762,7 +762,7 @@ export class LiquidClient {
|
|
|
762
762
|
this.connection,
|
|
763
763
|
mint,
|
|
764
764
|
quoteMint,
|
|
765
|
-
this.config
|
|
765
|
+
this.config,
|
|
766
766
|
);
|
|
767
767
|
}
|
|
768
768
|
|
|
@@ -771,7 +771,7 @@ export class LiquidClient {
|
|
|
771
771
|
return fetchStableBondingCurveByAddressFn(
|
|
772
772
|
this.connection,
|
|
773
773
|
address,
|
|
774
|
-
this.config
|
|
774
|
+
this.config,
|
|
775
775
|
);
|
|
776
776
|
}
|
|
777
777
|
|
|
@@ -786,7 +786,7 @@ export class LiquidClient {
|
|
|
786
786
|
this.connection,
|
|
787
787
|
baseMint,
|
|
788
788
|
quoteMint,
|
|
789
|
-
this.config
|
|
789
|
+
this.config,
|
|
790
790
|
);
|
|
791
791
|
}
|
|
792
792
|
|
|
@@ -800,7 +800,7 @@ export class LiquidClient {
|
|
|
800
800
|
return fetchObservationStateFn(
|
|
801
801
|
this.connection,
|
|
802
802
|
poolAddress,
|
|
803
|
-
this.config
|
|
803
|
+
this.config,
|
|
804
804
|
);
|
|
805
805
|
}
|
|
806
806
|
|
|
@@ -860,14 +860,14 @@ export class LiquidClient {
|
|
|
860
860
|
previewBuyOnCurve(
|
|
861
861
|
mint: PublicKey,
|
|
862
862
|
amountInQuote: BN,
|
|
863
|
-
options: CurveAsyncOptions
|
|
863
|
+
options: CurveAsyncOptions,
|
|
864
864
|
): Promise<BuyCurvePreview> {
|
|
865
865
|
return previewBuyOnCurveFn(
|
|
866
866
|
this.connection,
|
|
867
867
|
mint,
|
|
868
868
|
amountInQuote,
|
|
869
869
|
this.config,
|
|
870
|
-
options
|
|
870
|
+
options,
|
|
871
871
|
);
|
|
872
872
|
}
|
|
873
873
|
|
|
@@ -882,14 +882,14 @@ export class LiquidClient {
|
|
|
882
882
|
previewSellOnCurve(
|
|
883
883
|
mint: PublicKey,
|
|
884
884
|
amountInTokens: BN,
|
|
885
|
-
options: CurveAsyncOptions
|
|
885
|
+
options: CurveAsyncOptions,
|
|
886
886
|
): Promise<SellCurvePreview> {
|
|
887
887
|
return previewSellOnCurveFn(
|
|
888
888
|
this.connection,
|
|
889
889
|
mint,
|
|
890
890
|
amountInTokens,
|
|
891
891
|
this.config,
|
|
892
|
-
options
|
|
892
|
+
options,
|
|
893
893
|
);
|
|
894
894
|
}
|
|
895
895
|
|
|
@@ -898,7 +898,7 @@ export class LiquidClient {
|
|
|
898
898
|
baseMint: PublicKey,
|
|
899
899
|
quoteMint: PublicKey,
|
|
900
900
|
amountIn: BN,
|
|
901
|
-
options?: { prefetched?: SwapPrefetchedState }
|
|
901
|
+
options?: { prefetched?: SwapPrefetchedState },
|
|
902
902
|
): Promise<SwapPreview> {
|
|
903
903
|
return previewSwapSellFn(
|
|
904
904
|
this.connection,
|
|
@@ -906,7 +906,7 @@ export class LiquidClient {
|
|
|
906
906
|
quoteMint,
|
|
907
907
|
amountIn,
|
|
908
908
|
this.config,
|
|
909
|
-
options
|
|
909
|
+
options,
|
|
910
910
|
);
|
|
911
911
|
}
|
|
912
912
|
|
|
@@ -915,7 +915,7 @@ export class LiquidClient {
|
|
|
915
915
|
baseMint: PublicKey,
|
|
916
916
|
quoteMint: PublicKey,
|
|
917
917
|
amountOut: BN,
|
|
918
|
-
options?: { prefetched?: SwapPrefetchedState }
|
|
918
|
+
options?: { prefetched?: SwapPrefetchedState },
|
|
919
919
|
): Promise<SwapPreview> {
|
|
920
920
|
return previewSwapBuyFn(
|
|
921
921
|
this.connection,
|
|
@@ -923,7 +923,7 @@ export class LiquidClient {
|
|
|
923
923
|
quoteMint,
|
|
924
924
|
amountOut,
|
|
925
925
|
this.config,
|
|
926
|
-
options
|
|
926
|
+
options,
|
|
927
927
|
);
|
|
928
928
|
}
|
|
929
929
|
|
|
@@ -935,12 +935,12 @@ export class LiquidClient {
|
|
|
935
935
|
/** Derives the stable bonding curve PDA for a token mint and quote mint. */
|
|
936
936
|
getStableBondingCurvePDA(
|
|
937
937
|
mint: PublicKey,
|
|
938
|
-
quoteMint: PublicKey
|
|
938
|
+
quoteMint: PublicKey,
|
|
939
939
|
): [PublicKey, number] {
|
|
940
940
|
return getStableBondingCurvePDA(
|
|
941
941
|
mint,
|
|
942
942
|
quoteMint,
|
|
943
|
-
this.config.liquidProgramId
|
|
943
|
+
this.config.liquidProgramId,
|
|
944
944
|
);
|
|
945
945
|
}
|
|
946
946
|
|
|
@@ -948,7 +948,7 @@ export class LiquidClient {
|
|
|
948
948
|
getBondingCurveSolVaultPDA(bondingCurve: PublicKey): [PublicKey, number] {
|
|
949
949
|
return getBondingCurveSolVaultPDA(
|
|
950
950
|
bondingCurve,
|
|
951
|
-
this.config.liquidProgramId
|
|
951
|
+
this.config.liquidProgramId,
|
|
952
952
|
);
|
|
953
953
|
}
|
|
954
954
|
|
|
@@ -965,7 +965,7 @@ export class LiquidClient {
|
|
|
965
965
|
/** Derives the pool state PDA for a token pair. */
|
|
966
966
|
getPoolPDA(
|
|
967
967
|
baseMint: PublicKey,
|
|
968
|
-
quoteMint: PublicKey = WSOL_MINT
|
|
968
|
+
quoteMint: PublicKey = WSOL_MINT,
|
|
969
969
|
): [PublicKey, number] {
|
|
970
970
|
return getPoolPDA(baseMint, quoteMint, this.config.liquidSwapProgramId);
|
|
971
971
|
}
|
|
@@ -978,12 +978,12 @@ export class LiquidClient {
|
|
|
978
978
|
/** Derives the pool vault PDA for a specific token. */
|
|
979
979
|
getPoolVaultPDA(
|
|
980
980
|
poolState: PublicKey,
|
|
981
|
-
mint: PublicKey
|
|
981
|
+
mint: PublicKey,
|
|
982
982
|
): [PublicKey, number] {
|
|
983
983
|
return getPoolVaultPDA(
|
|
984
984
|
poolState,
|
|
985
985
|
mint,
|
|
986
|
-
this.config.liquidSwapProgramId
|
|
986
|
+
this.config.liquidSwapProgramId,
|
|
987
987
|
);
|
|
988
988
|
}
|
|
989
989
|
|
|
@@ -1005,12 +1005,12 @@ export class LiquidClient {
|
|
|
1005
1005
|
/** Derives the recipient vault PDA for a specific recipient within a fee config. */
|
|
1006
1006
|
getRecipientVaultPDA(
|
|
1007
1007
|
feeConfig: PublicKey,
|
|
1008
|
-
recipient: PublicKey
|
|
1008
|
+
recipient: PublicKey,
|
|
1009
1009
|
): [PublicKey, number] {
|
|
1010
1010
|
return getRecipientVaultPDA(
|
|
1011
1011
|
feeConfig,
|
|
1012
1012
|
recipient,
|
|
1013
|
-
this.config.liquidFeesProgramId
|
|
1013
|
+
this.config.liquidFeesProgramId,
|
|
1014
1014
|
);
|
|
1015
1015
|
}
|
|
1016
1016
|
|
|
@@ -1029,7 +1029,7 @@ export class LiquidClient {
|
|
|
1029
1029
|
return getUserSnapshotPDA(
|
|
1030
1030
|
user,
|
|
1031
1031
|
index,
|
|
1032
|
-
this.config.liquidStateProgramId
|
|
1032
|
+
this.config.liquidStateProgramId,
|
|
1033
1033
|
);
|
|
1034
1034
|
}
|
|
1035
1035
|
|
|
@@ -1064,7 +1064,7 @@ export class LiquidClient {
|
|
|
1064
1064
|
*/
|
|
1065
1065
|
buildTransaction(
|
|
1066
1066
|
instructions: TransactionInstruction[],
|
|
1067
|
-
options: BuildTransactionOptions
|
|
1067
|
+
options: BuildTransactionOptions,
|
|
1068
1068
|
): Promise<Transaction> {
|
|
1069
1069
|
return buildTransactionFn(this.connection, instructions, options);
|
|
1070
1070
|
}
|