@omnipair/program-interface 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -58
- package/dist/constants.d.ts +4 -4
- package/package.json +61 -61
- package/src/constants.ts +58 -58
- package/src/index.ts +9 -9
package/README.md
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
# @omnipair/program-interface
|
|
2
|
-
|
|
3
|
-
TypeScript interface for the [Omnipair](https://omnipair.fi) Solana program - an oracleless spot and margin money market protocol.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @omnipair/program-interface
|
|
9
|
-
# or
|
|
10
|
-
yarn add @omnipair/program-interface
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import { Program } from "@coral-xyz/anchor";
|
|
17
|
-
import { IDL, Omnipair, PROGRAM_ID, derivePairAddress } from "@omnipair/program-interface";
|
|
18
|
-
|
|
19
|
-
// Create a typed program instance
|
|
20
|
-
const program = new Program<Omnipair>(IDL, PROGRAM_ID, provider);
|
|
21
|
-
|
|
22
|
-
// Fetch a pair account (fully typed)
|
|
23
|
-
const [pairAddress] = derivePairAddress(token0, token1);
|
|
24
|
-
const pair = await program.account.pair.fetch(pairAddress);
|
|
25
|
-
|
|
26
|
-
console.log("Reserve0:", pair.reserve0.toString());
|
|
27
|
-
console.log("Reserve1:", pair.reserve1.toString());
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Exports
|
|
31
|
-
|
|
32
|
-
### IDL
|
|
33
|
-
The Anchor IDL JSON for the Omnipair program.
|
|
34
|
-
|
|
35
|
-
### Types
|
|
36
|
-
All TypeScript types generated from the IDL:
|
|
37
|
-
- `Omnipair` - The program type
|
|
38
|
-
- Account types: `Pair`, `UserPosition`, `RateModel`, `FutarchyAuthority`
|
|
39
|
-
- Instruction argument types
|
|
40
|
-
- Event types
|
|
41
|
-
|
|
42
|
-
### Constants
|
|
43
|
-
- `PROGRAM_ID` - The Omnipair program ID
|
|
44
|
-
- `DEPLOYER_DEV` - Development deployer address
|
|
45
|
-
- `DEPLOYER_PROD` - Production deployer address
|
|
46
|
-
- `SEEDS` - PDA seed constants
|
|
47
|
-
|
|
48
|
-
### Utilities
|
|
49
|
-
- `derivePairAddress(token0, token1)` - Derive a Pair PDA
|
|
50
|
-
- `deriveUserPositionAddress(pair, user)` - Derive a UserPosition PDA
|
|
51
|
-
|
|
52
|
-
## Peer Dependencies
|
|
53
|
-
|
|
54
|
-
- `@coral-xyz/anchor` >= 0.30.0
|
|
55
|
-
|
|
56
|
-
## License
|
|
57
|
-
|
|
58
|
-
MIT
|
|
1
|
+
# @omnipair/program-interface
|
|
2
|
+
|
|
3
|
+
TypeScript interface for the [Omnipair](https://omnipair.fi) Solana program - an oracleless spot and margin money market protocol.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @omnipair/program-interface
|
|
9
|
+
# or
|
|
10
|
+
yarn add @omnipair/program-interface
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Program } from "@coral-xyz/anchor";
|
|
17
|
+
import { IDL, Omnipair, PROGRAM_ID, derivePairAddress } from "@omnipair/program-interface";
|
|
18
|
+
|
|
19
|
+
// Create a typed program instance
|
|
20
|
+
const program = new Program<Omnipair>(IDL, PROGRAM_ID, provider);
|
|
21
|
+
|
|
22
|
+
// Fetch a pair account (fully typed)
|
|
23
|
+
const [pairAddress] = derivePairAddress(token0, token1);
|
|
24
|
+
const pair = await program.account.pair.fetch(pairAddress);
|
|
25
|
+
|
|
26
|
+
console.log("Reserve0:", pair.reserve0.toString());
|
|
27
|
+
console.log("Reserve1:", pair.reserve1.toString());
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Exports
|
|
31
|
+
|
|
32
|
+
### IDL
|
|
33
|
+
The Anchor IDL JSON for the Omnipair program.
|
|
34
|
+
|
|
35
|
+
### Types
|
|
36
|
+
All TypeScript types generated from the IDL:
|
|
37
|
+
- `Omnipair` - The program type
|
|
38
|
+
- Account types: `Pair`, `UserPosition`, `RateModel`, `FutarchyAuthority`
|
|
39
|
+
- Instruction argument types
|
|
40
|
+
- Event types
|
|
41
|
+
|
|
42
|
+
### Constants
|
|
43
|
+
- `PROGRAM_ID` - The Omnipair program ID
|
|
44
|
+
- `DEPLOYER_DEV` - Development deployer address
|
|
45
|
+
- `DEPLOYER_PROD` - Production deployer address
|
|
46
|
+
- `SEEDS` - PDA seed constants
|
|
47
|
+
|
|
48
|
+
### Utilities
|
|
49
|
+
- `derivePairAddress(token0, token1)` - Derive a Pair PDA
|
|
50
|
+
- `deriveUserPositionAddress(pair, user)` - Derive a UserPosition PDA
|
|
51
|
+
|
|
52
|
+
## Peer Dependencies
|
|
53
|
+
|
|
54
|
+
- `@coral-xyz/anchor` >= 0.30.0
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT
|
package/dist/constants.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ export declare const DEPLOYER_PROD: PublicKey;
|
|
|
15
15
|
* PDA seeds used by the program
|
|
16
16
|
*/
|
|
17
17
|
export declare const SEEDS: {
|
|
18
|
-
readonly PAIR: Buffer
|
|
19
|
-
readonly USER_POSITION: Buffer
|
|
20
|
-
readonly FUTARCHY_AUTHORITY: Buffer
|
|
21
|
-
readonly RATE_MODEL: Buffer
|
|
18
|
+
readonly PAIR: Buffer;
|
|
19
|
+
readonly USER_POSITION: Buffer;
|
|
20
|
+
readonly FUTARCHY_AUTHORITY: Buffer;
|
|
21
|
+
readonly RATE_MODEL: Buffer;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Derive Pair PDA address
|
package/package.json
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@omnipair/program-interface",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Omnipair program IDL, TypeScript types, and constants",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Omnipair <security@omnipair.fi>",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/omnipair/omnipair-rs.git",
|
|
10
|
-
"directory": "packages/program-interface"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://omnipair.fi",
|
|
13
|
-
"keywords": [
|
|
14
|
-
"solana",
|
|
15
|
-
"anchor",
|
|
16
|
-
"omnipair",
|
|
17
|
-
"defi",
|
|
18
|
-
"amm",
|
|
19
|
-
"lending"
|
|
20
|
-
],
|
|
21
|
-
"type": "module",
|
|
22
|
-
"publishConfig": {
|
|
23
|
-
"access": "public"
|
|
24
|
-
},
|
|
25
|
-
"main": "./dist/index.js",
|
|
26
|
-
"module": "./dist/index.js",
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"import": "./dist/index.js",
|
|
31
|
-
"types": "./dist/index.d.ts"
|
|
32
|
-
},
|
|
33
|
-
"./idl": {
|
|
34
|
-
"import": "./dist/idl.js",
|
|
35
|
-
"types": "./dist/idl.d.ts"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"files": [
|
|
39
|
-
"dist",
|
|
40
|
-
"src"
|
|
41
|
-
],
|
|
42
|
-
"scripts": {
|
|
43
|
-
"prepare-idl": "node scripts/prepare.js",
|
|
44
|
-
"build": "npm run prepare-idl && tsc",
|
|
45
|
-
"clean": "rm -rf dist",
|
|
46
|
-
"prepublishOnly": "npm run clean && npm run build"
|
|
47
|
-
},
|
|
48
|
-
"dependencies": {
|
|
49
|
-
"@coral-xyz/anchor": ">=0.30.0",
|
|
50
|
-
"@solana/web3.js": "^1.95.0"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"typescript": "^5.0.0"
|
|
54
|
-
},
|
|
55
|
-
"peerDependencies": {
|
|
56
|
-
"@coral-xyz/anchor": ">=0.30.0"
|
|
57
|
-
},
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">=18"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@omnipair/program-interface",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Omnipair program IDL, TypeScript types, and constants",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Omnipair <security@omnipair.fi>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/omnipair/omnipair-rs.git",
|
|
10
|
+
"directory": "packages/program-interface"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://omnipair.fi",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"solana",
|
|
15
|
+
"anchor",
|
|
16
|
+
"omnipair",
|
|
17
|
+
"defi",
|
|
18
|
+
"amm",
|
|
19
|
+
"lending"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./idl": {
|
|
34
|
+
"import": "./dist/idl.js",
|
|
35
|
+
"types": "./dist/idl.d.ts"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"src"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"prepare-idl": "node scripts/prepare.js",
|
|
44
|
+
"build": "npm run prepare-idl && tsc",
|
|
45
|
+
"clean": "rm -rf dist",
|
|
46
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@coral-xyz/anchor": ">=0.30.0",
|
|
50
|
+
"@solana/web3.js": "^1.95.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"typescript": "^5.0.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@coral-xyz/anchor": ">=0.30.0"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=18"
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/constants.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Omnipair program ID (mainnet/devnet)
|
|
5
|
-
*/
|
|
6
|
-
export const PROGRAM_ID = new PublicKey(
|
|
7
|
-
"omniSVEL3cY36TYhunvJC6vBXxbJrqrn7JhDrXUTerb"
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Development deployer address
|
|
12
|
-
*/
|
|
13
|
-
export const DEPLOYER_DEV = new PublicKey(
|
|
14
|
-
"C7GKpfqQyBoFR6S13DECwBjdi7aCQKbbeKjXm4Jt5Hds"
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Production deployer address
|
|
19
|
-
*/
|
|
20
|
-
export const DEPLOYER_PROD = new PublicKey(
|
|
21
|
-
"8tF4uYMBXqGhCUGRZL3AmPqRzbX8JJ1TpYnY3uJKN4kt"
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* PDA seeds used by the program
|
|
26
|
-
*/
|
|
27
|
-
export const SEEDS = {
|
|
28
|
-
PAIR: Buffer.from("gamm_pair"),
|
|
29
|
-
USER_POSITION: Buffer.from("user_position"),
|
|
30
|
-
FUTARCHY_AUTHORITY: Buffer.from("futarchy_authority"),
|
|
31
|
-
RATE_MODEL: Buffer.from("rate_model"),
|
|
32
|
-
} as const;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Derive Pair PDA address
|
|
36
|
-
*/
|
|
37
|
-
export function derivePairAddress(
|
|
38
|
-
token0: PublicKey,
|
|
39
|
-
token1: PublicKey
|
|
40
|
-
): [PublicKey, number] {
|
|
41
|
-
return PublicKey.findProgramAddressSync(
|
|
42
|
-
[SEEDS.PAIR, token0.toBuffer(), token1.toBuffer()],
|
|
43
|
-
PROGRAM_ID
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Derive User Position PDA address
|
|
49
|
-
*/
|
|
50
|
-
export function deriveUserPositionAddress(
|
|
51
|
-
pair: PublicKey,
|
|
52
|
-
user: PublicKey
|
|
53
|
-
): [PublicKey, number] {
|
|
54
|
-
return PublicKey.findProgramAddressSync(
|
|
55
|
-
[SEEDS.USER_POSITION, pair.toBuffer(), user.toBuffer()],
|
|
56
|
-
PROGRAM_ID
|
|
57
|
-
);
|
|
58
|
-
}
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Omnipair program ID (mainnet/devnet)
|
|
5
|
+
*/
|
|
6
|
+
export const PROGRAM_ID = new PublicKey(
|
|
7
|
+
"omniSVEL3cY36TYhunvJC6vBXxbJrqrn7JhDrXUTerb"
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Development deployer address
|
|
12
|
+
*/
|
|
13
|
+
export const DEPLOYER_DEV = new PublicKey(
|
|
14
|
+
"C7GKpfqQyBoFR6S13DECwBjdi7aCQKbbeKjXm4Jt5Hds"
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Production deployer address
|
|
19
|
+
*/
|
|
20
|
+
export const DEPLOYER_PROD = new PublicKey(
|
|
21
|
+
"8tF4uYMBXqGhCUGRZL3AmPqRzbX8JJ1TpYnY3uJKN4kt"
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* PDA seeds used by the program
|
|
26
|
+
*/
|
|
27
|
+
export const SEEDS = {
|
|
28
|
+
PAIR: Buffer.from("gamm_pair"),
|
|
29
|
+
USER_POSITION: Buffer.from("user_position"),
|
|
30
|
+
FUTARCHY_AUTHORITY: Buffer.from("futarchy_authority"),
|
|
31
|
+
RATE_MODEL: Buffer.from("rate_model"),
|
|
32
|
+
} as const;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Derive Pair PDA address
|
|
36
|
+
*/
|
|
37
|
+
export function derivePairAddress(
|
|
38
|
+
token0: PublicKey,
|
|
39
|
+
token1: PublicKey
|
|
40
|
+
): [PublicKey, number] {
|
|
41
|
+
return PublicKey.findProgramAddressSync(
|
|
42
|
+
[SEEDS.PAIR, token0.toBuffer(), token1.toBuffer()],
|
|
43
|
+
PROGRAM_ID
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Derive User Position PDA address
|
|
49
|
+
*/
|
|
50
|
+
export function deriveUserPositionAddress(
|
|
51
|
+
pair: PublicKey,
|
|
52
|
+
user: PublicKey
|
|
53
|
+
): [PublicKey, number] {
|
|
54
|
+
return PublicKey.findProgramAddressSync(
|
|
55
|
+
[SEEDS.USER_POSITION, pair.toBuffer(), user.toBuffer()],
|
|
56
|
+
PROGRAM_ID
|
|
57
|
+
);
|
|
58
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Re-export IDL
|
|
2
|
-
export { default as IDL } from "./idl.json";
|
|
3
|
-
export type { Omnipair } from "./types";
|
|
4
|
-
|
|
5
|
-
// Re-export types
|
|
6
|
-
export * from "./types";
|
|
7
|
-
|
|
8
|
-
// Re-export constants and utilities
|
|
9
|
-
export * from "./constants";
|
|
1
|
+
// Re-export IDL
|
|
2
|
+
export { default as IDL } from "./idl.json";
|
|
3
|
+
export type { Omnipair } from "./types";
|
|
4
|
+
|
|
5
|
+
// Re-export types
|
|
6
|
+
export * from "./types";
|
|
7
|
+
|
|
8
|
+
// Re-export constants and utilities
|
|
9
|
+
export * from "./constants";
|