@hadron-fi/sdk 0.4.1 → 0.4.3
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/dist/index.d.mts +21 -5
- package/dist/index.d.ts +21 -5
- package/dist/index.js +60 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -397,6 +397,13 @@ declare class Hadron {
|
|
|
397
397
|
poolAddress: PublicKey;
|
|
398
398
|
seed: bigint;
|
|
399
399
|
};
|
|
400
|
+
/**
|
|
401
|
+
* Build idempotent create-ATA instructions for the fee recipient for both mints.
|
|
402
|
+
*
|
|
403
|
+
* These are no-ops on-chain if the ATAs already exist. Include them alongside
|
|
404
|
+
* initialize or first deposit to ensure swaps don't fail due to missing fee ATAs.
|
|
405
|
+
*/
|
|
406
|
+
static buildFeeRecipientAtaIxs(payer: PublicKey, feeRecipient: PublicKey, mintX: PublicKey, mintY: PublicKey, tokenProgramX?: PublicKey, tokenProgramY?: PublicKey): TransactionInstruction[];
|
|
400
407
|
/** Generate a random u64 seed. */
|
|
401
408
|
private static randomSeed;
|
|
402
409
|
/** Re-fetch all account state from the chain. */
|
|
@@ -750,9 +757,18 @@ declare function wrapSolInstructions(user: PublicKey, lamports: bigint): Transac
|
|
|
750
757
|
*/
|
|
751
758
|
declare function createWsolAtaInstruction(user: PublicKey): TransactionInstruction;
|
|
752
759
|
/**
|
|
753
|
-
* Build
|
|
760
|
+
* Build instructions to unwrap wSOL — closes the ATA (sending lamports back to
|
|
761
|
+
* the user) and immediately re-creates it so the ATA remains open for future
|
|
762
|
+
* deposits (e.g. fee collection).
|
|
754
763
|
*/
|
|
755
|
-
declare function
|
|
764
|
+
declare function unwrapSolInstructions(user: PublicKey): TransactionInstruction[];
|
|
765
|
+
/**
|
|
766
|
+
* Build idempotent create-ATA instructions for the fee recipient for both mints.
|
|
767
|
+
*
|
|
768
|
+
* These are no-ops if the ATAs already exist. Include them in the initialize or
|
|
769
|
+
* first deposit transaction to ensure swaps don't fail due to missing fee ATAs.
|
|
770
|
+
*/
|
|
771
|
+
declare function buildFeeRecipientAtaIxs(payer: PublicKey, feeRecipient: PublicKey, mintX: PublicKey, mintY: PublicKey, tokenProgramX?: PublicKey, tokenProgramY?: PublicKey): TransactionInstruction[];
|
|
756
772
|
|
|
757
773
|
/**
|
|
758
774
|
* Get the ATA address, and optionally return a create instruction if it doesn't exist.
|
|
@@ -927,9 +943,9 @@ declare function buildUpdateSpreadConfig(admin: PublicKey, configPda: PublicKey,
|
|
|
927
943
|
declare function buildSetPoolState(authority: PublicKey, configPda: PublicKey, params: SetPoolStateParams, programId?: PublicKey): TransactionInstruction;
|
|
928
944
|
/**
|
|
929
945
|
* Build an UpdateDeltaStaleness instruction.
|
|
930
|
-
* Accounts: authority, config.
|
|
946
|
+
* Accounts: authority (quoting authority), config, curveMeta.
|
|
931
947
|
*/
|
|
932
|
-
declare function buildUpdateDeltaStaleness(authority: PublicKey, configPda: PublicKey, params: UpdateDeltaStalenessParams, programId?: PublicKey): TransactionInstruction;
|
|
948
|
+
declare function buildUpdateDeltaStaleness(authority: PublicKey, configPda: PublicKey, curveMetaPda: PublicKey, params: UpdateDeltaStalenessParams, programId?: PublicKey): TransactionInstruction;
|
|
933
949
|
/**
|
|
934
950
|
* Build a ClosePool instruction.
|
|
935
951
|
* Accounts: authority, config, midprice_oracle, curve_meta, curve_prefabs,
|
|
@@ -938,4 +954,4 @@ declare function buildUpdateDeltaStaleness(authority: PublicKey, configPda: Publ
|
|
|
938
954
|
*/
|
|
939
955
|
declare function buildClosePool(authority: PublicKey, configPda: PublicKey, midpriceOraclePda: PublicKey, curveMetaPda: PublicKey, curvePrefabsPda: PublicKey, curveUpdatesPda: PublicKey, vaultX: PublicKey, vaultY: PublicKey, tokenProgramX: PublicKey, tokenProgramY: PublicKey, spreadConfigInitialized?: boolean, authorityAtaX?: PublicKey, authorityAtaY?: PublicKey, programId?: PublicKey): TransactionInstruction;
|
|
940
956
|
|
|
941
|
-
export { ABSOLUTE_MAX_CURVE_POINTS, ABSOLUTE_MAX_PREFAB_SLOTS, type AllocateCurvePrefabsParams, type AmendOrderParams, CONFIG_SEED, CONFIG_SIZE, CURVE_META_SEED, CURVE_META_SIZE, CURVE_POINT_LEN, CURVE_PREFABS_SEED, CURVE_SIDE_HEADER, CURVE_UPDATES_SEED, CURVE_UPDATES_SIZE, CURVE_UPDATE_OP_SIZE, type CancelOrderParams, type CurvePoint, type CurveSide, CurveType, type CurveUpdateOp, CurveUpdateOpKind, CurveXMode, DEFAULT_MAX_CURVE_POINTS, DEFAULT_MAX_PREFAB_SLOTS, type DecodedConfig, type DecodedCurveMeta, type DecodedCurveUpdates, type DecodedFeeConfig, type DecodedMidpriceOracle, type DecodedSpreadConfig, type DepositParams, Discriminator, FEE_CONFIG_SEED, FEE_CONFIG_SIZE, HADRON_PROGRAM_ID, Hadron, HadronOrderbook, type InitializeFeeConfigParams, type InitializeParams, type InitializePoolFeeConfigParams, type InitializeSpreadConfigParams, Interpolation, MAX_CURVE_UPDATE_OPS, MAX_SETCURVE_POINTS, MIDPRICE_ORACLE_SEED, MIDPRICE_ORACLE_SIZE, type NominateAuthorityParams, OracleMode, type OrderSide, type OrderbookLevel, type OrderbookState, POINT_DATA_SIZE, type PlaceOrderParams, type PoolAddresses, PoolState, Q32_ONE, RiskMode, type RotateFeeAdminParams, SPREAD_CONFIG_SEED, type SetCurveBothParams, type SetCurveParams, type SetCurvePointInput, type SetPoolStateParams, type SetQuotingAuthorityParams, type SetRiskCurveAbsoluteBothParams, type SetRiskCurveAbsoluteParams, type SetRiskCurveAbsolutePointInput, type SetRiskCurveBothParams, type SetRiskCurveParams, type SetRiskCurvePointInput, Side, type SpreadTriggerInput, type StagedOrder, type SwapParams, type SwitchCurveParams, type UpdateBaseSpreadParams, type UpdateDeltaStalenessParams, type UpdateFeeConfigParams, type UpdateMidpriceAndBaseSpreadParams, type UpdateMidpriceParams, type UpdatePoolFeeConfigParams, type UpdateSpreadConfigParams, type WithdrawParams, buildAcceptAuthority, buildAllocateCurvePrefabs, buildApplyCurveUpdates, buildClosePool, buildDeposit, buildInitialize, buildInitializeFeeConfig, buildInitializePoolFeeConfig, buildInitializeSpreadConfig, buildNominateAuthority, buildRotateFeeAdmin, buildSetCurve, buildSetCurveBoth, buildSetPoolState, buildSetQuotingAuthority, buildSetRiskCurve, buildSetRiskCurveAbsolute, buildSetRiskCurveAbsoluteBoth, buildSetRiskCurveBoth, buildSubmitCurveUpdates, buildSwapExactIn, buildSwitchPriceCurve, buildSwitchRiskCurve, buildUpdateBaseSpread, buildUpdateDeltaStaleness, buildUpdateFeeConfig, buildUpdateMidprice, buildUpdateMidpriceAndBaseSpread, buildUpdatePoolFeeConfig, buildUpdateSpreadConfig, buildWithdraw, createWsolAtaInstruction, curvePrefabsSize, decodeActiveCurves, decodeConfig, decodeCurveMeta, decodeCurveSide, decodeCurveUpdates, decodeFeeConfig, decodeMidpriceOracle, decodeSpreadConfig, derivePoolAddresses, fromQ32, getConfigAddress, getCurveMetaAddress, getCurvePrefabsAddress, getCurveUpdatesAddress, getFeeConfigAddress, getMidpriceOracleAddress, getOrCreateAta, getPoolFeeConfigAddress, getSpreadConfigAddress, isNativeMint, isSlotInitialized, pctToQ32, spreadBpsToQ32, spreadQ32ToBps, toQ32,
|
|
957
|
+
export { ABSOLUTE_MAX_CURVE_POINTS, ABSOLUTE_MAX_PREFAB_SLOTS, type AllocateCurvePrefabsParams, type AmendOrderParams, CONFIG_SEED, CONFIG_SIZE, CURVE_META_SEED, CURVE_META_SIZE, CURVE_POINT_LEN, CURVE_PREFABS_SEED, CURVE_SIDE_HEADER, CURVE_UPDATES_SEED, CURVE_UPDATES_SIZE, CURVE_UPDATE_OP_SIZE, type CancelOrderParams, type CurvePoint, type CurveSide, CurveType, type CurveUpdateOp, CurveUpdateOpKind, CurveXMode, DEFAULT_MAX_CURVE_POINTS, DEFAULT_MAX_PREFAB_SLOTS, type DecodedConfig, type DecodedCurveMeta, type DecodedCurveUpdates, type DecodedFeeConfig, type DecodedMidpriceOracle, type DecodedSpreadConfig, type DepositParams, Discriminator, FEE_CONFIG_SEED, FEE_CONFIG_SIZE, HADRON_PROGRAM_ID, Hadron, HadronOrderbook, type InitializeFeeConfigParams, type InitializeParams, type InitializePoolFeeConfigParams, type InitializeSpreadConfigParams, Interpolation, MAX_CURVE_UPDATE_OPS, MAX_SETCURVE_POINTS, MIDPRICE_ORACLE_SEED, MIDPRICE_ORACLE_SIZE, type NominateAuthorityParams, OracleMode, type OrderSide, type OrderbookLevel, type OrderbookState, POINT_DATA_SIZE, type PlaceOrderParams, type PoolAddresses, PoolState, Q32_ONE, RiskMode, type RotateFeeAdminParams, SPREAD_CONFIG_SEED, type SetCurveBothParams, type SetCurveParams, type SetCurvePointInput, type SetPoolStateParams, type SetQuotingAuthorityParams, type SetRiskCurveAbsoluteBothParams, type SetRiskCurveAbsoluteParams, type SetRiskCurveAbsolutePointInput, type SetRiskCurveBothParams, type SetRiskCurveParams, type SetRiskCurvePointInput, Side, type SpreadTriggerInput, type StagedOrder, type SwapParams, type SwitchCurveParams, type UpdateBaseSpreadParams, type UpdateDeltaStalenessParams, type UpdateFeeConfigParams, type UpdateMidpriceAndBaseSpreadParams, type UpdateMidpriceParams, type UpdatePoolFeeConfigParams, type UpdateSpreadConfigParams, type WithdrawParams, buildAcceptAuthority, buildAllocateCurvePrefabs, buildApplyCurveUpdates, buildClosePool, buildDeposit, buildFeeRecipientAtaIxs, buildInitialize, buildInitializeFeeConfig, buildInitializePoolFeeConfig, buildInitializeSpreadConfig, buildNominateAuthority, buildRotateFeeAdmin, buildSetCurve, buildSetCurveBoth, buildSetPoolState, buildSetQuotingAuthority, buildSetRiskCurve, buildSetRiskCurveAbsolute, buildSetRiskCurveAbsoluteBoth, buildSetRiskCurveBoth, buildSubmitCurveUpdates, buildSwapExactIn, buildSwitchPriceCurve, buildSwitchRiskCurve, buildUpdateBaseSpread, buildUpdateDeltaStaleness, buildUpdateFeeConfig, buildUpdateMidprice, buildUpdateMidpriceAndBaseSpread, buildUpdatePoolFeeConfig, buildUpdateSpreadConfig, buildWithdraw, createWsolAtaInstruction, curvePrefabsSize, decodeActiveCurves, decodeConfig, decodeCurveMeta, decodeCurveSide, decodeCurveUpdates, decodeFeeConfig, decodeMidpriceOracle, decodeSpreadConfig, derivePoolAddresses, fromQ32, getConfigAddress, getCurveMetaAddress, getCurvePrefabsAddress, getCurveUpdatesAddress, getFeeConfigAddress, getMidpriceOracleAddress, getOrCreateAta, getPoolFeeConfigAddress, getSpreadConfigAddress, isNativeMint, isSlotInitialized, pctToQ32, spreadBpsToQ32, spreadQ32ToBps, toQ32, unwrapSolInstructions, wrapSolInstructions };
|
package/dist/index.d.ts
CHANGED
|
@@ -397,6 +397,13 @@ declare class Hadron {
|
|
|
397
397
|
poolAddress: PublicKey;
|
|
398
398
|
seed: bigint;
|
|
399
399
|
};
|
|
400
|
+
/**
|
|
401
|
+
* Build idempotent create-ATA instructions for the fee recipient for both mints.
|
|
402
|
+
*
|
|
403
|
+
* These are no-ops on-chain if the ATAs already exist. Include them alongside
|
|
404
|
+
* initialize or first deposit to ensure swaps don't fail due to missing fee ATAs.
|
|
405
|
+
*/
|
|
406
|
+
static buildFeeRecipientAtaIxs(payer: PublicKey, feeRecipient: PublicKey, mintX: PublicKey, mintY: PublicKey, tokenProgramX?: PublicKey, tokenProgramY?: PublicKey): TransactionInstruction[];
|
|
400
407
|
/** Generate a random u64 seed. */
|
|
401
408
|
private static randomSeed;
|
|
402
409
|
/** Re-fetch all account state from the chain. */
|
|
@@ -750,9 +757,18 @@ declare function wrapSolInstructions(user: PublicKey, lamports: bigint): Transac
|
|
|
750
757
|
*/
|
|
751
758
|
declare function createWsolAtaInstruction(user: PublicKey): TransactionInstruction;
|
|
752
759
|
/**
|
|
753
|
-
* Build
|
|
760
|
+
* Build instructions to unwrap wSOL — closes the ATA (sending lamports back to
|
|
761
|
+
* the user) and immediately re-creates it so the ATA remains open for future
|
|
762
|
+
* deposits (e.g. fee collection).
|
|
754
763
|
*/
|
|
755
|
-
declare function
|
|
764
|
+
declare function unwrapSolInstructions(user: PublicKey): TransactionInstruction[];
|
|
765
|
+
/**
|
|
766
|
+
* Build idempotent create-ATA instructions for the fee recipient for both mints.
|
|
767
|
+
*
|
|
768
|
+
* These are no-ops if the ATAs already exist. Include them in the initialize or
|
|
769
|
+
* first deposit transaction to ensure swaps don't fail due to missing fee ATAs.
|
|
770
|
+
*/
|
|
771
|
+
declare function buildFeeRecipientAtaIxs(payer: PublicKey, feeRecipient: PublicKey, mintX: PublicKey, mintY: PublicKey, tokenProgramX?: PublicKey, tokenProgramY?: PublicKey): TransactionInstruction[];
|
|
756
772
|
|
|
757
773
|
/**
|
|
758
774
|
* Get the ATA address, and optionally return a create instruction if it doesn't exist.
|
|
@@ -927,9 +943,9 @@ declare function buildUpdateSpreadConfig(admin: PublicKey, configPda: PublicKey,
|
|
|
927
943
|
declare function buildSetPoolState(authority: PublicKey, configPda: PublicKey, params: SetPoolStateParams, programId?: PublicKey): TransactionInstruction;
|
|
928
944
|
/**
|
|
929
945
|
* Build an UpdateDeltaStaleness instruction.
|
|
930
|
-
* Accounts: authority, config.
|
|
946
|
+
* Accounts: authority (quoting authority), config, curveMeta.
|
|
931
947
|
*/
|
|
932
|
-
declare function buildUpdateDeltaStaleness(authority: PublicKey, configPda: PublicKey, params: UpdateDeltaStalenessParams, programId?: PublicKey): TransactionInstruction;
|
|
948
|
+
declare function buildUpdateDeltaStaleness(authority: PublicKey, configPda: PublicKey, curveMetaPda: PublicKey, params: UpdateDeltaStalenessParams, programId?: PublicKey): TransactionInstruction;
|
|
933
949
|
/**
|
|
934
950
|
* Build a ClosePool instruction.
|
|
935
951
|
* Accounts: authority, config, midprice_oracle, curve_meta, curve_prefabs,
|
|
@@ -938,4 +954,4 @@ declare function buildUpdateDeltaStaleness(authority: PublicKey, configPda: Publ
|
|
|
938
954
|
*/
|
|
939
955
|
declare function buildClosePool(authority: PublicKey, configPda: PublicKey, midpriceOraclePda: PublicKey, curveMetaPda: PublicKey, curvePrefabsPda: PublicKey, curveUpdatesPda: PublicKey, vaultX: PublicKey, vaultY: PublicKey, tokenProgramX: PublicKey, tokenProgramY: PublicKey, spreadConfigInitialized?: boolean, authorityAtaX?: PublicKey, authorityAtaY?: PublicKey, programId?: PublicKey): TransactionInstruction;
|
|
940
956
|
|
|
941
|
-
export { ABSOLUTE_MAX_CURVE_POINTS, ABSOLUTE_MAX_PREFAB_SLOTS, type AllocateCurvePrefabsParams, type AmendOrderParams, CONFIG_SEED, CONFIG_SIZE, CURVE_META_SEED, CURVE_META_SIZE, CURVE_POINT_LEN, CURVE_PREFABS_SEED, CURVE_SIDE_HEADER, CURVE_UPDATES_SEED, CURVE_UPDATES_SIZE, CURVE_UPDATE_OP_SIZE, type CancelOrderParams, type CurvePoint, type CurveSide, CurveType, type CurveUpdateOp, CurveUpdateOpKind, CurveXMode, DEFAULT_MAX_CURVE_POINTS, DEFAULT_MAX_PREFAB_SLOTS, type DecodedConfig, type DecodedCurveMeta, type DecodedCurveUpdates, type DecodedFeeConfig, type DecodedMidpriceOracle, type DecodedSpreadConfig, type DepositParams, Discriminator, FEE_CONFIG_SEED, FEE_CONFIG_SIZE, HADRON_PROGRAM_ID, Hadron, HadronOrderbook, type InitializeFeeConfigParams, type InitializeParams, type InitializePoolFeeConfigParams, type InitializeSpreadConfigParams, Interpolation, MAX_CURVE_UPDATE_OPS, MAX_SETCURVE_POINTS, MIDPRICE_ORACLE_SEED, MIDPRICE_ORACLE_SIZE, type NominateAuthorityParams, OracleMode, type OrderSide, type OrderbookLevel, type OrderbookState, POINT_DATA_SIZE, type PlaceOrderParams, type PoolAddresses, PoolState, Q32_ONE, RiskMode, type RotateFeeAdminParams, SPREAD_CONFIG_SEED, type SetCurveBothParams, type SetCurveParams, type SetCurvePointInput, type SetPoolStateParams, type SetQuotingAuthorityParams, type SetRiskCurveAbsoluteBothParams, type SetRiskCurveAbsoluteParams, type SetRiskCurveAbsolutePointInput, type SetRiskCurveBothParams, type SetRiskCurveParams, type SetRiskCurvePointInput, Side, type SpreadTriggerInput, type StagedOrder, type SwapParams, type SwitchCurveParams, type UpdateBaseSpreadParams, type UpdateDeltaStalenessParams, type UpdateFeeConfigParams, type UpdateMidpriceAndBaseSpreadParams, type UpdateMidpriceParams, type UpdatePoolFeeConfigParams, type UpdateSpreadConfigParams, type WithdrawParams, buildAcceptAuthority, buildAllocateCurvePrefabs, buildApplyCurveUpdates, buildClosePool, buildDeposit, buildInitialize, buildInitializeFeeConfig, buildInitializePoolFeeConfig, buildInitializeSpreadConfig, buildNominateAuthority, buildRotateFeeAdmin, buildSetCurve, buildSetCurveBoth, buildSetPoolState, buildSetQuotingAuthority, buildSetRiskCurve, buildSetRiskCurveAbsolute, buildSetRiskCurveAbsoluteBoth, buildSetRiskCurveBoth, buildSubmitCurveUpdates, buildSwapExactIn, buildSwitchPriceCurve, buildSwitchRiskCurve, buildUpdateBaseSpread, buildUpdateDeltaStaleness, buildUpdateFeeConfig, buildUpdateMidprice, buildUpdateMidpriceAndBaseSpread, buildUpdatePoolFeeConfig, buildUpdateSpreadConfig, buildWithdraw, createWsolAtaInstruction, curvePrefabsSize, decodeActiveCurves, decodeConfig, decodeCurveMeta, decodeCurveSide, decodeCurveUpdates, decodeFeeConfig, decodeMidpriceOracle, decodeSpreadConfig, derivePoolAddresses, fromQ32, getConfigAddress, getCurveMetaAddress, getCurvePrefabsAddress, getCurveUpdatesAddress, getFeeConfigAddress, getMidpriceOracleAddress, getOrCreateAta, getPoolFeeConfigAddress, getSpreadConfigAddress, isNativeMint, isSlotInitialized, pctToQ32, spreadBpsToQ32, spreadQ32ToBps, toQ32,
|
|
957
|
+
export { ABSOLUTE_MAX_CURVE_POINTS, ABSOLUTE_MAX_PREFAB_SLOTS, type AllocateCurvePrefabsParams, type AmendOrderParams, CONFIG_SEED, CONFIG_SIZE, CURVE_META_SEED, CURVE_META_SIZE, CURVE_POINT_LEN, CURVE_PREFABS_SEED, CURVE_SIDE_HEADER, CURVE_UPDATES_SEED, CURVE_UPDATES_SIZE, CURVE_UPDATE_OP_SIZE, type CancelOrderParams, type CurvePoint, type CurveSide, CurveType, type CurveUpdateOp, CurveUpdateOpKind, CurveXMode, DEFAULT_MAX_CURVE_POINTS, DEFAULT_MAX_PREFAB_SLOTS, type DecodedConfig, type DecodedCurveMeta, type DecodedCurveUpdates, type DecodedFeeConfig, type DecodedMidpriceOracle, type DecodedSpreadConfig, type DepositParams, Discriminator, FEE_CONFIG_SEED, FEE_CONFIG_SIZE, HADRON_PROGRAM_ID, Hadron, HadronOrderbook, type InitializeFeeConfigParams, type InitializeParams, type InitializePoolFeeConfigParams, type InitializeSpreadConfigParams, Interpolation, MAX_CURVE_UPDATE_OPS, MAX_SETCURVE_POINTS, MIDPRICE_ORACLE_SEED, MIDPRICE_ORACLE_SIZE, type NominateAuthorityParams, OracleMode, type OrderSide, type OrderbookLevel, type OrderbookState, POINT_DATA_SIZE, type PlaceOrderParams, type PoolAddresses, PoolState, Q32_ONE, RiskMode, type RotateFeeAdminParams, SPREAD_CONFIG_SEED, type SetCurveBothParams, type SetCurveParams, type SetCurvePointInput, type SetPoolStateParams, type SetQuotingAuthorityParams, type SetRiskCurveAbsoluteBothParams, type SetRiskCurveAbsoluteParams, type SetRiskCurveAbsolutePointInput, type SetRiskCurveBothParams, type SetRiskCurveParams, type SetRiskCurvePointInput, Side, type SpreadTriggerInput, type StagedOrder, type SwapParams, type SwitchCurveParams, type UpdateBaseSpreadParams, type UpdateDeltaStalenessParams, type UpdateFeeConfigParams, type UpdateMidpriceAndBaseSpreadParams, type UpdateMidpriceParams, type UpdatePoolFeeConfigParams, type UpdateSpreadConfigParams, type WithdrawParams, buildAcceptAuthority, buildAllocateCurvePrefabs, buildApplyCurveUpdates, buildClosePool, buildDeposit, buildFeeRecipientAtaIxs, buildInitialize, buildInitializeFeeConfig, buildInitializePoolFeeConfig, buildInitializeSpreadConfig, buildNominateAuthority, buildRotateFeeAdmin, buildSetCurve, buildSetCurveBoth, buildSetPoolState, buildSetQuotingAuthority, buildSetRiskCurve, buildSetRiskCurveAbsolute, buildSetRiskCurveAbsoluteBoth, buildSetRiskCurveBoth, buildSubmitCurveUpdates, buildSwapExactIn, buildSwitchPriceCurve, buildSwitchRiskCurve, buildUpdateBaseSpread, buildUpdateDeltaStaleness, buildUpdateFeeConfig, buildUpdateMidprice, buildUpdateMidpriceAndBaseSpread, buildUpdatePoolFeeConfig, buildUpdateSpreadConfig, buildWithdraw, createWsolAtaInstruction, curvePrefabsSize, decodeActiveCurves, decodeConfig, decodeCurveMeta, decodeCurveSide, decodeCurveUpdates, decodeFeeConfig, decodeMidpriceOracle, decodeSpreadConfig, derivePoolAddresses, fromQ32, getConfigAddress, getCurveMetaAddress, getCurvePrefabsAddress, getCurveUpdatesAddress, getFeeConfigAddress, getMidpriceOracleAddress, getOrCreateAta, getPoolFeeConfigAddress, getSpreadConfigAddress, isNativeMint, isSlotInitialized, pctToQ32, spreadBpsToQ32, spreadQ32ToBps, toQ32, unwrapSolInstructions, wrapSolInstructions };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/hadron.ts
|
|
2
|
+
var _spltoken = require('@solana/spl-token');
|
|
3
|
+
|
|
4
|
+
// src/helpers/sol.ts
|
|
2
5
|
|
|
3
6
|
|
|
4
7
|
var _web3js = require('@solana/web3.js');
|
|
@@ -7,7 +10,7 @@ var _web3js = require('@solana/web3.js');
|
|
|
7
10
|
|
|
8
11
|
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
|
|
@@ -43,9 +46,38 @@ function createWsolAtaInstruction(user) {
|
|
|
43
46
|
_spltoken.TOKEN_PROGRAM_ID
|
|
44
47
|
);
|
|
45
48
|
}
|
|
46
|
-
function
|
|
49
|
+
function unwrapSolInstructions(user) {
|
|
47
50
|
const ata = _spltoken.getAssociatedTokenAddressSync.call(void 0, _spltoken.NATIVE_MINT, user, false, _spltoken.TOKEN_PROGRAM_ID);
|
|
48
|
-
return
|
|
51
|
+
return [
|
|
52
|
+
_spltoken.createCloseAccountInstruction.call(void 0, ata, user, user, [], _spltoken.TOKEN_PROGRAM_ID),
|
|
53
|
+
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
54
|
+
user,
|
|
55
|
+
ata,
|
|
56
|
+
user,
|
|
57
|
+
_spltoken.NATIVE_MINT,
|
|
58
|
+
_spltoken.TOKEN_PROGRAM_ID
|
|
59
|
+
)
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
function buildFeeRecipientAtaIxs(payer, feeRecipient, mintX, mintY, tokenProgramX = _spltoken.TOKEN_PROGRAM_ID, tokenProgramY = _spltoken.TOKEN_PROGRAM_ID) {
|
|
63
|
+
const ataX = _spltoken.getAssociatedTokenAddressSync.call(void 0, mintX, feeRecipient, false, tokenProgramX);
|
|
64
|
+
const ataY = _spltoken.getAssociatedTokenAddressSync.call(void 0, mintY, feeRecipient, false, tokenProgramY);
|
|
65
|
+
return [
|
|
66
|
+
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
67
|
+
payer,
|
|
68
|
+
ataX,
|
|
69
|
+
feeRecipient,
|
|
70
|
+
mintX,
|
|
71
|
+
tokenProgramX
|
|
72
|
+
),
|
|
73
|
+
_spltoken.createAssociatedTokenAccountIdempotentInstruction.call(void 0,
|
|
74
|
+
payer,
|
|
75
|
+
ataY,
|
|
76
|
+
feeRecipient,
|
|
77
|
+
mintY,
|
|
78
|
+
tokenProgramY
|
|
79
|
+
)
|
|
80
|
+
];
|
|
49
81
|
}
|
|
50
82
|
|
|
51
83
|
// src/constants/index.ts
|
|
@@ -1262,7 +1294,7 @@ function buildSetPoolState(authority, configPda, params, programId = HADRON_PROG
|
|
|
1262
1294
|
data
|
|
1263
1295
|
});
|
|
1264
1296
|
}
|
|
1265
|
-
function buildUpdateDeltaStaleness(authority, configPda, params, programId = HADRON_PROGRAM_ID) {
|
|
1297
|
+
function buildUpdateDeltaStaleness(authority, configPda, curveMetaPda, params, programId = HADRON_PROGRAM_ID) {
|
|
1266
1298
|
const data = Buffer.alloc(1 + 1);
|
|
1267
1299
|
data.writeUInt8(Discriminator.UpdateDeltaStaleness, 0);
|
|
1268
1300
|
data.writeUInt8(params.deltaStaleness, 1);
|
|
@@ -1270,7 +1302,8 @@ function buildUpdateDeltaStaleness(authority, configPda, params, programId = HAD
|
|
|
1270
1302
|
programId,
|
|
1271
1303
|
keys: [
|
|
1272
1304
|
{ pubkey: authority, isSigner: true, isWritable: false },
|
|
1273
|
-
{ pubkey: configPda, isSigner: false, isWritable: true }
|
|
1305
|
+
{ pubkey: configPda, isSigner: false, isWritable: true },
|
|
1306
|
+
{ pubkey: curveMetaPda, isSigner: false, isWritable: false }
|
|
1274
1307
|
],
|
|
1275
1308
|
data
|
|
1276
1309
|
});
|
|
@@ -1417,6 +1450,22 @@ var Hadron = class _Hadron {
|
|
|
1417
1450
|
instructions.push(buildInitialize(payer, resolvedParams, programId));
|
|
1418
1451
|
return { instructions, poolAddress, seed };
|
|
1419
1452
|
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Build idempotent create-ATA instructions for the fee recipient for both mints.
|
|
1455
|
+
*
|
|
1456
|
+
* These are no-ops on-chain if the ATAs already exist. Include them alongside
|
|
1457
|
+
* initialize or first deposit to ensure swaps don't fail due to missing fee ATAs.
|
|
1458
|
+
*/
|
|
1459
|
+
static buildFeeRecipientAtaIxs(payer, feeRecipient, mintX, mintY, tokenProgramX, tokenProgramY) {
|
|
1460
|
+
return buildFeeRecipientAtaIxs(
|
|
1461
|
+
payer,
|
|
1462
|
+
feeRecipient,
|
|
1463
|
+
mintX,
|
|
1464
|
+
mintY,
|
|
1465
|
+
_nullishCoalesce(tokenProgramX, () => ( _spltoken.TOKEN_PROGRAM_ID)),
|
|
1466
|
+
_nullishCoalesce(tokenProgramY, () => ( _spltoken.TOKEN_PROGRAM_ID))
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1420
1469
|
/** Generate a random u64 seed. */
|
|
1421
1470
|
static randomSeed() {
|
|
1422
1471
|
const buf = new Uint8Array(8);
|
|
@@ -1684,6 +1733,7 @@ var Hadron = class _Hadron {
|
|
|
1684
1733
|
return buildUpdateDeltaStaleness(
|
|
1685
1734
|
authority,
|
|
1686
1735
|
this.poolAddress,
|
|
1736
|
+
this.addresses.curveMeta,
|
|
1687
1737
|
params,
|
|
1688
1738
|
this.programId
|
|
1689
1739
|
);
|
|
@@ -1797,7 +1847,7 @@ var Hadron = class _Hadron {
|
|
|
1797
1847
|
}
|
|
1798
1848
|
ixs.push(this.withdraw(user, params));
|
|
1799
1849
|
if (hasSol) {
|
|
1800
|
-
ixs.push(
|
|
1850
|
+
ixs.push(...unwrapSolInstructions(user));
|
|
1801
1851
|
}
|
|
1802
1852
|
return ixs;
|
|
1803
1853
|
}
|
|
@@ -1818,7 +1868,7 @@ var Hadron = class _Hadron {
|
|
|
1818
1868
|
}
|
|
1819
1869
|
ixs.push(this.swap(user, params));
|
|
1820
1870
|
if (isNativeMint(outputMint)) {
|
|
1821
|
-
ixs.push(
|
|
1871
|
+
ixs.push(...unwrapSolInstructions(user));
|
|
1822
1872
|
}
|
|
1823
1873
|
return ixs;
|
|
1824
1874
|
}
|
|
@@ -2506,5 +2556,6 @@ async function getOrCreateAta(connection, mint, owner, payer, tokenProgram = _sp
|
|
|
2506
2556
|
|
|
2507
2557
|
|
|
2508
2558
|
|
|
2509
|
-
|
|
2559
|
+
|
|
2560
|
+
exports.ABSOLUTE_MAX_CURVE_POINTS = ABSOLUTE_MAX_CURVE_POINTS; exports.ABSOLUTE_MAX_PREFAB_SLOTS = ABSOLUTE_MAX_PREFAB_SLOTS; exports.CONFIG_SEED = CONFIG_SEED; exports.CONFIG_SIZE = CONFIG_SIZE; exports.CURVE_META_SEED = CURVE_META_SEED; exports.CURVE_META_SIZE = CURVE_META_SIZE; exports.CURVE_POINT_LEN = CURVE_POINT_LEN; exports.CURVE_PREFABS_SEED = CURVE_PREFABS_SEED; exports.CURVE_SIDE_HEADER = CURVE_SIDE_HEADER; exports.CURVE_UPDATES_SEED = CURVE_UPDATES_SEED; exports.CURVE_UPDATES_SIZE = CURVE_UPDATES_SIZE; exports.CURVE_UPDATE_OP_SIZE = CURVE_UPDATE_OP_SIZE; exports.CurveType = CurveType; exports.CurveUpdateOpKind = CurveUpdateOpKind; exports.CurveXMode = CurveXMode; exports.DEFAULT_MAX_CURVE_POINTS = DEFAULT_MAX_CURVE_POINTS; exports.DEFAULT_MAX_PREFAB_SLOTS = DEFAULT_MAX_PREFAB_SLOTS; exports.Discriminator = Discriminator; exports.FEE_CONFIG_SEED = FEE_CONFIG_SEED; exports.FEE_CONFIG_SIZE = FEE_CONFIG_SIZE; exports.HADRON_PROGRAM_ID = HADRON_PROGRAM_ID; exports.Hadron = Hadron; exports.HadronOrderbook = HadronOrderbook; exports.Interpolation = Interpolation; exports.MAX_CURVE_UPDATE_OPS = MAX_CURVE_UPDATE_OPS; exports.MAX_SETCURVE_POINTS = MAX_SETCURVE_POINTS; exports.MIDPRICE_ORACLE_SEED = MIDPRICE_ORACLE_SEED; exports.MIDPRICE_ORACLE_SIZE = MIDPRICE_ORACLE_SIZE; exports.NATIVE_MINT = _spltoken.NATIVE_MINT; exports.OracleMode = OracleMode; exports.POINT_DATA_SIZE = POINT_DATA_SIZE; exports.PoolState = PoolState; exports.Q32_ONE = Q32_ONE; exports.RiskMode = RiskMode; exports.SPREAD_CONFIG_SEED = SPREAD_CONFIG_SEED; exports.Side = Side; exports.buildAcceptAuthority = buildAcceptAuthority; exports.buildAllocateCurvePrefabs = buildAllocateCurvePrefabs; exports.buildApplyCurveUpdates = buildApplyCurveUpdates; exports.buildClosePool = buildClosePool; exports.buildDeposit = buildDeposit; exports.buildFeeRecipientAtaIxs = buildFeeRecipientAtaIxs; exports.buildInitialize = buildInitialize; exports.buildInitializeFeeConfig = buildInitializeFeeConfig; exports.buildInitializePoolFeeConfig = buildInitializePoolFeeConfig; exports.buildInitializeSpreadConfig = buildInitializeSpreadConfig; exports.buildNominateAuthority = buildNominateAuthority; exports.buildRotateFeeAdmin = buildRotateFeeAdmin; exports.buildSetCurve = buildSetCurve; exports.buildSetCurveBoth = buildSetCurveBoth; exports.buildSetPoolState = buildSetPoolState; exports.buildSetQuotingAuthority = buildSetQuotingAuthority; exports.buildSetRiskCurve = buildSetRiskCurve; exports.buildSetRiskCurveAbsolute = buildSetRiskCurveAbsolute; exports.buildSetRiskCurveAbsoluteBoth = buildSetRiskCurveAbsoluteBoth; exports.buildSetRiskCurveBoth = buildSetRiskCurveBoth; exports.buildSubmitCurveUpdates = buildSubmitCurveUpdates; exports.buildSwapExactIn = buildSwapExactIn; exports.buildSwitchPriceCurve = buildSwitchPriceCurve; exports.buildSwitchRiskCurve = buildSwitchRiskCurve; exports.buildUpdateBaseSpread = buildUpdateBaseSpread; exports.buildUpdateDeltaStaleness = buildUpdateDeltaStaleness; exports.buildUpdateFeeConfig = buildUpdateFeeConfig; exports.buildUpdateMidprice = buildUpdateMidprice; exports.buildUpdateMidpriceAndBaseSpread = buildUpdateMidpriceAndBaseSpread; exports.buildUpdatePoolFeeConfig = buildUpdatePoolFeeConfig; exports.buildUpdateSpreadConfig = buildUpdateSpreadConfig; exports.buildWithdraw = buildWithdraw; exports.createWsolAtaInstruction = createWsolAtaInstruction; exports.curvePrefabsSize = curvePrefabsSize; exports.decodeActiveCurves = decodeActiveCurves; exports.decodeConfig = decodeConfig; exports.decodeCurveMeta = decodeCurveMeta; exports.decodeCurveSide = decodeCurveSide; exports.decodeCurveUpdates = decodeCurveUpdates; exports.decodeFeeConfig = decodeFeeConfig; exports.decodeMidpriceOracle = decodeMidpriceOracle; exports.decodeSpreadConfig = decodeSpreadConfig; exports.derivePoolAddresses = derivePoolAddresses; exports.fromQ32 = fromQ32; exports.getConfigAddress = getConfigAddress; exports.getCurveMetaAddress = getCurveMetaAddress; exports.getCurvePrefabsAddress = getCurvePrefabsAddress; exports.getCurveUpdatesAddress = getCurveUpdatesAddress; exports.getFeeConfigAddress = getFeeConfigAddress; exports.getMidpriceOracleAddress = getMidpriceOracleAddress; exports.getOrCreateAta = getOrCreateAta; exports.getPoolFeeConfigAddress = getPoolFeeConfigAddress; exports.getSpreadConfigAddress = getSpreadConfigAddress; exports.isNativeMint = isNativeMint; exports.isSlotInitialized = isSlotInitialized; exports.pctToQ32 = pctToQ32; exports.spreadBpsToQ32 = spreadBpsToQ32; exports.spreadQ32ToBps = spreadQ32ToBps; exports.toQ32 = toQ32; exports.unwrapSolInstructions = unwrapSolInstructions; exports.wrapSolInstructions = wrapSolInstructions;
|
|
2510
2561
|
//# sourceMappingURL=index.js.map
|