@wzrd_sol/sdk 0.1.0 → 0.1.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/README.md +7 -7
- package/dist/accounts.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/instructions.js +3 -3
- package/dist/pda.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @wzrd_sol/sdk
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for the Liquid Attention Protocol on Solana.
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ Builds `deposit_market`, `settle_market`, and `claim_global` transaction instruc
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install @
|
|
10
|
+
npm install @wzrd_sol/sdk @solana/web3.js
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
## Example Scripts
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
getGlobalRootConfigPDA,
|
|
47
47
|
getClaimStatePDA,
|
|
48
48
|
PROGRAM_ID,
|
|
49
|
-
} from '@
|
|
49
|
+
} from '@wzrd_sol/sdk';
|
|
50
50
|
|
|
51
51
|
const protocolState = getProtocolStatePDA();
|
|
52
52
|
const marketVault = getMarketVaultPDA(protocolState, 6); // market ID 6
|
|
@@ -57,7 +57,7 @@ const position = getUserPositionPDA(marketVault, walletPubkey);
|
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
59
|
import { Connection, Keypair, VersionedTransaction, TransactionMessage } from '@solana/web3.js';
|
|
60
|
-
import { createDepositMarketIx } from '@
|
|
60
|
+
import { createDepositMarketIx } from '@wzrd_sol/sdk';
|
|
61
61
|
|
|
62
62
|
const connection = new Connection('https://api.mainnet-beta.solana.com');
|
|
63
63
|
const wallet = Keypair.fromSecretKey(/* your key */);
|
|
@@ -81,7 +81,7 @@ console.log('Deposit tx:', sig);
|
|
|
81
81
|
### Claim CCM via Merkle Proof
|
|
82
82
|
|
|
83
83
|
```typescript
|
|
84
|
-
import { createClaimGlobalIx } from '@
|
|
84
|
+
import { createClaimGlobalIx } from '@wzrd_sol/sdk';
|
|
85
85
|
|
|
86
86
|
// Fetch proof from the server API
|
|
87
87
|
const res = await fetch(`https://api.twzrd.xyz/v1/claims/${wallet.publicKey.toBase58()}`);
|
|
@@ -101,7 +101,7 @@ const ixs = await createClaimGlobalIx(
|
|
|
101
101
|
### Settle a Matured Position
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
import { createSettleMarketIx } from '@
|
|
104
|
+
import { createSettleMarketIx } from '@wzrd_sol/sdk';
|
|
105
105
|
|
|
106
106
|
const ixs = await createSettleMarketIx(connection, wallet.publicKey, 6);
|
|
107
107
|
// Build, sign, send as above
|
|
@@ -110,7 +110,7 @@ const ixs = await createSettleMarketIx(connection, wallet.publicKey, 6);
|
|
|
110
110
|
### Read On-Chain State
|
|
111
111
|
|
|
112
112
|
```typescript
|
|
113
|
-
import { fetchMarketVault, fetchOnChainPosition, fetchTokenBalance } from '@
|
|
113
|
+
import { fetchMarketVault, fetchOnChainPosition, fetchTokenBalance } from '@wzrd_sol/sdk';
|
|
114
114
|
|
|
115
115
|
const vault = await fetchMarketVault(connection, 6);
|
|
116
116
|
console.log('Total deposited:', vault?.totalDeposited);
|
package/dist/accounts.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* programs/attention-oracle/src/state/*.rs.
|
|
6
6
|
*/
|
|
7
7
|
import { PublicKey } from '@solana/web3.js';
|
|
8
|
-
import { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA } from './pda';
|
|
8
|
+
import { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA } from './pda.js';
|
|
9
9
|
// ── Parsers ────────────────────────────────────────────
|
|
10
10
|
/** Parse a MarketVault account's core fields (skip Anchor discriminator). */
|
|
11
11
|
export function parseMarketVault(data) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @wzrd_sol/sdk — TypeScript SDK for the Liquid Attention Protocol.
|
|
3
3
|
*
|
|
4
4
|
* PDA derivation, instruction builders, and account parsers for
|
|
5
5
|
* deposit_market, settle_market, and claim_global.
|
|
6
6
|
*/
|
|
7
7
|
export declare const VERSION = "0.1.0";
|
|
8
|
-
export { PROGRAM_ID, DEVNET_PROGRAM_ID, MAINNET_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, } from './constants';
|
|
9
|
-
export { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getAta, } from './pda';
|
|
10
|
-
export type { MarketVaultData, MarketVaultFull, ProtocolStateData, OnChainPosition, } from './accounts';
|
|
11
|
-
export { parseMarketVault, parseProtocolState, parseUserMarketPosition, fetchOnChainPosition, fetchMarketVault, fetchTokenBalance, } from './accounts';
|
|
12
|
-
export { anchorDisc, createAtaIdempotentIx, createDepositMarketIx, createSettleMarketIx, createInitializeMarketVaultIx, createClaimGlobalIx, createChannelConfigV2Ix, } from './instructions';
|
|
8
|
+
export { PROGRAM_ID, DEVNET_PROGRAM_ID, MAINNET_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, } from './constants.js';
|
|
9
|
+
export { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getAta, } from './pda.js';
|
|
10
|
+
export type { MarketVaultData, MarketVaultFull, ProtocolStateData, OnChainPosition, } from './accounts.js';
|
|
11
|
+
export { parseMarketVault, parseProtocolState, parseUserMarketPosition, fetchOnChainPosition, fetchMarketVault, fetchTokenBalance, } from './accounts.js';
|
|
12
|
+
export { anchorDisc, createAtaIdempotentIx, createDepositMarketIx, createSettleMarketIx, createInitializeMarketVaultIx, createClaimGlobalIx, createChannelConfigV2Ix, } from './instructions.js';
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
2
|
+
* @wzrd_sol/sdk — TypeScript SDK for the Liquid Attention Protocol.
|
|
3
3
|
*
|
|
4
4
|
* PDA derivation, instruction builders, and account parsers for
|
|
5
5
|
* deposit_market, settle_market, and claim_global.
|
|
6
6
|
*/
|
|
7
7
|
export const VERSION = '0.1.0';
|
|
8
8
|
// ── Constants ──────────────────────────────────────────
|
|
9
|
-
export { PROGRAM_ID, DEVNET_PROGRAM_ID, MAINNET_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, } from './constants';
|
|
9
|
+
export { PROGRAM_ID, DEVNET_PROGRAM_ID, MAINNET_PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, } from './constants.js';
|
|
10
10
|
// ── PDA Derivation ─────────────────────────────────────
|
|
11
|
-
export { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getAta, } from './pda';
|
|
12
|
-
export { parseMarketVault, parseProtocolState, parseUserMarketPosition, fetchOnChainPosition, fetchMarketVault, fetchTokenBalance, } from './accounts';
|
|
11
|
+
export { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getAta, } from './pda.js';
|
|
12
|
+
export { parseMarketVault, parseProtocolState, parseUserMarketPosition, fetchOnChainPosition, fetchMarketVault, fetchTokenBalance, } from './accounts.js';
|
|
13
13
|
// ── Instruction Builders ───────────────────────────────
|
|
14
|
-
export { anchorDisc, createAtaIdempotentIx, createDepositMarketIx, createSettleMarketIx, createInitializeMarketVaultIx, createClaimGlobalIx, createChannelConfigV2Ix, } from './instructions';
|
|
14
|
+
export { anchorDisc, createAtaIdempotentIx, createDepositMarketIx, createSettleMarketIx, createInitializeMarketVaultIx, createClaimGlobalIx, createChannelConfigV2Ix, } from './instructions.js';
|
package/dist/instructions.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* that the wallet adapter signs directly — no server signing needed.
|
|
6
6
|
*/
|
|
7
7
|
import { SystemProgram, TransactionInstruction, } from '@solana/web3.js';
|
|
8
|
-
import { PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, } from './constants';
|
|
9
|
-
import { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getAta, } from './pda';
|
|
10
|
-
import { parseMarketVault, parseProtocolState } from './accounts';
|
|
8
|
+
import { PROGRAM_ID, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, } from './constants.js';
|
|
9
|
+
import { getProtocolStatePDA, getMarketVaultPDA, getUserPositionPDA, getGlobalRootConfigPDA, getClaimStatePDA, getChannelConfigV2PDA, getAta, } from './pda.js';
|
|
10
|
+
import { parseMarketVault, parseProtocolState } from './accounts.js';
|
|
11
11
|
// ── Helpers ────────────────────────────────────────────
|
|
12
12
|
/**
|
|
13
13
|
* Anchor instruction discriminator: first 8 bytes of SHA-256("global:<name>").
|
package/dist/pda.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Seeds must match programs/attention-oracle/src/constants.rs.
|
|
5
5
|
*/
|
|
6
6
|
import { PublicKey } from '@solana/web3.js';
|
|
7
|
-
import { PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, } from './constants';
|
|
7
|
+
import { PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, PROTOCOL_STATE_SEED, MARKET_VAULT_SEED, MARKET_POSITION_SEED, GLOBAL_ROOT_SEED, CLAIM_STATE_GLOBAL_SEED, CHANNEL_CONFIG_V2_SEED, } from './constants.js';
|
|
8
8
|
/** Derive the singleton ProtocolState PDA. */
|
|
9
9
|
export function getProtocolStatePDA(programId = PROGRAM_ID) {
|
|
10
10
|
return PublicKey.findProgramAddressSync([Buffer.from(PROTOCOL_STATE_SEED)], programId)[0];
|