@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,342 @@
|
|
|
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
|
+
getBytesDecoder,
|
|
14
|
+
getBytesEncoder,
|
|
15
|
+
getStructDecoder,
|
|
16
|
+
getStructEncoder,
|
|
17
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
18
|
+
SolanaError,
|
|
19
|
+
transformEncoder,
|
|
20
|
+
type AccountMeta,
|
|
21
|
+
type AccountSignerMeta,
|
|
22
|
+
type Address,
|
|
23
|
+
type FixedSizeCodec,
|
|
24
|
+
type FixedSizeDecoder,
|
|
25
|
+
type FixedSizeEncoder,
|
|
26
|
+
type Instruction,
|
|
27
|
+
type InstructionWithAccounts,
|
|
28
|
+
type InstructionWithData,
|
|
29
|
+
type ReadonlyAccount,
|
|
30
|
+
type ReadonlyUint8Array,
|
|
31
|
+
type TransactionSigner,
|
|
32
|
+
type WritableAccount,
|
|
33
|
+
type WritableSignerAccount,
|
|
34
|
+
} from "@solana/kit";
|
|
35
|
+
import {
|
|
36
|
+
getAccountMetaFactory,
|
|
37
|
+
getAddressFromResolvedInstructionAccount,
|
|
38
|
+
type ResolvedInstructionAccount,
|
|
39
|
+
} from "@solana/program-client-core";
|
|
40
|
+
import { findPositionPda } from "../pdas";
|
|
41
|
+
import { PICON_DLMM_PROGRAM_ADDRESS } from "../programs";
|
|
42
|
+
|
|
43
|
+
export const CLOSE_POSITION_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
44
|
+
123, 134, 81, 0, 49, 68, 98, 98,
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
export function getClosePositionDiscriminatorBytes(): ReadonlyUint8Array {
|
|
48
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
49
|
+
CLOSE_POSITION_DISCRIMINATOR,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type ClosePositionInstruction<
|
|
54
|
+
TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
55
|
+
TAccountOwner extends string | AccountMeta<string> = string,
|
|
56
|
+
TAccountPosition extends string | AccountMeta<string> = string,
|
|
57
|
+
TAccountPositionMint extends string | AccountMeta<string> = string,
|
|
58
|
+
TAccountPositionTokenAccount extends string | AccountMeta<string> = string,
|
|
59
|
+
TAccountTokenProgram extends string | AccountMeta<string> =
|
|
60
|
+
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",
|
|
61
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
62
|
+
> = Instruction<TProgram> &
|
|
63
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
64
|
+
InstructionWithAccounts<
|
|
65
|
+
[
|
|
66
|
+
TAccountOwner extends string
|
|
67
|
+
? WritableSignerAccount<TAccountOwner> &
|
|
68
|
+
AccountSignerMeta<TAccountOwner>
|
|
69
|
+
: TAccountOwner,
|
|
70
|
+
TAccountPosition extends string
|
|
71
|
+
? WritableAccount<TAccountPosition>
|
|
72
|
+
: TAccountPosition,
|
|
73
|
+
TAccountPositionMint extends string
|
|
74
|
+
? WritableAccount<TAccountPositionMint>
|
|
75
|
+
: TAccountPositionMint,
|
|
76
|
+
TAccountPositionTokenAccount extends string
|
|
77
|
+
? WritableAccount<TAccountPositionTokenAccount>
|
|
78
|
+
: TAccountPositionTokenAccount,
|
|
79
|
+
TAccountTokenProgram extends string
|
|
80
|
+
? ReadonlyAccount<TAccountTokenProgram>
|
|
81
|
+
: TAccountTokenProgram,
|
|
82
|
+
...TRemainingAccounts,
|
|
83
|
+
]
|
|
84
|
+
>;
|
|
85
|
+
|
|
86
|
+
export type ClosePositionInstructionData = {
|
|
87
|
+
discriminator: ReadonlyUint8Array;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type ClosePositionInstructionDataArgs = {};
|
|
91
|
+
|
|
92
|
+
export function getClosePositionInstructionDataEncoder(): FixedSizeEncoder<ClosePositionInstructionDataArgs> {
|
|
93
|
+
return transformEncoder(
|
|
94
|
+
getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
|
|
95
|
+
(value) => ({ ...value, discriminator: CLOSE_POSITION_DISCRIMINATOR }),
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getClosePositionInstructionDataDecoder(): FixedSizeDecoder<ClosePositionInstructionData> {
|
|
100
|
+
return getStructDecoder([
|
|
101
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function getClosePositionInstructionDataCodec(): FixedSizeCodec<
|
|
106
|
+
ClosePositionInstructionDataArgs,
|
|
107
|
+
ClosePositionInstructionData
|
|
108
|
+
> {
|
|
109
|
+
return combineCodec(
|
|
110
|
+
getClosePositionInstructionDataEncoder(),
|
|
111
|
+
getClosePositionInstructionDataDecoder(),
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type ClosePositionAsyncInput<
|
|
116
|
+
TAccountOwner extends string = string,
|
|
117
|
+
TAccountPosition extends string = string,
|
|
118
|
+
TAccountPositionMint extends string = string,
|
|
119
|
+
TAccountPositionTokenAccount extends string = string,
|
|
120
|
+
TAccountTokenProgram extends string = string,
|
|
121
|
+
> = {
|
|
122
|
+
owner: TransactionSigner<TAccountOwner>;
|
|
123
|
+
position?: Address<TAccountPosition>;
|
|
124
|
+
positionMint: Address<TAccountPositionMint>;
|
|
125
|
+
positionTokenAccount: Address<TAccountPositionTokenAccount>;
|
|
126
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export async function getClosePositionInstructionAsync<
|
|
130
|
+
TAccountOwner extends string,
|
|
131
|
+
TAccountPosition extends string,
|
|
132
|
+
TAccountPositionMint extends string,
|
|
133
|
+
TAccountPositionTokenAccount extends string,
|
|
134
|
+
TAccountTokenProgram extends string,
|
|
135
|
+
TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
136
|
+
>(
|
|
137
|
+
input: ClosePositionAsyncInput<
|
|
138
|
+
TAccountOwner,
|
|
139
|
+
TAccountPosition,
|
|
140
|
+
TAccountPositionMint,
|
|
141
|
+
TAccountPositionTokenAccount,
|
|
142
|
+
TAccountTokenProgram
|
|
143
|
+
>,
|
|
144
|
+
config?: { programAddress?: TProgramAddress },
|
|
145
|
+
): Promise<
|
|
146
|
+
ClosePositionInstruction<
|
|
147
|
+
TProgramAddress,
|
|
148
|
+
TAccountOwner,
|
|
149
|
+
TAccountPosition,
|
|
150
|
+
TAccountPositionMint,
|
|
151
|
+
TAccountPositionTokenAccount,
|
|
152
|
+
TAccountTokenProgram
|
|
153
|
+
>
|
|
154
|
+
> {
|
|
155
|
+
// Program address.
|
|
156
|
+
const programAddress = config?.programAddress ?? PICON_DLMM_PROGRAM_ADDRESS;
|
|
157
|
+
|
|
158
|
+
// Original accounts.
|
|
159
|
+
const originalAccounts = {
|
|
160
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
161
|
+
position: { value: input.position ?? null, isWritable: true },
|
|
162
|
+
positionMint: { value: input.positionMint ?? null, isWritable: true },
|
|
163
|
+
positionTokenAccount: {
|
|
164
|
+
value: input.positionTokenAccount ?? null,
|
|
165
|
+
isWritable: true,
|
|
166
|
+
},
|
|
167
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
168
|
+
};
|
|
169
|
+
const accounts = originalAccounts as Record<
|
|
170
|
+
keyof typeof originalAccounts,
|
|
171
|
+
ResolvedInstructionAccount
|
|
172
|
+
>;
|
|
173
|
+
|
|
174
|
+
// Resolve default values.
|
|
175
|
+
if (!accounts.position.value) {
|
|
176
|
+
accounts.position.value = await findPositionPda({
|
|
177
|
+
positionMint: getAddressFromResolvedInstructionAccount(
|
|
178
|
+
"positionMint",
|
|
179
|
+
accounts.positionMint.value,
|
|
180
|
+
),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
if (!accounts.tokenProgram.value) {
|
|
184
|
+
accounts.tokenProgram.value =
|
|
185
|
+
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" as Address<"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb">;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
189
|
+
return Object.freeze({
|
|
190
|
+
accounts: [
|
|
191
|
+
getAccountMeta("owner", accounts.owner),
|
|
192
|
+
getAccountMeta("position", accounts.position),
|
|
193
|
+
getAccountMeta("positionMint", accounts.positionMint),
|
|
194
|
+
getAccountMeta("positionTokenAccount", accounts.positionTokenAccount),
|
|
195
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
196
|
+
],
|
|
197
|
+
data: getClosePositionInstructionDataEncoder().encode({}),
|
|
198
|
+
programAddress,
|
|
199
|
+
} as ClosePositionInstruction<
|
|
200
|
+
TProgramAddress,
|
|
201
|
+
TAccountOwner,
|
|
202
|
+
TAccountPosition,
|
|
203
|
+
TAccountPositionMint,
|
|
204
|
+
TAccountPositionTokenAccount,
|
|
205
|
+
TAccountTokenProgram
|
|
206
|
+
>);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export type ClosePositionInput<
|
|
210
|
+
TAccountOwner extends string = string,
|
|
211
|
+
TAccountPosition extends string = string,
|
|
212
|
+
TAccountPositionMint extends string = string,
|
|
213
|
+
TAccountPositionTokenAccount extends string = string,
|
|
214
|
+
TAccountTokenProgram extends string = string,
|
|
215
|
+
> = {
|
|
216
|
+
owner: TransactionSigner<TAccountOwner>;
|
|
217
|
+
position: Address<TAccountPosition>;
|
|
218
|
+
positionMint: Address<TAccountPositionMint>;
|
|
219
|
+
positionTokenAccount: Address<TAccountPositionTokenAccount>;
|
|
220
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export function getClosePositionInstruction<
|
|
224
|
+
TAccountOwner extends string,
|
|
225
|
+
TAccountPosition extends string,
|
|
226
|
+
TAccountPositionMint extends string,
|
|
227
|
+
TAccountPositionTokenAccount extends string,
|
|
228
|
+
TAccountTokenProgram extends string,
|
|
229
|
+
TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
230
|
+
>(
|
|
231
|
+
input: ClosePositionInput<
|
|
232
|
+
TAccountOwner,
|
|
233
|
+
TAccountPosition,
|
|
234
|
+
TAccountPositionMint,
|
|
235
|
+
TAccountPositionTokenAccount,
|
|
236
|
+
TAccountTokenProgram
|
|
237
|
+
>,
|
|
238
|
+
config?: { programAddress?: TProgramAddress },
|
|
239
|
+
): ClosePositionInstruction<
|
|
240
|
+
TProgramAddress,
|
|
241
|
+
TAccountOwner,
|
|
242
|
+
TAccountPosition,
|
|
243
|
+
TAccountPositionMint,
|
|
244
|
+
TAccountPositionTokenAccount,
|
|
245
|
+
TAccountTokenProgram
|
|
246
|
+
> {
|
|
247
|
+
// Program address.
|
|
248
|
+
const programAddress = config?.programAddress ?? PICON_DLMM_PROGRAM_ADDRESS;
|
|
249
|
+
|
|
250
|
+
// Original accounts.
|
|
251
|
+
const originalAccounts = {
|
|
252
|
+
owner: { value: input.owner ?? null, isWritable: true },
|
|
253
|
+
position: { value: input.position ?? null, isWritable: true },
|
|
254
|
+
positionMint: { value: input.positionMint ?? null, isWritable: true },
|
|
255
|
+
positionTokenAccount: {
|
|
256
|
+
value: input.positionTokenAccount ?? null,
|
|
257
|
+
isWritable: true,
|
|
258
|
+
},
|
|
259
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
260
|
+
};
|
|
261
|
+
const accounts = originalAccounts as Record<
|
|
262
|
+
keyof typeof originalAccounts,
|
|
263
|
+
ResolvedInstructionAccount
|
|
264
|
+
>;
|
|
265
|
+
|
|
266
|
+
// Resolve default values.
|
|
267
|
+
if (!accounts.tokenProgram.value) {
|
|
268
|
+
accounts.tokenProgram.value =
|
|
269
|
+
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" as Address<"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb">;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
273
|
+
return Object.freeze({
|
|
274
|
+
accounts: [
|
|
275
|
+
getAccountMeta("owner", accounts.owner),
|
|
276
|
+
getAccountMeta("position", accounts.position),
|
|
277
|
+
getAccountMeta("positionMint", accounts.positionMint),
|
|
278
|
+
getAccountMeta("positionTokenAccount", accounts.positionTokenAccount),
|
|
279
|
+
getAccountMeta("tokenProgram", accounts.tokenProgram),
|
|
280
|
+
],
|
|
281
|
+
data: getClosePositionInstructionDataEncoder().encode({}),
|
|
282
|
+
programAddress,
|
|
283
|
+
} as ClosePositionInstruction<
|
|
284
|
+
TProgramAddress,
|
|
285
|
+
TAccountOwner,
|
|
286
|
+
TAccountPosition,
|
|
287
|
+
TAccountPositionMint,
|
|
288
|
+
TAccountPositionTokenAccount,
|
|
289
|
+
TAccountTokenProgram
|
|
290
|
+
>);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export type ParsedClosePositionInstruction<
|
|
294
|
+
TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
295
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
296
|
+
> = {
|
|
297
|
+
programAddress: Address<TProgram>;
|
|
298
|
+
accounts: {
|
|
299
|
+
owner: TAccountMetas[0];
|
|
300
|
+
position: TAccountMetas[1];
|
|
301
|
+
positionMint: TAccountMetas[2];
|
|
302
|
+
positionTokenAccount: TAccountMetas[3];
|
|
303
|
+
tokenProgram: TAccountMetas[4];
|
|
304
|
+
};
|
|
305
|
+
data: ClosePositionInstructionData;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export function parseClosePositionInstruction<
|
|
309
|
+
TProgram extends string,
|
|
310
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
311
|
+
>(
|
|
312
|
+
instruction: Instruction<TProgram> &
|
|
313
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
314
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
315
|
+
): ParsedClosePositionInstruction<TProgram, TAccountMetas> {
|
|
316
|
+
if (instruction.accounts.length < 5) {
|
|
317
|
+
throw new SolanaError(
|
|
318
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
319
|
+
{
|
|
320
|
+
actualAccountMetas: instruction.accounts.length,
|
|
321
|
+
expectedAccountMetas: 5,
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
let accountIndex = 0;
|
|
326
|
+
const getNextAccount = () => {
|
|
327
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
328
|
+
accountIndex += 1;
|
|
329
|
+
return accountMeta;
|
|
330
|
+
};
|
|
331
|
+
return {
|
|
332
|
+
programAddress: instruction.programAddress,
|
|
333
|
+
accounts: {
|
|
334
|
+
owner: getNextAccount(),
|
|
335
|
+
position: getNextAccount(),
|
|
336
|
+
positionMint: getNextAccount(),
|
|
337
|
+
positionTokenAccount: getNextAccount(),
|
|
338
|
+
tokenProgram: getNextAccount(),
|
|
339
|
+
},
|
|
340
|
+
data: getClosePositionInstructionDataDecoder().decode(instruction.data),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
@@ -0,0 +1,369 @@
|
|
|
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
|
+
getAddressDecoder,
|
|
14
|
+
getAddressEncoder,
|
|
15
|
+
getBytesDecoder,
|
|
16
|
+
getBytesEncoder,
|
|
17
|
+
getOptionDecoder,
|
|
18
|
+
getOptionEncoder,
|
|
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 Codec,
|
|
28
|
+
type Decoder,
|
|
29
|
+
type Encoder,
|
|
30
|
+
type Instruction,
|
|
31
|
+
type InstructionWithAccounts,
|
|
32
|
+
type InstructionWithData,
|
|
33
|
+
type Option,
|
|
34
|
+
type OptionOrNullable,
|
|
35
|
+
type ReadonlyAccount,
|
|
36
|
+
type ReadonlyUint8Array,
|
|
37
|
+
type TransactionSigner,
|
|
38
|
+
type WritableAccount,
|
|
39
|
+
type WritableSignerAccount,
|
|
40
|
+
} from "@solana/kit";
|
|
41
|
+
import {
|
|
42
|
+
getAccountMetaFactory,
|
|
43
|
+
type ResolvedInstructionAccount,
|
|
44
|
+
} from "@solana/program-client-core";
|
|
45
|
+
import { findAdminConfigPda } from "../pdas";
|
|
46
|
+
import { PICON_DLMM_PROGRAM_ADDRESS } from "../programs";
|
|
47
|
+
|
|
48
|
+
export const CREATE_ADMIN_CONFIG_DISCRIMINATOR: ReadonlyUint8Array =
|
|
49
|
+
new Uint8Array([19, 140, 214, 88, 151, 236, 89, 5]);
|
|
50
|
+
|
|
51
|
+
export function getCreateAdminConfigDiscriminatorBytes(): ReadonlyUint8Array {
|
|
52
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
53
|
+
CREATE_ADMIN_CONFIG_DISCRIMINATOR,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type CreateAdminConfigInstruction<
|
|
58
|
+
TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
59
|
+
TAccountDeployer extends string | AccountMeta<string> = string,
|
|
60
|
+
TAccountAdminConfig extends string | AccountMeta<string> = string,
|
|
61
|
+
TAccountProgram extends string | AccountMeta<string> =
|
|
62
|
+
"pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC",
|
|
63
|
+
TAccountProgramData extends string | AccountMeta<string> = string,
|
|
64
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
65
|
+
"11111111111111111111111111111111",
|
|
66
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
67
|
+
> = Instruction<TProgram> &
|
|
68
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
69
|
+
InstructionWithAccounts<
|
|
70
|
+
[
|
|
71
|
+
TAccountDeployer extends string
|
|
72
|
+
? WritableSignerAccount<TAccountDeployer> &
|
|
73
|
+
AccountSignerMeta<TAccountDeployer>
|
|
74
|
+
: TAccountDeployer,
|
|
75
|
+
TAccountAdminConfig extends string
|
|
76
|
+
? WritableAccount<TAccountAdminConfig>
|
|
77
|
+
: TAccountAdminConfig,
|
|
78
|
+
TAccountProgram extends string
|
|
79
|
+
? ReadonlyAccount<TAccountProgram>
|
|
80
|
+
: TAccountProgram,
|
|
81
|
+
TAccountProgramData extends string
|
|
82
|
+
? ReadonlyAccount<TAccountProgramData>
|
|
83
|
+
: TAccountProgramData,
|
|
84
|
+
TAccountSystemProgram extends string
|
|
85
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
86
|
+
: TAccountSystemProgram,
|
|
87
|
+
...TRemainingAccounts,
|
|
88
|
+
]
|
|
89
|
+
>;
|
|
90
|
+
|
|
91
|
+
export type CreateAdminConfigInstructionData = {
|
|
92
|
+
discriminator: ReadonlyUint8Array;
|
|
93
|
+
authority: Address;
|
|
94
|
+
metadataUpdateAuthority: Option<Address>;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type CreateAdminConfigInstructionDataArgs = {
|
|
98
|
+
authority: Address;
|
|
99
|
+
metadataUpdateAuthority: OptionOrNullable<Address>;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export function getCreateAdminConfigInstructionDataEncoder(): Encoder<CreateAdminConfigInstructionDataArgs> {
|
|
103
|
+
return transformEncoder(
|
|
104
|
+
getStructEncoder([
|
|
105
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
106
|
+
["authority", getAddressEncoder()],
|
|
107
|
+
["metadataUpdateAuthority", getOptionEncoder(getAddressEncoder())],
|
|
108
|
+
]),
|
|
109
|
+
(value) => ({ ...value, discriminator: CREATE_ADMIN_CONFIG_DISCRIMINATOR }),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function getCreateAdminConfigInstructionDataDecoder(): Decoder<CreateAdminConfigInstructionData> {
|
|
114
|
+
return getStructDecoder([
|
|
115
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
116
|
+
["authority", getAddressDecoder()],
|
|
117
|
+
["metadataUpdateAuthority", getOptionDecoder(getAddressDecoder())],
|
|
118
|
+
]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function getCreateAdminConfigInstructionDataCodec(): Codec<
|
|
122
|
+
CreateAdminConfigInstructionDataArgs,
|
|
123
|
+
CreateAdminConfigInstructionData
|
|
124
|
+
> {
|
|
125
|
+
return combineCodec(
|
|
126
|
+
getCreateAdminConfigInstructionDataEncoder(),
|
|
127
|
+
getCreateAdminConfigInstructionDataDecoder(),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type CreateAdminConfigAsyncInput<
|
|
132
|
+
TAccountDeployer extends string = string,
|
|
133
|
+
TAccountAdminConfig extends string = string,
|
|
134
|
+
TAccountProgram extends string = string,
|
|
135
|
+
TAccountProgramData extends string = string,
|
|
136
|
+
TAccountSystemProgram extends string = string,
|
|
137
|
+
> = {
|
|
138
|
+
deployer: TransactionSigner<TAccountDeployer>;
|
|
139
|
+
adminConfig?: Address<TAccountAdminConfig>;
|
|
140
|
+
program?: Address<TAccountProgram>;
|
|
141
|
+
programData: Address<TAccountProgramData>;
|
|
142
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
143
|
+
authority: CreateAdminConfigInstructionDataArgs["authority"];
|
|
144
|
+
metadataUpdateAuthority: CreateAdminConfigInstructionDataArgs["metadataUpdateAuthority"];
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export async function getCreateAdminConfigInstructionAsync<
|
|
148
|
+
TAccountDeployer extends string,
|
|
149
|
+
TAccountAdminConfig extends string,
|
|
150
|
+
TAccountProgram extends string,
|
|
151
|
+
TAccountProgramData extends string,
|
|
152
|
+
TAccountSystemProgram extends string,
|
|
153
|
+
TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
154
|
+
>(
|
|
155
|
+
input: CreateAdminConfigAsyncInput<
|
|
156
|
+
TAccountDeployer,
|
|
157
|
+
TAccountAdminConfig,
|
|
158
|
+
TAccountProgram,
|
|
159
|
+
TAccountProgramData,
|
|
160
|
+
TAccountSystemProgram
|
|
161
|
+
>,
|
|
162
|
+
config?: { programAddress?: TProgramAddress },
|
|
163
|
+
): Promise<
|
|
164
|
+
CreateAdminConfigInstruction<
|
|
165
|
+
TProgramAddress,
|
|
166
|
+
TAccountDeployer,
|
|
167
|
+
TAccountAdminConfig,
|
|
168
|
+
TAccountProgram,
|
|
169
|
+
TAccountProgramData,
|
|
170
|
+
TAccountSystemProgram
|
|
171
|
+
>
|
|
172
|
+
> {
|
|
173
|
+
// Program address.
|
|
174
|
+
const programAddress = config?.programAddress ?? PICON_DLMM_PROGRAM_ADDRESS;
|
|
175
|
+
|
|
176
|
+
// Original accounts.
|
|
177
|
+
const originalAccounts = {
|
|
178
|
+
deployer: { value: input.deployer ?? null, isWritable: true },
|
|
179
|
+
adminConfig: { value: input.adminConfig ?? null, isWritable: true },
|
|
180
|
+
program: { value: input.program ?? null, isWritable: false },
|
|
181
|
+
programData: { value: input.programData ?? null, isWritable: false },
|
|
182
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
183
|
+
};
|
|
184
|
+
const accounts = originalAccounts as Record<
|
|
185
|
+
keyof typeof originalAccounts,
|
|
186
|
+
ResolvedInstructionAccount
|
|
187
|
+
>;
|
|
188
|
+
|
|
189
|
+
// Original args.
|
|
190
|
+
const args = { ...input };
|
|
191
|
+
|
|
192
|
+
// Resolve default values.
|
|
193
|
+
if (!accounts.adminConfig.value) {
|
|
194
|
+
accounts.adminConfig.value = await findAdminConfigPda();
|
|
195
|
+
}
|
|
196
|
+
if (!accounts.program.value) {
|
|
197
|
+
accounts.program.value =
|
|
198
|
+
"pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC" as Address<"pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC">;
|
|
199
|
+
}
|
|
200
|
+
if (!accounts.systemProgram.value) {
|
|
201
|
+
accounts.systemProgram.value =
|
|
202
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
206
|
+
return Object.freeze({
|
|
207
|
+
accounts: [
|
|
208
|
+
getAccountMeta("deployer", accounts.deployer),
|
|
209
|
+
getAccountMeta("adminConfig", accounts.adminConfig),
|
|
210
|
+
getAccountMeta("program", accounts.program),
|
|
211
|
+
getAccountMeta("programData", accounts.programData),
|
|
212
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
213
|
+
],
|
|
214
|
+
data: getCreateAdminConfigInstructionDataEncoder().encode(
|
|
215
|
+
args as CreateAdminConfigInstructionDataArgs,
|
|
216
|
+
),
|
|
217
|
+
programAddress,
|
|
218
|
+
} as CreateAdminConfigInstruction<
|
|
219
|
+
TProgramAddress,
|
|
220
|
+
TAccountDeployer,
|
|
221
|
+
TAccountAdminConfig,
|
|
222
|
+
TAccountProgram,
|
|
223
|
+
TAccountProgramData,
|
|
224
|
+
TAccountSystemProgram
|
|
225
|
+
>);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type CreateAdminConfigInput<
|
|
229
|
+
TAccountDeployer extends string = string,
|
|
230
|
+
TAccountAdminConfig extends string = string,
|
|
231
|
+
TAccountProgram extends string = string,
|
|
232
|
+
TAccountProgramData extends string = string,
|
|
233
|
+
TAccountSystemProgram extends string = string,
|
|
234
|
+
> = {
|
|
235
|
+
deployer: TransactionSigner<TAccountDeployer>;
|
|
236
|
+
adminConfig: Address<TAccountAdminConfig>;
|
|
237
|
+
program?: Address<TAccountProgram>;
|
|
238
|
+
programData: Address<TAccountProgramData>;
|
|
239
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
240
|
+
authority: CreateAdminConfigInstructionDataArgs["authority"];
|
|
241
|
+
metadataUpdateAuthority: CreateAdminConfigInstructionDataArgs["metadataUpdateAuthority"];
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export function getCreateAdminConfigInstruction<
|
|
245
|
+
TAccountDeployer extends string,
|
|
246
|
+
TAccountAdminConfig extends string,
|
|
247
|
+
TAccountProgram extends string,
|
|
248
|
+
TAccountProgramData extends string,
|
|
249
|
+
TAccountSystemProgram extends string,
|
|
250
|
+
TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
251
|
+
>(
|
|
252
|
+
input: CreateAdminConfigInput<
|
|
253
|
+
TAccountDeployer,
|
|
254
|
+
TAccountAdminConfig,
|
|
255
|
+
TAccountProgram,
|
|
256
|
+
TAccountProgramData,
|
|
257
|
+
TAccountSystemProgram
|
|
258
|
+
>,
|
|
259
|
+
config?: { programAddress?: TProgramAddress },
|
|
260
|
+
): CreateAdminConfigInstruction<
|
|
261
|
+
TProgramAddress,
|
|
262
|
+
TAccountDeployer,
|
|
263
|
+
TAccountAdminConfig,
|
|
264
|
+
TAccountProgram,
|
|
265
|
+
TAccountProgramData,
|
|
266
|
+
TAccountSystemProgram
|
|
267
|
+
> {
|
|
268
|
+
// Program address.
|
|
269
|
+
const programAddress = config?.programAddress ?? PICON_DLMM_PROGRAM_ADDRESS;
|
|
270
|
+
|
|
271
|
+
// Original accounts.
|
|
272
|
+
const originalAccounts = {
|
|
273
|
+
deployer: { value: input.deployer ?? null, isWritable: true },
|
|
274
|
+
adminConfig: { value: input.adminConfig ?? null, isWritable: true },
|
|
275
|
+
program: { value: input.program ?? null, isWritable: false },
|
|
276
|
+
programData: { value: input.programData ?? null, isWritable: false },
|
|
277
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
278
|
+
};
|
|
279
|
+
const accounts = originalAccounts as Record<
|
|
280
|
+
keyof typeof originalAccounts,
|
|
281
|
+
ResolvedInstructionAccount
|
|
282
|
+
>;
|
|
283
|
+
|
|
284
|
+
// Original args.
|
|
285
|
+
const args = { ...input };
|
|
286
|
+
|
|
287
|
+
// Resolve default values.
|
|
288
|
+
if (!accounts.program.value) {
|
|
289
|
+
accounts.program.value =
|
|
290
|
+
"pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC" as Address<"pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC">;
|
|
291
|
+
}
|
|
292
|
+
if (!accounts.systemProgram.value) {
|
|
293
|
+
accounts.systemProgram.value =
|
|
294
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
298
|
+
return Object.freeze({
|
|
299
|
+
accounts: [
|
|
300
|
+
getAccountMeta("deployer", accounts.deployer),
|
|
301
|
+
getAccountMeta("adminConfig", accounts.adminConfig),
|
|
302
|
+
getAccountMeta("program", accounts.program),
|
|
303
|
+
getAccountMeta("programData", accounts.programData),
|
|
304
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
305
|
+
],
|
|
306
|
+
data: getCreateAdminConfigInstructionDataEncoder().encode(
|
|
307
|
+
args as CreateAdminConfigInstructionDataArgs,
|
|
308
|
+
),
|
|
309
|
+
programAddress,
|
|
310
|
+
} as CreateAdminConfigInstruction<
|
|
311
|
+
TProgramAddress,
|
|
312
|
+
TAccountDeployer,
|
|
313
|
+
TAccountAdminConfig,
|
|
314
|
+
TAccountProgram,
|
|
315
|
+
TAccountProgramData,
|
|
316
|
+
TAccountSystemProgram
|
|
317
|
+
>);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export type ParsedCreateAdminConfigInstruction<
|
|
321
|
+
TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
322
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
323
|
+
> = {
|
|
324
|
+
programAddress: Address<TProgram>;
|
|
325
|
+
accounts: {
|
|
326
|
+
deployer: TAccountMetas[0];
|
|
327
|
+
adminConfig: TAccountMetas[1];
|
|
328
|
+
program: TAccountMetas[2];
|
|
329
|
+
programData: TAccountMetas[3];
|
|
330
|
+
systemProgram: TAccountMetas[4];
|
|
331
|
+
};
|
|
332
|
+
data: CreateAdminConfigInstructionData;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export function parseCreateAdminConfigInstruction<
|
|
336
|
+
TProgram extends string,
|
|
337
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
338
|
+
>(
|
|
339
|
+
instruction: Instruction<TProgram> &
|
|
340
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
341
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
342
|
+
): ParsedCreateAdminConfigInstruction<TProgram, TAccountMetas> {
|
|
343
|
+
if (instruction.accounts.length < 5) {
|
|
344
|
+
throw new SolanaError(
|
|
345
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
346
|
+
{
|
|
347
|
+
actualAccountMetas: instruction.accounts.length,
|
|
348
|
+
expectedAccountMetas: 5,
|
|
349
|
+
},
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
let accountIndex = 0;
|
|
353
|
+
const getNextAccount = () => {
|
|
354
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
355
|
+
accountIndex += 1;
|
|
356
|
+
return accountMeta;
|
|
357
|
+
};
|
|
358
|
+
return {
|
|
359
|
+
programAddress: instruction.programAddress,
|
|
360
|
+
accounts: {
|
|
361
|
+
deployer: getNextAccount(),
|
|
362
|
+
adminConfig: getNextAccount(),
|
|
363
|
+
program: getNextAccount(),
|
|
364
|
+
programData: getNextAccount(),
|
|
365
|
+
systemProgram: getNextAccount(),
|
|
366
|
+
},
|
|
367
|
+
data: getCreateAdminConfigInstructionDataDecoder().decode(instruction.data),
|
|
368
|
+
};
|
|
369
|
+
}
|