@picon-finance/dlmm-sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +48 -0
- package/dist/actions/accept_admin_authority.d.ts +13 -0
- package/dist/actions/accept_admin_authority.d.ts.map +1 -0
- package/dist/actions/accept_admin_authority.js +7 -0
- package/dist/actions/claim_fee.d.ts +21 -0
- package/dist/actions/claim_fee.d.ts.map +1 -0
- package/dist/actions/claim_fee.js +40 -0
- package/dist/actions/claim_multiple_fees.d.ts +19 -0
- package/dist/actions/claim_multiple_fees.d.ts.map +1 -0
- package/dist/actions/claim_multiple_fees.js +81 -0
- package/dist/actions/claim_protocol_fee.d.ts +18 -0
- package/dist/actions/claim_protocol_fee.d.ts.map +1 -0
- package/dist/actions/claim_protocol_fee.js +33 -0
- package/dist/actions/close_position.d.ts +14 -0
- package/dist/actions/close_position.d.ts.map +1 -0
- package/dist/actions/close_position.js +14 -0
- package/dist/actions/create_admin_config.d.ts +15 -0
- package/dist/actions/create_admin_config.d.ts.map +1 -0
- package/dist/actions/create_admin_config.js +30 -0
- package/dist/actions/create_bin_array.d.ts +16 -0
- package/dist/actions/create_bin_array.d.ts.map +1 -0
- package/dist/actions/create_bin_array.js +10 -0
- package/dist/actions/create_pool.d.ts +21 -0
- package/dist/actions/create_pool.d.ts.map +1 -0
- package/dist/actions/create_pool.js +22 -0
- package/dist/actions/delete_bin_array.d.ts +16 -0
- package/dist/actions/delete_bin_array.d.ts.map +1 -0
- package/dist/actions/delete_bin_array.js +13 -0
- package/dist/actions/deposit_by_weight.d.ts +27 -0
- package/dist/actions/deposit_by_weight.d.ts.map +1 -0
- package/dist/actions/deposit_by_weight.js +52 -0
- package/dist/actions/get_admin_config.d.ts +4 -0
- package/dist/actions/get_admin_config.d.ts.map +1 -0
- package/dist/actions/get_admin_config.js +7 -0
- package/dist/actions/get_bin_arrays_by_indices.d.ts +5 -0
- package/dist/actions/get_bin_arrays_by_indices.d.ts.map +1 -0
- package/dist/actions/get_bin_arrays_by_indices.js +6 -0
- package/dist/actions/get_pool.d.ts +4 -0
- package/dist/actions/get_pool.d.ts.map +1 -0
- package/dist/actions/get_pool.js +5 -0
- package/dist/actions/get_position.d.ts +4 -0
- package/dist/actions/get_position.d.ts.map +1 -0
- package/dist/actions/get_position.js +5 -0
- package/dist/actions/get_position_by_position_mint.d.ts +4 -0
- package/dist/actions/get_position_by_position_mint.d.ts.map +1 -0
- package/dist/actions/get_position_by_position_mint.js +6 -0
- package/dist/actions/get_positions_by_owner.d.ts +5 -0
- package/dist/actions/get_positions_by_owner.d.ts.map +1 -0
- package/dist/actions/get_positions_by_owner.js +33 -0
- package/dist/actions/get_positions_by_position_mints.d.ts +5 -0
- package/dist/actions/get_positions_by_position_mints.d.ts.map +1 -0
- package/dist/actions/get_positions_by_position_mints.js +9 -0
- package/dist/actions/helpers/build_swap_transaction_message.d.ts +22 -0
- package/dist/actions/helpers/build_swap_transaction_message.d.ts.map +1 -0
- package/dist/actions/helpers/build_swap_transaction_message.js +50 -0
- package/dist/actions/helpers/build_transaction_message.d.ts +20 -0
- package/dist/actions/helpers/build_transaction_message.d.ts.map +1 -0
- package/dist/actions/helpers/build_transaction_message.js +5 -0
- package/dist/actions/helpers/index.d.ts +8 -0
- package/dist/actions/helpers/index.d.ts.map +1 -0
- package/dist/actions/helpers/index.js +7 -0
- package/dist/actions/helpers/resolve_active_bin_and_mints.d.ts +12 -0
- package/dist/actions/helpers/resolve_active_bin_and_mints.d.ts.map +1 -0
- package/dist/actions/helpers/resolve_active_bin_and_mints.js +13 -0
- package/dist/actions/helpers/resolve_admin_config_address.d.ts +3 -0
- package/dist/actions/helpers/resolve_admin_config_address.d.ts.map +1 -0
- package/dist/actions/helpers/resolve_admin_config_address.js +9 -0
- package/dist/actions/helpers/resolve_mint_info.d.ts +10 -0
- package/dist/actions/helpers/resolve_mint_info.d.ts.map +1 -0
- package/dist/actions/helpers/resolve_mint_info.js +20 -0
- package/dist/actions/helpers/resolve_position_range.d.ts +12 -0
- package/dist/actions/helpers/resolve_position_range.d.ts.map +1 -0
- package/dist/actions/helpers/resolve_position_range.js +12 -0
- package/dist/actions/helpers/resolve_token_mints_and_programs.d.ts +15 -0
- package/dist/actions/helpers/resolve_token_mints_and_programs.d.ts.map +1 -0
- package/dist/actions/helpers/resolve_token_mints_and_programs.js +29 -0
- package/dist/actions/index.d.ts +31 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +28 -0
- package/dist/actions/is_admin_config_active.d.ts +4 -0
- package/dist/actions/is_admin_config_active.d.ts.map +1 -0
- package/dist/actions/is_admin_config_active.js +7 -0
- package/dist/actions/on_event.d.ts +11 -0
- package/dist/actions/on_event.d.ts.map +1 -0
- package/dist/actions/on_event.js +50 -0
- package/dist/actions/open_position.d.ts +17 -0
- package/dist/actions/open_position.d.ts.map +1 -0
- package/dist/actions/open_position.js +31 -0
- package/dist/actions/quote.d.ts +13 -0
- package/dist/actions/quote.d.ts.map +1 -0
- package/dist/actions/quote.js +43 -0
- package/dist/actions/set_metadata_update_authority.d.ts +14 -0
- package/dist/actions/set_metadata_update_authority.d.ts.map +1 -0
- package/dist/actions/set_metadata_update_authority.js +7 -0
- package/dist/actions/set_pool_dynamic_fee_config.d.ts +16 -0
- package/dist/actions/set_pool_dynamic_fee_config.d.ts.map +1 -0
- package/dist/actions/set_pool_dynamic_fee_config.js +7 -0
- package/dist/actions/set_pool_protocol_share.d.ts +15 -0
- package/dist/actions/set_pool_protocol_share.d.ts.map +1 -0
- package/dist/actions/set_pool_protocol_share.js +7 -0
- package/dist/actions/swap.d.ts +22 -0
- package/dist/actions/swap.d.ts.map +1 -0
- package/dist/actions/swap.js +19 -0
- package/dist/actions/sync_pool.d.ts +15 -0
- package/dist/actions/sync_pool.d.ts.map +1 -0
- package/dist/actions/sync_pool.js +26 -0
- package/dist/actions/transfer_admin_authority.d.ts +14 -0
- package/dist/actions/transfer_admin_authority.d.ts.map +1 -0
- package/dist/actions/transfer_admin_authority.js +7 -0
- package/dist/actions/withdraw.d.ts +22 -0
- package/dist/actions/withdraw.d.ts.map +1 -0
- package/dist/actions/withdraw.js +41 -0
- package/dist/events.d.ts +93 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +166 -0
- package/dist/generated/accounts/adminConfig.d.ts +35 -0
- package/dist/generated/accounts/adminConfig.d.ts.map +1 -0
- package/dist/generated/accounts/adminConfig.js +60 -0
- package/dist/generated/accounts/binArray.d.ts +40 -0
- package/dist/generated/accounts/binArray.d.ts.map +1 -0
- package/dist/generated/accounts/binArray.js +65 -0
- package/dist/generated/accounts/index.d.ts +12 -0
- package/dist/generated/accounts/index.d.ts.map +1 -0
- package/dist/generated/accounts/index.js +11 -0
- package/dist/generated/accounts/pool.d.ts +54 -0
- package/dist/generated/accounts/pool.d.ts.map +1 -0
- package/dist/generated/accounts/pool.js +79 -0
- package/dist/generated/accounts/position.d.ts +42 -0
- package/dist/generated/accounts/position.d.ts.map +1 -0
- package/dist/generated/accounts/position.js +67 -0
- package/dist/generated/errors/index.d.ts +9 -0
- package/dist/generated/errors/index.d.ts.map +1 -0
- package/dist/generated/errors/index.js +8 -0
- package/dist/generated/errors/piconDlmm.d.ts +58 -0
- package/dist/generated/errors/piconDlmm.d.ts.map +1 -0
- package/dist/generated/errors/piconDlmm.js +80 -0
- package/dist/generated/index.d.ts +14 -0
- package/dist/generated/index.d.ts.map +1 -0
- package/dist/generated/index.js +13 -0
- package/dist/generated/instructions/acceptAdminAuthority.d.ts +47 -0
- package/dist/generated/instructions/acceptAdminAuthority.d.ts.map +1 -0
- package/dist/generated/instructions/acceptAdminAuthority.js +99 -0
- package/dist/generated/instructions/claimFee.d.ts +83 -0
- package/dist/generated/instructions/claimFee.d.ts.map +1 -0
- package/dist/generated/instructions/claimFee.js +127 -0
- package/dist/generated/instructions/claimProtocolFee.d.ts +83 -0
- package/dist/generated/instructions/claimProtocolFee.d.ts.map +1 -0
- package/dist/generated/instructions/claimProtocolFee.js +147 -0
- package/dist/generated/instructions/closePosition.d.ts +59 -0
- package/dist/generated/instructions/closePosition.d.ts.map +1 -0
- package/dist/generated/instructions/closePosition.js +124 -0
- package/dist/generated/instructions/createAdminConfig.d.ts +68 -0
- package/dist/generated/instructions/createAdminConfig.d.ts.map +1 -0
- package/dist/generated/instructions/createAdminConfig.js +132 -0
- package/dist/generated/instructions/createBinArray.d.ts +64 -0
- package/dist/generated/instructions/createBinArray.d.ts.map +1 -0
- package/dist/generated/instructions/createBinArray.js +122 -0
- package/dist/generated/instructions/createPool.d.ts +100 -0
- package/dist/generated/instructions/createPool.d.ts.map +1 -0
- package/dist/generated/instructions/createPool.js +202 -0
- package/dist/generated/instructions/deleteBinArray.d.ts +68 -0
- package/dist/generated/instructions/deleteBinArray.d.ts.map +1 -0
- package/dist/generated/instructions/deleteBinArray.js +130 -0
- package/dist/generated/instructions/depositByWeight.d.ts +99 -0
- package/dist/generated/instructions/depositByWeight.d.ts.map +1 -0
- package/dist/generated/instructions/depositByWeight.js +136 -0
- package/dist/generated/instructions/index.d.ts +25 -0
- package/dist/generated/instructions/index.d.ts.map +1 -0
- package/dist/generated/instructions/index.js +24 -0
- package/dist/generated/instructions/openPosition.d.ts +88 -0
- package/dist/generated/instructions/openPosition.d.ts.map +1 -0
- package/dist/generated/instructions/openPosition.js +200 -0
- package/dist/generated/instructions/setMetadataUpdateAuthority.d.ts +52 -0
- package/dist/generated/instructions/setMetadataUpdateAuthority.d.ts.map +1 -0
- package/dist/generated/instructions/setMetadataUpdateAuthority.js +98 -0
- package/dist/generated/instructions/setPoolDynamicFeeConfig.d.ts +57 -0
- package/dist/generated/instructions/setPoolDynamicFeeConfig.d.ts.map +1 -0
- package/dist/generated/instructions/setPoolDynamicFeeConfig.js +107 -0
- package/dist/generated/instructions/setPoolProtocolShare.d.ts +56 -0
- package/dist/generated/instructions/setPoolProtocolShare.d.ts.map +1 -0
- package/dist/generated/instructions/setPoolProtocolShare.js +106 -0
- package/dist/generated/instructions/swap.d.ts +74 -0
- package/dist/generated/instructions/swap.d.ts.map +1 -0
- package/dist/generated/instructions/swap.js +108 -0
- package/dist/generated/instructions/syncPool.d.ts +44 -0
- package/dist/generated/instructions/syncPool.d.ts.map +1 -0
- package/dist/generated/instructions/syncPool.js +71 -0
- package/dist/generated/instructions/transferAdminAuthority.d.ts +52 -0
- package/dist/generated/instructions/transferAdminAuthority.d.ts.map +1 -0
- package/dist/generated/instructions/transferAdminAuthority.js +98 -0
- package/dist/generated/instructions/withdraw.d.ts +86 -0
- package/dist/generated/instructions/withdraw.d.ts.map +1 -0
- package/dist/generated/instructions/withdraw.js +129 -0
- package/dist/generated/pdas/adminConfig.d.ts +12 -0
- package/dist/generated/pdas/adminConfig.d.ts.map +1 -0
- package/dist/generated/pdas/adminConfig.js +19 -0
- package/dist/generated/pdas/binArray.d.ts +16 -0
- package/dist/generated/pdas/binArray.d.ts.map +1 -0
- package/dist/generated/pdas/binArray.js +19 -0
- package/dist/generated/pdas/index.d.ts +12 -0
- package/dist/generated/pdas/index.d.ts.map +1 -0
- package/dist/generated/pdas/index.js +11 -0
- package/dist/generated/pdas/pool.d.ts +18 -0
- package/dist/generated/pdas/pool.d.ts.map +1 -0
- package/dist/generated/pdas/pool.js +21 -0
- package/dist/generated/pdas/position.d.ts +15 -0
- package/dist/generated/pdas/position.d.ts.map +1 -0
- package/dist/generated/pdas/position.js +18 -0
- package/dist/generated/programs/index.d.ts +9 -0
- package/dist/generated/programs/index.d.ts.map +1 -0
- package/dist/generated/programs/index.js +8 -0
- package/dist/generated/programs/piconDlmm.d.ts +126 -0
- package/dist/generated/programs/piconDlmm.d.ts.map +1 -0
- package/dist/generated/programs/piconDlmm.js +285 -0
- package/dist/generated/types/bin.d.ts +28 -0
- package/dist/generated/types/bin.d.ts.map +1 -0
- package/dist/generated/types/bin.js +31 -0
- package/dist/generated/types/distributionMode.d.ts +19 -0
- package/dist/generated/types/distributionMode.d.ts.map +1 -0
- package/dist/generated/types/distributionMode.js +24 -0
- package/dist/generated/types/dynamicFeeConfig.d.ts +29 -0
- package/dist/generated/types/dynamicFeeConfig.d.ts.map +1 -0
- package/dist/generated/types/dynamicFeeConfig.js +29 -0
- package/dist/generated/types/dynamicFeeState.d.ts +27 -0
- package/dist/generated/types/dynamicFeeState.d.ts.map +1 -0
- package/dist/generated/types/dynamicFeeState.js +30 -0
- package/dist/generated/types/feeState.d.ts +26 -0
- package/dist/generated/types/feeState.d.ts.map +1 -0
- package/dist/generated/types/feeState.js +29 -0
- package/dist/generated/types/index.d.ts +13 -0
- package/dist/generated/types/index.d.ts.map +1 -0
- package/dist/generated/types/index.js +12 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/picon_dlmm.json +2378 -0
- package/dist/program_addresses.d.ts +4 -0
- package/dist/program_addresses.d.ts.map +1 -0
- package/dist/program_addresses.js +8 -0
- package/dist/quote/index.d.ts +4 -0
- package/dist/quote/index.d.ts.map +1 -0
- package/dist/quote/index.js +5 -0
- package/dist/quote/wasm-node/picon_dlmm_quote.d.ts +6 -0
- package/dist/quote/wasm-node/picon_dlmm_quote.d.ts.map +1 -0
- package/dist/quote/wasm-node/picon_dlmm_quote.js +398 -0
- package/dist/quote/wasm-node/picon_dlmm_quote_bg.wasm +0 -0
- package/dist/quote/wasm-node-loader.d.ts +4 -0
- package/dist/quote/wasm-node-loader.d.ts.map +1 -0
- package/dist/quote/wasm-node-loader.js +7 -0
- package/dist/quote/wasm-web/picon_dlmm_quote.d.ts +9 -0
- package/dist/quote/wasm-web/picon_dlmm_quote.d.ts.map +1 -0
- package/dist/quote/wasm-web/picon_dlmm_quote.js +486 -0
- package/dist/quote/wasm-web/picon_dlmm_quote_bg.wasm +0 -0
- package/dist/quote/wasm-web-loader.d.ts +4 -0
- package/dist/quote/wasm-web-loader.d.ts.map +1 -0
- package/dist/quote/wasm-web-loader.js +12 -0
- package/dist/utils/admin_config.d.ts +3 -0
- package/dist/utils/admin_config.d.ts.map +1 -0
- package/dist/utils/admin_config.js +4 -0
- package/dist/utils/ata.d.ts +49 -0
- package/dist/utils/ata.d.ts.map +1 -0
- package/dist/utils/ata.js +113 -0
- package/dist/utils/bin_array.d.ts +8 -0
- package/dist/utils/bin_array.d.ts.map +1 -0
- package/dist/utils/bin_array.js +29 -0
- package/dist/utils/bin_location.d.ts +11 -0
- package/dist/utils/bin_location.d.ts.map +1 -0
- package/dist/utils/bin_location.js +55 -0
- package/dist/utils/chunk.d.ts +2 -0
- package/dist/utils/chunk.d.ts.map +1 -0
- package/dist/utils/chunk.js +7 -0
- package/dist/utils/compute_budget.d.ts +11 -0
- package/dist/utils/compute_budget.d.ts.map +1 -0
- package/dist/utils/compute_budget.js +22 -0
- package/dist/utils/constants.d.ts +12 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +20 -0
- package/dist/utils/transfer_fee.d.ts +4 -0
- package/dist/utils/transfer_fee.d.ts.map +1 -0
- package/dist/utils/transfer_fee.js +21 -0
- package/dist/utils/type_guards.d.ts +2 -0
- package/dist/utils/type_guards.d.ts.map +1 -0
- package/dist/utils/type_guards.js +3 -0
- package/package.json +59 -0
- package/src/actions/accept_admin_authority.ts +17 -0
- package/src/actions/claim_fee.ts +84 -0
- package/src/actions/claim_multiple_fees.ts +123 -0
- package/src/actions/claim_protocol_fee.ts +68 -0
- package/src/actions/close_position.ts +21 -0
- package/src/actions/create_admin_config.ts +50 -0
- package/src/actions/create_bin_array.ts +30 -0
- package/src/actions/create_pool.ts +49 -0
- package/src/actions/delete_bin_array.ts +33 -0
- package/src/actions/deposit_by_weight.ts +107 -0
- package/src/actions/get_admin_config.ts +13 -0
- package/src/actions/get_bin_arrays_by_indices.ts +15 -0
- package/src/actions/get_pool.ts +8 -0
- package/src/actions/get_position.ts +8 -0
- package/src/actions/get_position_by_position_mint.ts +14 -0
- package/src/actions/get_positions_by_owner.ts +48 -0
- package/src/actions/get_positions_by_position_mints.ts +21 -0
- package/src/actions/helpers/build_swap_transaction_message.ts +86 -0
- package/src/actions/helpers/build_transaction_message.ts +45 -0
- package/src/actions/helpers/index.ts +7 -0
- package/src/actions/helpers/resolve_active_bin_and_mints.ts +21 -0
- package/src/actions/helpers/resolve_admin_config_address.ts +11 -0
- package/src/actions/helpers/resolve_mint_info.ts +36 -0
- package/src/actions/helpers/resolve_position_range.ts +21 -0
- package/src/actions/helpers/resolve_token_mints_and_programs.ts +56 -0
- package/src/actions/index.ts +34 -0
- package/src/actions/is_admin_config_active.ts +14 -0
- package/src/actions/on_event.ts +78 -0
- package/src/actions/open_position.ts +66 -0
- package/src/actions/quote.ts +70 -0
- package/src/actions/set_metadata_update_authority.ts +17 -0
- package/src/actions/set_pool_dynamic_fee_config.ts +17 -0
- package/src/actions/set_pool_protocol_share.ts +17 -0
- package/src/actions/swap.ts +56 -0
- package/src/actions/sync_pool.ts +35 -0
- package/src/actions/transfer_admin_authority.ts +17 -0
- package/src/actions/withdraw.ts +87 -0
- package/src/events.ts +279 -0
- package/src/generated/accounts/adminConfig.ts +147 -0
- package/src/generated/accounts/binArray.ts +155 -0
- package/src/generated/accounts/index.ts +12 -0
- package/src/generated/accounts/pool.ts +192 -0
- package/src/generated/accounts/position.ts +164 -0
- package/src/generated/errors/index.ts +9 -0
- package/src/generated/errors/piconDlmm.ts +124 -0
- package/src/generated/index.ts +14 -0
- package/src/generated/instructions/acceptAdminAuthority.ts +262 -0
- package/src/generated/instructions/claimFee.ts +395 -0
- package/src/generated/instructions/claimProtocolFee.ts +462 -0
- package/src/generated/instructions/closePosition.ts +342 -0
- package/src/generated/instructions/createAdminConfig.ts +369 -0
- package/src/generated/instructions/createBinArray.ts +344 -0
- package/src/generated/instructions/createPool.ts +582 -0
- package/src/generated/instructions/deleteBinArray.ts +365 -0
- package/src/generated/instructions/depositByWeight.ts +435 -0
- package/src/generated/instructions/index.ts +25 -0
- package/src/generated/instructions/openPosition.ts +547 -0
- package/src/generated/instructions/setMetadataUpdateAuthority.ts +274 -0
- package/src/generated/instructions/setPoolDynamicFeeConfig.ts +304 -0
- package/src/generated/instructions/setPoolProtocolShare.ts +298 -0
- package/src/generated/instructions/swap.ts +336 -0
- package/src/generated/instructions/syncPool.ts +189 -0
- package/src/generated/instructions/transferAdminAuthority.ts +271 -0
- package/src/generated/instructions/withdraw.ts +402 -0
- package/src/generated/pdas/adminConfig.ts +32 -0
- package/src/generated/pdas/binArray.ts +40 -0
- package/src/generated/pdas/index.ts +12 -0
- package/src/generated/pdas/pool.ts +43 -0
- package/src/generated/pdas/position.ts +37 -0
- package/src/generated/programs/index.ts +9 -0
- package/src/generated/programs/piconDlmm.ts +803 -0
- package/src/generated/types/bin.ts +64 -0
- package/src/generated/types/distributionMode.ts +43 -0
- package/src/generated/types/dynamicFeeConfig.ts +69 -0
- package/src/generated/types/dynamicFeeState.ts +71 -0
- package/src/generated/types/feeState.ts +60 -0
- package/src/generated/types/index.ts +13 -0
- package/src/index.ts +4 -0
- package/src/picon_dlmm.json +2378 -0
- package/src/program_addresses.ts +10 -0
- package/src/quote/index.ts +14 -0
- package/src/quote/wasm-node/package.json +4 -0
- package/src/quote/wasm-node/picon_dlmm_quote.d.ts +64 -0
- package/src/quote/wasm-node/picon_dlmm_quote.js +407 -0
- package/src/quote/wasm-node/picon_dlmm_quote_bg.wasm +0 -0
- package/src/quote/wasm-node/picon_dlmm_quote_bg.wasm.d.ts +11 -0
- package/src/quote/wasm-node-loader.ts +11 -0
- package/src/quote/wasm-web/picon_dlmm_quote.d.ts +100 -0
- package/src/quote/wasm-web/picon_dlmm_quote.js +500 -0
- package/src/quote/wasm-web/picon_dlmm_quote_bg.wasm +0 -0
- package/src/quote/wasm-web/picon_dlmm_quote_bg.wasm.d.ts +11 -0
- package/src/quote/wasm-web-loader.ts +17 -0
- package/src/utils/admin_config.ts +6 -0
- package/src/utils/ata.ts +213 -0
- package/src/utils/bin_array.ts +45 -0
- package/src/utils/bin_location.ts +79 -0
- package/src/utils/chunk.ts +7 -0
- package/src/utils/compute_budget.ts +58 -0
- package/src/utils/constants.ts +24 -0
- package/src/utils/transfer_fee.ts +29 -0
- package/src/utils/type_guards.ts +3 -0
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
combineCodec,
|
|
11
|
+
fixDecoderSize,
|
|
12
|
+
fixEncoderSize,
|
|
13
|
+
getAddressEncoder,
|
|
14
|
+
getBytesDecoder,
|
|
15
|
+
getBytesEncoder,
|
|
16
|
+
getI32Decoder,
|
|
17
|
+
getI32Encoder,
|
|
18
|
+
getProgramDerivedAddress,
|
|
19
|
+
getStructDecoder,
|
|
20
|
+
getStructEncoder,
|
|
21
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
22
|
+
SolanaError,
|
|
23
|
+
transformEncoder,
|
|
24
|
+
type AccountMeta,
|
|
25
|
+
type AccountSignerMeta,
|
|
26
|
+
type Address,
|
|
27
|
+
type FixedSizeCodec,
|
|
28
|
+
type FixedSizeDecoder,
|
|
29
|
+
type FixedSizeEncoder,
|
|
30
|
+
type Instruction,
|
|
31
|
+
type InstructionWithAccounts,
|
|
32
|
+
type InstructionWithData,
|
|
33
|
+
type ReadonlyAccount,
|
|
34
|
+
type ReadonlyUint8Array,
|
|
35
|
+
type TransactionSigner,
|
|
36
|
+
type WritableAccount,
|
|
37
|
+
type WritableSignerAccount,
|
|
38
|
+
} from "@solana/kit";
|
|
39
|
+
import {
|
|
40
|
+
getAccountMetaFactory,
|
|
41
|
+
getAddressFromResolvedInstructionAccount,
|
|
42
|
+
type ResolvedInstructionAccount,
|
|
43
|
+
} from "@solana/program-client-core";
|
|
44
|
+
import { findAdminConfigPda, findPositionPda } from "../pdas";
|
|
45
|
+
import { PICON_DLMM_PROGRAM_ADDRESS } from "../programs";
|
|
46
|
+
|
|
47
|
+
export const OPEN_POSITION_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
48
|
+
135, 128, 47, 77, 15, 152, 240, 49,
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
export function getOpenPositionDiscriminatorBytes(): ReadonlyUint8Array {
|
|
52
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
53
|
+
OPEN_POSITION_DISCRIMINATOR,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type OpenPositionInstruction<
|
|
58
|
+
TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
59
|
+
TAccountOwner extends string | AccountMeta<string> = string,
|
|
60
|
+
TAccountPool extends string | AccountMeta<string> = string,
|
|
61
|
+
TAccountPosition extends string | AccountMeta<string> = string,
|
|
62
|
+
TAccountPositionMint extends string | AccountMeta<string> = string,
|
|
63
|
+
TAccountPositionTokenAccount extends string | AccountMeta<string> = string,
|
|
64
|
+
TAccountAdminConfig extends string | AccountMeta<string> = string,
|
|
65
|
+
TAccountMetadataUpdateAuthority extends string | AccountMeta<string> = string,
|
|
66
|
+
TAccountTokenProgram extends string | AccountMeta<string> =
|
|
67
|
+
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",
|
|
68
|
+
TAccountAssociatedTokenProgram extends string | AccountMeta<string> =
|
|
69
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
70
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
71
|
+
"11111111111111111111111111111111",
|
|
72
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
73
|
+
> = Instruction<TProgram> &
|
|
74
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
75
|
+
InstructionWithAccounts<
|
|
76
|
+
[
|
|
77
|
+
TAccountOwner extends string
|
|
78
|
+
? WritableSignerAccount<TAccountOwner> &
|
|
79
|
+
AccountSignerMeta<TAccountOwner>
|
|
80
|
+
: TAccountOwner,
|
|
81
|
+
TAccountPool extends string
|
|
82
|
+
? ReadonlyAccount<TAccountPool>
|
|
83
|
+
: TAccountPool,
|
|
84
|
+
TAccountPosition extends string
|
|
85
|
+
? WritableAccount<TAccountPosition>
|
|
86
|
+
: TAccountPosition,
|
|
87
|
+
TAccountPositionMint extends string
|
|
88
|
+
? WritableSignerAccount<TAccountPositionMint> &
|
|
89
|
+
AccountSignerMeta<TAccountPositionMint>
|
|
90
|
+
: TAccountPositionMint,
|
|
91
|
+
TAccountPositionTokenAccount extends string
|
|
92
|
+
? WritableAccount<TAccountPositionTokenAccount>
|
|
93
|
+
: TAccountPositionTokenAccount,
|
|
94
|
+
TAccountAdminConfig extends string
|
|
95
|
+
? ReadonlyAccount<TAccountAdminConfig>
|
|
96
|
+
: TAccountAdminConfig,
|
|
97
|
+
TAccountMetadataUpdateAuthority extends string
|
|
98
|
+
? ReadonlyAccount<TAccountMetadataUpdateAuthority>
|
|
99
|
+
: TAccountMetadataUpdateAuthority,
|
|
100
|
+
TAccountTokenProgram extends string
|
|
101
|
+
? ReadonlyAccount<TAccountTokenProgram>
|
|
102
|
+
: TAccountTokenProgram,
|
|
103
|
+
TAccountAssociatedTokenProgram extends string
|
|
104
|
+
? ReadonlyAccount<TAccountAssociatedTokenProgram>
|
|
105
|
+
: TAccountAssociatedTokenProgram,
|
|
106
|
+
TAccountSystemProgram extends string
|
|
107
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
108
|
+
: TAccountSystemProgram,
|
|
109
|
+
...TRemainingAccounts,
|
|
110
|
+
]
|
|
111
|
+
>;
|
|
112
|
+
|
|
113
|
+
export type OpenPositionInstructionData = {
|
|
114
|
+
discriminator: ReadonlyUint8Array;
|
|
115
|
+
lowerBinId: number;
|
|
116
|
+
upperBinId: number;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type OpenPositionInstructionDataArgs = {
|
|
120
|
+
lowerBinId: number;
|
|
121
|
+
upperBinId: number;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export function getOpenPositionInstructionDataEncoder(): FixedSizeEncoder<OpenPositionInstructionDataArgs> {
|
|
125
|
+
return transformEncoder(
|
|
126
|
+
getStructEncoder([
|
|
127
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
128
|
+
["lowerBinId", getI32Encoder()],
|
|
129
|
+
["upperBinId", getI32Encoder()],
|
|
130
|
+
]),
|
|
131
|
+
(value) => ({ ...value, discriminator: OPEN_POSITION_DISCRIMINATOR }),
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function getOpenPositionInstructionDataDecoder(): FixedSizeDecoder<OpenPositionInstructionData> {
|
|
136
|
+
return getStructDecoder([
|
|
137
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
138
|
+
["lowerBinId", getI32Decoder()],
|
|
139
|
+
["upperBinId", getI32Decoder()],
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function getOpenPositionInstructionDataCodec(): FixedSizeCodec<
|
|
144
|
+
OpenPositionInstructionDataArgs,
|
|
145
|
+
OpenPositionInstructionData
|
|
146
|
+
> {
|
|
147
|
+
return combineCodec(
|
|
148
|
+
getOpenPositionInstructionDataEncoder(),
|
|
149
|
+
getOpenPositionInstructionDataDecoder(),
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type OpenPositionAsyncInput<
|
|
154
|
+
TAccountOwner extends string = string,
|
|
155
|
+
TAccountPool extends string = string,
|
|
156
|
+
TAccountPosition extends string = string,
|
|
157
|
+
TAccountPositionMint extends string = string,
|
|
158
|
+
TAccountPositionTokenAccount extends string = string,
|
|
159
|
+
TAccountAdminConfig extends string = string,
|
|
160
|
+
TAccountMetadataUpdateAuthority extends string = string,
|
|
161
|
+
TAccountTokenProgram extends string = string,
|
|
162
|
+
TAccountAssociatedTokenProgram extends string = string,
|
|
163
|
+
TAccountSystemProgram extends string = string,
|
|
164
|
+
> = {
|
|
165
|
+
owner: TransactionSigner<TAccountOwner>;
|
|
166
|
+
pool: Address<TAccountPool>;
|
|
167
|
+
position?: Address<TAccountPosition>;
|
|
168
|
+
positionMint: TransactionSigner<TAccountPositionMint>;
|
|
169
|
+
positionTokenAccount?: Address<TAccountPositionTokenAccount>;
|
|
170
|
+
adminConfig?: Address<TAccountAdminConfig>;
|
|
171
|
+
metadataUpdateAuthority: Address<TAccountMetadataUpdateAuthority>;
|
|
172
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
173
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
174
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
175
|
+
lowerBinId: OpenPositionInstructionDataArgs["lowerBinId"];
|
|
176
|
+
upperBinId: OpenPositionInstructionDataArgs["upperBinId"];
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export async function getOpenPositionInstructionAsync<
|
|
180
|
+
TAccountOwner extends string,
|
|
181
|
+
TAccountPool extends string,
|
|
182
|
+
TAccountPosition extends string,
|
|
183
|
+
TAccountPositionMint extends string,
|
|
184
|
+
TAccountPositionTokenAccount extends string,
|
|
185
|
+
TAccountAdminConfig extends string,
|
|
186
|
+
TAccountMetadataUpdateAuthority extends string,
|
|
187
|
+
TAccountTokenProgram extends string,
|
|
188
|
+
TAccountAssociatedTokenProgram extends string,
|
|
189
|
+
TAccountSystemProgram extends string,
|
|
190
|
+
TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
191
|
+
>(
|
|
192
|
+
input: OpenPositionAsyncInput<
|
|
193
|
+
TAccountOwner,
|
|
194
|
+
TAccountPool,
|
|
195
|
+
TAccountPosition,
|
|
196
|
+
TAccountPositionMint,
|
|
197
|
+
TAccountPositionTokenAccount,
|
|
198
|
+
TAccountAdminConfig,
|
|
199
|
+
TAccountMetadataUpdateAuthority,
|
|
200
|
+
TAccountTokenProgram,
|
|
201
|
+
TAccountAssociatedTokenProgram,
|
|
202
|
+
TAccountSystemProgram
|
|
203
|
+
>,
|
|
204
|
+
config?: { programAddress?: TProgramAddress },
|
|
205
|
+
): Promise<
|
|
206
|
+
OpenPositionInstruction<
|
|
207
|
+
TProgramAddress,
|
|
208
|
+
TAccountOwner,
|
|
209
|
+
TAccountPool,
|
|
210
|
+
TAccountPosition,
|
|
211
|
+
TAccountPositionMint,
|
|
212
|
+
TAccountPositionTokenAccount,
|
|
213
|
+
TAccountAdminConfig,
|
|
214
|
+
TAccountMetadataUpdateAuthority,
|
|
215
|
+
TAccountTokenProgram,
|
|
216
|
+
TAccountAssociatedTokenProgram,
|
|
217
|
+
TAccountSystemProgram
|
|
218
|
+
>
|
|
219
|
+
> {
|
|
220
|
+
// Program address.
|
|
221
|
+
const programAddress = config?.programAddress ?? PICON_DLMM_PROGRAM_ADDRESS;
|
|
222
|
+
|
|
223
|
+
// Original accounts.
|
|
224
|
+
const originalAccounts = {
|
|
225
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
226
|
+
pool: { value: input.pool ?? null, isWritable: false },
|
|
227
|
+
position: { value: input.position ?? null, isWritable: true },
|
|
228
|
+
positionMint: { value: input.positionMint ?? null, isWritable: true },
|
|
229
|
+
positionTokenAccount: {
|
|
230
|
+
value: input.positionTokenAccount ?? null,
|
|
231
|
+
isWritable: true,
|
|
232
|
+
},
|
|
233
|
+
adminConfig: { value: input.adminConfig ?? null, isWritable: false },
|
|
234
|
+
metadataUpdateAuthority: {
|
|
235
|
+
value: input.metadataUpdateAuthority ?? null,
|
|
236
|
+
isWritable: false,
|
|
237
|
+
},
|
|
238
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
239
|
+
associatedTokenProgram: {
|
|
240
|
+
value: input.associatedTokenProgram ?? null,
|
|
241
|
+
isWritable: false,
|
|
242
|
+
},
|
|
243
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
244
|
+
};
|
|
245
|
+
const accounts = originalAccounts as Record<
|
|
246
|
+
keyof typeof originalAccounts,
|
|
247
|
+
ResolvedInstructionAccount
|
|
248
|
+
>;
|
|
249
|
+
|
|
250
|
+
// Original args.
|
|
251
|
+
const args = { ...input };
|
|
252
|
+
|
|
253
|
+
// Resolve default values.
|
|
254
|
+
if (!accounts.position.value) {
|
|
255
|
+
accounts.position.value = await findPositionPda({
|
|
256
|
+
positionMint: getAddressFromResolvedInstructionAccount(
|
|
257
|
+
"positionMint",
|
|
258
|
+
accounts.positionMint.value,
|
|
259
|
+
),
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (!accounts.tokenProgram.value) {
|
|
263
|
+
accounts.tokenProgram.value =
|
|
264
|
+
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" as Address<"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb">;
|
|
265
|
+
}
|
|
266
|
+
if (!accounts.positionTokenAccount.value) {
|
|
267
|
+
accounts.positionTokenAccount.value = await getProgramDerivedAddress({
|
|
268
|
+
programAddress:
|
|
269
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">,
|
|
270
|
+
seeds: [
|
|
271
|
+
getAddressEncoder().encode(
|
|
272
|
+
getAddressFromResolvedInstructionAccount(
|
|
273
|
+
"owner",
|
|
274
|
+
accounts.owner.value,
|
|
275
|
+
),
|
|
276
|
+
),
|
|
277
|
+
getAddressEncoder().encode(
|
|
278
|
+
getAddressFromResolvedInstructionAccount(
|
|
279
|
+
"tokenProgram",
|
|
280
|
+
accounts.tokenProgram.value,
|
|
281
|
+
),
|
|
282
|
+
),
|
|
283
|
+
getAddressEncoder().encode(
|
|
284
|
+
getAddressFromResolvedInstructionAccount(
|
|
285
|
+
"positionMint",
|
|
286
|
+
accounts.positionMint.value,
|
|
287
|
+
),
|
|
288
|
+
),
|
|
289
|
+
],
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
if (!accounts.adminConfig.value) {
|
|
293
|
+
accounts.adminConfig.value = await findAdminConfigPda();
|
|
294
|
+
}
|
|
295
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
296
|
+
accounts.associatedTokenProgram.value =
|
|
297
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
|
|
298
|
+
}
|
|
299
|
+
if (!accounts.systemProgram.value) {
|
|
300
|
+
accounts.systemProgram.value =
|
|
301
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
305
|
+
return Object.freeze({
|
|
306
|
+
accounts: [
|
|
307
|
+
getAccountMeta("owner", accounts.owner),
|
|
308
|
+
getAccountMeta("pool", accounts.pool),
|
|
309
|
+
getAccountMeta("position", accounts.position),
|
|
310
|
+
getAccountMeta("positionMint", accounts.positionMint),
|
|
311
|
+
getAccountMeta("positionTokenAccount", accounts.positionTokenAccount),
|
|
312
|
+
getAccountMeta("adminConfig", accounts.adminConfig),
|
|
313
|
+
getAccountMeta(
|
|
314
|
+
"metadataUpdateAuthority",
|
|
315
|
+
accounts.metadataUpdateAuthority,
|
|
316
|
+
),
|
|
317
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
318
|
+
getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram),
|
|
319
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
320
|
+
],
|
|
321
|
+
data: getOpenPositionInstructionDataEncoder().encode(
|
|
322
|
+
args as OpenPositionInstructionDataArgs,
|
|
323
|
+
),
|
|
324
|
+
programAddress,
|
|
325
|
+
} as OpenPositionInstruction<
|
|
326
|
+
TProgramAddress,
|
|
327
|
+
TAccountOwner,
|
|
328
|
+
TAccountPool,
|
|
329
|
+
TAccountPosition,
|
|
330
|
+
TAccountPositionMint,
|
|
331
|
+
TAccountPositionTokenAccount,
|
|
332
|
+
TAccountAdminConfig,
|
|
333
|
+
TAccountMetadataUpdateAuthority,
|
|
334
|
+
TAccountTokenProgram,
|
|
335
|
+
TAccountAssociatedTokenProgram,
|
|
336
|
+
TAccountSystemProgram
|
|
337
|
+
>);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export type OpenPositionInput<
|
|
341
|
+
TAccountOwner extends string = string,
|
|
342
|
+
TAccountPool extends string = string,
|
|
343
|
+
TAccountPosition extends string = string,
|
|
344
|
+
TAccountPositionMint extends string = string,
|
|
345
|
+
TAccountPositionTokenAccount extends string = string,
|
|
346
|
+
TAccountAdminConfig extends string = string,
|
|
347
|
+
TAccountMetadataUpdateAuthority extends string = string,
|
|
348
|
+
TAccountTokenProgram extends string = string,
|
|
349
|
+
TAccountAssociatedTokenProgram extends string = string,
|
|
350
|
+
TAccountSystemProgram extends string = string,
|
|
351
|
+
> = {
|
|
352
|
+
owner: TransactionSigner<TAccountOwner>;
|
|
353
|
+
pool: Address<TAccountPool>;
|
|
354
|
+
position: Address<TAccountPosition>;
|
|
355
|
+
positionMint: TransactionSigner<TAccountPositionMint>;
|
|
356
|
+
positionTokenAccount: Address<TAccountPositionTokenAccount>;
|
|
357
|
+
adminConfig: Address<TAccountAdminConfig>;
|
|
358
|
+
metadataUpdateAuthority: Address<TAccountMetadataUpdateAuthority>;
|
|
359
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
360
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
361
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
362
|
+
lowerBinId: OpenPositionInstructionDataArgs["lowerBinId"];
|
|
363
|
+
upperBinId: OpenPositionInstructionDataArgs["upperBinId"];
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export function getOpenPositionInstruction<
|
|
367
|
+
TAccountOwner extends string,
|
|
368
|
+
TAccountPool extends string,
|
|
369
|
+
TAccountPosition extends string,
|
|
370
|
+
TAccountPositionMint extends string,
|
|
371
|
+
TAccountPositionTokenAccount extends string,
|
|
372
|
+
TAccountAdminConfig extends string,
|
|
373
|
+
TAccountMetadataUpdateAuthority extends string,
|
|
374
|
+
TAccountTokenProgram extends string,
|
|
375
|
+
TAccountAssociatedTokenProgram extends string,
|
|
376
|
+
TAccountSystemProgram extends string,
|
|
377
|
+
TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
378
|
+
>(
|
|
379
|
+
input: OpenPositionInput<
|
|
380
|
+
TAccountOwner,
|
|
381
|
+
TAccountPool,
|
|
382
|
+
TAccountPosition,
|
|
383
|
+
TAccountPositionMint,
|
|
384
|
+
TAccountPositionTokenAccount,
|
|
385
|
+
TAccountAdminConfig,
|
|
386
|
+
TAccountMetadataUpdateAuthority,
|
|
387
|
+
TAccountTokenProgram,
|
|
388
|
+
TAccountAssociatedTokenProgram,
|
|
389
|
+
TAccountSystemProgram
|
|
390
|
+
>,
|
|
391
|
+
config?: { programAddress?: TProgramAddress },
|
|
392
|
+
): OpenPositionInstruction<
|
|
393
|
+
TProgramAddress,
|
|
394
|
+
TAccountOwner,
|
|
395
|
+
TAccountPool,
|
|
396
|
+
TAccountPosition,
|
|
397
|
+
TAccountPositionMint,
|
|
398
|
+
TAccountPositionTokenAccount,
|
|
399
|
+
TAccountAdminConfig,
|
|
400
|
+
TAccountMetadataUpdateAuthority,
|
|
401
|
+
TAccountTokenProgram,
|
|
402
|
+
TAccountAssociatedTokenProgram,
|
|
403
|
+
TAccountSystemProgram
|
|
404
|
+
> {
|
|
405
|
+
// Program address.
|
|
406
|
+
const programAddress = config?.programAddress ?? PICON_DLMM_PROGRAM_ADDRESS;
|
|
407
|
+
|
|
408
|
+
// Original accounts.
|
|
409
|
+
const originalAccounts = {
|
|
410
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
411
|
+
pool: { value: input.pool ?? null, isWritable: false },
|
|
412
|
+
position: { value: input.position ?? null, isWritable: true },
|
|
413
|
+
positionMint: { value: input.positionMint ?? null, isWritable: true },
|
|
414
|
+
positionTokenAccount: {
|
|
415
|
+
value: input.positionTokenAccount ?? null,
|
|
416
|
+
isWritable: true,
|
|
417
|
+
},
|
|
418
|
+
adminConfig: { value: input.adminConfig ?? null, isWritable: false },
|
|
419
|
+
metadataUpdateAuthority: {
|
|
420
|
+
value: input.metadataUpdateAuthority ?? null,
|
|
421
|
+
isWritable: false,
|
|
422
|
+
},
|
|
423
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
424
|
+
associatedTokenProgram: {
|
|
425
|
+
value: input.associatedTokenProgram ?? null,
|
|
426
|
+
isWritable: false,
|
|
427
|
+
},
|
|
428
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
429
|
+
};
|
|
430
|
+
const accounts = originalAccounts as Record<
|
|
431
|
+
keyof typeof originalAccounts,
|
|
432
|
+
ResolvedInstructionAccount
|
|
433
|
+
>;
|
|
434
|
+
|
|
435
|
+
// Original args.
|
|
436
|
+
const args = { ...input };
|
|
437
|
+
|
|
438
|
+
// Resolve default values.
|
|
439
|
+
if (!accounts.tokenProgram.value) {
|
|
440
|
+
accounts.tokenProgram.value =
|
|
441
|
+
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" as Address<"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb">;
|
|
442
|
+
}
|
|
443
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
444
|
+
accounts.associatedTokenProgram.value =
|
|
445
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
|
|
446
|
+
}
|
|
447
|
+
if (!accounts.systemProgram.value) {
|
|
448
|
+
accounts.systemProgram.value =
|
|
449
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
453
|
+
return Object.freeze({
|
|
454
|
+
accounts: [
|
|
455
|
+
getAccountMeta("owner", accounts.owner),
|
|
456
|
+
getAccountMeta("pool", accounts.pool),
|
|
457
|
+
getAccountMeta("position", accounts.position),
|
|
458
|
+
getAccountMeta("positionMint", accounts.positionMint),
|
|
459
|
+
getAccountMeta("positionTokenAccount", accounts.positionTokenAccount),
|
|
460
|
+
getAccountMeta("adminConfig", accounts.adminConfig),
|
|
461
|
+
getAccountMeta(
|
|
462
|
+
"metadataUpdateAuthority",
|
|
463
|
+
accounts.metadataUpdateAuthority,
|
|
464
|
+
),
|
|
465
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
466
|
+
getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram),
|
|
467
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
468
|
+
],
|
|
469
|
+
data: getOpenPositionInstructionDataEncoder().encode(
|
|
470
|
+
args as OpenPositionInstructionDataArgs,
|
|
471
|
+
),
|
|
472
|
+
programAddress,
|
|
473
|
+
} as OpenPositionInstruction<
|
|
474
|
+
TProgramAddress,
|
|
475
|
+
TAccountOwner,
|
|
476
|
+
TAccountPool,
|
|
477
|
+
TAccountPosition,
|
|
478
|
+
TAccountPositionMint,
|
|
479
|
+
TAccountPositionTokenAccount,
|
|
480
|
+
TAccountAdminConfig,
|
|
481
|
+
TAccountMetadataUpdateAuthority,
|
|
482
|
+
TAccountTokenProgram,
|
|
483
|
+
TAccountAssociatedTokenProgram,
|
|
484
|
+
TAccountSystemProgram
|
|
485
|
+
>);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export type ParsedOpenPositionInstruction<
|
|
489
|
+
TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
490
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
491
|
+
> = {
|
|
492
|
+
programAddress: Address<TProgram>;
|
|
493
|
+
accounts: {
|
|
494
|
+
owner: TAccountMetas[0];
|
|
495
|
+
pool: TAccountMetas[1];
|
|
496
|
+
position: TAccountMetas[2];
|
|
497
|
+
positionMint: TAccountMetas[3];
|
|
498
|
+
positionTokenAccount: TAccountMetas[4];
|
|
499
|
+
adminConfig: TAccountMetas[5];
|
|
500
|
+
metadataUpdateAuthority: TAccountMetas[6];
|
|
501
|
+
tokenProgram: TAccountMetas[7];
|
|
502
|
+
associatedTokenProgram: TAccountMetas[8];
|
|
503
|
+
systemProgram: TAccountMetas[9];
|
|
504
|
+
};
|
|
505
|
+
data: OpenPositionInstructionData;
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
export function parseOpenPositionInstruction<
|
|
509
|
+
TProgram extends string,
|
|
510
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
511
|
+
>(
|
|
512
|
+
instruction: Instruction<TProgram> &
|
|
513
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
514
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
515
|
+
): ParsedOpenPositionInstruction<TProgram, TAccountMetas> {
|
|
516
|
+
if (instruction.accounts.length < 10) {
|
|
517
|
+
throw new SolanaError(
|
|
518
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
519
|
+
{
|
|
520
|
+
actualAccountMetas: instruction.accounts.length,
|
|
521
|
+
expectedAccountMetas: 10,
|
|
522
|
+
},
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
let accountIndex = 0;
|
|
526
|
+
const getNextAccount = () => {
|
|
527
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
528
|
+
accountIndex += 1;
|
|
529
|
+
return accountMeta;
|
|
530
|
+
};
|
|
531
|
+
return {
|
|
532
|
+
programAddress: instruction.programAddress,
|
|
533
|
+
accounts: {
|
|
534
|
+
owner: getNextAccount(),
|
|
535
|
+
pool: getNextAccount(),
|
|
536
|
+
position: getNextAccount(),
|
|
537
|
+
positionMint: getNextAccount(),
|
|
538
|
+
positionTokenAccount: getNextAccount(),
|
|
539
|
+
adminConfig: getNextAccount(),
|
|
540
|
+
metadataUpdateAuthority: getNextAccount(),
|
|
541
|
+
tokenProgram: getNextAccount(),
|
|
542
|
+
associatedTokenProgram: getNextAccount(),
|
|
543
|
+
systemProgram: getNextAccount(),
|
|
544
|
+
},
|
|
545
|
+
data: getOpenPositionInstructionDataDecoder().decode(instruction.data),
|
|
546
|
+
};
|
|
547
|
+
}
|