@omnipair/program-interface 0.0.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 -0
- package/dist/constants.d.ts +31 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +35 -0
- package/dist/constants.js.map +1 -0
- package/dist/idl.json +5460 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +5467 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
- package/src/constants.ts +58 -0
- package/src/idl.json +5460 -0
- package/src/index.ts +9 -0
- package/src/types.ts +5466 -0
package/README.md
ADDED
|
@@ -0,0 +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
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Omnipair program ID (mainnet/devnet)
|
|
4
|
+
*/
|
|
5
|
+
export declare const PROGRAM_ID: PublicKey;
|
|
6
|
+
/**
|
|
7
|
+
* Development deployer address
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEPLOYER_DEV: PublicKey;
|
|
10
|
+
/**
|
|
11
|
+
* Production deployer address
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEPLOYER_PROD: PublicKey;
|
|
14
|
+
/**
|
|
15
|
+
* PDA seeds used by the program
|
|
16
|
+
*/
|
|
17
|
+
export declare const SEEDS: {
|
|
18
|
+
readonly PAIR: Buffer<ArrayBuffer>;
|
|
19
|
+
readonly USER_POSITION: Buffer<ArrayBuffer>;
|
|
20
|
+
readonly FUTARCHY_AUTHORITY: Buffer<ArrayBuffer>;
|
|
21
|
+
readonly RATE_MODEL: Buffer<ArrayBuffer>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Derive Pair PDA address
|
|
25
|
+
*/
|
|
26
|
+
export declare function derivePairAddress(token0: PublicKey, token1: PublicKey): [PublicKey, number];
|
|
27
|
+
/**
|
|
28
|
+
* Derive User Position PDA address
|
|
29
|
+
*/
|
|
30
|
+
export declare function deriveUserPositionAddress(pair: PublicKey, user: PublicKey): [PublicKey, number];
|
|
31
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,UAAU,WAEtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,WAExB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,WAEzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK;;;;;CAKR,CAAC;AAEX;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,SAAS,GAChB,CAAC,SAAS,EAAE,MAAM,CAAC,CAKrB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,SAAS,GACd,CAAC,SAAS,EAAE,MAAM,CAAC,CAKrB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Omnipair program ID (mainnet/devnet)
|
|
4
|
+
*/
|
|
5
|
+
export const PROGRAM_ID = new PublicKey("omniSVEL3cY36TYhunvJC6vBXxbJrqrn7JhDrXUTerb");
|
|
6
|
+
/**
|
|
7
|
+
* Development deployer address
|
|
8
|
+
*/
|
|
9
|
+
export const DEPLOYER_DEV = new PublicKey("C7GKpfqQyBoFR6S13DECwBjdi7aCQKbbeKjXm4Jt5Hds");
|
|
10
|
+
/**
|
|
11
|
+
* Production deployer address
|
|
12
|
+
*/
|
|
13
|
+
export const DEPLOYER_PROD = new PublicKey("8tF4uYMBXqGhCUGRZL3AmPqRzbX8JJ1TpYnY3uJKN4kt");
|
|
14
|
+
/**
|
|
15
|
+
* PDA seeds used by the program
|
|
16
|
+
*/
|
|
17
|
+
export const SEEDS = {
|
|
18
|
+
PAIR: Buffer.from("gamm_pair"),
|
|
19
|
+
USER_POSITION: Buffer.from("user_position"),
|
|
20
|
+
FUTARCHY_AUTHORITY: Buffer.from("futarchy_authority"),
|
|
21
|
+
RATE_MODEL: Buffer.from("rate_model"),
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Derive Pair PDA address
|
|
25
|
+
*/
|
|
26
|
+
export function derivePairAddress(token0, token1) {
|
|
27
|
+
return PublicKey.findProgramAddressSync([SEEDS.PAIR, token0.toBuffer(), token1.toBuffer()], PROGRAM_ID);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Derive User Position PDA address
|
|
31
|
+
*/
|
|
32
|
+
export function deriveUserPositionAddress(pair, user) {
|
|
33
|
+
return PublicKey.findProgramAddressSync([SEEDS.USER_POSITION, pair.toBuffer(), user.toBuffer()], PROGRAM_ID);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,SAAS,CACrC,6CAA6C,CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,SAAS,CACvC,8CAA8C,CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,SAAS,CACxC,8CAA8C,CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC;IAC3C,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;CAC7B,CAAC;AAEX;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAiB,EACjB,MAAiB;IAEjB,OAAO,SAAS,CAAC,sBAAsB,CACrC,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,EAClD,UAAU,CACX,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,IAAe,EACf,IAAe;IAEf,OAAO,SAAS,CAAC,sBAAsB,CACrC,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EACvD,UAAU,CACX,CAAC;AACJ,CAAC"}
|