@send-fun/sdk 1.0.0 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@send-fun/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Kit-native TypeScript SDK for send.fun",
5
5
  "keywords": [
6
6
  "dex",
@@ -43,6 +43,7 @@
43
43
  },
44
44
  "dependencies": {},
45
45
  "devDependencies": {
46
+ "@solana-program/token-2022": "^0.9.0",
46
47
  "@solana/kit": "^6.10.0",
47
48
  "@solana/program-client-core": "^6.10.0",
48
49
  "@types/node": "^24.10.4",
@@ -70,7 +70,8 @@ export async function buyExactOut(
70
70
  return {
71
71
  instruction: await buildBuyExactOutInstruction({
72
72
  ...params,
73
- amountOut: params.baseAmountOut,
73
+ // Capped at the supply left. The program reverts a short fill.
74
+ amountOut: quote.baseToUser,
74
75
  maxAmountIn: maxQuoteIn,
75
76
  }),
76
77
  quote,
@@ -488,12 +488,13 @@ export async function fetchSendMint(
488
488
 
489
489
  export interface PendingReward {
490
490
  rewardMint: Address;
491
- /** Base units of `rewardMint`. */
491
+ /** Base units of `rewardMint` debited at the vault (matches `ClaimEvent.amount`); a
492
+ * `TransferFeeConfig` mint delivers less -- net it with `transferFee.fetchMintFees`. */
492
493
  pending: bigint;
493
494
  }
494
495
 
495
496
  /** One entry per reward mint, in `knownRewardMints` order, else sorted by address. Each amount is in
496
- * its own mint's base units, so never sum them. */
497
+ * its own mint's base units, so never sum them, and is the vault's debit, not the claimant's credit. */
497
498
  export async function fetchPendingRewards(
498
499
  rpc: RewardMintRpc & Rpc<GetMultipleAccountsApi>,
499
500
  user: Address,
@@ -28,11 +28,12 @@ const ACCOUNT_TYPE_MINT = 1;
28
28
 
29
29
  const TLV_START = 166;
30
30
 
31
+ const TLV_TYPE = 2;
32
+
31
33
  const TLV_HEADER = 4;
32
34
 
33
35
  const TRANSFER_FEE_CONFIG_TYPE = 1;
34
36
 
35
- // Trailing rent slack reads as `ExtensionType::Uninitialized`, ending the list.
36
37
  const UNINITIALIZED_TYPE = 0;
37
38
 
38
39
  // Config authority, withdraw authority, `withheld_amount` u64, then older and
@@ -111,15 +112,17 @@ export function decodeTransferFeeConfig(
111
112
 
112
113
  let offset = TLV_START;
113
114
  while (offset < data.length) {
115
+ // Too short for a type, or a zero type: trailing slack, as SPL reads it.
116
+ if (offset + TLV_TYPE > data.length) return undefined;
117
+ const extensionType = view.getUint16(offset, true);
118
+ if (extensionType === UNINITIALIZED_TYPE) return undefined;
119
+
114
120
  if (offset + TLV_HEADER > data.length) {
115
121
  throw new RangeError(
116
122
  'decodeTransferFeeConfig: a TLV entry header runs past the end of the account',
117
123
  );
118
124
  }
119
125
 
120
- const extensionType = view.getUint16(offset, true);
121
- if (extensionType === UNINITIALIZED_TYPE) return undefined;
122
-
123
126
  const length = view.getUint16(offset + 2, true);
124
127
  const payload = offset + TLV_HEADER;
125
128
  const next = payload + length;