@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,582 @@
|
|
|
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
|
+
getU16Decoder,
|
|
22
|
+
getU16Encoder,
|
|
23
|
+
getU32Decoder,
|
|
24
|
+
getU32Encoder,
|
|
25
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
26
|
+
SolanaError,
|
|
27
|
+
transformEncoder,
|
|
28
|
+
type AccountMeta,
|
|
29
|
+
type AccountSignerMeta,
|
|
30
|
+
type Address,
|
|
31
|
+
type FixedSizeCodec,
|
|
32
|
+
type FixedSizeDecoder,
|
|
33
|
+
type FixedSizeEncoder,
|
|
34
|
+
type Instruction,
|
|
35
|
+
type InstructionWithAccounts,
|
|
36
|
+
type InstructionWithData,
|
|
37
|
+
type ReadonlyAccount,
|
|
38
|
+
type ReadonlyUint8Array,
|
|
39
|
+
type TransactionSigner,
|
|
40
|
+
type WritableAccount,
|
|
41
|
+
type WritableSignerAccount,
|
|
42
|
+
} from "@solana/kit";
|
|
43
|
+
import {
|
|
44
|
+
getAccountMetaFactory,
|
|
45
|
+
getAddressFromResolvedInstructionAccount,
|
|
46
|
+
getNonNullResolvedInstructionInput,
|
|
47
|
+
type ResolvedInstructionAccount,
|
|
48
|
+
} from "@solana/program-client-core";
|
|
49
|
+
import { findAdminConfigPda, findPoolPda } from "../pdas";
|
|
50
|
+
import { PICON_DLMM_PROGRAM_ADDRESS } from "../programs";
|
|
51
|
+
|
|
52
|
+
export const CREATE_POOL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
53
|
+
233, 146, 209, 142, 207, 104, 64, 188,
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
export function getCreatePoolDiscriminatorBytes(): ReadonlyUint8Array {
|
|
57
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(CREATE_POOL_DISCRIMINATOR);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type CreatePoolInstruction<
|
|
61
|
+
TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
62
|
+
TAccountAuthority extends string | AccountMeta<string> = string,
|
|
63
|
+
TAccountAdminConfig extends string | AccountMeta<string> = string,
|
|
64
|
+
TAccountTokenMintX extends string | AccountMeta<string> = string,
|
|
65
|
+
TAccountTokenMintY extends string | AccountMeta<string> = string,
|
|
66
|
+
TAccountTokenVaultX extends string | AccountMeta<string> = string,
|
|
67
|
+
TAccountTokenVaultY extends string | AccountMeta<string> = string,
|
|
68
|
+
TAccountPool extends string | AccountMeta<string> = string,
|
|
69
|
+
TAccountTokenProgramX extends string | AccountMeta<string> = string,
|
|
70
|
+
TAccountTokenProgramY extends string | AccountMeta<string> = string,
|
|
71
|
+
TAccountAssociatedTokenProgram extends string | AccountMeta<string> =
|
|
72
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
73
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
74
|
+
"11111111111111111111111111111111",
|
|
75
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
76
|
+
> = Instruction<TProgram> &
|
|
77
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
78
|
+
InstructionWithAccounts<
|
|
79
|
+
[
|
|
80
|
+
TAccountAuthority extends string
|
|
81
|
+
? WritableSignerAccount<TAccountAuthority> &
|
|
82
|
+
AccountSignerMeta<TAccountAuthority>
|
|
83
|
+
: TAccountAuthority,
|
|
84
|
+
TAccountAdminConfig extends string
|
|
85
|
+
? ReadonlyAccount<TAccountAdminConfig>
|
|
86
|
+
: TAccountAdminConfig,
|
|
87
|
+
TAccountTokenMintX extends string
|
|
88
|
+
? ReadonlyAccount<TAccountTokenMintX>
|
|
89
|
+
: TAccountTokenMintX,
|
|
90
|
+
TAccountTokenMintY extends string
|
|
91
|
+
? ReadonlyAccount<TAccountTokenMintY>
|
|
92
|
+
: TAccountTokenMintY,
|
|
93
|
+
TAccountTokenVaultX extends string
|
|
94
|
+
? WritableAccount<TAccountTokenVaultX>
|
|
95
|
+
: TAccountTokenVaultX,
|
|
96
|
+
TAccountTokenVaultY extends string
|
|
97
|
+
? WritableAccount<TAccountTokenVaultY>
|
|
98
|
+
: TAccountTokenVaultY,
|
|
99
|
+
TAccountPool extends string
|
|
100
|
+
? WritableAccount<TAccountPool>
|
|
101
|
+
: TAccountPool,
|
|
102
|
+
TAccountTokenProgramX extends string
|
|
103
|
+
? ReadonlyAccount<TAccountTokenProgramX>
|
|
104
|
+
: TAccountTokenProgramX,
|
|
105
|
+
TAccountTokenProgramY extends string
|
|
106
|
+
? ReadonlyAccount<TAccountTokenProgramY>
|
|
107
|
+
: TAccountTokenProgramY,
|
|
108
|
+
TAccountAssociatedTokenProgram extends string
|
|
109
|
+
? ReadonlyAccount<TAccountAssociatedTokenProgram>
|
|
110
|
+
: TAccountAssociatedTokenProgram,
|
|
111
|
+
TAccountSystemProgram extends string
|
|
112
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
113
|
+
: TAccountSystemProgram,
|
|
114
|
+
...TRemainingAccounts,
|
|
115
|
+
]
|
|
116
|
+
>;
|
|
117
|
+
|
|
118
|
+
export type CreatePoolInstructionData = {
|
|
119
|
+
discriminator: ReadonlyUint8Array;
|
|
120
|
+
binStep: number;
|
|
121
|
+
feeRate: number;
|
|
122
|
+
protocolShare: number;
|
|
123
|
+
activeBinId: number;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type CreatePoolInstructionDataArgs = {
|
|
127
|
+
binStep: number;
|
|
128
|
+
feeRate: number;
|
|
129
|
+
protocolShare: number;
|
|
130
|
+
activeBinId: number;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export function getCreatePoolInstructionDataEncoder(): FixedSizeEncoder<CreatePoolInstructionDataArgs> {
|
|
134
|
+
return transformEncoder(
|
|
135
|
+
getStructEncoder([
|
|
136
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
137
|
+
["binStep", getU16Encoder()],
|
|
138
|
+
["feeRate", getU32Encoder()],
|
|
139
|
+
["protocolShare", getU16Encoder()],
|
|
140
|
+
["activeBinId", getI32Encoder()],
|
|
141
|
+
]),
|
|
142
|
+
(value) => ({ ...value, discriminator: CREATE_POOL_DISCRIMINATOR }),
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function getCreatePoolInstructionDataDecoder(): FixedSizeDecoder<CreatePoolInstructionData> {
|
|
147
|
+
return getStructDecoder([
|
|
148
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
149
|
+
["binStep", getU16Decoder()],
|
|
150
|
+
["feeRate", getU32Decoder()],
|
|
151
|
+
["protocolShare", getU16Decoder()],
|
|
152
|
+
["activeBinId", getI32Decoder()],
|
|
153
|
+
]);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function getCreatePoolInstructionDataCodec(): FixedSizeCodec<
|
|
157
|
+
CreatePoolInstructionDataArgs,
|
|
158
|
+
CreatePoolInstructionData
|
|
159
|
+
> {
|
|
160
|
+
return combineCodec(
|
|
161
|
+
getCreatePoolInstructionDataEncoder(),
|
|
162
|
+
getCreatePoolInstructionDataDecoder(),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type CreatePoolAsyncInput<
|
|
167
|
+
TAccountAuthority extends string = string,
|
|
168
|
+
TAccountAdminConfig extends string = string,
|
|
169
|
+
TAccountTokenMintX extends string = string,
|
|
170
|
+
TAccountTokenMintY extends string = string,
|
|
171
|
+
TAccountTokenVaultX extends string = string,
|
|
172
|
+
TAccountTokenVaultY extends string = string,
|
|
173
|
+
TAccountPool extends string = string,
|
|
174
|
+
TAccountTokenProgramX extends string = string,
|
|
175
|
+
TAccountTokenProgramY extends string = string,
|
|
176
|
+
TAccountAssociatedTokenProgram extends string = string,
|
|
177
|
+
TAccountSystemProgram extends string = string,
|
|
178
|
+
> = {
|
|
179
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
180
|
+
adminConfig?: Address<TAccountAdminConfig>;
|
|
181
|
+
tokenMintX: Address<TAccountTokenMintX>;
|
|
182
|
+
tokenMintY: Address<TAccountTokenMintY>;
|
|
183
|
+
tokenVaultX?: Address<TAccountTokenVaultX>;
|
|
184
|
+
tokenVaultY?: Address<TAccountTokenVaultY>;
|
|
185
|
+
pool?: Address<TAccountPool>;
|
|
186
|
+
tokenProgramX: Address<TAccountTokenProgramX>;
|
|
187
|
+
tokenProgramY: Address<TAccountTokenProgramY>;
|
|
188
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
189
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
190
|
+
binStep: CreatePoolInstructionDataArgs["binStep"];
|
|
191
|
+
feeRate: CreatePoolInstructionDataArgs["feeRate"];
|
|
192
|
+
protocolShare: CreatePoolInstructionDataArgs["protocolShare"];
|
|
193
|
+
activeBinId: CreatePoolInstructionDataArgs["activeBinId"];
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export async function getCreatePoolInstructionAsync<
|
|
197
|
+
TAccountAuthority extends string,
|
|
198
|
+
TAccountAdminConfig extends string,
|
|
199
|
+
TAccountTokenMintX extends string,
|
|
200
|
+
TAccountTokenMintY extends string,
|
|
201
|
+
TAccountTokenVaultX extends string,
|
|
202
|
+
TAccountTokenVaultY extends string,
|
|
203
|
+
TAccountPool extends string,
|
|
204
|
+
TAccountTokenProgramX extends string,
|
|
205
|
+
TAccountTokenProgramY extends string,
|
|
206
|
+
TAccountAssociatedTokenProgram extends string,
|
|
207
|
+
TAccountSystemProgram extends string,
|
|
208
|
+
TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
209
|
+
>(
|
|
210
|
+
input: CreatePoolAsyncInput<
|
|
211
|
+
TAccountAuthority,
|
|
212
|
+
TAccountAdminConfig,
|
|
213
|
+
TAccountTokenMintX,
|
|
214
|
+
TAccountTokenMintY,
|
|
215
|
+
TAccountTokenVaultX,
|
|
216
|
+
TAccountTokenVaultY,
|
|
217
|
+
TAccountPool,
|
|
218
|
+
TAccountTokenProgramX,
|
|
219
|
+
TAccountTokenProgramY,
|
|
220
|
+
TAccountAssociatedTokenProgram,
|
|
221
|
+
TAccountSystemProgram
|
|
222
|
+
>,
|
|
223
|
+
config?: { programAddress?: TProgramAddress },
|
|
224
|
+
): Promise<
|
|
225
|
+
CreatePoolInstruction<
|
|
226
|
+
TProgramAddress,
|
|
227
|
+
TAccountAuthority,
|
|
228
|
+
TAccountAdminConfig,
|
|
229
|
+
TAccountTokenMintX,
|
|
230
|
+
TAccountTokenMintY,
|
|
231
|
+
TAccountTokenVaultX,
|
|
232
|
+
TAccountTokenVaultY,
|
|
233
|
+
TAccountPool,
|
|
234
|
+
TAccountTokenProgramX,
|
|
235
|
+
TAccountTokenProgramY,
|
|
236
|
+
TAccountAssociatedTokenProgram,
|
|
237
|
+
TAccountSystemProgram
|
|
238
|
+
>
|
|
239
|
+
> {
|
|
240
|
+
// Program address.
|
|
241
|
+
const programAddress = config?.programAddress ?? PICON_DLMM_PROGRAM_ADDRESS;
|
|
242
|
+
|
|
243
|
+
// Original accounts.
|
|
244
|
+
const originalAccounts = {
|
|
245
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
246
|
+
adminConfig: { value: input.adminConfig ?? null, isWritable: false },
|
|
247
|
+
tokenMintX: { value: input.tokenMintX ?? null, isWritable: false },
|
|
248
|
+
tokenMintY: { value: input.tokenMintY ?? null, isWritable: false },
|
|
249
|
+
tokenVaultX: { value: input.tokenVaultX ?? null, isWritable: true },
|
|
250
|
+
tokenVaultY: { value: input.tokenVaultY ?? null, isWritable: true },
|
|
251
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
252
|
+
tokenProgramX: { value: input.tokenProgramX ?? null, isWritable: false },
|
|
253
|
+
tokenProgramY: { value: input.tokenProgramY ?? null, isWritable: false },
|
|
254
|
+
associatedTokenProgram: {
|
|
255
|
+
value: input.associatedTokenProgram ?? null,
|
|
256
|
+
isWritable: false,
|
|
257
|
+
},
|
|
258
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
259
|
+
};
|
|
260
|
+
const accounts = originalAccounts as Record<
|
|
261
|
+
keyof typeof originalAccounts,
|
|
262
|
+
ResolvedInstructionAccount
|
|
263
|
+
>;
|
|
264
|
+
|
|
265
|
+
// Original args.
|
|
266
|
+
const args = { ...input };
|
|
267
|
+
|
|
268
|
+
// Resolve default values.
|
|
269
|
+
if (!accounts.adminConfig.value) {
|
|
270
|
+
accounts.adminConfig.value = await findAdminConfigPda();
|
|
271
|
+
}
|
|
272
|
+
if (!accounts.pool.value) {
|
|
273
|
+
accounts.pool.value = await findPoolPda({
|
|
274
|
+
tokenMintX: getAddressFromResolvedInstructionAccount(
|
|
275
|
+
"tokenMintX",
|
|
276
|
+
accounts.tokenMintX.value,
|
|
277
|
+
),
|
|
278
|
+
tokenMintY: getAddressFromResolvedInstructionAccount(
|
|
279
|
+
"tokenMintY",
|
|
280
|
+
accounts.tokenMintY.value,
|
|
281
|
+
),
|
|
282
|
+
binStep: getNonNullResolvedInstructionInput("binStep", args.binStep),
|
|
283
|
+
feeRate: getNonNullResolvedInstructionInput("feeRate", args.feeRate),
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
if (!accounts.tokenVaultX.value) {
|
|
287
|
+
accounts.tokenVaultX.value = await getProgramDerivedAddress({
|
|
288
|
+
programAddress:
|
|
289
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">,
|
|
290
|
+
seeds: [
|
|
291
|
+
getAddressEncoder().encode(
|
|
292
|
+
getAddressFromResolvedInstructionAccount("pool", accounts.pool.value),
|
|
293
|
+
),
|
|
294
|
+
getAddressEncoder().encode(
|
|
295
|
+
getAddressFromResolvedInstructionAccount(
|
|
296
|
+
"tokenProgramX",
|
|
297
|
+
accounts.tokenProgramX.value,
|
|
298
|
+
),
|
|
299
|
+
),
|
|
300
|
+
getAddressEncoder().encode(
|
|
301
|
+
getAddressFromResolvedInstructionAccount(
|
|
302
|
+
"tokenMintX",
|
|
303
|
+
accounts.tokenMintX.value,
|
|
304
|
+
),
|
|
305
|
+
),
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
if (!accounts.tokenVaultY.value) {
|
|
310
|
+
accounts.tokenVaultY.value = await getProgramDerivedAddress({
|
|
311
|
+
programAddress:
|
|
312
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">,
|
|
313
|
+
seeds: [
|
|
314
|
+
getAddressEncoder().encode(
|
|
315
|
+
getAddressFromResolvedInstructionAccount("pool", accounts.pool.value),
|
|
316
|
+
),
|
|
317
|
+
getAddressEncoder().encode(
|
|
318
|
+
getAddressFromResolvedInstructionAccount(
|
|
319
|
+
"tokenProgramY",
|
|
320
|
+
accounts.tokenProgramY.value,
|
|
321
|
+
),
|
|
322
|
+
),
|
|
323
|
+
getAddressEncoder().encode(
|
|
324
|
+
getAddressFromResolvedInstructionAccount(
|
|
325
|
+
"tokenMintY",
|
|
326
|
+
accounts.tokenMintY.value,
|
|
327
|
+
),
|
|
328
|
+
),
|
|
329
|
+
],
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
333
|
+
accounts.associatedTokenProgram.value =
|
|
334
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
|
|
335
|
+
}
|
|
336
|
+
if (!accounts.systemProgram.value) {
|
|
337
|
+
accounts.systemProgram.value =
|
|
338
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
342
|
+
return Object.freeze({
|
|
343
|
+
accounts: [
|
|
344
|
+
getAccountMeta("authority", accounts.authority),
|
|
345
|
+
getAccountMeta("adminConfig", accounts.adminConfig),
|
|
346
|
+
getAccountMeta("tokenMintX", accounts.tokenMintX),
|
|
347
|
+
getAccountMeta("tokenMintY", accounts.tokenMintY),
|
|
348
|
+
getAccountMeta("tokenVaultX", accounts.tokenVaultX),
|
|
349
|
+
getAccountMeta("tokenVaultY", accounts.tokenVaultY),
|
|
350
|
+
getAccountMeta("pool", accounts.pool),
|
|
351
|
+
getAccountMeta("tokenProgramX", accounts.tokenProgramX),
|
|
352
|
+
getAccountMeta("tokenProgramY", accounts.tokenProgramY),
|
|
353
|
+
getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram),
|
|
354
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
355
|
+
],
|
|
356
|
+
data: getCreatePoolInstructionDataEncoder().encode(
|
|
357
|
+
args as CreatePoolInstructionDataArgs,
|
|
358
|
+
),
|
|
359
|
+
programAddress,
|
|
360
|
+
} as CreatePoolInstruction<
|
|
361
|
+
TProgramAddress,
|
|
362
|
+
TAccountAuthority,
|
|
363
|
+
TAccountAdminConfig,
|
|
364
|
+
TAccountTokenMintX,
|
|
365
|
+
TAccountTokenMintY,
|
|
366
|
+
TAccountTokenVaultX,
|
|
367
|
+
TAccountTokenVaultY,
|
|
368
|
+
TAccountPool,
|
|
369
|
+
TAccountTokenProgramX,
|
|
370
|
+
TAccountTokenProgramY,
|
|
371
|
+
TAccountAssociatedTokenProgram,
|
|
372
|
+
TAccountSystemProgram
|
|
373
|
+
>);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export type CreatePoolInput<
|
|
377
|
+
TAccountAuthority extends string = string,
|
|
378
|
+
TAccountAdminConfig extends string = string,
|
|
379
|
+
TAccountTokenMintX extends string = string,
|
|
380
|
+
TAccountTokenMintY extends string = string,
|
|
381
|
+
TAccountTokenVaultX extends string = string,
|
|
382
|
+
TAccountTokenVaultY extends string = string,
|
|
383
|
+
TAccountPool extends string = string,
|
|
384
|
+
TAccountTokenProgramX extends string = string,
|
|
385
|
+
TAccountTokenProgramY extends string = string,
|
|
386
|
+
TAccountAssociatedTokenProgram extends string = string,
|
|
387
|
+
TAccountSystemProgram extends string = string,
|
|
388
|
+
> = {
|
|
389
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
390
|
+
adminConfig: Address<TAccountAdminConfig>;
|
|
391
|
+
tokenMintX: Address<TAccountTokenMintX>;
|
|
392
|
+
tokenMintY: Address<TAccountTokenMintY>;
|
|
393
|
+
tokenVaultX: Address<TAccountTokenVaultX>;
|
|
394
|
+
tokenVaultY: Address<TAccountTokenVaultY>;
|
|
395
|
+
pool: Address<TAccountPool>;
|
|
396
|
+
tokenProgramX: Address<TAccountTokenProgramX>;
|
|
397
|
+
tokenProgramY: Address<TAccountTokenProgramY>;
|
|
398
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
399
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
400
|
+
binStep: CreatePoolInstructionDataArgs["binStep"];
|
|
401
|
+
feeRate: CreatePoolInstructionDataArgs["feeRate"];
|
|
402
|
+
protocolShare: CreatePoolInstructionDataArgs["protocolShare"];
|
|
403
|
+
activeBinId: CreatePoolInstructionDataArgs["activeBinId"];
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
export function getCreatePoolInstruction<
|
|
407
|
+
TAccountAuthority extends string,
|
|
408
|
+
TAccountAdminConfig extends string,
|
|
409
|
+
TAccountTokenMintX extends string,
|
|
410
|
+
TAccountTokenMintY extends string,
|
|
411
|
+
TAccountTokenVaultX extends string,
|
|
412
|
+
TAccountTokenVaultY extends string,
|
|
413
|
+
TAccountPool extends string,
|
|
414
|
+
TAccountTokenProgramX extends string,
|
|
415
|
+
TAccountTokenProgramY extends string,
|
|
416
|
+
TAccountAssociatedTokenProgram extends string,
|
|
417
|
+
TAccountSystemProgram extends string,
|
|
418
|
+
TProgramAddress extends Address = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
419
|
+
>(
|
|
420
|
+
input: CreatePoolInput<
|
|
421
|
+
TAccountAuthority,
|
|
422
|
+
TAccountAdminConfig,
|
|
423
|
+
TAccountTokenMintX,
|
|
424
|
+
TAccountTokenMintY,
|
|
425
|
+
TAccountTokenVaultX,
|
|
426
|
+
TAccountTokenVaultY,
|
|
427
|
+
TAccountPool,
|
|
428
|
+
TAccountTokenProgramX,
|
|
429
|
+
TAccountTokenProgramY,
|
|
430
|
+
TAccountAssociatedTokenProgram,
|
|
431
|
+
TAccountSystemProgram
|
|
432
|
+
>,
|
|
433
|
+
config?: { programAddress?: TProgramAddress },
|
|
434
|
+
): CreatePoolInstruction<
|
|
435
|
+
TProgramAddress,
|
|
436
|
+
TAccountAuthority,
|
|
437
|
+
TAccountAdminConfig,
|
|
438
|
+
TAccountTokenMintX,
|
|
439
|
+
TAccountTokenMintY,
|
|
440
|
+
TAccountTokenVaultX,
|
|
441
|
+
TAccountTokenVaultY,
|
|
442
|
+
TAccountPool,
|
|
443
|
+
TAccountTokenProgramX,
|
|
444
|
+
TAccountTokenProgramY,
|
|
445
|
+
TAccountAssociatedTokenProgram,
|
|
446
|
+
TAccountSystemProgram
|
|
447
|
+
> {
|
|
448
|
+
// Program address.
|
|
449
|
+
const programAddress = config?.programAddress ?? PICON_DLMM_PROGRAM_ADDRESS;
|
|
450
|
+
|
|
451
|
+
// Original accounts.
|
|
452
|
+
const originalAccounts = {
|
|
453
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
454
|
+
adminConfig: { value: input.adminConfig ?? null, isWritable: false },
|
|
455
|
+
tokenMintX: { value: input.tokenMintX ?? null, isWritable: false },
|
|
456
|
+
tokenMintY: { value: input.tokenMintY ?? null, isWritable: false },
|
|
457
|
+
tokenVaultX: { value: input.tokenVaultX ?? null, isWritable: true },
|
|
458
|
+
tokenVaultY: { value: input.tokenVaultY ?? null, isWritable: true },
|
|
459
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
460
|
+
tokenProgramX: { value: input.tokenProgramX ?? null, isWritable: false },
|
|
461
|
+
tokenProgramY: { value: input.tokenProgramY ?? null, isWritable: false },
|
|
462
|
+
associatedTokenProgram: {
|
|
463
|
+
value: input.associatedTokenProgram ?? null,
|
|
464
|
+
isWritable: false,
|
|
465
|
+
},
|
|
466
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
467
|
+
};
|
|
468
|
+
const accounts = originalAccounts as Record<
|
|
469
|
+
keyof typeof originalAccounts,
|
|
470
|
+
ResolvedInstructionAccount
|
|
471
|
+
>;
|
|
472
|
+
|
|
473
|
+
// Original args.
|
|
474
|
+
const args = { ...input };
|
|
475
|
+
|
|
476
|
+
// Resolve default values.
|
|
477
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
478
|
+
accounts.associatedTokenProgram.value =
|
|
479
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
|
|
480
|
+
}
|
|
481
|
+
if (!accounts.systemProgram.value) {
|
|
482
|
+
accounts.systemProgram.value =
|
|
483
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
487
|
+
return Object.freeze({
|
|
488
|
+
accounts: [
|
|
489
|
+
getAccountMeta("authority", accounts.authority),
|
|
490
|
+
getAccountMeta("adminConfig", accounts.adminConfig),
|
|
491
|
+
getAccountMeta("tokenMintX", accounts.tokenMintX),
|
|
492
|
+
getAccountMeta("tokenMintY", accounts.tokenMintY),
|
|
493
|
+
getAccountMeta("tokenVaultX", accounts.tokenVaultX),
|
|
494
|
+
getAccountMeta("tokenVaultY", accounts.tokenVaultY),
|
|
495
|
+
getAccountMeta("pool", accounts.pool),
|
|
496
|
+
getAccountMeta("tokenProgramX", accounts.tokenProgramX),
|
|
497
|
+
getAccountMeta("tokenProgramY", accounts.tokenProgramY),
|
|
498
|
+
getAccountMeta("associatedTokenProgram", accounts.associatedTokenProgram),
|
|
499
|
+
getAccountMeta("systemProgram", accounts.systemProgram),
|
|
500
|
+
],
|
|
501
|
+
data: getCreatePoolInstructionDataEncoder().encode(
|
|
502
|
+
args as CreatePoolInstructionDataArgs,
|
|
503
|
+
),
|
|
504
|
+
programAddress,
|
|
505
|
+
} as CreatePoolInstruction<
|
|
506
|
+
TProgramAddress,
|
|
507
|
+
TAccountAuthority,
|
|
508
|
+
TAccountAdminConfig,
|
|
509
|
+
TAccountTokenMintX,
|
|
510
|
+
TAccountTokenMintY,
|
|
511
|
+
TAccountTokenVaultX,
|
|
512
|
+
TAccountTokenVaultY,
|
|
513
|
+
TAccountPool,
|
|
514
|
+
TAccountTokenProgramX,
|
|
515
|
+
TAccountTokenProgramY,
|
|
516
|
+
TAccountAssociatedTokenProgram,
|
|
517
|
+
TAccountSystemProgram
|
|
518
|
+
>);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
export type ParsedCreatePoolInstruction<
|
|
522
|
+
TProgram extends string = typeof PICON_DLMM_PROGRAM_ADDRESS,
|
|
523
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
524
|
+
> = {
|
|
525
|
+
programAddress: Address<TProgram>;
|
|
526
|
+
accounts: {
|
|
527
|
+
authority: TAccountMetas[0];
|
|
528
|
+
adminConfig: TAccountMetas[1];
|
|
529
|
+
tokenMintX: TAccountMetas[2];
|
|
530
|
+
tokenMintY: TAccountMetas[3];
|
|
531
|
+
tokenVaultX: TAccountMetas[4];
|
|
532
|
+
tokenVaultY: TAccountMetas[5];
|
|
533
|
+
pool: TAccountMetas[6];
|
|
534
|
+
tokenProgramX: TAccountMetas[7];
|
|
535
|
+
tokenProgramY: TAccountMetas[8];
|
|
536
|
+
associatedTokenProgram: TAccountMetas[9];
|
|
537
|
+
systemProgram: TAccountMetas[10];
|
|
538
|
+
};
|
|
539
|
+
data: CreatePoolInstructionData;
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
export function parseCreatePoolInstruction<
|
|
543
|
+
TProgram extends string,
|
|
544
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
545
|
+
>(
|
|
546
|
+
instruction: Instruction<TProgram> &
|
|
547
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
548
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
549
|
+
): ParsedCreatePoolInstruction<TProgram, TAccountMetas> {
|
|
550
|
+
if (instruction.accounts.length < 11) {
|
|
551
|
+
throw new SolanaError(
|
|
552
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
553
|
+
{
|
|
554
|
+
actualAccountMetas: instruction.accounts.length,
|
|
555
|
+
expectedAccountMetas: 11,
|
|
556
|
+
},
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
let accountIndex = 0;
|
|
560
|
+
const getNextAccount = () => {
|
|
561
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
562
|
+
accountIndex += 1;
|
|
563
|
+
return accountMeta;
|
|
564
|
+
};
|
|
565
|
+
return {
|
|
566
|
+
programAddress: instruction.programAddress,
|
|
567
|
+
accounts: {
|
|
568
|
+
authority: getNextAccount(),
|
|
569
|
+
adminConfig: getNextAccount(),
|
|
570
|
+
tokenMintX: getNextAccount(),
|
|
571
|
+
tokenMintY: getNextAccount(),
|
|
572
|
+
tokenVaultX: getNextAccount(),
|
|
573
|
+
tokenVaultY: getNextAccount(),
|
|
574
|
+
pool: getNextAccount(),
|
|
575
|
+
tokenProgramX: getNextAccount(),
|
|
576
|
+
tokenProgramY: getNextAccount(),
|
|
577
|
+
associatedTokenProgram: getNextAccount(),
|
|
578
|
+
systemProgram: getNextAccount(),
|
|
579
|
+
},
|
|
580
|
+
data: getCreatePoolInstructionDataDecoder().decode(instruction.data),
|
|
581
|
+
};
|
|
582
|
+
}
|