@exponent-labs/generic-sy-pda 0.0.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [0.0.3](https://github.com/exponent-finance/exponent-core/compare/@exponent-labs/generic-sy-pda@0.0.2...@exponent-labs/generic-sy-pda@0.0.3) (2025-03-03)
7
+
8
+ **Note:** Version bump only for package @exponent-labs/generic-sy-pda
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.0.2](https://github.com/exponent-finance/exponent-core/compare/@exponent-labs/generic-sy-pda@0.0.1...@exponent-labs/generic-sy-pda@0.0.2) (2025-03-03)
15
+
16
+ **Note:** Version bump only for package @exponent-labs/generic-sy-pda
@@ -0,0 +1,40 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare class GenericSyPda {
3
+ programId: PublicKey;
4
+ interfaceByte: number;
5
+ constructor(programId: PublicKey, interfaceByte: number);
6
+ private findProgramAddressSync;
7
+ emissionTracker({ yieldBearingMint }: {
8
+ yieldBearingMint: PublicKey;
9
+ }): PublicKey;
10
+ mintSy({ yieldBearingMint }: {
11
+ yieldBearingMint: PublicKey;
12
+ }): PublicKey;
13
+ accountAuthority({ yieldBearingMint }: {
14
+ yieldBearingMint: PublicKey;
15
+ }): PublicKey;
16
+ mintSyAuthority({ yieldBearingMint }: {
17
+ yieldBearingMint: PublicKey;
18
+ }): PublicKey;
19
+ position({ yieldBearingMint, owner }: {
20
+ yieldBearingMint: PublicKey;
21
+ owner: PublicKey;
22
+ }): PublicKey;
23
+ syEscrowAuthority({ yieldBearingMint }: {
24
+ yieldBearingMint: PublicKey;
25
+ }): PublicKey;
26
+ syEscrow({ yieldBearingMint }: {
27
+ yieldBearingMint: PublicKey;
28
+ }): PublicKey;
29
+ syMeta({ yieldBearingMint }: {
30
+ yieldBearingMint: PublicKey;
31
+ }): PublicKey;
32
+ accountAuthorityToken({ yieldBearingMint }: {
33
+ yieldBearingMint: PublicKey;
34
+ }): PublicKey;
35
+ underlyingEscrow({ yieldBearingMint, mintUnderlying, tokenProgramUnderlying, }: {
36
+ yieldBearingMint: PublicKey;
37
+ mintUnderlying: PublicKey;
38
+ tokenProgramUnderlying: PublicKey;
39
+ }): PublicKey;
40
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenericSyPda = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const spl_token_1 = require("@solana/spl-token");
6
+ class GenericSyPda {
7
+ programId;
8
+ interfaceByte;
9
+ constructor(programId, interfaceByte) {
10
+ this.programId = programId;
11
+ this.interfaceByte = interfaceByte;
12
+ }
13
+ findProgramAddressSync(seeds) {
14
+ return web3_js_1.PublicKey.findProgramAddressSync(seeds, this.programId)[0];
15
+ }
16
+ emissionTracker({ yieldBearingMint }) {
17
+ return this.findProgramAddressSync([
18
+ Buffer.from("emission_tracker"),
19
+ Buffer.from([this.interfaceByte]),
20
+ yieldBearingMint.toBuffer(),
21
+ ]);
22
+ }
23
+ mintSy({ yieldBearingMint }) {
24
+ return this.findProgramAddressSync([
25
+ Buffer.from("generic_token"),
26
+ Buffer.from([this.interfaceByte]),
27
+ yieldBearingMint.toBuffer(),
28
+ ]);
29
+ }
30
+ accountAuthority({ yieldBearingMint }) {
31
+ return this.findProgramAddressSync([Buffer.from("account_authority"), yieldBearingMint.toBuffer()]);
32
+ }
33
+ mintSyAuthority({ yieldBearingMint }) {
34
+ return this.findProgramAddressSync([Buffer.from("mint_authority"), yieldBearingMint.toBuffer()]);
35
+ }
36
+ position({ yieldBearingMint, owner }) {
37
+ return this.findProgramAddressSync([
38
+ Buffer.from("position"),
39
+ Buffer.from([this.interfaceByte]),
40
+ yieldBearingMint.toBuffer(),
41
+ owner.toBuffer(),
42
+ ]);
43
+ }
44
+ syEscrowAuthority({ yieldBearingMint }) {
45
+ return this.findProgramAddressSync([Buffer.from("stake_pool_authority"), yieldBearingMint.toBuffer()]);
46
+ }
47
+ syEscrow({ yieldBearingMint }) {
48
+ return this.findProgramAddressSync([
49
+ Buffer.from("sy_escrow"),
50
+ Buffer.from([this.interfaceByte]),
51
+ yieldBearingMint.toBuffer(),
52
+ ]);
53
+ }
54
+ syMeta({ yieldBearingMint }) {
55
+ return this.findProgramAddressSync([
56
+ Buffer.from("meta"),
57
+ Buffer.from([this.interfaceByte]),
58
+ yieldBearingMint.toBuffer(),
59
+ ]);
60
+ }
61
+ accountAuthorityToken({ yieldBearingMint }) {
62
+ return this.findProgramAddressSync([Buffer.from("account_authority_token"), yieldBearingMint.toBuffer()]);
63
+ }
64
+ underlyingEscrow({ yieldBearingMint, mintUnderlying, tokenProgramUnderlying, }) {
65
+ const owner = this.accountAuthority({ yieldBearingMint });
66
+ return (0, spl_token_1.getAssociatedTokenAddressSync)(mintUnderlying, owner, true, tokenProgramUnderlying);
67
+ }
68
+ }
69
+ exports.GenericSyPda = GenericSyPda;
70
+ //# sourceMappingURL=genericSyPda.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genericSyPda.js","sourceRoot":"","sources":["../src/genericSyPda.ts"],"names":[],"mappings":";;;AAAA,6CAA2C;AAC3C,iDAAiE;AAGjE,MAAa,YAAY;IACJ;IAA6B;IAAhD,YAAmB,SAAoB,EAAS,aAAqB;QAAlD,cAAS,GAAT,SAAS,CAAW;QAAS,kBAAa,GAAb,aAAa,CAAQ;IAAG,CAAC;IAEjE,sBAAsB,CAAC,KAAe;QAC5C,OAAO,mBAAS,CAAC,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACnE,CAAC;IAED,eAAe,CAAC,EAAE,gBAAgB,EAAmC;QACnE,OAAO,IAAI,CAAC,sBAAsB,CAAC;YACjC,MAAM,CAAC,I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AE,CAAC,CAAC,CAAA;IACxG,CAAC;IAED,QAAQ,CAAC,EAAE,gBAAgB,EAAmC;QAC5D,OAAO,IAAI,CAAC,sBAAsB,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACjC,gBAAgB,CAAC,QAAQ,EAAE;SAC5B,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAC,EAAE,gBAAgB,EAAmC;QAC1D,OAAO,IAAI,CAAC,sBAAsB,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YACnB,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACjC,gBAAgB,CAAC,QAAQ,EAAE;SAC5B,CAAC,CAAA;IACJ,CAAC;IAED,qBAAqB,CAAC,EAAE,gBAAgB,EAAmC;QACzE,OAAO,IAAI,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,EAAE,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAC3G,CAAC;IAED,gBAAgB,CAAC,EACf,gBAAgB,EAChB,cAAc,EACd,sBAAsB,GAKvB;QACC,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAA;QACzD,OAAO,IAAA,yCAA6B,EAAC,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE,sBAAsB,CAAC,CAAA;IAC3F,CAAC;CACF;AA5ED,oCA4EC"}
@@ -0,0 +1 @@
1
+ export * from "./genericSyPda";
package/build/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./genericSyPda"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B"}
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@exponent-labs/generic-sy-pda",
3
+ "version": "0.0.3",
4
+ "main": "build/index.js",
5
+ "types": "build/index.d.ts",
6
+ "license": "AGPL-3.0",
7
+ "scripts": {
8
+ "build": "tsc --build"
9
+ },
10
+ "dependencies": {
11
+ "@exponent-labs/generic-sy-idl": "^0.0.3"
12
+ },
13
+ "devDependencies": {
14
+ "typescript": "5.4.5"
15
+ },
16
+ "gitHead": "209b8847e9a0fadb5b5ec96b9b47f0ace4a3bf9d"
17
+ }
@@ -0,0 +1,81 @@
1
+ import { PublicKey } from "@solana/web3.js"
2
+ import { getAssociatedTokenAddressSync } from "@solana/spl-token"
3
+ import { IDL } from "@exponent-labs/generic-sy-idl"
4
+
5
+ export class GenericSyPda {
6
+ constructor(public programId: PublicKey, public interfaceByte: number) {}
7
+
8
+ private findProgramAddressSync(seeds: Buffer[]) {
9
+ return PublicKey.findProgramAddressSync(seeds, this.programId)[0]
10
+ }
11
+
12
+ emissionTracker({ yieldBearingMint }: { yieldBearingMint: PublicKey }) {
13
+ return this.findProgramAddressSync([
14
+ Buffer.from("emission_tracker"),
15
+ Buffer.from([this.interfaceByte]),
16
+ yieldBearingMint.toBuffer(),
17
+ ])
18
+ }
19
+
20
+ mintSy({ yieldBearingMint }: { yieldBearingMint: PublicKey }) {
21
+ return this.findProgramAddressSync([
22
+ Buffer.from("generic_token"),
23
+ Buffer.from([this.interfaceByte]),
24
+ yieldBearingMint.toBuffer(),
25
+ ])
26
+ }
27
+
28
+ accountAuthority({ yieldBearingMint }: { yieldBearingMint: PublicKey }) {
29
+ return this.findProgramAddressSync([Buffer.from("account_authority"), yieldBearingMint.toBuffer()])
30
+ }
31
+
32
+ mintSyAuthority({ yieldBearingMint }: { yieldBearingMint: PublicKey }) {
33
+ return this.findProgramAddressSync([Buffer.from("mint_authority"), yieldBearingMint.toBuffer()])
34
+ }
35
+
36
+ position({ yieldBearingMint, owner }: { yieldBearingMint: PublicKey; owner: PublicKey }) {
37
+ return this.findProgramAddressSync([
38
+ Buffer.from("position"),
39
+ Buffer.from([this.interfaceByte]),
40
+ yieldBearingMint.toBuffer(),
41
+ owner.toBuffer(),
42
+ ])
43
+ }
44
+
45
+ syEscrowAuthority({ yieldBearingMint }: { yieldBearingMint: PublicKey }) {
46
+ return this.findProgramAddressSync([Buffer.from("stake_pool_authority"), yieldBearingMint.toBuffer()])
47
+ }
48
+
49
+ syEscrow({ yieldBearingMint }: { yieldBearingMint: PublicKey }) {
50
+ return this.findProgramAddressSync([
51
+ Buffer.from("sy_escrow"),
52
+ Buffer.from([this.interfaceByte]),
53
+ yieldBearingMint.toBuffer(),
54
+ ])
55
+ }
56
+
57
+ syMeta({ yieldBearingMint }: { yieldBearingMint: PublicKey }) {
58
+ return this.findProgramAddressSync([
59
+ Buffer.from("meta"),
60
+ Buffer.from([this.interfaceByte]),
61
+ yieldBearingMint.toBuffer(),
62
+ ])
63
+ }
64
+
65
+ accountAuthorityToken({ yieldBearingMint }: { yieldBearingMint: PublicKey }) {
66
+ return this.findProgramAddressSync([Buffer.from("account_authority_token"), yieldBearingMint.toBuffer()])
67
+ }
68
+
69
+ underlyingEscrow({
70
+ yieldBearingMint,
71
+ mintUnderlying,
72
+ tokenProgramUnderlying,
73
+ }: {
74
+ yieldBearingMint: PublicKey
75
+ mintUnderlying: PublicKey
76
+ tokenProgramUnderlying: PublicKey
77
+ }) {
78
+ const owner = this.accountAuthority({ yieldBearingMint })
79
+ return getAssociatedTokenAddressSync(mintUnderlying, owner, true, tokenProgramUnderlying)
80
+ }
81
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./genericSyPda"
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "sourceMap": true,
5
+ "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
6
+ "composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */,
7
+ "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
8
+ "module": "CommonJS" /* Specify what module code is generated. */,
9
+ "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
10
+ "outDir": "./build" /* Specify an output folder for all emitted files. */,
11
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
12
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
13
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
14
+ },
15
+ "include": ["src"],
16
+ "exclude": ["build"],
17
+ "references": [
18
+ {
19
+ "path": "../generic-sy-idl"
20
+ }
21
+ ]
22
+ }