@pipeline-sol/sdk 0.0.0-stage → 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 +209 -2
- package/dist/actions.d.ts +87 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +326 -0
- package/dist/actions.js.map +1 -0
- package/dist/codecs.d.ts +188 -0
- package/dist/codecs.d.ts.map +1 -0
- package/dist/codecs.js +296 -0
- package/dist/codecs.js.map +1 -0
- package/dist/constants.d.ts +97 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +98 -0
- package/dist/constants.js.map +1 -0
- package/dist/discovery.d.ts +17 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +47 -0
- package/dist/discovery.js.map +1 -0
- package/dist/events.d.ts +106 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +149 -0
- package/dist/events.js.map +1 -0
- package/dist/fees.d.ts +16 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/fees.js +60 -0
- package/dist/fees.js.map +1 -0
- package/dist/http.d.ts +23 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +99 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect.d.ts +410 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +828 -0
- package/dist/inspect.js.map +1 -0
- package/dist/instructions.d.ts +101 -0
- package/dist/instructions.d.ts.map +1 -0
- package/dist/instructions.js +201 -0
- package/dist/instructions.js.map +1 -0
- package/dist/listing.d.ts +35 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +49 -0
- package/dist/listing.js.map +1 -0
- package/dist/metadata.d.ts +266 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +515 -0
- package/dist/metadata.js.map +1 -0
- package/dist/pda.d.ts +21 -0
- package/dist/pda.d.ts.map +1 -0
- package/dist/pda.js +52 -0
- package/dist/pda.js.map +1 -0
- package/dist/quote.d.ts +63 -0
- package/dist/quote.d.ts.map +1 -0
- package/dist/quote.js +169 -0
- package/dist/quote.js.map +1 -0
- package/package.json +56 -5
- package/schema/strategy-metadata.v1.json +171 -0
package/README.md
CHANGED
|
@@ -1,3 +1,210 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Pipeline TypeScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Instruction builders, account and event decoders, fee maths, discovery and RPC quoting for
|
|
4
|
+
the Pipeline router (`PiPEf4fFBpYXCtgfiWgVWzZNXnq2wZ7bnXidJCTwf34`). Built on
|
|
5
|
+
[`@solana/kit`](https://github.com/anza-xyz/kit).
|
|
6
|
+
|
|
7
|
+
> **Placeholder names.** The package name `@pipeline-sol/sdk` and the product name
|
|
8
|
+
> are working names and will change before publishing. The package is `private` for now.
|
|
9
|
+
|
|
10
|
+
Every byte layout mirrors the Rust crates `pipeline-strategy-interface`, `pipeline-client`
|
|
11
|
+
and `pipeline-events`. The tests check this against vectors generated by those crates
|
|
12
|
+
(`test/fixtures.json`).
|
|
13
|
+
|
|
14
|
+
## Build and test
|
|
15
|
+
|
|
16
|
+
Node 20.19 or later.
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
cd sdk/ts
|
|
20
|
+
npm install
|
|
21
|
+
npm run build # tsc → dist/
|
|
22
|
+
npm test # typecheck, format check, vitest
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The tests never touch the network. To regenerate the cross-language fixtures after
|
|
26
|
+
changing a Rust layout (run from `sdk/ts`):
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm run fixtures # cargo run -p pipeline-client --example ts_fixtures > test/fixtures.json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Conventions
|
|
33
|
+
|
|
34
|
+
- Addresses are kit `Address` strings; instructions are kit `Instruction`s with
|
|
35
|
+
`AccountMeta { address, role }`.
|
|
36
|
+
- `u64` and `i64` are `bigint`; `u8` and `u16` are `number`; `Option<T>` is `T | null`;
|
|
37
|
+
`Vec<u8>` is a byte array.
|
|
38
|
+
- PDA helpers and instruction builders are `async`, because kit derives PDAs with WebCrypto.
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
### Build a swap
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { address } from '@solana/kit';
|
|
46
|
+
import { amountForBudget, associatedTokenAddress, swap, TOKEN_PROGRAM_ADDRESS, TradeMode } from '@pipeline-sol/sdk';
|
|
47
|
+
|
|
48
|
+
const trader = address('...');
|
|
49
|
+
const inputMint = address('...');
|
|
50
|
+
const outputMint = address('...');
|
|
51
|
+
|
|
52
|
+
// Spend at most 1 token (9 decimals) in total, including Pipeline's 0.25% and a 0.5%
|
|
53
|
+
// integrator fee.
|
|
54
|
+
const amountIn = amountForBudget(1_000_000_000n, 50);
|
|
55
|
+
|
|
56
|
+
const instruction = await swap(
|
|
57
|
+
{
|
|
58
|
+
trader,
|
|
59
|
+
strategyProgram: address('...'),
|
|
60
|
+
marketState: address('...'),
|
|
61
|
+
traderInput: await associatedTokenAddress(trader, inputMint, TOKEN_PROGRAM_ADDRESS),
|
|
62
|
+
traderOutput: await associatedTokenAddress(trader, outputMint, TOKEN_PROGRAM_ADDRESS),
|
|
63
|
+
inputVault: address('...'), // from the market account's `vaults`
|
|
64
|
+
inputMint,
|
|
65
|
+
outputMint,
|
|
66
|
+
inputTokenProgram: TOKEN_PROGRAM_ADDRESS,
|
|
67
|
+
outputTokenProgram: TOKEN_PROGRAM_ADDRESS,
|
|
68
|
+
integratorFeeAccount: address('...'), // or null
|
|
69
|
+
strategyAccounts: [], // from resolveAccounts(...)
|
|
70
|
+
inputHookAccounts: [], // Token-2022 transfer-hook accounts, if any
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
mode: TradeMode.ExactIn,
|
|
74
|
+
amountIn,
|
|
75
|
+
amountOut: 0n,
|
|
76
|
+
minAmountOut: 990_000n,
|
|
77
|
+
integratorFeeBps: 50,
|
|
78
|
+
extra: new Uint8Array(),
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`inputHookAccounts` in the instruction data is always set from the number of hook accounts
|
|
84
|
+
passed. Add the instruction to a transaction with kit as usual, together with a compute
|
|
85
|
+
unit limit.
|
|
86
|
+
|
|
87
|
+
### Discover markets and quote
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { address, createSolanaRpc } from '@solana/kit';
|
|
91
|
+
import {
|
|
92
|
+
fetchMarkets,
|
|
93
|
+
marketViewFromMarket,
|
|
94
|
+
quoteStrategy,
|
|
95
|
+
resolveAccounts,
|
|
96
|
+
TOKEN_PROGRAM_ADDRESS,
|
|
97
|
+
TradeMode,
|
|
98
|
+
} from '@pipeline-sol/sdk';
|
|
99
|
+
|
|
100
|
+
const rpc = createSolanaRpc('https://api.devnet.solana.com');
|
|
101
|
+
const [{ address: marketAddress, account }] = await fetchMarkets(rpc);
|
|
102
|
+
const market = marketViewFromMarket(marketAddress, account, [TOKEN_PROGRAM_ADDRESS, TOKEN_PROGRAM_ADDRESS]);
|
|
103
|
+
|
|
104
|
+
const trade = {
|
|
105
|
+
mode: TradeMode.ExactIn,
|
|
106
|
+
inputIndex: 0,
|
|
107
|
+
outputIndex: 1,
|
|
108
|
+
amount: 1_000_000n,
|
|
109
|
+
trader: null,
|
|
110
|
+
extra: new Uint8Array(),
|
|
111
|
+
};
|
|
112
|
+
const feePayer = address('...'); // any funded account; nothing is signed
|
|
113
|
+
const strategyAccounts = await resolveAccounts(rpc, market, trade, feePayer);
|
|
114
|
+
const { quote } = await quoteStrategy(rpc, market, trade, strategyAccounts, feePayer);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`quoteStrategy` runs the strategy's own `pipeline_quote` by simulation, so amounts are at
|
|
118
|
+
the strategy's vaults: Pipeline's fee, the integrator fee and token transfer fees are not
|
|
119
|
+
applied (use the fee helpers below). The runtime strips trailing zero bytes from return
|
|
120
|
+
data; the SDK pads them back before decoding.
|
|
121
|
+
|
|
122
|
+
### Decode events
|
|
123
|
+
|
|
124
|
+
The router emits events as self-CPIs. Decode one instruction's data, or pull every event
|
|
125
|
+
out of a transaction fetched with `getTransaction(signature, { encoding: 'json', maxSupportedTransactionVersion: 0 })`:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { decodeEvent, extractEventsFromInnerInstructions } from '@pipeline-sol/sdk';
|
|
129
|
+
|
|
130
|
+
const event = decodeEvent(instructionData); // PipelineEvent | null
|
|
131
|
+
if (event?.type === 'Swap') {
|
|
132
|
+
console.log(event.data.netSent, event.data.pipelineFee);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const accountKeys = [
|
|
136
|
+
...tx.transaction.message.accountKeys,
|
|
137
|
+
...(tx.meta.loadedAddresses?.writable ?? []),
|
|
138
|
+
...(tx.meta.loadedAddresses?.readonly ?? []),
|
|
139
|
+
];
|
|
140
|
+
const events = extractEventsFromInnerInstructions(accountKeys, tx.meta.innerInstructions ?? []);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Fee maths
|
|
144
|
+
|
|
145
|
+
Identical to the Rust `fees` module. All fees round up.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
import { amountForBudget, ceilBps, maxTotalSpend, pipelineFee } from '@pipeline-sol/sdk';
|
|
149
|
+
|
|
150
|
+
pipelineFee(400n); // 1n
|
|
151
|
+
pipelineFee(401n); // 2n
|
|
152
|
+
ceilBps(10_000n, 50n); // 50n
|
|
153
|
+
maxTotalSpend(1_000_000n, 50); // 1_007_500n, or null on u64 overflow
|
|
154
|
+
amountForBudget(1_007_500n, 50); // 1_000_000n
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Show and filter on trust facts
|
|
158
|
+
|
|
159
|
+
`inspectMarket` and `inspectStrategy` read the router's registry, the strategy program, its
|
|
160
|
+
metadata, OtterSec's verified-builds API and each mint, and return facts plus flags. There
|
|
161
|
+
are no scores and no safe/unsafe judgements.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import { filterMarkets, inspectMarket } from '@pipeline-sol/sdk';
|
|
165
|
+
|
|
166
|
+
const facts = await inspectMarket(rpc, marketAddress, { cluster: 'devnet' });
|
|
167
|
+
const shown = filterMarkets([facts!], { exclude: ['permanent-delegate', 'transfer-hook'] });
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
OtterSec only covers mainnet. Pass `cluster` so the lookup is skipped elsewhere
|
|
171
|
+
(`verifiedBuild.status` is then `not-applicable` and neither build flag is set).
|
|
172
|
+
|
|
173
|
+
When valid metadata links a conformance report, `inspectStrategy` fetches it (1 MiB at most,
|
|
174
|
+
with the same rules as metadata), checks it against `conformance.sha256` if given, and
|
|
175
|
+
compares its `strategy.program_id` and `strategy.executable_sha256` with the deployed program
|
|
176
|
+
(`conformance`: `current`, `stale` or `unverified`, with a `reason`). Pass
|
|
177
|
+
`conformanceReport: false` to skip it; neither conformance flag is then set.
|
|
178
|
+
`evaluateConformanceReport` does the comparison on a report you already have.
|
|
179
|
+
`FLAG_DESCRIPTIONS` holds each flag's exact meaning:
|
|
180
|
+
|
|
181
|
+
| Group | Flags |
|
|
182
|
+
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
183
|
+
| Program | `upgradeable`, `frozen`, `program-missing`, `verified-build`, `unverified-build` |
|
|
184
|
+
| Registry | `unregistered`, `metadata-missing`, `metadata-unreachable`, `metadata-invalid`, `conformance-report` (the linked report is for the deployed code), `conformance-stale` (it is for other code) |
|
|
185
|
+
| Checks | `checks-passed`, `checks-failed`, `checks-pending`: set by the hosted API from its `pipeline-check` runs, never by the SDK |
|
|
186
|
+
| Mints | `mint-unreadable`, `token-2022`, `mint-authority`, `freeze-authority`, `transfer-hook` (a hook is set), `transfer-hook-authority` (can set one), `transfer-fee` (non-zero now or scheduled), `transfer-fee-authority` (can change it), `permanent-delegate`, `non-transferable`, `default-frozen`, `pausable`, `paused`, `closable-mint`, `interest-bearing`, `scaled-ui-amount`, `confidential-transfers`, `permissioned-burn`, `unknown-extension` |
|
|
187
|
+
|
|
188
|
+
### Strategy metadata and custom actions
|
|
189
|
+
|
|
190
|
+
`fetchStrategyMetadata(uri)` fetches and validates a strategy's metadata document
|
|
191
|
+
(`schema/strategy-metadata.v1.json`; see `docs/STRATEGY-GUIDE.md` section 7).
|
|
192
|
+
`buildActionInstruction` turns one of its `actions` into an instruction, and
|
|
193
|
+
`buildCreateMarketFromMetadata` turns its `init` into `create_market`.
|
|
194
|
+
|
|
195
|
+
## Contents
|
|
196
|
+
|
|
197
|
+
| Module | What it provides |
|
|
198
|
+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
199
|
+
| `constants` | Program addresses, seeds, discriminators, `PIPELINE_FEE_BPS`, trade account positions |
|
|
200
|
+
| `pda` | `configPda`, `strategyPda`, `marketPda`, `feeAuthorityPda`, `feeAccountPda`, `registerPda`, `eventAuthorityPda`, `programDataPda`, `associatedTokenAddress` |
|
|
201
|
+
| `codecs` | Borsh codecs for strategy wire types, router arguments, `SwapResult` and router accounts (`decodeConfig`, `decodeStrategy`, `decodeMarket` check the Anchor discriminator) |
|
|
202
|
+
| `instructions` | `initializeConfig`, `updateConfig`, `registerStrategy`, `updateMetadata`, `createMarket`, `registerExistingMarket`, `initFeeAccount`, `swap`, `sweepFees` |
|
|
203
|
+
| `fees` | `ceilBps`, `pipelineFee`, `maxTotalSpend`, `amountForBudget` |
|
|
204
|
+
| `events` | `decodeEvent`, `encodeEvent`, `extractEvents`, `extractEventsFromInnerInstructions` |
|
|
205
|
+
| `discovery` | `fetchMarkets`, `fetchStrategies` (`getProgramAccounts` filtered by discriminator) |
|
|
206
|
+
| `quote` | `quoteStrategy`, `resolveAccounts` (RPC simulation), and the instructions they simulate |
|
|
207
|
+
| `listing` | `registerAndListMarketInstructions`, `createAndListMarketInstructions` (record a market, then `init_fee_account` per mint) |
|
|
208
|
+
| `metadata` | Strategy metadata v1 (`schema/strategy-metadata.v1.json`): `parseStrategyMetadata`, `fetchStrategyMetadata` (https, ipfs, ar; size limit and timeout), `parseAccountSource` |
|
|
209
|
+
| `actions` | `buildActionInstruction`, `resolveInit`, `buildCreateMarketFromMetadata`, `encodeArg`: instructions from metadata `actions` and `init` |
|
|
210
|
+
| `inspect` | `inspectProgram`, `fetchVerifiedBuild`, `inspectMint`, `inspectStrategy`, `inspectMarket`, `FLAG_DESCRIPTIONS`, `filterMarkets`: trust facts and filter flags, no judgements |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type AccountMeta, type Address, type GetAccountInfoApi, type ReadonlyUint8Array, type Rpc } from '@solana/kit';
|
|
2
|
+
import { type PipelineInstruction } from './instructions.js';
|
|
3
|
+
import { type AccountSource, type ArgType, type MetadataAccount, type MetadataAction, type MetadataArg, type MetadataInit } from './metadata.js';
|
|
4
|
+
import type { MarketView } from './quote.js';
|
|
5
|
+
/** A value for one metadata argument. Integers may be given as decimal strings. */
|
|
6
|
+
export type ArgValue = bigint | number | string | boolean | ReadonlyUint8Array;
|
|
7
|
+
/** Thrown when an action or init description can't be turned into an instruction. */
|
|
8
|
+
export declare class MetadataInstructionError extends Error {
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
/** Everything account sources may refer to. Leave out what doesn't apply. */
|
|
12
|
+
export type SourceContext = {
|
|
13
|
+
strategyProgram: Address;
|
|
14
|
+
/** The user's wallet; the creator for `init`. */
|
|
15
|
+
wallet?: Address;
|
|
16
|
+
marketState?: Address;
|
|
17
|
+
/** Mints, vaults and token programs, for an existing market. */
|
|
18
|
+
market?: MarketView;
|
|
19
|
+
/** Values for `input:<name>` sources. */
|
|
20
|
+
inputs?: Record<string, Address>;
|
|
21
|
+
/** Encoded arguments, for `arg:<name>` seeds. */
|
|
22
|
+
args?: Record<string, Uint8Array>;
|
|
23
|
+
/**
|
|
24
|
+
* The token program owning each mint, for `ata:` and `token_program_of:` sources whose
|
|
25
|
+
* mint isn't one of the market's. Looked up with `rpc` if missing.
|
|
26
|
+
*/
|
|
27
|
+
tokenPrograms?: Record<string, Address>;
|
|
28
|
+
rpc?: Rpc<GetAccountInfoApi>;
|
|
29
|
+
};
|
|
30
|
+
/** Anchor's instruction discriminator, `sha256("global:<name>")[..8]`. */
|
|
31
|
+
export declare function anchorDiscriminator(name: string): Promise<Uint8Array>;
|
|
32
|
+
/** Borsh-encodes one argument value as its declared type. */
|
|
33
|
+
export declare function encodeArg(type: ArgType, value: ArgValue, name?: string): Uint8Array;
|
|
34
|
+
/** Encodes every argument by name. Fails on a missing value. */
|
|
35
|
+
export declare function encodeArgs(specs: readonly MetadataArg[], values: Record<string, ArgValue>): Record<string, Uint8Array>;
|
|
36
|
+
/** Resolves an account source to an address. */
|
|
37
|
+
export declare function resolveAccountSource(source: string | AccountSource, context: SourceContext): Promise<Address>;
|
|
38
|
+
/** Resolves an ordered account list. */
|
|
39
|
+
export declare function resolveMetadataAccounts(accounts: readonly MetadataAccount[], context: SourceContext): Promise<AccountMeta[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Builds a custom action from strategy metadata as an instruction to the strategy
|
|
42
|
+
* program: the discriminator (given, or Anchor's from the action name), the Borsh-encoded
|
|
43
|
+
* arguments, and the resolved accounts. The user signs it directly; it doesn't go through
|
|
44
|
+
* the router.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildActionInstruction(input: {
|
|
47
|
+
action: MetadataAction;
|
|
48
|
+
market: MarketView;
|
|
49
|
+
wallet: Address;
|
|
50
|
+
args?: Record<string, ArgValue>;
|
|
51
|
+
inputs?: Record<string, Address>;
|
|
52
|
+
tokenPrograms?: Record<string, Address>;
|
|
53
|
+
rpc?: Rpc<GetAccountInfoApi>;
|
|
54
|
+
}): Promise<PipelineInstruction>;
|
|
55
|
+
/** What `create_market` needs from a strategy's `init` description. */
|
|
56
|
+
export type ResolvedInit = {
|
|
57
|
+
marketState: Address;
|
|
58
|
+
/** `true` when the market state is a new keypair that must sign the transaction. */
|
|
59
|
+
marketStateSigns: boolean;
|
|
60
|
+
/** The market's router account. */
|
|
61
|
+
market: Address;
|
|
62
|
+
initData: Uint8Array;
|
|
63
|
+
strategyAccounts: AccountMeta[];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Resolves a strategy's metadata `init` into `create_market` inputs. When the market
|
|
67
|
+
* state is a `new_keypair` (the default), pass the new keypair's address as
|
|
68
|
+
* `marketState`; it must sign.
|
|
69
|
+
*/
|
|
70
|
+
export declare function resolveInit(input: {
|
|
71
|
+
init: MetadataInit;
|
|
72
|
+
strategyProgram: Address;
|
|
73
|
+
creator: Address;
|
|
74
|
+
marketState?: Address;
|
|
75
|
+
args?: Record<string, ArgValue>;
|
|
76
|
+
inputs?: Record<string, Address>;
|
|
77
|
+
tokenPrograms?: Record<string, Address>;
|
|
78
|
+
rpc?: Rpc<GetAccountInfoApi>;
|
|
79
|
+
}): Promise<ResolvedInit>;
|
|
80
|
+
/** {@link resolveInit}, then the router's `create_market` instruction. */
|
|
81
|
+
export declare function buildCreateMarketFromMetadata(input: Parameters<typeof resolveInit>[0] & {
|
|
82
|
+
maxCreatorLamports: bigint;
|
|
83
|
+
}): Promise<{
|
|
84
|
+
instruction: PipelineInstruction;
|
|
85
|
+
resolved: ResolvedInit;
|
|
86
|
+
}>;
|
|
87
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAIA,OAAO,EAUH,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,GAAG,EACX,MAAM,aAAa,CAAC;AAS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O,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAChC,GAAG,OAAO,CAAC,YAAY,CAAC,CAsCxB;AAED,0EAA0E;AAC1E,wBAAsB,6BAA6B,CAC/C,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG;IAAE,kBAAkB,EAAE,MAAM,CAAA;CAAE,GAC1E,OAAO,CAAC;IAAE,WAAW,EAAE,mBAAmB,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,CAAC,CAYvE"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
// Turns a metadata `action` or `init` description into real instruction data and
|
|
2
|
+
// accounts, so a desk can render a form for any strategy and submit it without
|
|
3
|
+
// strategy-specific code.
|
|
4
|
+
import { AccountRole, getAddressEncoder, getI64Encoder, getProgramDerivedAddress, getU16Encoder, getU32Encoder, getU64Encoder, getU8Encoder, isAddress, } from '@solana/kit';
|
|
5
|
+
import { getBorshBytesCodec, getBorshStringCodec } from './codecs.js';
|
|
6
|
+
import { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, SYSTEM_PROGRAM_ADDRESS, TOKEN_2022_PROGRAM_ADDRESS, TOKEN_PROGRAM_ADDRESS, } from './constants.js';
|
|
7
|
+
import { createMarket } from './instructions.js';
|
|
8
|
+
import { hexToBytes, parseAccountSource, sourceNeedsMarket, } from './metadata.js';
|
|
9
|
+
import { associatedTokenAddress, marketPda } from './pda.js';
|
|
10
|
+
/** Thrown when an action or init description can't be turned into an instruction. */
|
|
11
|
+
export class MetadataInstructionError extends Error {
|
|
12
|
+
name = 'MetadataInstructionError';
|
|
13
|
+
}
|
|
14
|
+
const addressEncoder = getAddressEncoder();
|
|
15
|
+
const utf8 = new TextEncoder();
|
|
16
|
+
/** Anchor's instruction discriminator, `sha256("global:<name>")[..8]`. */
|
|
17
|
+
export async function anchorDiscriminator(name) {
|
|
18
|
+
const digest = await crypto.subtle.digest('SHA-256', utf8.encode(`global:${name}`));
|
|
19
|
+
return new Uint8Array(digest).slice(0, 8);
|
|
20
|
+
}
|
|
21
|
+
function fail(message) {
|
|
22
|
+
throw new MetadataInstructionError(message);
|
|
23
|
+
}
|
|
24
|
+
function integer(value, name) {
|
|
25
|
+
if (typeof value === 'bigint') {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === 'number' && Number.isSafeInteger(value)) {
|
|
29
|
+
return BigInt(value);
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === 'string' && /^-?\d+$/.test(value.trim())) {
|
|
32
|
+
return BigInt(value.trim());
|
|
33
|
+
}
|
|
34
|
+
return fail(`argument "${name}" must be an integer`);
|
|
35
|
+
}
|
|
36
|
+
const INTEGER_RANGES = {
|
|
37
|
+
u8: [0n, 0xffn],
|
|
38
|
+
u16: [0n, 0xffffn],
|
|
39
|
+
u32: [0n, 0xffffffffn],
|
|
40
|
+
u64: [0n, 0xffffffffffffffffn],
|
|
41
|
+
i64: [-(1n << 63n), (1n << 63n) - 1n],
|
|
42
|
+
};
|
|
43
|
+
/** Borsh-encodes one argument value as its declared type. */
|
|
44
|
+
export function encodeArg(type, value, name = 'value') {
|
|
45
|
+
const range = INTEGER_RANGES[type];
|
|
46
|
+
if (range) {
|
|
47
|
+
const n = integer(value, name);
|
|
48
|
+
if (n < range[0] || n > range[1]) {
|
|
49
|
+
fail(`argument "${name}" is out of range for ${type}`);
|
|
50
|
+
}
|
|
51
|
+
switch (type) {
|
|
52
|
+
case 'u8':
|
|
53
|
+
return getU8Encoder().encode(Number(n));
|
|
54
|
+
case 'u16':
|
|
55
|
+
return getU16Encoder().encode(Number(n));
|
|
56
|
+
case 'u32':
|
|
57
|
+
return getU32Encoder().encode(Number(n));
|
|
58
|
+
case 'u64':
|
|
59
|
+
return getU64Encoder().encode(n);
|
|
60
|
+
default:
|
|
61
|
+
return getI64Encoder().encode(n);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
switch (type) {
|
|
65
|
+
case 'bool':
|
|
66
|
+
if (value === true || value === 'true') {
|
|
67
|
+
return new Uint8Array([1]);
|
|
68
|
+
}
|
|
69
|
+
if (value === false || value === 'false') {
|
|
70
|
+
return new Uint8Array([0]);
|
|
71
|
+
}
|
|
72
|
+
return fail(`argument "${name}" must be a boolean`);
|
|
73
|
+
case 'pubkey':
|
|
74
|
+
if (typeof value !== 'string' || !isAddress(value)) {
|
|
75
|
+
return fail(`argument "${name}" must be an address`);
|
|
76
|
+
}
|
|
77
|
+
return addressEncoder.encode(value);
|
|
78
|
+
case 'bytes': {
|
|
79
|
+
let bytes;
|
|
80
|
+
if (value instanceof Uint8Array) {
|
|
81
|
+
bytes = value;
|
|
82
|
+
}
|
|
83
|
+
else if (typeof value === 'string' && /^(?:0x)?(?:[0-9a-fA-F]{2})*$/.test(value)) {
|
|
84
|
+
bytes = hexToBytes(value.replace(/^0x/, ''));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return fail(`argument "${name}" must be bytes or a hex string`);
|
|
88
|
+
}
|
|
89
|
+
return getBorshBytesCodec().encode(bytes);
|
|
90
|
+
}
|
|
91
|
+
case 'string':
|
|
92
|
+
if (typeof value !== 'string') {
|
|
93
|
+
return fail(`argument "${name}" must be a string`);
|
|
94
|
+
}
|
|
95
|
+
return getBorshStringCodec().encode(value);
|
|
96
|
+
default:
|
|
97
|
+
return fail(`unknown argument type "${type}"`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Encodes every argument by name. Fails on a missing value. */
|
|
101
|
+
export function encodeArgs(specs, values) {
|
|
102
|
+
const encoded = {};
|
|
103
|
+
for (const spec of specs) {
|
|
104
|
+
const value = values[spec.name];
|
|
105
|
+
if (value === undefined) {
|
|
106
|
+
fail(`missing argument "${spec.name}"`);
|
|
107
|
+
}
|
|
108
|
+
encoded[spec.name] = encodeArg(spec.type, value, spec.name);
|
|
109
|
+
}
|
|
110
|
+
return encoded;
|
|
111
|
+
}
|
|
112
|
+
function concat(parts) {
|
|
113
|
+
const total = parts.reduce((sum, part) => sum + part.length, 0);
|
|
114
|
+
const out = new Uint8Array(total);
|
|
115
|
+
let offset = 0;
|
|
116
|
+
for (const part of parts) {
|
|
117
|
+
out.set(part, offset);
|
|
118
|
+
offset += part.length;
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
function parsed(text) {
|
|
123
|
+
const source = parseAccountSource(text);
|
|
124
|
+
return typeof source === 'string' ? fail(source) : source;
|
|
125
|
+
}
|
|
126
|
+
function marketIndex(context, kind, index) {
|
|
127
|
+
const market = context.market ?? fail(`"${kind}:${index}" needs a market`);
|
|
128
|
+
const mint = market.mints[index] ?? fail(`the market has no mint ${index}`);
|
|
129
|
+
return { market, mint, vault: market.vaults[index], tokenProgram: market.tokenPrograms[index] };
|
|
130
|
+
}
|
|
131
|
+
async function tokenProgramOf(context, mint) {
|
|
132
|
+
const index = context.market?.mints.indexOf(mint) ?? -1;
|
|
133
|
+
if (index >= 0 && context.market?.tokenPrograms[index]) {
|
|
134
|
+
return context.market.tokenPrograms[index];
|
|
135
|
+
}
|
|
136
|
+
const known = context.tokenPrograms?.[mint];
|
|
137
|
+
if (known) {
|
|
138
|
+
return known;
|
|
139
|
+
}
|
|
140
|
+
if (!context.rpc) {
|
|
141
|
+
return fail(`token program of ${mint} unknown: pass tokenPrograms or rpc`);
|
|
142
|
+
}
|
|
143
|
+
const { value } = await context.rpc
|
|
144
|
+
.getAccountInfo(mint, { encoding: 'base64', dataSlice: { offset: 0, length: 0 } })
|
|
145
|
+
.send();
|
|
146
|
+
if (!value || (value.owner !== TOKEN_PROGRAM_ADDRESS && value.owner !== TOKEN_2022_PROGRAM_ADDRESS)) {
|
|
147
|
+
return fail(`${mint} is not a token mint`);
|
|
148
|
+
}
|
|
149
|
+
return value.owner;
|
|
150
|
+
}
|
|
151
|
+
/** Resolves an account source to an address. */
|
|
152
|
+
export async function resolveAccountSource(source, context) {
|
|
153
|
+
const s = typeof source === 'string' ? parsed(source) : source;
|
|
154
|
+
switch (s.kind) {
|
|
155
|
+
case 'wallet':
|
|
156
|
+
return context.wallet ?? fail('"wallet" needs a wallet');
|
|
157
|
+
case 'market_state':
|
|
158
|
+
return context.marketState ?? context.market?.marketState ?? fail('"market_state" needs a market state');
|
|
159
|
+
case 'market': {
|
|
160
|
+
if (context.market) {
|
|
161
|
+
return context.market.market;
|
|
162
|
+
}
|
|
163
|
+
const marketState = context.marketState ?? fail('"market" needs a market state');
|
|
164
|
+
return marketPda(context.strategyProgram, marketState);
|
|
165
|
+
}
|
|
166
|
+
case 'strategy_program':
|
|
167
|
+
return context.strategyProgram;
|
|
168
|
+
case 'system_program':
|
|
169
|
+
return SYSTEM_PROGRAM_ADDRESS;
|
|
170
|
+
case 'associated_token_program':
|
|
171
|
+
return ASSOCIATED_TOKEN_PROGRAM_ADDRESS;
|
|
172
|
+
case 'mint':
|
|
173
|
+
return marketIndex(context, s.kind, s.index).mint;
|
|
174
|
+
case 'vault':
|
|
175
|
+
return marketIndex(context, s.kind, s.index).vault ?? fail(`the market has no vault ${s.index}`);
|
|
176
|
+
case 'token_program':
|
|
177
|
+
return marketIndex(context, s.kind, s.index).tokenProgram ?? fail(`no token program for mint ${s.index}`);
|
|
178
|
+
case 'wallet_token_account': {
|
|
179
|
+
const { mint, tokenProgram } = marketIndex(context, s.kind, s.index);
|
|
180
|
+
const wallet = context.wallet ?? fail('"wallet_token_account" needs a wallet');
|
|
181
|
+
return associatedTokenAddress(wallet, mint, tokenProgram ?? (await tokenProgramOf(context, mint)));
|
|
182
|
+
}
|
|
183
|
+
case 'fixed':
|
|
184
|
+
return s.address;
|
|
185
|
+
case 'input': {
|
|
186
|
+
const value = context.inputs?.[s.name] ?? fail(`missing input "${s.name}"`);
|
|
187
|
+
return isAddress(value) ? value : fail(`input "${s.name}" is not an address`);
|
|
188
|
+
}
|
|
189
|
+
case 'ata': {
|
|
190
|
+
const owner = await resolveAccountSource(s.owner, context);
|
|
191
|
+
const mint = await resolveAccountSource(s.mint, context);
|
|
192
|
+
return associatedTokenAddress(owner, mint, await tokenProgramOf(context, mint));
|
|
193
|
+
}
|
|
194
|
+
case 'token_program_of':
|
|
195
|
+
return tokenProgramOf(context, await resolveAccountSource(s.mint, context));
|
|
196
|
+
case 'pda': {
|
|
197
|
+
const seeds = [];
|
|
198
|
+
for (const seed of s.seeds) {
|
|
199
|
+
switch (seed.kind) {
|
|
200
|
+
case 'str':
|
|
201
|
+
seeds.push(utf8.encode(seed.text));
|
|
202
|
+
break;
|
|
203
|
+
case 'hex':
|
|
204
|
+
seeds.push(seed.bytes);
|
|
205
|
+
break;
|
|
206
|
+
case 'key':
|
|
207
|
+
seeds.push(addressEncoder.encode(await resolveAccountSource(seed.source, context)));
|
|
208
|
+
break;
|
|
209
|
+
case 'arg': {
|
|
210
|
+
const bytes = context.args?.[seed.name] ?? fail(`seed needs argument "${seed.name}"`);
|
|
211
|
+
if (bytes.length > 32) {
|
|
212
|
+
fail(`argument "${seed.name}" is longer than 32 bytes and can't be a seed`);
|
|
213
|
+
}
|
|
214
|
+
seeds.push(bytes);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const programAddress = s.program === 'strategy' ? context.strategyProgram : s.program;
|
|
220
|
+
const [pda] = await getProgramDerivedAddress({ programAddress, seeds });
|
|
221
|
+
return pda;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function role(account) {
|
|
226
|
+
if (account.signer) {
|
|
227
|
+
return account.writable ? AccountRole.WRITABLE_SIGNER : AccountRole.READONLY_SIGNER;
|
|
228
|
+
}
|
|
229
|
+
return account.writable ? AccountRole.WRITABLE : AccountRole.READONLY;
|
|
230
|
+
}
|
|
231
|
+
/** Resolves an ordered account list. */
|
|
232
|
+
export async function resolveMetadataAccounts(accounts, context) {
|
|
233
|
+
const metas = [];
|
|
234
|
+
for (const account of accounts) {
|
|
235
|
+
metas.push({ address: await resolveAccountSource(account.source, context), role: role(account) });
|
|
236
|
+
}
|
|
237
|
+
return metas;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Builds a custom action from strategy metadata as an instruction to the strategy
|
|
241
|
+
* program: the discriminator (given, or Anchor's from the action name), the Borsh-encoded
|
|
242
|
+
* arguments, and the resolved accounts. The user signs it directly; it doesn't go through
|
|
243
|
+
* the router.
|
|
244
|
+
*/
|
|
245
|
+
export async function buildActionInstruction(input) {
|
|
246
|
+
const specs = input.action.args ?? [];
|
|
247
|
+
const args = encodeArgs(specs, input.args ?? {});
|
|
248
|
+
const context = {
|
|
249
|
+
strategyProgram: input.market.strategyProgram,
|
|
250
|
+
wallet: input.wallet,
|
|
251
|
+
market: input.market,
|
|
252
|
+
marketState: input.market.marketState,
|
|
253
|
+
inputs: input.inputs,
|
|
254
|
+
args,
|
|
255
|
+
tokenPrograms: input.tokenPrograms,
|
|
256
|
+
rpc: input.rpc,
|
|
257
|
+
};
|
|
258
|
+
const discriminator = input.action.discriminator
|
|
259
|
+
? hexToBytes(input.action.discriminator)
|
|
260
|
+
: await anchorDiscriminator(input.action.name);
|
|
261
|
+
return {
|
|
262
|
+
programAddress: input.market.strategyProgram,
|
|
263
|
+
accounts: await resolveMetadataAccounts(input.action.accounts ?? [], context),
|
|
264
|
+
data: concat([discriminator, ...specs.map((spec) => args[spec.name])]),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Resolves a strategy's metadata `init` into `create_market` inputs. When the market
|
|
269
|
+
* state is a `new_keypair` (the default), pass the new keypair's address as
|
|
270
|
+
* `marketState`; it must sign.
|
|
271
|
+
*/
|
|
272
|
+
export async function resolveInit(input) {
|
|
273
|
+
const specs = input.init.args ?? [];
|
|
274
|
+
const args = encodeArgs(specs, input.args ?? {});
|
|
275
|
+
const context = {
|
|
276
|
+
strategyProgram: input.strategyProgram,
|
|
277
|
+
wallet: input.creator,
|
|
278
|
+
inputs: input.inputs,
|
|
279
|
+
args,
|
|
280
|
+
tokenPrograms: input.tokenPrograms,
|
|
281
|
+
rpc: input.rpc,
|
|
282
|
+
};
|
|
283
|
+
const stateSource = input.init.market_state ?? 'new_keypair';
|
|
284
|
+
let marketState;
|
|
285
|
+
let marketStateSigns;
|
|
286
|
+
if (stateSource === 'new_keypair') {
|
|
287
|
+
marketState = input.marketState ?? fail('pass the new market state keypair address as marketState');
|
|
288
|
+
marketStateSigns = true;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const source = parsed(stateSource);
|
|
292
|
+
if (sourceNeedsMarket(source) || source.kind === 'market_state' || source.kind === 'market') {
|
|
293
|
+
fail(`init.market_state "${stateSource}" can't be resolved before the market exists`);
|
|
294
|
+
}
|
|
295
|
+
marketState = await resolveAccountSource(source, context);
|
|
296
|
+
marketStateSigns = false;
|
|
297
|
+
}
|
|
298
|
+
context.marketState = marketState;
|
|
299
|
+
for (const account of input.init.accounts ?? []) {
|
|
300
|
+
if (sourceNeedsMarket(parsed(account.source))) {
|
|
301
|
+
fail(`init account "${account.name}" refers to the market's mints before the market exists`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
marketState,
|
|
306
|
+
marketStateSigns,
|
|
307
|
+
market: await marketPda(input.strategyProgram, marketState),
|
|
308
|
+
initData: concat(specs.map((spec) => args[spec.name])),
|
|
309
|
+
strategyAccounts: await resolveMetadataAccounts(input.init.accounts ?? [], context),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/** {@link resolveInit}, then the router's `create_market` instruction. */
|
|
313
|
+
export async function buildCreateMarketFromMetadata(input) {
|
|
314
|
+
const resolved = await resolveInit(input);
|
|
315
|
+
const instruction = await createMarket({
|
|
316
|
+
creator: input.creator,
|
|
317
|
+
strategyProgram: input.strategyProgram,
|
|
318
|
+
marketState: resolved.marketState,
|
|
319
|
+
marketStateSigns: resolved.marketStateSigns,
|
|
320
|
+
initData: resolved.initData,
|
|
321
|
+
maxCreatorLamports: input.maxCreatorLamports,
|
|
322
|
+
strategyAccounts: resolved.strategyAccounts,
|
|
323
|
+
});
|
|
324
|
+
return { instruction, resolved };
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,+EAA+E;AAC/E,0BAA0B;AAE1B,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EACxB,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,GAMZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EACH,gCAAgC,EAChC,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAA4B,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EACH,UAAU,EACV,kBAAkB,EAClB,iBAAiB,GAOpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAM7D,qFAAqF;AACrF,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACtC,IAAI,GAAG,0BAA0B,CAAC;CAC9C;AAsBD,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;AAC3C,MAAM,IAAI,GAAG,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