@hadron-fi/sdk 0.4.1 → 0.4.2
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 +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +56 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -7
- 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).
|
|
763
|
+
*/
|
|
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.
|
|
754
770
|
*/
|
|
755
|
-
declare function
|
|
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.
|
|
@@ -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).
|
|
763
|
+
*/
|
|
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.
|
|
754
770
|
*/
|
|
755
|
-
declare function
|
|
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.
|
|
@@ -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
|
|
@@ -1417,6 +1449,22 @@ var Hadron = class _Hadron {
|
|
|
1417
1449
|
instructions.push(buildInitialize(payer, resolvedParams, programId));
|
|
1418
1450
|
return { instructions, poolAddress, seed };
|
|
1419
1451
|
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Build idempotent create-ATA instructions for the fee recipient for both mints.
|
|
1454
|
+
*
|
|
1455
|
+
* These are no-ops on-chain if the ATAs already exist. Include them alongside
|
|
1456
|
+
* initialize or first deposit to ensure swaps don't fail due to missing fee ATAs.
|
|
1457
|
+
*/
|
|
1458
|
+
static buildFeeRecipientAtaIxs(payer, feeRecipient, mintX, mintY, tokenProgramX, tokenProgramY) {
|
|
1459
|
+
return buildFeeRecipientAtaIxs(
|
|
1460
|
+
payer,
|
|
1461
|
+
feeRecipient,
|
|
1462
|
+
mintX,
|
|
1463
|
+
mintY,
|
|
1464
|
+
_nullishCoalesce(tokenProgramX, () => ( _spltoken.TOKEN_PROGRAM_ID)),
|
|
1465
|
+
_nullishCoalesce(tokenProgramY, () => ( _spltoken.TOKEN_PROGRAM_ID))
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1420
1468
|
/** Generate a random u64 seed. */
|
|
1421
1469
|
static randomSeed() {
|
|
1422
1470
|
const buf = new Uint8Array(8);
|
|
@@ -1797,7 +1845,7 @@ var Hadron = class _Hadron {
|
|
|
1797
1845
|
}
|
|
1798
1846
|
ixs.push(this.withdraw(user, params));
|
|
1799
1847
|
if (hasSol) {
|
|
1800
|
-
ixs.push(
|
|
1848
|
+
ixs.push(...unwrapSolInstructions(user));
|
|
1801
1849
|
}
|
|
1802
1850
|
return ixs;
|
|
1803
1851
|
}
|
|
@@ -1818,7 +1866,7 @@ var Hadron = class _Hadron {
|
|
|
1818
1866
|
}
|
|
1819
1867
|
ixs.push(this.swap(user, params));
|
|
1820
1868
|
if (isNativeMint(outputMint)) {
|
|
1821
|
-
ixs.push(
|
|
1869
|
+
ixs.push(...unwrapSolInstructions(user));
|
|
1822
1870
|
}
|
|
1823
1871
|
return ixs;
|
|
1824
1872
|
}
|
|
@@ -2506,5 +2554,6 @@ async function getOrCreateAta(connection, mint, owner, payer, tokenProgram = _sp
|
|
|
2506
2554
|
|
|
2507
2555
|
|
|
2508
2556
|
|
|
2509
|
-
|
|
2557
|
+
|
|
2558
|
+
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
2559
|
//# sourceMappingURL=index.js.map
|