@glamsystems/glam-cli 1.0.6 → 1.0.7
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/main.js +351 -239
- package/package.json +2 -2
package/main.js
CHANGED
|
@@ -17,6 +17,7 @@ tslib_1.__exportStar(__webpack_require__(64), exports);
|
|
|
17
17
|
tslib_1.__exportStar(__webpack_require__(59), exports);
|
|
18
18
|
tslib_1.__exportStar(__webpack_require__(83), exports);
|
|
19
19
|
tslib_1.__exportStar(__webpack_require__(87), exports);
|
|
20
|
+
tslib_1.__exportStar(__webpack_require__(78), exports);
|
|
20
21
|
tslib_1.__exportStar(__webpack_require__(26), exports);
|
|
21
22
|
tslib_1.__exportStar(__webpack_require__(57), exports);
|
|
22
23
|
tslib_1.__exportStar(__webpack_require__(65), exports);
|
|
@@ -187,7 +188,7 @@ module.exports = require("@solana/web3.js");
|
|
|
187
188
|
/***/ ((module) => {
|
|
188
189
|
|
|
189
190
|
"use strict";
|
|
190
|
-
module.exports = /*#__PURE__*/JSON.parse('{"address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz","metadata":{"name":"glam_protocol","version":"1.0.2","spec":"0.1.0","description":"Glam Protocol"},"instructions":[{"name":"cancel_timelock","discriminator":[158,180,47,81,133,231,168,238],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[]},{"name":"close_state","discriminator":[25,1,184,101,200,245,210,246],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[]},{"name":"cpi_proxy","docs":["Only accessible by integration programs"],"discriminator":[65,134,48,2,7,232,199,46],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program"},{"name":"integration_authority","signer":true},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"data","type":"bytes"},{"name":"extra_params","type":{"vec":{"defined":{"name":"ExtraParams"}}}}]},{"name":"emergency_access_update","docs":["Bypasses the timelock for emergency updates on access control rules. Allowed operations:","- removing an integration program","- removing a delegate","- enabling/disabling glam state"],"discriminator":[207,247,157,14,87,132,230,0],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"args","type":{"defined":{"name":"EmergencyAccessUpdateArgs"}}}]},{"name":"enable_disable_protocols","discriminator":[222,198,164,163,194,161,11,171],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"integration_program","type":"pubkey"},{"name":"protocols_bitmask","type":"u16"},{"name":"set_enabled","type":"bool"}]},{"name":"extend_state","discriminator":[34,147,151,206,134,128,82,228],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"bytes","type":"u32"}]},{"name":"grant_revoke_delegate_permissions","discriminator":[162,21,218,157,218,86,114,171],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"delegate","type":"pubkey"},{"name":"integration_program","type":"pubkey"},{"name":"protocol_bitflag","type":"u16"},{"name":"permissions_bitmask","type":"u64"},{"name":"set_granted","type":"bool"}]},{"name":"initialize_state","discriminator":[190,171,224,219,217,72,199,176],"accounts":[{"name":"glam_state","writable":true,"pda":{"seeds":[{"kind":"const","value":[115,116,97,116,101]},{"kind":"account","path":"glam_signer"},{"kind":"arg","path":"state_model.created"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"base_asset_mint"}],"args":[{"name":"state","type":{"defined":{"name":"StateModel"}}}]},{"name":"jupiter_swap","discriminator":[116,207,0,196,252,120,243,18],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"},{"name":"input_stake_pool","optional":true},{"name":"output_stake_pool","optional":true}],"args":[{"name":"data","type":"bytes"}]},{"name":"link_unlink_mint_by_mint_authority","docs":["For glam mint program\'s use only"],"discriminator":[85,67,58,245,175,14,122,6],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint"},{"name":"glam_mint_authority","signer":true}],"args":[{"name":"link","type":"bool"}]},{"name":"reset_priced_protocols_by_mint_authority","docs":["For glam mint program\'s use only"],"discriminator":[86,95,153,145,179,181,107,235],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint"},{"name":"glam_mint_authority","signer":true}],"args":[]},{"name":"set_jupiter_swap_policy","discriminator":[189,182,227,165,127,148,246,189],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"policy","type":{"defined":{"name":"JupiterSwapPolicy"}}}]},{"name":"set_protocol_policy","discriminator":[37,99,61,122,227,102,182,180],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"integration_program","type":"pubkey"},{"name":"protocol_bitflag","type":"u16"},{"name":"data","type":"bytes"}]},{"name":"set_system_transfer_policy","discriminator":[102,21,157,101,19,4,100,213],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"policy","type":{"defined":{"name":"TransferPolicy"}}}]},{"name":"stake_authorize","discriminator":[127,247,88,164,201,0,79,7],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"}],"args":[{"name":"new_authority","type":"pubkey"},{"name":"staker_or_withdrawer","type":"u32"}]},{"name":"stake_deactivate","discriminator":[224,10,93,175,175,145,237,169],"accounts":[{"name":"glam_state"},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"}],"args":[]},{"name":"stake_delegate_stake","discriminator":[202,40,152,239,175,251,66,228],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"vote"},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"},{"name":"stake_config"}],"args":[]},{"name":"stake_initialize","discriminator":[68,66,118,79,15,144,190,190],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"rent","address":"SysvarRent111111111111111111111111111111111"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[]},{"name":"stake_merge","discriminator":[46,181,125,12,51,179,134,176],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"destination_stake","writable":true},{"name":"source_stake","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"}],"args":[]},{"name":"stake_move","discriminator":[165,157,188,245,244,234,42,186],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"source_stake","writable":true},{"name":"destination_stake","writable":true}],"args":[{"name":"move_stake","type":"bool"},{"name":"lamports","type":"u64"}]},{"name":"stake_split","discriminator":[63,128,169,206,158,60,135,48],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"split_stake","writable":true}],"args":[{"name":"lamports","type":"u64"}]},{"name":"stake_withdraw","discriminator":[199,13,168,20,92,151,29,56],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"lamports","type":"u64"}]},{"name":"system_transfer","docs":["Transfers SOL from the vault to another account.","","Token program ID is required as a remaining account when wrapping SOL (i.e., transfer to wSOL token account)."],"discriminator":[167,164,195,155,219,152,191,230],"accounts":[{"name":"glam_state"},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"11111111111111111111111111111111"},{"name":"to","writable":true}],"args":[{"name":"lamports","type":"u64"}]},{"name":"token_transfer_checked_by_mint_authority","docs":["For glam mint program\'s use only"],"discriminator":[37,131,188,85,45,183,8,81],"accounts":[{"name":"glam_state"},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_mint","writable":true},{"name":"glam_mint_authority","writable":true,"signer":true},{"name":"from","writable":true},{"name":"to","writable":true},{"name":"mint"},{"name":"token_program"}],"args":[{"name":"amount","type":"u64"},{"name":"decimals","type":"u8"}]},{"name":"update_mint_params","discriminator":[45,42,115,25,179,27,57,191],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"params","type":{"vec":{"defined":{"name":"EngineField"}}}}]},{"name":"update_mint_params_by_mint_authority","docs":["For glam mint program\'s use only, timelock is not enforced"],"discriminator":[94,160,55,53,175,225,62,118],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint"},{"name":"glam_mint_authority","signer":true}],"args":[{"name":"params","type":{"vec":{"defined":{"name":"EngineField"}}}}]},{"name":"update_priced_protocol","docs":["Only accessible by integration programs"],"discriminator":[10,106,94,171,118,217,62,98],"accounts":[{"name":"glam_state","writable":true},{"name":"integration_authority","signer":true}],"args":[{"name":"priced_protocol","type":{"defined":{"name":"PricedProtocol"}}}]},{"name":"update_state","discriminator":[135,112,215,75,247,185,53,176],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"state","type":{"defined":{"name":"StateModel"}}}]},{"name":"update_state_apply_timelock","discriminator":[66,12,138,80,133,85,46,220],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[]}],"accounts":[{"name":"StateAccount","discriminator":[142,247,54,95,85,133,249,103]}],"errors":[{"code":48000,"name":"UnauthorizedSigner","msg":"Signer is not authorized"},{"code":48001,"name":"UnauthorizedIntegrationProgram","msg":"Integration program is not authorized"},{"code":48002,"name":"IntegrationNotEnabled","msg":"Integration is not enabled"},{"code":48003,"name":"ProtocolNotEnabled","msg":"Protocol is not enabled"},{"code":48004,"name":"GlamStateDisabled","msg":"GLAM state is disabled"},{"code":48005,"name":"ProtocolPolicyViolation","msg":"Protocol policy violation"},{"code":48006,"name":"EmergencyUpdateDenied","msg":"Emergency update denied"},{"code":48007,"name":"TimelockStillActive","msg":"Timelock still active"},{"code":48008,"name":"CannotApplyChanges","msg":"Pending changes cannot be applied due to unfulfilled requests"},{"code":48009,"name":"AssetNotBorrowable","msg":"Asset is not allowed to borrow"},{"code":48010,"name":"UnexpectedProgramOwner","msg":"Account is owned by an unexpected program"},{"code":48011,"name":"InvalidAuthority","msg":"Invalid authority"},{"code":49000,"name":"InvalidAccountType","msg":"Invalid account type"},{"code":49001,"name":"InvalidName","msg":"Invalid name"},{"code":49002,"name":"InvalidSymbol","msg":"Symbol too long: max 32 chars"},{"code":49003,"name":"InvalidUri","msg":"Uri too long: max 128 chars"},{"code":49004,"name":"InvalidAssetsLen","msg":"Too many assets: max 100"},{"code":49005,"name":"InvalidIxArgs","msg":"Invalid instruction arguments"},{"code":49006,"name":"CannotCloseState","msg":"Glam state cannot be closed: mint must be closed and state must be disabled"},{"code":49007,"name":"InvalidMintParams","msg":"Invalid mint params"},{"code":49008,"name":"InvalidRemainingAccounts","msg":"Invalid accounts: the transaction is malformed"},{"code":49009,"name":"InvalidVaultTokenAccount","msg":"Invalid vault ata"},{"code":49010,"name":"NonZeroSupply","msg":"Glam mint supply not zero"},{"code":49011,"name":"MissingAccount","msg":"An account required by the instruction is missing"},{"code":49012,"name":"InvalidTimestamp","msg":"Invalid timestamp"},{"code":49013,"name":"EngineFieldNotFound","msg":"Engine field not found"},{"code":49014,"name":"InvalidBaseAsset","msg":"Invalid base asset"},{"code":49015,"name":"InvalidProtocolBitflag","msg":"Invalid protocol bitflag"},{"code":50000,"name":"WithdrawDenied","msg":"Withdraw denied. Only vaults allow withdraws (funds and mints don\'t)"},{"code":50001,"name":"InvalidAssetForSwap","msg":"Asset cannot be swapped"},{"code":50002,"name":"UnsupportedSwapIx","msg":"Unsupported swap instruction"},{"code":50003,"name":"SlippageLimitExceeded","msg":"Max slippage exceeded"},{"code":50004,"name":"InvalidPlatformFeeForSwap","msg":"Invalid platform fee"},{"code":50005,"name":"InvalidTokenAccount","msg":"Invalid token account"},{"code":50006,"name":"InvalidSwapAmount","msg":"Invalid swap amount"},{"code":50007,"name":"MultipleStakeAccountsDisallowed","msg":"Multiple stake accounts disallowed"},{"code":51000,"name":"InvalidAssetPrice","msg":"Invalid asset price"},{"code":51001,"name":"InvalidStableCoinPriceForSubscribe","msg":"Subscription not allowed: invalid stable coin price"},{"code":51100,"name":"InvalidPricingOracle","msg":"Invalid oracle for asset price"},{"code":51101,"name":"PricingError","msg":"Pricing error"},{"code":51102,"name":"PriceTooOld","msg":"Price is too old"},{"code":51103,"name":"ExternalPositionsNotPriced","msg":"Not all external vault accounts are priced"},{"code":51104,"name":"VaultTokensNotPriced","msg":"Not all vault tokens are priced"},{"code":51105,"name":"PriceDivergenceTooLarge","msg":"No priced assets found"},{"code":51106,"name":"PositiveAumRequired","msg":"AUM must be positive"},{"code":51107,"name":"MathError","msg":"Math error"},{"code":51108,"name":"TypeCastingError","msg":"Type casting error"},{"code":51109,"name":"BaseAssetNotSupported","msg":"Base asset must have 6 decimals."},{"code":51110,"name":"InvalidQuoteSpotMarket","msg":"Unsupported spot market for perp quotes"},{"code":51111,"name":"UnknownExternalVaultAsset","msg":"Unknown external vault account"},{"code":51112,"name":"InvalidPriceDenom","msg":"Invalid price denom"},{"code":51113,"name":"UnexpectedDiscriminator","msg":"Invalid account: discriminator mismatch"},{"code":52000,"name":"TransfersDisabled","msg":"Policy violation: transfers disabled"},{"code":52001,"name":"InvalidPolicyAccount","msg":"Policy account is mandatory"},{"code":52002,"name":"AmountTooBig","msg":"Policy violation: amount too big"},{"code":52003,"name":"LockUp","msg":"Policy violation: lock-up has not expired"}],"types":[{"name":"AccountType","type":{"kind":"enum","variants":[{"name":"Vault"},{"name":"TokenizedVault"},{"name":"Mint"}]}},{"name":"AccruedFees","type":{"kind":"struct","fields":[{"name":"vault_subscription_fee","type":"u128"},{"name":"vault_redemption_fee","type":"u128"},{"name":"manager_subscription_fee","type":"u128"},{"name":"manager_redemption_fee","type":"u128"},{"name":"management_fee","type":"u128"},{"name":"performance_fee","type":"u128"},{"name":"protocol_base_fee","type":"u128"},{"name":"protocol_flow_fee","type":"u128"}]}},{"name":"ActionType","type":{"kind":"enum","variants":[{"name":"AddExternalAccount"},{"name":"DeleteExternalAccount"},{"name":"DeleteExternalAccountIfZeroLamports"},{"name":"DeleteExternalAccountIfZeroBalance"},{"name":"AddAsset"},{"name":"DeleteAsset"}]}},{"name":"CreatedModel","type":{"kind":"struct","fields":[{"name":"key","type":{"array":["u8",8]}},{"name":"created_by","type":"pubkey"},{"name":"created_at","type":"i64"}]}},{"name":"DelegateAcl","type":{"kind":"struct","fields":[{"name":"pubkey","type":"pubkey"},{"name":"integration_permissions","type":{"vec":{"defined":{"name":"IntegrationPermissions"}}}},{"name":"expires_at","type":"i64"}]}},{"name":"EmergencyAccessUpdateArgs","type":{"kind":"struct","fields":[{"name":"disabled_integrations","type":{"vec":"pubkey"}},{"name":"disabled_delegates","type":{"vec":"pubkey"}},{"name":"state_enabled","type":{"option":"bool"}}]}},{"name":"EngineField","type":{"kind":"struct","fields":[{"name":"name","type":{"defined":{"name":"EngineFieldName"}}},{"name":"value","type":{"defined":{"name":"EngineFieldValue"}}}]}},{"name":"EngineFieldName","type":{"kind":"enum","variants":[{"name":"Owner"},{"name":"PortfolioManagerName"},{"name":"Name"},{"name":"Uri"},{"name":"Assets"},{"name":"DelegateAcls"},{"name":"IntegrationAcls"},{"name":"TimelockDuration"},{"name":"Borrowable"},{"name":"DefaultAccountStateFrozen"},{"name":"PermanentDelegate"},{"name":"NotifyAndSettle"},{"name":"FeeStructure"},{"name":"FeeParams"},{"name":"ClaimableFees"},{"name":"ClaimedFees"},{"name":"OracleConfigs"}]}},{"name":"EngineFieldValue","type":{"kind":"enum","variants":[{"name":"Boolean","fields":[{"name":"val","type":"bool"}]},{"name":"U8","fields":[{"name":"val","type":"u8"}]},{"name":"U32","fields":[{"name":"val","type":"u32"}]},{"name":"U64","fields":[{"name":"val","type":"u64"}]},{"name":"String","fields":[{"name":"val","type":"string"}]},{"name":"Pubkey","fields":[{"name":"val","type":"pubkey"}]},{"name":"VecPubkey","fields":[{"name":"val","type":{"vec":"pubkey"}}]},{"name":"VecU8","fields":[{"name":"val","type":"bytes"}]},{"name":"VecU32","fields":[{"name":"val","type":{"vec":"u32"}}]},{"name":"VecDelegateAcl","fields":[{"name":"val","type":{"vec":{"defined":{"name":"DelegateAcl"}}}}]},{"name":"VecIntegrationAcl","fields":[{"name":"val","type":{"vec":{"defined":{"name":"IntegrationAcl"}}}}]},{"name":"FeeStructure","fields":[{"name":"val","type":{"defined":{"name":"FeeStructure"}}}]},{"name":"FeeParams","fields":[{"name":"val","type":{"defined":{"name":"FeeParams"}}}]},{"name":"AccruedFees","fields":[{"name":"val","type":{"defined":{"name":"AccruedFees"}}}]},{"name":"NotifyAndSettle","fields":[{"name":"val","type":{"defined":{"name":"NotifyAndSettle"}}}]},{"name":"OracleConfigs","fields":[{"name":"val","type":{"defined":{"name":"OracleConfigs"}}}]}]}},{"name":"EntryExitFees","type":{"kind":"struct","fields":[{"name":"subscription_fee_bps","type":"u16"},{"name":"redemption_fee_bps","type":"u16"}]}},{"name":"ExtraParams","type":{"kind":"struct","fields":[{"name":"action_type","type":{"defined":{"name":"ActionType"}}},{"name":"pubkey","type":"pubkey"},{"name":"amount","type":{"option":"u64"}}]}},{"name":"FeeParams","type":{"kind":"struct","fields":[{"name":"year_in_seconds","type":"u32"},{"name":"pa_high_water_mark","type":"i128"},{"name":"pa_last_nav","type":"i128"},{"name":"last_aum","type":"i128"},{"name":"last_performance_fee_crystallized","type":"i64"},{"name":"last_management_fee_crystallized","type":"i64"},{"name":"last_protocol_fee_crystallized","type":"i64"}]}},{"name":"FeeStructure","type":{"kind":"struct","fields":[{"name":"vault","type":{"defined":{"name":"EntryExitFees"}}},{"name":"manager","type":{"defined":{"name":"EntryExitFees"}}},{"name":"management","type":{"defined":{"name":"ManagementFee"}}},{"name":"performance","type":{"defined":{"name":"PerformanceFee"}}},{"name":"protocol","type":{"defined":{"name":"ProtocolFees"}}}]}},{"name":"HurdleType","type":{"kind":"enum","variants":[{"name":"Hard"},{"name":"Soft"}]}},{"name":"IntegrationAcl","docs":["An integration program can have multiple protocols supported.","Enabled protocols are stored in a bitmask, and each protocol can have its own policy."],"type":{"kind":"struct","fields":[{"name":"integration_program","type":"pubkey"},{"name":"protocols_bitmask","type":"u16"},{"name":"protocol_policies","type":{"vec":{"defined":{"name":"ProtocolPolicy"}}}}]}},{"name":"IntegrationPermissions","docs":["Stores delegate permissions for an integration program."],"type":{"kind":"struct","fields":[{"name":"integration_program","type":"pubkey"},{"name":"protocol_permissions","type":{"vec":{"defined":{"name":"ProtocolPermissions"}}}}]}},{"name":"JupiterSwapPolicy","type":{"kind":"struct","fields":[{"name":"max_slippage_bps","type":"u16"},{"name":"swap_allowlist","type":{"option":{"vec":"pubkey"}}}]}},{"name":"ManagementFee","type":{"kind":"struct","fields":[{"name":"fee_bps","type":"u16"}]}},{"name":"NoticePeriodType","type":{"kind":"enum","variants":[{"name":"Hard"},{"name":"Soft"}]}},{"name":"NotifyAndSettle","type":{"kind":"struct","fields":[{"name":"model","type":{"defined":{"name":"ValuationModel"}}},{"name":"permissionless_fulfillment","type":"bool"},{"name":"subscribe_notice_period_type","type":{"defined":{"name":"NoticePeriodType"}}},{"name":"subscribe_notice_period","type":"u64"},{"name":"subscribe_settlement_period","type":"u64"},{"name":"subscribe_cancellation_window","type":"u64"},{"name":"redeem_notice_period_type","type":{"defined":{"name":"NoticePeriodType"}}},{"name":"redeem_notice_period","type":"u64"},{"name":"redeem_settlement_period","type":"u64"},{"name":"redeem_cancellation_window","type":"u64"},{"name":"time_unit","type":{"defined":{"name":"TimeUnit"}}},{"name":"_padding","type":{"array":["u8",3]}}]}},{"name":"OracleConfigs","docs":["Vault-specific oracle configs. If available, these configs are preferred over the global config."],"type":{"kind":"struct","fields":[{"name":"max_ages_seconds","type":{"vec":{"array":["u16",2]}}},{"name":"padding","type":{"array":["u8",12]}}]}},{"name":"PerformanceFee","type":{"kind":"struct","fields":[{"name":"fee_bps","type":"u16"},{"name":"hurdle_rate_bps","type":"u16"},{"name":"hurdle_type","type":{"defined":{"name":"HurdleType"}}}]}},{"name":"PricedProtocol","type":{"kind":"struct","fields":[{"name":"rent","type":"u64"},{"name":"amount","type":"i128"},{"name":"decimals","type":"u8"},{"name":"last_updated_slot","type":"u64"},{"name":"integration_program","type":"pubkey"},{"name":"protocol_bitflag","type":"u16"},{"name":"positions","type":{"vec":"pubkey"}}]}},{"name":"ProtocolFees","type":{"kind":"struct","fields":[{"name":"base_fee_bps","type":"u16"},{"name":"flow_fee_bps","type":"u16"}]}},{"name":"ProtocolPermissions","docs":["Represents a delegate\'s permissions for a specific protocol"],"type":{"kind":"struct","fields":[{"name":"protocol_bitflag","type":"u16"},{"name":"permissions_bitmask","type":"u64"}]}},{"name":"ProtocolPolicy","docs":["Stores policy data for an integrated protocol.","Integration programs serialize/deserialize this data."],"type":{"kind":"struct","fields":[{"name":"protocol_bitflag","type":"u16"},{"name":"data","type":"bytes"}]}},{"name":"StateAccount","type":{"kind":"struct","fields":[{"name":"account_type","type":{"defined":{"name":"AccountType"}}},{"name":"enabled","type":"bool"},{"name":"vault","type":"pubkey"},{"name":"owner","type":"pubkey"},{"name":"portfolio_manager_name","type":{"array":["u8",32]}},{"name":"created","type":{"defined":{"name":"CreatedModel"}}},{"name":"base_asset_mint","type":"pubkey"},{"name":"base_asset_decimals","type":"u8"},{"name":"base_asset_token_program","type":"u8"},{"name":"name","type":{"array":["u8",32]}},{"name":"timelock_duration","type":"u32"},{"name":"timelock_expires_at","type":"u64"},{"name":"mint","type":"pubkey"},{"name":"assets","type":{"vec":"pubkey"}},{"name":"integration_acls","type":{"vec":{"defined":{"name":"IntegrationAcl"}}}},{"name":"delegate_acls","type":{"vec":{"defined":{"name":"DelegateAcl"}}}},{"name":"external_positions","type":{"vec":"pubkey"}},{"name":"priced_protocols","type":{"vec":{"defined":{"name":"PricedProtocol"}}}},{"name":"params","type":{"vec":{"vec":{"defined":{"name":"EngineField"}}}}}]}},{"name":"StateModel","type":{"kind":"struct","fields":[{"name":"account_type","type":{"option":{"defined":{"name":"AccountType"}}}},{"name":"name","type":{"option":{"array":["u8",32]}}},{"name":"uri","type":{"option":"string"}},{"name":"enabled","type":{"option":"bool"}},{"name":"assets","type":{"option":{"vec":"pubkey"}}},{"name":"created","type":{"option":{"defined":{"name":"CreatedModel"}}}},{"name":"owner","type":{"option":"pubkey"}},{"name":"portfolio_manager_name","type":{"option":{"array":["u8",32]}}},{"name":"borrowable","type":{"option":{"vec":"pubkey"}}},{"name":"timelock_duration","type":{"option":"u32"}},{"name":"integration_acls","type":{"option":{"vec":{"defined":{"name":"IntegrationAcl"}}}}},{"name":"delegate_acls","type":{"option":{"vec":{"defined":{"name":"DelegateAcl"}}}}}]}},{"name":"TimeUnit","type":{"kind":"enum","variants":[{"name":"Second"},{"name":"Slot"}]}},{"name":"TransferPolicy","type":{"kind":"struct","fields":[{"name":"allowlist","type":{"vec":"pubkey"}}]}},{"name":"ValuationModel","type":{"kind":"enum","variants":[{"name":"Continuous"},{"name":"Periodic"}]}}],"constants":[{"name":"PROTO_JUPITER_SWAP","type":"u16","value":"4"},{"name":"PROTO_JUPITER_SWAP_PERM_SWAP_ALLOWLISTED","type":"u64","value":"4"},{"name":"PROTO_JUPITER_SWAP_PERM_SWAP_ANY","type":"u64","value":"1"},{"name":"PROTO_JUPITER_SWAP_PERM_SWAP_LST","type":"u64","value":"2"},{"name":"PROTO_STAKE","type":"u16","value":"2"},{"name":"PROTO_STAKE_PERM_STAKE","type":"u64","value":"1"},{"name":"PROTO_STAKE_PERM_UNSTAKE","type":"u64","value":"2"},{"name":"PROTO_SYSTEM","type":"u16","value":"1"},{"name":"PROTO_SYSTEM_PERM_TRANSFER","type":"u64","value":"2"},{"name":"PROTO_SYSTEM_PERM_WSOL","type":"u64","value":"1"}]}');
|
|
191
|
+
module.exports = /*#__PURE__*/JSON.parse('{"address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz","metadata":{"name":"glam_protocol","version":"1.0.2","spec":"0.1.0","description":"Glam Protocol"},"instructions":[{"name":"cancel_timelock","discriminator":[158,180,47,81,133,231,168,238],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[]},{"name":"close_state","discriminator":[25,1,184,101,200,245,210,246],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[]},{"name":"cpi_proxy","docs":["Only accessible by integration programs"],"discriminator":[65,134,48,2,7,232,199,46],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program"},{"name":"integration_authority","signer":true},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"data","type":"bytes"},{"name":"extra_params","type":{"vec":{"defined":{"name":"ExtraParams"}}}}]},{"name":"emergency_access_update","docs":["Bypasses the timelock for emergency updates on access control rules. Allowed operations:","- removing an integration program","- removing a delegate","- enabling/disabling glam state"],"discriminator":[207,247,157,14,87,132,230,0],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"args","type":{"defined":{"name":"EmergencyAccessUpdateArgs"}}}]},{"name":"enable_disable_protocols","discriminator":[222,198,164,163,194,161,11,171],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"integration_program","type":"pubkey"},{"name":"protocols_bitmask","type":"u16"},{"name":"set_enabled","type":"bool"}]},{"name":"extend_state","discriminator":[34,147,151,206,134,128,82,228],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"bytes","type":"u32"}]},{"name":"grant_revoke_delegate_permissions","discriminator":[162,21,218,157,218,86,114,171],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"delegate","type":"pubkey"},{"name":"integration_program","type":"pubkey"},{"name":"protocol_bitflag","type":"u16"},{"name":"permissions_bitmask","type":"u64"},{"name":"set_granted","type":"bool"}]},{"name":"initialize_state","discriminator":[190,171,224,219,217,72,199,176],"accounts":[{"name":"glam_state","writable":true,"pda":{"seeds":[{"kind":"const","value":[115,116,97,116,101]},{"kind":"account","path":"glam_signer"},{"kind":"arg","path":"state_model.created"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"base_asset_mint"}],"args":[{"name":"state","type":{"defined":{"name":"StateModel"}}}]},{"name":"jupiter_swap","discriminator":[116,207,0,196,252,120,243,18],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"},{"name":"input_stake_pool","optional":true},{"name":"output_stake_pool","optional":true}],"args":[{"name":"data","type":"bytes"}]},{"name":"link_unlink_mint_by_mint_authority","docs":["For glam mint program\'s use only"],"discriminator":[85,67,58,245,175,14,122,6],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint"},{"name":"glam_mint_authority","signer":true}],"args":[{"name":"link","type":"bool"}]},{"name":"reset_priced_protocols_by_mint_authority","docs":["For glam mint program\'s use only"],"discriminator":[86,95,153,145,179,181,107,235],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint"},{"name":"glam_mint_authority","signer":true}],"args":[]},{"name":"set_jupiter_swap_policy","discriminator":[189,182,227,165,127,148,246,189],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"policy","type":{"defined":{"name":"JupiterSwapPolicy"}}}]},{"name":"set_protocol_policy","discriminator":[37,99,61,122,227,102,182,180],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"integration_program","type":"pubkey"},{"name":"protocol_bitflag","type":"u16"},{"name":"data","type":"bytes"}]},{"name":"set_system_transfer_policy","discriminator":[102,21,157,101,19,4,100,213],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"policy","type":{"defined":{"name":"TransferPolicy"}}}]},{"name":"stake_authorize","discriminator":[127,247,88,164,201,0,79,7],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"}],"args":[{"name":"new_authority","type":"pubkey"},{"name":"staker_or_withdrawer","type":"u32"}]},{"name":"stake_deactivate","discriminator":[224,10,93,175,175,145,237,169],"accounts":[{"name":"glam_state"},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"}],"args":[]},{"name":"stake_delegate_stake","discriminator":[202,40,152,239,175,251,66,228],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"vote"},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"},{"name":"stake_config"}],"args":[]},{"name":"stake_initialize","discriminator":[68,66,118,79,15,144,190,190],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"rent","address":"SysvarRent111111111111111111111111111111111"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[]},{"name":"stake_merge","discriminator":[46,181,125,12,51,179,134,176],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"destination_stake","writable":true},{"name":"source_stake","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"}],"args":[]},{"name":"stake_move","discriminator":[165,157,188,245,244,234,42,186],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"source_stake","writable":true},{"name":"destination_stake","writable":true}],"args":[{"name":"move_stake","type":"bool"},{"name":"lamports","type":"u64"}]},{"name":"stake_split","discriminator":[63,128,169,206,158,60,135,48],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"split_stake","writable":true}],"args":[{"name":"lamports","type":"u64"}]},{"name":"stake_withdraw","discriminator":[199,13,168,20,92,151,29,56],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"Stake11111111111111111111111111111111111111"},{"name":"stake","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"lamports","type":"u64"}]},{"name":"system_transfer","docs":["Transfers SOL from the vault to another account.","","Token program ID is required as a remaining account when wrapping SOL (i.e., transfer to wSOL token account)."],"discriminator":[167,164,195,155,219,152,191,230],"accounts":[{"name":"glam_state"},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_signer","writable":true,"signer":true},{"name":"cpi_program","address":"11111111111111111111111111111111"},{"name":"to","writable":true}],"args":[{"name":"lamports","type":"u64"}]},{"name":"token_transfer_checked_by_mint_authority","docs":["For glam mint program\'s use only"],"discriminator":[37,131,188,85,45,183,8,81],"accounts":[{"name":"glam_state"},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}]}},{"name":"glam_mint","writable":true},{"name":"glam_mint_authority","writable":true,"signer":true},{"name":"from","writable":true},{"name":"to","writable":true},{"name":"mint"},{"name":"token_program"}],"args":[{"name":"amount","type":"u64"},{"name":"decimals","type":"u8"}]},{"name":"update_mint_params","discriminator":[45,42,115,25,179,27,57,191],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"params","type":{"vec":{"defined":{"name":"EngineField"}}}}]},{"name":"update_mint_params_by_mint_authority","docs":["For glam mint program\'s use only, timelock is not enforced"],"discriminator":[94,160,55,53,175,225,62,118],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint"},{"name":"glam_mint_authority","signer":true}],"args":[{"name":"params","type":{"vec":{"defined":{"name":"EngineField"}}}}]},{"name":"update_priced_protocol","docs":["Only accessible by integration programs"],"discriminator":[10,106,94,171,118,217,62,98],"accounts":[{"name":"glam_state","writable":true},{"name":"integration_authority","signer":true}],"args":[{"name":"priced_protocol","type":{"defined":{"name":"PricedProtocol"}}}]},{"name":"update_state","discriminator":[135,112,215,75,247,185,53,176],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[{"name":"state","type":{"defined":{"name":"StateModel"}}}]},{"name":"update_state_apply_timelock","discriminator":[66,12,138,80,133,85,46,220],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true}],"args":[]}],"accounts":[{"name":"StateAccount","discriminator":[142,247,54,95,85,133,249,103]}],"errors":[{"code":48000,"name":"UnauthorizedSigner","msg":"Signer is not authorized"},{"code":48001,"name":"UnauthorizedIntegrationProgram","msg":"Integration program is not authorized"},{"code":48002,"name":"IntegrationNotEnabled","msg":"Integration is not enabled"},{"code":48003,"name":"ProtocolNotEnabled","msg":"Protocol is not enabled"},{"code":48004,"name":"GlamStateDisabled","msg":"GLAM state is disabled"},{"code":48005,"name":"ProtocolPolicyViolation","msg":"Protocol policy violation"},{"code":48006,"name":"EmergencyUpdateDenied","msg":"Emergency update denied"},{"code":48007,"name":"TimelockStillActive","msg":"Timelock still active"},{"code":48008,"name":"CannotApplyChanges","msg":"Pending changes cannot be applied due to unfulfilled requests"},{"code":48009,"name":"AssetNotBorrowable","msg":"Asset is not allowed to borrow"},{"code":48010,"name":"UnexpectedProgramOwner","msg":"Account is owned by an unexpected program"},{"code":48011,"name":"InvalidAuthority","msg":"Invalid authority"},{"code":49000,"name":"InvalidAccountType","msg":"Invalid account type"},{"code":49001,"name":"InvalidName","msg":"Invalid name"},{"code":49002,"name":"InvalidSymbol","msg":"Symbol too long: max 32 chars"},{"code":49003,"name":"InvalidUri","msg":"Uri too long: max 128 chars"},{"code":49004,"name":"InvalidAssetsLen","msg":"Too many assets: max 100"},{"code":49005,"name":"InvalidIxArgs","msg":"Invalid instruction arguments"},{"code":49006,"name":"CannotCloseState","msg":"Glam state cannot be closed: mint must be closed and state must be disabled"},{"code":49007,"name":"InvalidMintParams","msg":"Invalid mint params"},{"code":49008,"name":"InvalidRemainingAccounts","msg":"Invalid accounts: the transaction is malformed"},{"code":49009,"name":"InvalidVaultTokenAccount","msg":"Invalid vault ata"},{"code":49010,"name":"NonZeroSupply","msg":"Glam mint supply not zero"},{"code":49011,"name":"MissingAccount","msg":"An account required by the instruction is missing"},{"code":49012,"name":"InvalidTimestamp","msg":"Invalid timestamp"},{"code":49013,"name":"EngineFieldNotFound","msg":"Engine field not found"},{"code":49014,"name":"InvalidBaseAsset","msg":"Invalid base asset"},{"code":49015,"name":"InvalidProtocolBitflag","msg":"Invalid protocol bitflag"},{"code":50000,"name":"WithdrawDenied","msg":"Withdraw denied. Only vaults allow withdraws (funds and mints don\'t)"},{"code":50001,"name":"InvalidAssetForSwap","msg":"Asset cannot be swapped"},{"code":50002,"name":"UnsupportedSwapIx","msg":"Unsupported swap instruction"},{"code":50003,"name":"SlippageLimitExceeded","msg":"Max slippage exceeded"},{"code":50004,"name":"InvalidPlatformFeeForSwap","msg":"Invalid platform fee"},{"code":50005,"name":"InvalidTokenAccount","msg":"Invalid token account"},{"code":50006,"name":"InvalidSwapAmount","msg":"Invalid swap amount"},{"code":50007,"name":"MultipleStakeAccountsDisallowed","msg":"Multiple stake accounts disallowed"},{"code":51000,"name":"InvalidAssetPrice","msg":"Invalid asset price"},{"code":51001,"name":"InvalidStableCoinPriceForSubscribe","msg":"Subscription not allowed: invalid stable coin price"},{"code":51100,"name":"InvalidPricingOracle","msg":"Invalid oracle for asset price"},{"code":51101,"name":"PricingError","msg":"Pricing error"},{"code":51102,"name":"PriceTooOld","msg":"Price is too old"},{"code":51103,"name":"ExternalPositionsNotPriced","msg":"Not all external vault accounts are priced"},{"code":51104,"name":"VaultTokensNotPriced","msg":"Not all vault tokens are priced"},{"code":51105,"name":"PriceDivergenceTooLarge","msg":"No priced assets found"},{"code":51106,"name":"PositiveAumRequired","msg":"AUM must be positive"},{"code":51107,"name":"MathError","msg":"Math error"},{"code":51108,"name":"TypeCastingError","msg":"Type casting error"},{"code":51109,"name":"BaseAssetNotSupported","msg":"Base asset must have 6 decimals."},{"code":51110,"name":"InvalidQuoteSpotMarket","msg":"Unsupported spot market for perp quotes"},{"code":51111,"name":"UnknownExternalVaultAsset","msg":"Unknown external vault account"},{"code":51112,"name":"InvalidPriceDenom","msg":"Invalid price denom"},{"code":51113,"name":"UnexpectedDiscriminator","msg":"Invalid account: discriminator mismatch"},{"code":52000,"name":"TransfersDisabled","msg":"Policy violation: transfers disabled"},{"code":52001,"name":"InvalidPolicyAccount","msg":"Policy account is mandatory"},{"code":52002,"name":"AmountTooBig","msg":"Policy violation: amount too big"},{"code":52003,"name":"LockUp","msg":"Policy violation: lock-up has not expired"}],"types":[{"name":"AccountType","type":{"kind":"enum","variants":[{"name":"Vault"},{"name":"TokenizedVault"},{"name":"Mint"}]}},{"name":"AccruedFees","type":{"kind":"struct","fields":[{"name":"vault_subscription_fee","type":"u128"},{"name":"vault_redemption_fee","type":"u128"},{"name":"manager_subscription_fee","type":"u128"},{"name":"manager_redemption_fee","type":"u128"},{"name":"management_fee","type":"u128"},{"name":"performance_fee","type":"u128"},{"name":"protocol_base_fee","type":"u128"},{"name":"protocol_flow_fee","type":"u128"}]}},{"name":"ActionType","type":{"kind":"enum","variants":[{"name":"AddExternalAccount"},{"name":"DeleteExternalAccount"},{"name":"DeleteExternalAccountIfZeroLamports"},{"name":"DeleteExternalAccountIfZeroBalance"},{"name":"AddAsset"},{"name":"DeleteAsset"}]}},{"name":"CreatedModel","type":{"kind":"struct","fields":[{"name":"key","type":{"array":["u8",8]}},{"name":"created_by","type":"pubkey"},{"name":"created_at","type":"i64"}]}},{"name":"DelegateAcl","type":{"kind":"struct","fields":[{"name":"pubkey","type":"pubkey"},{"name":"integration_permissions","type":{"vec":{"defined":{"name":"IntegrationPermissions"}}}},{"name":"expires_at","type":"i64"}]}},{"name":"EmergencyAccessUpdateArgs","type":{"kind":"struct","fields":[{"name":"disabled_integrations","type":{"vec":"pubkey"}},{"name":"disabled_delegates","type":{"vec":"pubkey"}},{"name":"state_enabled","type":{"option":"bool"}}]}},{"name":"EngineField","type":{"kind":"struct","fields":[{"name":"name","type":{"defined":{"name":"EngineFieldName"}}},{"name":"value","type":{"defined":{"name":"EngineFieldValue"}}}]}},{"name":"EngineFieldName","type":{"kind":"enum","variants":[{"name":"Owner"},{"name":"PortfolioManagerName"},{"name":"Name"},{"name":"Uri"},{"name":"Assets"},{"name":"DelegateAcls"},{"name":"IntegrationAcls"},{"name":"TimelockDuration"},{"name":"Borrowable"},{"name":"DefaultAccountStateFrozen"},{"name":"PermanentDelegate"},{"name":"NotifyAndSettle"},{"name":"FeeStructure"},{"name":"FeeParams"},{"name":"ClaimableFees"},{"name":"ClaimedFees"},{"name":"OracleConfigs"}]}},{"name":"EngineFieldValue","type":{"kind":"enum","variants":[{"name":"Boolean","fields":[{"name":"val","type":"bool"}]},{"name":"U8","fields":[{"name":"val","type":"u8"}]},{"name":"U32","fields":[{"name":"val","type":"u32"}]},{"name":"U64","fields":[{"name":"val","type":"u64"}]},{"name":"String","fields":[{"name":"val","type":"string"}]},{"name":"Pubkey","fields":[{"name":"val","type":"pubkey"}]},{"name":"VecPubkey","fields":[{"name":"val","type":{"vec":"pubkey"}}]},{"name":"VecU8","fields":[{"name":"val","type":"bytes"}]},{"name":"VecU32","fields":[{"name":"val","type":{"vec":"u32"}}]},{"name":"VecDelegateAcl","fields":[{"name":"val","type":{"vec":{"defined":{"name":"DelegateAcl"}}}}]},{"name":"VecIntegrationAcl","fields":[{"name":"val","type":{"vec":{"defined":{"name":"IntegrationAcl"}}}}]},{"name":"FeeStructure","fields":[{"name":"val","type":{"defined":{"name":"FeeStructure"}}}]},{"name":"FeeParams","fields":[{"name":"val","type":{"defined":{"name":"FeeParams"}}}]},{"name":"AccruedFees","fields":[{"name":"val","type":{"defined":{"name":"AccruedFees"}}}]},{"name":"NotifyAndSettle","fields":[{"name":"val","type":{"defined":{"name":"NotifyAndSettle"}}}]},{"name":"OracleConfigs","fields":[{"name":"val","type":{"defined":{"name":"OracleConfigs"}}}]}]}},{"name":"EntryExitFees","type":{"kind":"struct","fields":[{"name":"subscription_fee_bps","type":"u16"},{"name":"redemption_fee_bps","type":"u16"}]}},{"name":"ExtraParams","type":{"kind":"struct","fields":[{"name":"action_type","type":{"defined":{"name":"ActionType"}}},{"name":"pubkey","type":"pubkey"},{"name":"amount","type":{"option":"u64"}}]}},{"name":"FeeParams","type":{"kind":"struct","fields":[{"name":"year_in_seconds","type":"u32"},{"name":"pa_high_water_mark","type":"i128"},{"name":"pa_last_nav","type":"i128"},{"name":"last_aum","type":"i128"},{"name":"last_performance_fee_crystallized","type":"i64"},{"name":"last_management_fee_crystallized","type":"i64"},{"name":"last_protocol_fee_crystallized","type":"i64"}]}},{"name":"FeeStructure","type":{"kind":"struct","fields":[{"name":"vault","type":{"defined":{"name":"EntryExitFees"}}},{"name":"manager","type":{"defined":{"name":"EntryExitFees"}}},{"name":"management","type":{"defined":{"name":"ManagementFee"}}},{"name":"performance","type":{"defined":{"name":"PerformanceFee"}}},{"name":"protocol","type":{"defined":{"name":"ProtocolFees"}}}]}},{"name":"HurdleType","type":{"kind":"enum","variants":[{"name":"Hard"},{"name":"Soft"}]}},{"name":"IntegrationAcl","docs":["An integration program can have multiple protocols supported.","Enabled protocols are stored in a bitmask, and each protocol can have its own policy."],"type":{"kind":"struct","fields":[{"name":"integration_program","type":"pubkey"},{"name":"protocols_bitmask","type":"u16"},{"name":"protocol_policies","type":{"vec":{"defined":{"name":"ProtocolPolicy"}}}}]}},{"name":"IntegrationPermissions","docs":["Stores delegate permissions for an integration program."],"type":{"kind":"struct","fields":[{"name":"integration_program","type":"pubkey"},{"name":"protocol_permissions","type":{"vec":{"defined":{"name":"ProtocolPermissions"}}}}]}},{"name":"JupiterSwapPolicy","type":{"kind":"struct","fields":[{"name":"max_slippage_bps","type":"u16"},{"name":"swap_allowlist","type":{"option":{"vec":"pubkey"}}}]}},{"name":"ManagementFee","type":{"kind":"struct","fields":[{"name":"fee_bps","type":"u16"}]}},{"name":"NoticePeriodType","type":{"kind":"enum","variants":[{"name":"Hard"},{"name":"Soft"}]}},{"name":"NotifyAndSettle","type":{"kind":"struct","fields":[{"name":"model","type":{"defined":{"name":"ValuationModel"}}},{"name":"permissionless_fulfillment","type":"bool"},{"name":"subscribe_notice_period_type","type":{"defined":{"name":"NoticePeriodType"}}},{"name":"subscribe_notice_period","type":"u64"},{"name":"subscribe_settlement_period","type":"u64"},{"name":"subscribe_cancellation_window","type":"u64"},{"name":"redeem_notice_period_type","type":{"defined":{"name":"NoticePeriodType"}}},{"name":"redeem_notice_period","type":"u64"},{"name":"redeem_settlement_period","type":"u64"},{"name":"redeem_cancellation_window","type":"u64"},{"name":"time_unit","type":{"defined":{"name":"TimeUnit"}}},{"name":"_padding","type":{"array":["u8",3]}}]}},{"name":"OracleConfigs","docs":["Vault-specific oracle configs. If available, these configs are preferred over the global config."],"type":{"kind":"struct","fields":[{"name":"max_ages_seconds","type":{"vec":{"array":["u16",2]}}},{"name":"padding","type":{"array":["u8",12]}}]}},{"name":"PerformanceFee","type":{"kind":"struct","fields":[{"name":"fee_bps","type":"u16"},{"name":"hurdle_rate_bps","type":"u16"},{"name":"hurdle_type","type":{"defined":{"name":"HurdleType"}}}]}},{"name":"PricedProtocol","type":{"kind":"struct","fields":[{"name":"rent","type":"u64"},{"name":"amount","type":"i128"},{"name":"decimals","type":"u8"},{"name":"last_updated_slot","type":"u64"},{"name":"integration_program","type":"pubkey"},{"name":"protocol_bitflag","type":"u16"},{"name":"positions","type":{"vec":"pubkey"}}]}},{"name":"ProtocolFees","type":{"kind":"struct","fields":[{"name":"base_fee_bps","type":"u16"},{"name":"flow_fee_bps","type":"u16"}]}},{"name":"ProtocolPermissions","docs":["Represents a delegate\'s permissions for a specific protocol"],"type":{"kind":"struct","fields":[{"name":"protocol_bitflag","type":"u16"},{"name":"permissions_bitmask","type":"u64"}]}},{"name":"ProtocolPolicy","docs":["Stores policy data for an integrated protocol.","Integration programs serialize/deserialize this data."],"type":{"kind":"struct","fields":[{"name":"protocol_bitflag","type":"u16"},{"name":"data","type":"bytes"}]}},{"name":"StateAccount","type":{"kind":"struct","fields":[{"name":"account_type","type":{"defined":{"name":"AccountType"}}},{"name":"enabled","type":"bool"},{"name":"vault","type":"pubkey"},{"name":"owner","type":"pubkey"},{"name":"portfolio_manager_name","type":{"array":["u8",32]}},{"name":"created","type":{"defined":{"name":"CreatedModel"}}},{"name":"base_asset_mint","type":"pubkey"},{"name":"base_asset_decimals","type":"u8"},{"name":"base_asset_token_program","type":"u8"},{"name":"name","type":{"array":["u8",32]}},{"name":"timelock_duration","type":"u32"},{"name":"timelock_expires_at","type":"u64"},{"name":"mint","type":"pubkey"},{"name":"assets","type":{"vec":"pubkey"}},{"name":"integration_acls","type":{"vec":{"defined":{"name":"IntegrationAcl"}}}},{"name":"delegate_acls","type":{"vec":{"defined":{"name":"DelegateAcl"}}}},{"name":"external_positions","type":{"vec":"pubkey"}},{"name":"priced_protocols","type":{"vec":{"defined":{"name":"PricedProtocol"}}}},{"name":"params","type":{"vec":{"vec":{"defined":{"name":"EngineField"}}}}}]}},{"name":"StateModel","type":{"kind":"struct","fields":[{"name":"account_type","type":{"option":{"defined":{"name":"AccountType"}}}},{"name":"name","type":{"option":{"array":["u8",32]}}},{"name":"uri","type":{"option":"string"}},{"name":"enabled","type":{"option":"bool"}},{"name":"assets","type":{"option":{"vec":"pubkey"}}},{"name":"created","type":{"option":{"defined":{"name":"CreatedModel"}}}},{"name":"owner","type":{"option":"pubkey"}},{"name":"portfolio_manager_name","type":{"option":{"array":["u8",32]}}},{"name":"borrowable","type":{"option":{"vec":"pubkey"}}},{"name":"timelock_duration","type":{"option":"u32"}},{"name":"integration_acls","type":{"option":{"vec":{"defined":{"name":"IntegrationAcl"}}}}},{"name":"delegate_acls","type":{"option":{"vec":{"defined":{"name":"DelegateAcl"}}}}}]}},{"name":"TimeUnit","type":{"kind":"enum","variants":[{"name":"Second"},{"name":"Slot"}]}},{"name":"TransferPolicy","type":{"kind":"struct","fields":[{"name":"allowlist","type":{"vec":"pubkey"}}]}},{"name":"ValuationModel","type":{"kind":"enum","variants":[{"name":"Continuous"},{"name":"Periodic"}]}}],"constants":[{"name":"PROTO_JUPITER_SWAP","type":"u16","value":"4"},{"name":"PROTO_JUPITER_SWAP_PERM_SWAP_ALLOWLISTED","type":"u64","value":"4"},{"name":"PROTO_JUPITER_SWAP_PERM_SWAP_ANY","type":"u64","value":"1"},{"name":"PROTO_JUPITER_SWAP_PERM_SWAP_LST","type":"u64","value":"2"},{"name":"PROTO_STAKE","type":"u16","value":"2"},{"name":"PROTO_STAKE_PERM_STAKE","type":"u64","value":"1"},{"name":"PROTO_STAKE_PERM_UNSTAKE","type":"u64","value":"2"},{"name":"PROTO_SYSTEM","type":"u16","value":"1"},{"name":"PROTO_SYSTEM_PERM_EMERGENCY_UPDATE","type":"u64","value":"4"},{"name":"PROTO_SYSTEM_PERM_TRANSFER","type":"u64","value":"2"},{"name":"PROTO_SYSTEM_PERM_WSOL","type":"u64","value":"1"}]}');
|
|
191
192
|
|
|
192
193
|
/***/ }),
|
|
193
194
|
/* 7 */
|
|
@@ -387,7 +388,7 @@ class StateModel extends StateIdlModel {
|
|
|
387
388
|
return this.id?.toBase58() || "";
|
|
388
389
|
}
|
|
389
390
|
get nameStr() {
|
|
390
|
-
return this.name ? (0, common_1.
|
|
391
|
+
return this.name ? (0, common_1.charsToString)(this.name) : "";
|
|
391
392
|
}
|
|
392
393
|
get productType() {
|
|
393
394
|
// @ts-ignore
|
|
@@ -399,12 +400,9 @@ class StateModel extends StateIdlModel {
|
|
|
399
400
|
return new Date(createdAt * 1000).toISOString().split("T")[0] || "Unknown";
|
|
400
401
|
}
|
|
401
402
|
get sparkleKey() {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
// An edge case is mint is closed but state account is not
|
|
406
|
-
// this.mint would be `null`
|
|
407
|
-
return (!this.mint?.equals(web3_js_1.PublicKey.default) ? this.id : this.mint)?.toBase58();
|
|
403
|
+
const pubkey = (this.mint?.equals(web3_js_1.PublicKey.default) ? this.id : this.mint) ||
|
|
404
|
+
web3_js_1.PublicKey.default;
|
|
405
|
+
return pubkey.toBase58();
|
|
408
406
|
}
|
|
409
407
|
get baseAssetTokenProgramId() {
|
|
410
408
|
switch (this.baseAssetTokenProgram) {
|
|
@@ -485,7 +483,7 @@ class StateModel extends StateIdlModel {
|
|
|
485
483
|
? (0, spl_token_metadata_1.unpack)(extMetadata)
|
|
486
484
|
: {};
|
|
487
485
|
mintModel["symbol"] = tokenMetadata?.symbol;
|
|
488
|
-
mintModel["name"] = (0, common_1.
|
|
486
|
+
mintModel["name"] = (0, common_1.stringToChars)(tokenMetadata?.name);
|
|
489
487
|
mintModel["uri"] = tokenMetadata?.uri;
|
|
490
488
|
if (tokenMetadata?.additionalMetadata) {
|
|
491
489
|
tokenMetadata.additionalMetadata.forEach(([k, v]) => {
|
|
@@ -573,44 +571,86 @@ module.exports = require("@solana/spl-token-metadata");
|
|
|
573
571
|
|
|
574
572
|
/***/ }),
|
|
575
573
|
/* 25 */
|
|
576
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
574
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
577
575
|
|
|
578
576
|
"use strict";
|
|
579
577
|
|
|
580
578
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
581
|
-
exports.
|
|
582
|
-
exports.
|
|
583
|
-
exports.nameToChars = nameToChars;
|
|
579
|
+
exports.charsToString = charsToString;
|
|
580
|
+
exports.stringToChars = stringToChars;
|
|
584
581
|
exports.toUiAmount = toUiAmount;
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
*/
|
|
588
|
-
const setsAreEqual = (a, b) => {
|
|
589
|
-
if (a.size !== b.size)
|
|
590
|
-
return false;
|
|
591
|
-
for (let item of a) {
|
|
592
|
-
if (!b.has(item))
|
|
593
|
-
return false;
|
|
594
|
-
}
|
|
595
|
-
return true;
|
|
596
|
-
};
|
|
597
|
-
exports.setsAreEqual = setsAreEqual;
|
|
582
|
+
exports.fromUiAmount = fromUiAmount;
|
|
583
|
+
const anchor_1 = __webpack_require__(4);
|
|
598
584
|
/**
|
|
599
585
|
* Converts a buffer or array of character codes to a string
|
|
600
586
|
*/
|
|
601
|
-
function
|
|
587
|
+
function charsToString(chars) {
|
|
602
588
|
return String.fromCharCode(...chars)
|
|
603
589
|
.replace(/\0/g, "")
|
|
604
590
|
.trim();
|
|
605
591
|
}
|
|
606
592
|
/**
|
|
607
|
-
* Converts a string to an array of character codes
|
|
593
|
+
* Converts a string to an array of character codes
|
|
608
594
|
*/
|
|
609
|
-
function
|
|
610
|
-
return Array.from(Buffer.from(name).subarray(0,
|
|
595
|
+
function stringToChars(name, length = 32) {
|
|
596
|
+
return Array.from(Buffer.from(name).subarray(0, length));
|
|
611
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Safely converts a BN amount to a UI amount (with decimals).
|
|
600
|
+
*
|
|
601
|
+
* @param amount - The amount in base units (BN)
|
|
602
|
+
* @param decimals - The number of decimals (e.g., 9)
|
|
603
|
+
* @returns The UI amount as a number
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* // Convert 10010000000 base units with 9 decimals
|
|
607
|
+
* const uiAmount = toUiAmount(new BN(10010000000), 9); // Returns 10.01
|
|
608
|
+
*
|
|
609
|
+
* @throws Error if the BN amount is too large to safely convert to number
|
|
610
|
+
*/
|
|
612
611
|
function toUiAmount(amount, decimals) {
|
|
613
|
-
|
|
612
|
+
const divisor = new anchor_1.BN(10).pow(new anchor_1.BN(decimals));
|
|
613
|
+
const integerPart = amount.div(divisor);
|
|
614
|
+
const fractionalPart = amount.mod(divisor);
|
|
615
|
+
// Convert to number - will throw if too large for Number.MAX_SAFE_INTEGER
|
|
616
|
+
const intNum = integerPart.toNumber();
|
|
617
|
+
const fracNum = fractionalPart.toNumber();
|
|
618
|
+
return intNum + fracNum / Math.pow(10, decimals);
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Safely converts a UI amount (with decimals) to a BN amount.
|
|
622
|
+
*
|
|
623
|
+
* @param amount - The UI amount (e.g., 10.01)
|
|
624
|
+
* @param decimals - The number of decimals (e.g., 9)
|
|
625
|
+
* @returns BN representing the amount in base units
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* // Convert 10.01 with 9 decimals
|
|
629
|
+
* const amount = fromUiAmount(10.01, 9); // Returns BN(10010000000)
|
|
630
|
+
*/
|
|
631
|
+
function fromUiAmount(amount, decimals) {
|
|
632
|
+
// Handle scientific notation by converting to fixed-point string
|
|
633
|
+
let amountStr;
|
|
634
|
+
if (typeof amount === "number") {
|
|
635
|
+
// Convert number to fixed-point string to avoid scientific notation
|
|
636
|
+
amountStr = amount.toFixed(decimals);
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
amountStr = amount;
|
|
640
|
+
}
|
|
641
|
+
const [integerPart, fractionalPart = ""] = amountStr.split(".");
|
|
642
|
+
// Convert integer part
|
|
643
|
+
const integerBN = new anchor_1.BN(integerPart || "0");
|
|
644
|
+
// Convert fractional part
|
|
645
|
+
let fractionalBN = new anchor_1.BN(0);
|
|
646
|
+
if (fractionalPart) {
|
|
647
|
+
// Pad or truncate fractional part to match decimals
|
|
648
|
+
const paddedFractional = fractionalPart.padEnd(decimals, "0").slice(0, decimals);
|
|
649
|
+
fractionalBN = new anchor_1.BN(paddedFractional);
|
|
650
|
+
}
|
|
651
|
+
// Combine: (integer * 10^decimals) + fractional
|
|
652
|
+
const multiplier = new anchor_1.BN(10).pow(new anchor_1.BN(decimals));
|
|
653
|
+
return integerBN.mul(multiplier).add(fractionalBN);
|
|
614
654
|
}
|
|
615
655
|
|
|
616
656
|
|
|
@@ -875,7 +915,7 @@ class MintModel extends MintIdlModel {
|
|
|
875
915
|
this.pendingRequests = data.pendingRequests ?? null;
|
|
876
916
|
}
|
|
877
917
|
get nameStr() {
|
|
878
|
-
return this.name ? (0, common_1.
|
|
918
|
+
return this.name ? (0, common_1.charsToString)(this.name) : "";
|
|
879
919
|
}
|
|
880
920
|
}
|
|
881
921
|
exports.MintModel = MintModel;
|
|
@@ -1277,28 +1317,33 @@ exports.DRIFT_POOL_MAPPING = {
|
|
|
1277
1317
|
3: "Exponent Market",
|
|
1278
1318
|
};
|
|
1279
1319
|
/**
|
|
1280
|
-
* Get protocol and permission mappings at runtime to ensure correct program IDs based on environment
|
|
1320
|
+
* Get protocol and permission mappings at runtime to ensure correct program IDs based on environment.
|
|
1321
|
+
*
|
|
1322
|
+
* This method provides the source of truth for protocol and permission mappings and staging status in SDK.
|
|
1281
1323
|
*/
|
|
1282
1324
|
const getProtocolsAndPermissions = () => ({
|
|
1283
1325
|
// Supported protocols and permissions are defined in:
|
|
1284
1326
|
// @anchor/programs/glam_protocol/src/state/acl.rs
|
|
1285
1327
|
[(0, glamExports_1.getGlamProtocolProgramId)().toBase58()]: {
|
|
1286
1328
|
"0000000000000001": {
|
|
1287
|
-
name: "
|
|
1329
|
+
name: "SystemProgram",
|
|
1330
|
+
staging: false,
|
|
1288
1331
|
permissions: {
|
|
1289
1332
|
[1 << 0]: "WSOL",
|
|
1290
1333
|
[1 << 1]: "Transfer",
|
|
1291
1334
|
},
|
|
1292
1335
|
},
|
|
1293
1336
|
"0000000000000010": {
|
|
1294
|
-
name: "
|
|
1337
|
+
name: "StakeProgram",
|
|
1338
|
+
staging: true,
|
|
1295
1339
|
permissions: {
|
|
1296
1340
|
[1 << 0]: "Stake",
|
|
1297
1341
|
[1 << 1]: "Unstake",
|
|
1298
1342
|
},
|
|
1299
1343
|
},
|
|
1300
1344
|
"0000000000000100": {
|
|
1301
|
-
name: "
|
|
1345
|
+
name: "JupiterSwap",
|
|
1346
|
+
staging: false,
|
|
1302
1347
|
permissions: {
|
|
1303
1348
|
[1 << 0]: "SwapAny",
|
|
1304
1349
|
[1 << 1]: "SwapLST",
|
|
@@ -1310,7 +1355,8 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1310
1355
|
// @anchor/programs/glam_mint/src/state/acl.rs
|
|
1311
1356
|
[(0, glamExports_1.getGlamMintProgramId)().toBase58()]: {
|
|
1312
1357
|
"0000000000000001": {
|
|
1313
|
-
name: "
|
|
1358
|
+
name: "GlamMint",
|
|
1359
|
+
staging: false,
|
|
1314
1360
|
permissions: {
|
|
1315
1361
|
[1 << 0]: "MintTokens",
|
|
1316
1362
|
[1 << 1]: "BurnTokens",
|
|
@@ -1328,7 +1374,8 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1328
1374
|
// @anchor/programs/ext_kamino/src/state/acl.rs
|
|
1329
1375
|
[(0, glamExports_1.getExtKaminoProgramId)().toBase58()]: {
|
|
1330
1376
|
"0000000000000001": {
|
|
1331
|
-
name: "
|
|
1377
|
+
name: "KaminoLend",
|
|
1378
|
+
staging: false,
|
|
1332
1379
|
permissions: {
|
|
1333
1380
|
[1 << 0]: "Init",
|
|
1334
1381
|
[1 << 1]: "Deposit",
|
|
@@ -1338,14 +1385,16 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1338
1385
|
},
|
|
1339
1386
|
},
|
|
1340
1387
|
"0000000000000010": {
|
|
1341
|
-
name: "
|
|
1388
|
+
name: "KaminoVaults",
|
|
1389
|
+
staging: false,
|
|
1342
1390
|
permissions: {
|
|
1343
1391
|
[1 << 0]: "Deposit",
|
|
1344
1392
|
[1 << 1]: "Withdraw",
|
|
1345
1393
|
},
|
|
1346
1394
|
},
|
|
1347
1395
|
"0000000000000100": {
|
|
1348
|
-
name: "
|
|
1396
|
+
name: "KaminoFarms",
|
|
1397
|
+
staging: false,
|
|
1349
1398
|
permissions: {
|
|
1350
1399
|
[1 << 0]: "Stake",
|
|
1351
1400
|
[1 << 1]: "Unstake",
|
|
@@ -1357,7 +1406,8 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1357
1406
|
// @anchor/programs/ext_drift/src/state/acl.rs
|
|
1358
1407
|
[(0, glamExports_1.getExtDriftProgramId)().toBase58()]: {
|
|
1359
1408
|
"0000000000000001": {
|
|
1360
|
-
name: "
|
|
1409
|
+
name: "DriftProtocol",
|
|
1410
|
+
staging: false,
|
|
1361
1411
|
permissions: {
|
|
1362
1412
|
[1 << 0]: "InitUser",
|
|
1363
1413
|
[1 << 1]: "UpdateUser",
|
|
@@ -1373,7 +1423,8 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1373
1423
|
},
|
|
1374
1424
|
},
|
|
1375
1425
|
"0000000000000010": {
|
|
1376
|
-
name: "
|
|
1426
|
+
name: "DriftVaults",
|
|
1427
|
+
staging: false,
|
|
1377
1428
|
permissions: {
|
|
1378
1429
|
[1 << 0]: "Deposit",
|
|
1379
1430
|
[1 << 1]: "Withdraw",
|
|
@@ -1384,7 +1435,8 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1384
1435
|
// @anchor/programs/ext_spl/src/state/acl.rs
|
|
1385
1436
|
[(0, glamExports_1.getExtSplProgramId)().toBase58()]: {
|
|
1386
1437
|
"0000000000000001": {
|
|
1387
|
-
name: "
|
|
1438
|
+
name: "SplToken",
|
|
1439
|
+
staging: false,
|
|
1388
1440
|
permissions: {
|
|
1389
1441
|
[1 << 0]: "Transfer",
|
|
1390
1442
|
},
|
|
@@ -1395,6 +1447,7 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1395
1447
|
[(0, glamExports_1.getExtCctpProgramId)().toBase58()]: {
|
|
1396
1448
|
"0000000000000001": {
|
|
1397
1449
|
name: "CCTP",
|
|
1450
|
+
staging: false,
|
|
1398
1451
|
permissions: {
|
|
1399
1452
|
[1 << 0]: "Transfer",
|
|
1400
1453
|
},
|
|
@@ -1405,6 +1458,7 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1405
1458
|
[(0, glamExports_1.getExtMarinadeProgramId)().toBase58()]: {
|
|
1406
1459
|
"0000000000000001": {
|
|
1407
1460
|
name: "Marinade",
|
|
1461
|
+
staging: true,
|
|
1408
1462
|
permissions: {
|
|
1409
1463
|
[1 << 0]: "Stake",
|
|
1410
1464
|
[1 << 1]: "Unstake",
|
|
@@ -1415,7 +1469,8 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1415
1469
|
// @anchor/programs/ext_stake_pool/src/state/acl.rs
|
|
1416
1470
|
[(0, glamExports_1.getExtStakePoolProgramId)().toBase58()]: {
|
|
1417
1471
|
"0000000000000001": {
|
|
1418
|
-
name: "
|
|
1472
|
+
name: "StakePool",
|
|
1473
|
+
staging: true,
|
|
1419
1474
|
permissions: {
|
|
1420
1475
|
[1 << 0]: "DepositSol",
|
|
1421
1476
|
[1 << 1]: "DepositStake",
|
|
@@ -1426,7 +1481,8 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1426
1481
|
},
|
|
1427
1482
|
},
|
|
1428
1483
|
"0000000000000010": {
|
|
1429
|
-
name: "
|
|
1484
|
+
name: "SanctumSingle",
|
|
1485
|
+
staging: true,
|
|
1430
1486
|
permissions: {
|
|
1431
1487
|
[1 << 0]: "DepositSol",
|
|
1432
1488
|
[1 << 1]: "DepositStake",
|
|
@@ -1437,7 +1493,8 @@ const getProtocolsAndPermissions = () => ({
|
|
|
1437
1493
|
},
|
|
1438
1494
|
},
|
|
1439
1495
|
"0000000000000100": {
|
|
1440
|
-
name: "
|
|
1496
|
+
name: "SanctumMulti",
|
|
1497
|
+
staging: true,
|
|
1441
1498
|
permissions: {
|
|
1442
1499
|
[1 << 0]: "DepositSol",
|
|
1443
1500
|
[1 << 1]: "DepositStake",
|
|
@@ -1471,7 +1528,7 @@ const getProgramAndBitflagByProtocolName = () => {
|
|
|
1471
1528
|
const mapping = {};
|
|
1472
1529
|
Object.entries((0, exports.getProtocolsAndPermissions)()).forEach(([programId, protocols]) => {
|
|
1473
1530
|
Object.entries(protocols).forEach(([bitflag, protocol]) => {
|
|
1474
|
-
const name = protocol.name
|
|
1531
|
+
const name = protocol.name;
|
|
1475
1532
|
mapping[name] = [programId, bitflag];
|
|
1476
1533
|
});
|
|
1477
1534
|
});
|
|
@@ -1685,6 +1742,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
1685
1742
|
exports.formatBits = formatBits;
|
|
1686
1743
|
exports.parseProtocolsBitmask = parseProtocolsBitmask;
|
|
1687
1744
|
exports.parseProtocolPermissionsBitmask = parseProtocolPermissionsBitmask;
|
|
1745
|
+
exports.parsePermissionNames = parsePermissionNames;
|
|
1746
|
+
const web3_js_1 = __webpack_require__(5);
|
|
1688
1747
|
const anchor_1 = __webpack_require__(4);
|
|
1689
1748
|
const constants_1 = __webpack_require__(31);
|
|
1690
1749
|
/**
|
|
@@ -1790,6 +1849,38 @@ function parseProtocolPermissionsBitmask(integrationProgram, protocolBitflag, pe
|
|
|
1790
1849
|
permissions,
|
|
1791
1850
|
};
|
|
1792
1851
|
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Given the protocol name and a list of permission names, returns the permissions bitmask.
|
|
1854
|
+
*/
|
|
1855
|
+
function parsePermissionNames({ protocolName, permissionNames, }) {
|
|
1856
|
+
const protocolConfig = (0, constants_1.getProgramAndBitflagByProtocolName)()[protocolName];
|
|
1857
|
+
if (!protocolConfig) {
|
|
1858
|
+
throw new Error(`Unknown protocol name ${protocolName}`);
|
|
1859
|
+
}
|
|
1860
|
+
const [programIdStr, bitflagStr] = protocolConfig;
|
|
1861
|
+
const protocolPermissions = (0, constants_1.getProtocolsAndPermissions)()[programIdStr]?.[bitflagStr];
|
|
1862
|
+
if (!protocolPermissions) {
|
|
1863
|
+
throw new Error(`Protocol mapping not found for protocol name ${protocolName}`);
|
|
1864
|
+
}
|
|
1865
|
+
const integrationProgram = new web3_js_1.PublicKey(programIdStr);
|
|
1866
|
+
const protocolBitflag = parseInt(bitflagStr, 2);
|
|
1867
|
+
// Calculate permissions bitmask
|
|
1868
|
+
const permissionNameToBitflag = {};
|
|
1869
|
+
for (const [bitflag, name] of Object.entries(protocolPermissions.permissions)) {
|
|
1870
|
+
permissionNameToBitflag[name] = new anchor_1.BN(bitflag);
|
|
1871
|
+
}
|
|
1872
|
+
const permissionsBitmask = permissionNames.reduce((mask, p) => {
|
|
1873
|
+
if (!permissionNameToBitflag[p]) {
|
|
1874
|
+
throw new Error(`Unknown permission name ${p} for protocol name ${protocolName}`);
|
|
1875
|
+
}
|
|
1876
|
+
return mask.or(permissionNameToBitflag[p]);
|
|
1877
|
+
}, new anchor_1.BN(0));
|
|
1878
|
+
return {
|
|
1879
|
+
integrationProgram,
|
|
1880
|
+
protocolBitflag,
|
|
1881
|
+
permissionsBitmask,
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1793
1884
|
|
|
1794
1885
|
|
|
1795
1886
|
/***/ }),
|
|
@@ -1906,7 +1997,7 @@ async function buildComputeBudgetInstructions(computeUnitLimit, options) {
|
|
|
1906
1997
|
"use strict";
|
|
1907
1998
|
|
|
1908
1999
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1909
|
-
exports.publicKeyToEvmAddress = exports.bytesToHex = exports.evmAddressToPublicKey = exports.hexToBytes = exports.evmAddressToBytes32 = void 0;
|
|
2000
|
+
exports.isValidEvmAddress = exports.publicKeyToEvmAddress = exports.bytesToHex = exports.evmAddressToPublicKey = exports.hexToBytes = exports.evmAddressToBytes32 = void 0;
|
|
1910
2001
|
const web3_js_1 = __webpack_require__(5);
|
|
1911
2002
|
const evmAddressToBytes32 = (address) => `0x000000000000000000000000${address.replace("0x", "")}`;
|
|
1912
2003
|
exports.evmAddressToBytes32 = evmAddressToBytes32;
|
|
@@ -1937,6 +2028,14 @@ const publicKeyToEvmAddress = (publicKey) => {
|
|
|
1937
2028
|
return `0x${evmAddress}`;
|
|
1938
2029
|
};
|
|
1939
2030
|
exports.publicKeyToEvmAddress = publicKeyToEvmAddress;
|
|
2031
|
+
/**
|
|
2032
|
+
* Validates if a string is a valid EVM address (40 hex characters)
|
|
2033
|
+
*/
|
|
2034
|
+
const isValidEvmAddress = (addr) => {
|
|
2035
|
+
const cleanAddr = addr.startsWith("0x") ? addr.slice(2) : addr;
|
|
2036
|
+
return /^[0-9a-fA-F]{40}$/.test(cleanAddr);
|
|
2037
|
+
};
|
|
2038
|
+
exports.isValidEvmAddress = isValidEvmAddress;
|
|
1940
2039
|
|
|
1941
2040
|
|
|
1942
2041
|
/***/ }),
|
|
@@ -3106,8 +3205,21 @@ module.exports = require("decimal.js");
|
|
|
3106
3205
|
"use strict";
|
|
3107
3206
|
|
|
3108
3207
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3109
|
-
exports.JupiterApiClient = exports.JUPITER_API_DEFAULT = void 0;
|
|
3208
|
+
exports.JupiterApiClient = exports.JUPITER_API_DEFAULT = exports.JupTokenList = void 0;
|
|
3110
3209
|
const zod_1 = __webpack_require__(52);
|
|
3210
|
+
class JupTokenList {
|
|
3211
|
+
constructor(tokens) {
|
|
3212
|
+
this.tokens = tokens;
|
|
3213
|
+
this.mintMap = new Map(tokens.map((token) => [token.address, token]));
|
|
3214
|
+
}
|
|
3215
|
+
getByMint(mintAddress) {
|
|
3216
|
+
return this.mintMap.get(mintAddress.toString());
|
|
3217
|
+
}
|
|
3218
|
+
getBySymbol(symbol) {
|
|
3219
|
+
return this.tokens.find((token) => token.symbol === symbol);
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
exports.JupTokenList = JupTokenList;
|
|
3111
3223
|
const TOKEN_LIST_CACHE_TTL = 5 * 60 * 1000; // 5 minutes
|
|
3112
3224
|
exports.JUPITER_API_DEFAULT = "https://api.jup.ag";
|
|
3113
3225
|
// Zod schemas for runtime validation
|
|
@@ -3181,8 +3293,9 @@ class JupiterApiClient {
|
|
|
3181
3293
|
usdPrice: t.usdPrice,
|
|
3182
3294
|
slot: t.priceBlockId,
|
|
3183
3295
|
}));
|
|
3184
|
-
|
|
3185
|
-
|
|
3296
|
+
const jupTokenList = new JupTokenList(tokenList);
|
|
3297
|
+
this.tokenListCache = { data: jupTokenList, timestamp: Date.now() };
|
|
3298
|
+
return jupTokenList;
|
|
3186
3299
|
}
|
|
3187
3300
|
async fetchProgramLabels() {
|
|
3188
3301
|
if (!this.apiKey) {
|
|
@@ -4052,7 +4165,7 @@ tslib_1.__exportStar(__webpack_require__(63), exports);
|
|
|
4052
4165
|
"use strict";
|
|
4053
4166
|
|
|
4054
4167
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4055
|
-
exports.DriftProtocolClient = exports.DRIFT_MARGIN_PRECISION = exports.DRIFT_SIGNER = void 0;
|
|
4168
|
+
exports.DriftProtocolClient = exports.DriftMarketConfigs = exports.DRIFT_MARGIN_PRECISION = exports.DRIFT_SIGNER = void 0;
|
|
4056
4169
|
const web3_js_1 = __webpack_require__(5);
|
|
4057
4170
|
const types_1 = __webpack_require__(47);
|
|
4058
4171
|
const driftLayouts_1 = __webpack_require__(61);
|
|
@@ -4062,6 +4175,31 @@ const spl_token_1 = __webpack_require__(23);
|
|
|
4062
4175
|
const anchor_1 = __webpack_require__(4);
|
|
4063
4176
|
exports.DRIFT_SIGNER = new web3_js_1.PublicKey("JCNCMFXo5M5qwUPg2Utu1u6YWp3MbygxqBsBeXXJfrw");
|
|
4064
4177
|
exports.DRIFT_MARGIN_PRECISION = 10000;
|
|
4178
|
+
class DriftMarketConfigs {
|
|
4179
|
+
constructor(orderConstants, perpMarkets, spotMarkets) {
|
|
4180
|
+
this.orderConstants = orderConstants;
|
|
4181
|
+
this.perpMarkets = perpMarkets;
|
|
4182
|
+
this.spotMarkets = spotMarkets;
|
|
4183
|
+
}
|
|
4184
|
+
getPerp(marketIndex) {
|
|
4185
|
+
const market = this.perpMarkets[marketIndex];
|
|
4186
|
+
if (market.marketIndex === marketIndex) {
|
|
4187
|
+
return market;
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
getSpot(mintOrIndex) {
|
|
4191
|
+
if (typeof mintOrIndex === "number") {
|
|
4192
|
+
const market = this.spotMarkets[mintOrIndex];
|
|
4193
|
+
if (market.marketIndex === mintOrIndex) {
|
|
4194
|
+
return market;
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
else {
|
|
4198
|
+
return this.spotMarkets.find(({ mint }) => mint.equals(mintOrIndex));
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
exports.DriftMarketConfigs = DriftMarketConfigs;
|
|
4065
4203
|
class TxBuilder extends base_1.BaseTxBuilder {
|
|
4066
4204
|
async initializeUserStatsIx(glamSigner) {
|
|
4067
4205
|
const { userStats } = this.client.getDriftUserPdas();
|
|
@@ -4488,6 +4626,15 @@ class DriftProtocolClient {
|
|
|
4488
4626
|
userStats: this.getUserStatsPda(vault),
|
|
4489
4627
|
};
|
|
4490
4628
|
}
|
|
4629
|
+
getSubAccountId(driftUser) {
|
|
4630
|
+
for (let i = 0; i < 100; ++i) {
|
|
4631
|
+
const { user } = this.getDriftUserPdas(i);
|
|
4632
|
+
if (user.equals(driftUser)) {
|
|
4633
|
+
return i;
|
|
4634
|
+
}
|
|
4635
|
+
}
|
|
4636
|
+
throw new Error("Sub account not found");
|
|
4637
|
+
}
|
|
4491
4638
|
get driftStatePda() {
|
|
4492
4639
|
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("drift_state")], constants_1.DRIFT_PROGRAM_ID)[0];
|
|
4493
4640
|
}
|
|
@@ -4565,11 +4712,7 @@ class DriftProtocolClient {
|
|
|
4565
4712
|
// FIXME: one day the number of markets will exceed 100 and a better solution will be needed
|
|
4566
4713
|
const perpMarkets = await this.fetchAndParsePerpMarkets(Array.from(Array(100).keys()), skipCache);
|
|
4567
4714
|
const spotMarkets = await this.fetchAndParseSpotMarkets(Array.from(Array(100).keys()), skipCache);
|
|
4568
|
-
this.marketConfigs = {
|
|
4569
|
-
orderConstants: { perpBaseScale: 9, quoteScale: 6 },
|
|
4570
|
-
perpMarkets,
|
|
4571
|
-
spotMarkets,
|
|
4572
|
-
};
|
|
4715
|
+
this.marketConfigs = new DriftMarketConfigs({ perpBaseScale: 9, quoteScale: 6 }, perpMarkets, spotMarkets);
|
|
4573
4716
|
return this.marketConfigs;
|
|
4574
4717
|
}
|
|
4575
4718
|
async fetchAndParseDriftUser(subAccountId = 0) {
|
|
@@ -4796,7 +4939,7 @@ DriftVaultDepositor._layout = (0, borsh_1.struct)([
|
|
|
4796
4939
|
]);
|
|
4797
4940
|
class DriftVault extends base_1.Decodable {
|
|
4798
4941
|
get name() {
|
|
4799
|
-
return (0, common_1.
|
|
4942
|
+
return (0, common_1.charsToString)(this.nameBytes);
|
|
4800
4943
|
}
|
|
4801
4944
|
marketPda(marketType, marketIndex) {
|
|
4802
4945
|
const marketTypeStr = marketType === types_1.MarketType.SPOT ? "spot" : "perp";
|
|
@@ -5229,7 +5372,7 @@ class DriftUser {
|
|
|
5229
5372
|
return instance;
|
|
5230
5373
|
}
|
|
5231
5374
|
get name() {
|
|
5232
|
-
return (0, common_1.
|
|
5375
|
+
return (0, common_1.charsToString)(this.nameBytes);
|
|
5233
5376
|
}
|
|
5234
5377
|
getAddress() {
|
|
5235
5378
|
return this._address;
|
|
@@ -5238,7 +5381,7 @@ class DriftUser {
|
|
|
5238
5381
|
exports.DriftUser = DriftUser;
|
|
5239
5382
|
class DriftSpotMarket extends base_1.Decodable {
|
|
5240
5383
|
get name() {
|
|
5241
|
-
return (0, common_1.
|
|
5384
|
+
return (0, common_1.charsToString)(this.nameBytes);
|
|
5242
5385
|
}
|
|
5243
5386
|
get oracleSource() {
|
|
5244
5387
|
return types_1.OracleSource.get(this.oracleSourceOrd);
|
|
@@ -5281,7 +5424,7 @@ class DriftPerpMarket extends base_1.Decodable {
|
|
|
5281
5424
|
return instance;
|
|
5282
5425
|
}
|
|
5283
5426
|
get name() {
|
|
5284
|
-
return (0, common_1.
|
|
5427
|
+
return (0, common_1.charsToString)(this.nameBytes);
|
|
5285
5428
|
}
|
|
5286
5429
|
get oracleSource() {
|
|
5287
5430
|
return types_1.OracleSource.get(this.oracleSourceOrd);
|
|
@@ -6777,7 +6920,7 @@ class TxBuilder extends base_1.BaseTxBuilder {
|
|
|
6777
6920
|
// stateInitKey = hash state name and get first 8 bytes
|
|
6778
6921
|
// useful for re-computing state account PDA in the future
|
|
6779
6922
|
const stateInitKey = [
|
|
6780
|
-
...Buffer.from(anchor.utils.sha256.hash((0, common_1.
|
|
6923
|
+
...Buffer.from(anchor.utils.sha256.hash((0, common_1.charsToString)(params.name))).subarray(0, 8),
|
|
6781
6924
|
];
|
|
6782
6925
|
const created = new models_1.CreatedModel({ key: stateInitKey });
|
|
6783
6926
|
const owner = params.owner || glamSigner;
|
|
@@ -7600,7 +7743,7 @@ const constants_1 = __webpack_require__(31);
|
|
|
7600
7743
|
const MAX_RESERVES = 25;
|
|
7601
7744
|
class KVaultState extends base_1.Decodable {
|
|
7602
7745
|
get nameStr() {
|
|
7603
|
-
return (0, utils_1.
|
|
7746
|
+
return (0, utils_1.charsToString)(this.name);
|
|
7604
7747
|
}
|
|
7605
7748
|
get validAllocations() {
|
|
7606
7749
|
return this.vaultAllocationStrategy.filter(({ reserve }) => !reserve.equals(web3_js_1.PublicKey.default));
|
|
@@ -8904,8 +9047,8 @@ class PriceClient {
|
|
|
8904
9047
|
}
|
|
8905
9048
|
// Build a map of token prices (in USD)
|
|
8906
9049
|
const tokenPricesMap = new utils_1.PkMap();
|
|
8907
|
-
const tokenList = await this.jupiterApi.fetchTokensList();
|
|
8908
|
-
tokenList.forEach((item) => {
|
|
9050
|
+
const tokenList = await this.jupiterApi.fetchTokensList(true);
|
|
9051
|
+
tokenList.tokens.forEach((item) => {
|
|
8909
9052
|
const tokenMint = new web3_js_1.PublicKey(item.address);
|
|
8910
9053
|
tokenPricesMap.set(tokenMint, item);
|
|
8911
9054
|
});
|
|
@@ -9019,8 +9162,6 @@ class PriceClient {
|
|
|
9019
9162
|
}
|
|
9020
9163
|
for (const pubkey of tokenAccountPubkeys) {
|
|
9021
9164
|
const data = accountsDataMap.get(pubkey);
|
|
9022
|
-
if (!data)
|
|
9023
|
-
continue;
|
|
9024
9165
|
const { amount, mint } = spl_token_1.AccountLayout.decode(data);
|
|
9025
9166
|
const tokenInfo = tokenPricesMap.get(mint);
|
|
9026
9167
|
if (tokenInfo) {
|
|
@@ -9081,11 +9222,9 @@ class PriceClient {
|
|
|
9081
9222
|
.add(depositor.lastWithdrawRequest.value);
|
|
9082
9223
|
const { mint, decimals } = dvault.getBaseAsset(spotMarketsMap);
|
|
9083
9224
|
const tokenPrice = tokenPricesMap.get(mint);
|
|
9084
|
-
if (!tokenPrice)
|
|
9085
|
-
continue;
|
|
9086
9225
|
const { usdPrice, slot } = tokenPrice;
|
|
9087
9226
|
const holding = new Holding(mint, decimals, amount, usdPrice, { slot, source: priceSource }, "DriftVaults", {
|
|
9088
|
-
vault:
|
|
9227
|
+
vault: dvault.getAddress(),
|
|
9089
9228
|
depositor: depositor.getAddress(),
|
|
9090
9229
|
});
|
|
9091
9230
|
holdings.push(holding);
|
|
@@ -9096,21 +9235,15 @@ class PriceClient {
|
|
|
9096
9235
|
const holdings = [];
|
|
9097
9236
|
for (const obligation of obligationPubkeys) {
|
|
9098
9237
|
const obligationData = accountsDataMap.get(obligation);
|
|
9099
|
-
if (!obligationData)
|
|
9100
|
-
continue;
|
|
9101
9238
|
const { activeDeposits, activeBorrows } = deser_1.Obligation.decode(obligation, obligationData);
|
|
9102
9239
|
for (const { depositReserve, depositedAmount } of activeDeposits) {
|
|
9103
9240
|
const reserve = reservesMap.get(depositReserve);
|
|
9104
|
-
if (!reserve)
|
|
9105
|
-
continue;
|
|
9106
9241
|
const { collateralExchangeRate, lendingMarket, liquidity } = reserve;
|
|
9107
9242
|
const supplyAmount = new decimal_js_1.default(depositedAmount.toString())
|
|
9108
9243
|
.div(collateralExchangeRate)
|
|
9109
9244
|
.floor();
|
|
9110
9245
|
const amount = new anchor_1.BN(supplyAmount.toString());
|
|
9111
9246
|
const tokenPrice = tokenPricesMap.get(liquidity.mintPubkey);
|
|
9112
|
-
if (!tokenPrice)
|
|
9113
|
-
continue;
|
|
9114
9247
|
const { usdPrice, slot } = tokenPrice;
|
|
9115
9248
|
const holding = new Holding(liquidity.mintPubkey, liquidity.mintDecimals.toNumber(), amount, usdPrice, { slot, source: priceSource }, "KaminoLend", {
|
|
9116
9249
|
obligation,
|
|
@@ -9122,8 +9255,6 @@ class PriceClient {
|
|
|
9122
9255
|
}
|
|
9123
9256
|
for (const { borrowReserve, borrowedAmountSf, cumulativeBorrowRateBsf, } of activeBorrows) {
|
|
9124
9257
|
const reserve = reservesMap.get(borrowReserve);
|
|
9125
|
-
if (!reserve)
|
|
9126
|
-
continue;
|
|
9127
9258
|
const { cumulativeBorrowRate, lendingMarket, liquidity } = reserve;
|
|
9128
9259
|
const obligationCumulativeBorrowRate = (0, utils_1.bfToDecimal)(cumulativeBorrowRateBsf);
|
|
9129
9260
|
const borrowAmount = new utils_1.Fraction(borrowedAmountSf)
|
|
@@ -9133,8 +9264,6 @@ class PriceClient {
|
|
|
9133
9264
|
.ceil();
|
|
9134
9265
|
const amount = new anchor_1.BN(borrowAmount.toString());
|
|
9135
9266
|
const tokenPrice = tokenPricesMap.get(liquidity.mintPubkey);
|
|
9136
|
-
if (!tokenPrice)
|
|
9137
|
-
continue;
|
|
9138
9267
|
const { usdPrice, slot } = tokenPrice;
|
|
9139
9268
|
const holding = new Holding(liquidity.mintPubkey, liquidity.mintDecimals.toNumber(), amount, usdPrice, { slot, source: priceSource }, "KaminoLend", {
|
|
9140
9269
|
obligation,
|
|
@@ -9151,14 +9280,10 @@ class PriceClient {
|
|
|
9151
9280
|
const holdings = [];
|
|
9152
9281
|
for (const [ata, kvaultState] of kvaultAtasAndStates.pkEntries()) {
|
|
9153
9282
|
const ataData = accountsDataMap.get(ata);
|
|
9154
|
-
if (!ataData)
|
|
9155
|
-
continue;
|
|
9156
9283
|
const tokenAccount = spl_token_1.AccountLayout.decode(ataData);
|
|
9157
9284
|
let aum = new decimal_js_1.default(kvaultState.tokenAvailable.toString());
|
|
9158
9285
|
kvaultState.validAllocations.map((allocation) => {
|
|
9159
9286
|
const reserve = reservesMap.get(allocation.reserve);
|
|
9160
|
-
if (!reserve)
|
|
9161
|
-
return;
|
|
9162
9287
|
const { collateralExchangeRate } = reserve;
|
|
9163
9288
|
// allocation ctoken amount to liq asset amount
|
|
9164
9289
|
const liqAmount = new decimal_js_1.default(allocation.ctokenAllocation.toString())
|
|
@@ -9172,8 +9297,6 @@ class PriceClient {
|
|
|
9172
9297
|
.mul(aum)
|
|
9173
9298
|
.floor();
|
|
9174
9299
|
const tokenPrice = tokenPricesMap.get(kvaultState.tokenMint);
|
|
9175
|
-
if (!tokenPrice)
|
|
9176
|
-
continue;
|
|
9177
9300
|
const { usdPrice, slot } = tokenPrice;
|
|
9178
9301
|
const holding = new Holding(kvaultState.tokenMint, kvaultState.tokenMintDecimals.toNumber(), new anchor_1.BN(amount.toString()), usdPrice, { slot, source: priceSource }, "KaminoVaults", {
|
|
9179
9302
|
kaminoVault: kvaultState._address,
|
|
@@ -9920,7 +10043,7 @@ class TxBuilder extends base_1.BaseTxBuilder {
|
|
|
9920
10043
|
? initMintParams.decimals
|
|
9921
10044
|
: null;
|
|
9922
10045
|
const stateInitKey = [
|
|
9923
|
-
...Buffer.from(anchor_1.utils.sha256.hash((0, common_1.
|
|
10046
|
+
...Buffer.from(anchor_1.utils.sha256.hash((0, common_1.charsToString)(initMintParams.name))).subarray(0, 8),
|
|
9924
10047
|
];
|
|
9925
10048
|
const glamState = (0, glamPDAs_1.getStatePda)(stateInitKey, glamSigner, this.client.base.protocolProgram.programId);
|
|
9926
10049
|
const postInstructions = [];
|
|
@@ -10852,11 +10975,12 @@ const MESSAGE_RECEIVED_EVENT_DISCM = new Uint8Array([
|
|
|
10852
10975
|
]);
|
|
10853
10976
|
const CCTP_DOMAIN_SOLANA = 5;
|
|
10854
10977
|
class CctpBridgeEvent {
|
|
10855
|
-
constructor(amount, sourceDomain, sourceAddress, destinationDomain, destinationAddress, attestation, nonce, status, txHash) {
|
|
10978
|
+
constructor(amount, sourceDomain, sourceAddress, destinationDomain, destinationCaller, destinationAddress, attestation, nonce, status, txHash) {
|
|
10856
10979
|
this.amount = amount;
|
|
10857
10980
|
this.sourceDomain = sourceDomain;
|
|
10858
10981
|
this.sourceAddress = sourceAddress;
|
|
10859
10982
|
this.destinationDomain = destinationDomain;
|
|
10983
|
+
this.destinationCaller = destinationCaller;
|
|
10860
10984
|
this.destinationAddress = destinationAddress;
|
|
10861
10985
|
this.attestation = attestation;
|
|
10862
10986
|
this.nonce = nonce;
|
|
@@ -10878,7 +11002,7 @@ class TxBuilder extends base_1.BaseTxBuilder {
|
|
|
10878
11002
|
amount,
|
|
10879
11003
|
destinationDomain: domain,
|
|
10880
11004
|
mintRecipient: recipient,
|
|
10881
|
-
destinationCaller: web3_js_1.PublicKey.default,
|
|
11005
|
+
destinationCaller: params.destinationCaller || web3_js_1.PublicKey.default,
|
|
10882
11006
|
...params,
|
|
10883
11007
|
};
|
|
10884
11008
|
const denylistAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("denylist_account"), this.client.base.vaultPda.toBuffer()], constants_1.TOKEN_MESSENGER_MINTER_V2)[0];
|
|
@@ -11191,6 +11315,7 @@ class CctpClient {
|
|
|
11191
11315
|
const status = message.status;
|
|
11192
11316
|
const nonce = message.decodedMessage.nonce;
|
|
11193
11317
|
const destinationDomain = Number(message.decodedMessage.destinationDomain);
|
|
11318
|
+
const destinationCaller = message.decodedMessage.destinationCaller;
|
|
11194
11319
|
const destinationAddress = message.decodedMessage.decodedMessageBody.mintRecipient;
|
|
11195
11320
|
const sourceAddress = message.decodedMessage.decodedMessageBody.messageSender;
|
|
11196
11321
|
const amount = message.decodedMessage.decodedMessageBody.amount;
|
|
@@ -11198,7 +11323,7 @@ class CctpClient {
|
|
|
11198
11323
|
if (sourceDomain === 5 && token !== constants_1.USDC.toBase58()) {
|
|
11199
11324
|
throw new Error("Invalid message, expected burn token to be USDC");
|
|
11200
11325
|
}
|
|
11201
|
-
return new CctpBridgeEvent(new anchor_1.BN(amount), sourceDomain, sourceAddress, destinationDomain, destinationAddress, attestation, nonce, status, txHash ?? "");
|
|
11326
|
+
return new CctpBridgeEvent(new anchor_1.BN(amount), sourceDomain, sourceAddress, destinationDomain, destinationCaller, destinationAddress, attestation, nonce, status, txHash ?? "");
|
|
11202
11327
|
});
|
|
11203
11328
|
}
|
|
11204
11329
|
/**
|
|
@@ -14720,7 +14845,7 @@ const os_1 = tslib_1.__importDefault(__webpack_require__(110));
|
|
|
14720
14845
|
const path_1 = tslib_1.__importDefault(__webpack_require__(94));
|
|
14721
14846
|
class CliConfig {
|
|
14722
14847
|
constructor(config = {}, configPath) {
|
|
14723
|
-
this.cluster = glam_sdk_1.ClusterNetwork.fromStr(config.cluster);
|
|
14848
|
+
this.cluster = glam_sdk_1.ClusterNetwork.fromStr(config.cluster || "mainnet-beta");
|
|
14724
14849
|
this.json_rpc_url = config.json_rpc_url || "";
|
|
14725
14850
|
this.tx_rpc_url = config.tx_rpc_url || "";
|
|
14726
14851
|
this.websocket_disabled = config.websocket_disabled || false;
|
|
@@ -14831,14 +14956,14 @@ async function confirmOperation(message) {
|
|
|
14831
14956
|
process.exit(0);
|
|
14832
14957
|
}
|
|
14833
14958
|
}
|
|
14834
|
-
catch (
|
|
14959
|
+
catch (err) {
|
|
14835
14960
|
// Handle Ctrl+C interruption gracefully
|
|
14836
|
-
if (
|
|
14837
|
-
|
|
14961
|
+
if (err.name === "ExitPromptError" ||
|
|
14962
|
+
err.message?.includes("force closed")) {
|
|
14838
14963
|
console.log("\nOperation cancelled.");
|
|
14839
14964
|
process.exit(0);
|
|
14840
14965
|
}
|
|
14841
|
-
throw
|
|
14966
|
+
throw err;
|
|
14842
14967
|
}
|
|
14843
14968
|
}
|
|
14844
14969
|
function parseStateJson(json) {
|
|
@@ -14856,14 +14981,12 @@ function parseStateJson(json) {
|
|
|
14856
14981
|
});
|
|
14857
14982
|
const params = {
|
|
14858
14983
|
accountType: glam_sdk_1.StateAccountType.from(state.accountType),
|
|
14859
|
-
name:
|
|
14984
|
+
name: (0, glam_sdk_1.stringToChars)(state.name),
|
|
14860
14985
|
enabled: state.enabled !== false,
|
|
14861
14986
|
assets: state.assets?.map((asset) => new web3_js_1.PublicKey(asset)) || null,
|
|
14862
|
-
baseAssetMint: state.baseAssetMint
|
|
14863
|
-
? new web3_js_1.PublicKey(state.baseAssetMint)
|
|
14864
|
-
: null,
|
|
14987
|
+
baseAssetMint: new web3_js_1.PublicKey(state.baseAssetMint),
|
|
14865
14988
|
portfolioManagerName: state.portfolioManagerName
|
|
14866
|
-
? (0, glam_sdk_1.
|
|
14989
|
+
? (0, glam_sdk_1.stringToChars)(state.portfolioManagerName)
|
|
14867
14990
|
: null,
|
|
14868
14991
|
};
|
|
14869
14992
|
return params;
|
|
@@ -14884,7 +15007,7 @@ function parseMintJson(json, accountType) {
|
|
|
14884
15007
|
});
|
|
14885
15008
|
const params = {
|
|
14886
15009
|
accountType,
|
|
14887
|
-
name: (0, glam_sdk_1.
|
|
15010
|
+
name: (0, glam_sdk_1.stringToChars)(mint.name),
|
|
14888
15011
|
symbol: mint.symbol,
|
|
14889
15012
|
uri: mint.uri,
|
|
14890
15013
|
baseAssetMint: new web3_js_1.PublicKey(mint.baseAssetMint),
|
|
@@ -46674,7 +46797,7 @@ function installDriftProtocolCommands(drift, context) {
|
|
|
46674
46797
|
}, (txSig) => `Drift user (sub-account ${subAccountId}) initialized: ${txSig}`);
|
|
46675
46798
|
});
|
|
46676
46799
|
drift
|
|
46677
|
-
.command("users")
|
|
46800
|
+
.command("list-users")
|
|
46678
46801
|
.description("List drift users (sub accounts)")
|
|
46679
46802
|
.action(async () => {
|
|
46680
46803
|
const driftUsers = await context.glamClient.drift.fetchAndParseDriftUsers();
|
|
@@ -46684,7 +46807,7 @@ function installDriftProtocolCommands(drift, context) {
|
|
|
46684
46807
|
});
|
|
46685
46808
|
});
|
|
46686
46809
|
drift
|
|
46687
|
-
.command("positions")
|
|
46810
|
+
.command("list-positions")
|
|
46688
46811
|
.option("-s, --sub-account-id <sub_account_id>", "Sub account ID", utils_1.validateSubAccountId, 0)
|
|
46689
46812
|
.description("List drift positions")
|
|
46690
46813
|
.action(async ({ subAccountId }) => {
|
|
@@ -46825,7 +46948,7 @@ function installDriftProtocolCommands(drift, context) {
|
|
|
46825
46948
|
}, (txSig) => `Perp order placed: ${txSig}`);
|
|
46826
46949
|
});
|
|
46827
46950
|
drift
|
|
46828
|
-
.command("orders")
|
|
46951
|
+
.command("list-orders")
|
|
46829
46952
|
.option("-s, --sub-account-id <sub_account_id>", "Sub account ID", utils_1.validateSubAccountId, 0)
|
|
46830
46953
|
.description("List open orders")
|
|
46831
46954
|
.action(async ({ subAccountId }) => {
|
|
@@ -46841,6 +46964,10 @@ function installDriftProtocolCommands(drift, context) {
|
|
|
46841
46964
|
const directionStr = Object.entries(direction)[0][0];
|
|
46842
46965
|
if (marketType === glam_sdk_1.MarketType.SPOT) {
|
|
46843
46966
|
const marketConfig = marketConfigs.spotMarkets.find((m) => m.marketIndex === marketIndex);
|
|
46967
|
+
if (!marketConfig) {
|
|
46968
|
+
console.error(`Spot market not found at index ${marketIndex}`);
|
|
46969
|
+
process.exit(1);
|
|
46970
|
+
}
|
|
46844
46971
|
const amount = baseAssetAmount.toNumber() / 10 ** marketConfig.decimals;
|
|
46845
46972
|
const priceStr = price.toNumber() / 10 ** marketConfigs.orderConstants.quoteScale;
|
|
46846
46973
|
const marketName = marketConfig.name;
|
|
@@ -46848,6 +46975,10 @@ function installDriftProtocolCommands(drift, context) {
|
|
|
46848
46975
|
}
|
|
46849
46976
|
else {
|
|
46850
46977
|
const marketConfig = marketConfigs.perpMarkets.find((m) => m.marketIndex === marketIndex);
|
|
46978
|
+
if (!marketConfig) {
|
|
46979
|
+
console.error(`Perp market not found at index ${marketIndex}`);
|
|
46980
|
+
process.exit(1);
|
|
46981
|
+
}
|
|
46851
46982
|
const amount = baseAssetAmount.toNumber() /
|
|
46852
46983
|
10 ** marketConfigs.orderConstants.perpBaseScale;
|
|
46853
46984
|
const priceStr = price.toNumber() / 10 ** marketConfigs.orderConstants.quoteScale;
|
|
@@ -47089,9 +47220,9 @@ module.exports = /*#__PURE__*/JSON.parse('[{"address":"So11111111111111111111111
|
|
|
47089
47220
|
|
|
47090
47221
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
47091
47222
|
exports.installLstCommands = installLstCommands;
|
|
47092
|
-
const anchor_1 = __webpack_require__(4);
|
|
47093
47223
|
const web3_js_1 = __webpack_require__(5);
|
|
47094
47224
|
const utils_1 = __webpack_require__(100);
|
|
47225
|
+
const glam_sdk_1 = __webpack_require__(1);
|
|
47095
47226
|
function installLstCommands(lst, context) {
|
|
47096
47227
|
lst
|
|
47097
47228
|
.command("stake")
|
|
@@ -47100,7 +47231,7 @@ function installLstCommands(lst, context) {
|
|
|
47100
47231
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
47101
47232
|
.description("Stake SOL into a LST pool")
|
|
47102
47233
|
.action(async (stakepool, amount, options) => {
|
|
47103
|
-
const amountBN =
|
|
47234
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(parseFloat(amount), 9);
|
|
47104
47235
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.stakePool.depositSol(new web3_js_1.PublicKey(stakepool), amountBN, context.txOptions), {
|
|
47105
47236
|
skip: options?.yes,
|
|
47106
47237
|
message: `Confirm staking ${amount} SOL into ${stakepool}`,
|
|
@@ -47114,7 +47245,7 @@ function installLstCommands(lst, context) {
|
|
|
47114
47245
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
47115
47246
|
.description("Unstake LST and receive SOL in a stake account")
|
|
47116
47247
|
.action(async (asset, amount, options) => {
|
|
47117
|
-
const amountBN =
|
|
47248
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, 9);
|
|
47118
47249
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.stakePool.unstake(asset, amountBN, options.deactivate, context.txOptions), {
|
|
47119
47250
|
skip: options?.yes,
|
|
47120
47251
|
message: `Confirm unstaking ${amount} ${asset}`,
|
|
@@ -47131,9 +47262,8 @@ function installLstCommands(lst, context) {
|
|
|
47131
47262
|
|
|
47132
47263
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
47133
47264
|
exports.installMarinadeCommands = installMarinadeCommands;
|
|
47134
|
-
const anchor_1 = __webpack_require__(4);
|
|
47135
47265
|
const utils_1 = __webpack_require__(100);
|
|
47136
|
-
const
|
|
47266
|
+
const glam_sdk_1 = __webpack_require__(1);
|
|
47137
47267
|
function installMarinadeCommands(marinade, context) {
|
|
47138
47268
|
marinade
|
|
47139
47269
|
.command("stake")
|
|
@@ -47141,7 +47271,7 @@ function installMarinadeCommands(marinade, context) {
|
|
|
47141
47271
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
47142
47272
|
.description("Stake SOL and get mSOL")
|
|
47143
47273
|
.action(async (amount, options) => {
|
|
47144
|
-
const amountBN =
|
|
47274
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(parseFloat(amount), 9);
|
|
47145
47275
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.marinade.deposit(amountBN, context.txOptions), {
|
|
47146
47276
|
skip: options?.yes,
|
|
47147
47277
|
message: `Confirm staking ${amount} SOL to Marinade stake pool`,
|
|
@@ -47153,7 +47283,7 @@ function installMarinadeCommands(marinade, context) {
|
|
|
47153
47283
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
47154
47284
|
.description("Stake SOL to Marinade Native")
|
|
47155
47285
|
.action(async (amount, options) => {
|
|
47156
|
-
const amountBN =
|
|
47286
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(parseFloat(amount), 9);
|
|
47157
47287
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.marinade.depositNative(amountBN, context.txOptions), {
|
|
47158
47288
|
skip: options?.yes,
|
|
47159
47289
|
message: `Confirm staking ${amount} SOL to Marinade Native`,
|
|
@@ -47166,7 +47296,7 @@ function installMarinadeCommands(marinade, context) {
|
|
|
47166
47296
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
47167
47297
|
.description("Withdraw <amount> mSOL into a stake account")
|
|
47168
47298
|
.action(async (amount, options) => {
|
|
47169
|
-
const amountBN =
|
|
47299
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, 9);
|
|
47170
47300
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.marinade.withdrawStakeAccount(amountBN, options.deactivate, context.txOptions), {
|
|
47171
47301
|
skip: options?.yes,
|
|
47172
47302
|
message: `Confirm withdrawing ${amount} mSOL into a stake account`,
|
|
@@ -47293,7 +47423,7 @@ function installKaminoLendCommands(klend, context) {
|
|
|
47293
47423
|
.description("List Kamino deposits and borrows")
|
|
47294
47424
|
.action(async (market) => {
|
|
47295
47425
|
const vault = context.glamClient.vaultPda;
|
|
47296
|
-
const lendingMarket = market ? new web3_js_1.PublicKey(market) :
|
|
47426
|
+
const lendingMarket = market ? new web3_js_1.PublicKey(market) : undefined;
|
|
47297
47427
|
const obligations = await context.glamClient.kaminoLending.findAndParseObligations(vault, lendingMarket);
|
|
47298
47428
|
const reservesSet = new glam_sdk_1.PkSet();
|
|
47299
47429
|
for (const { activeDeposits, activeBorrows } of obligations) {
|
|
@@ -47307,13 +47437,23 @@ function installKaminoLendCommands(klend, context) {
|
|
|
47307
47437
|
console.log(`Obligation: ${obligation.getAddress()}`);
|
|
47308
47438
|
let i = 0;
|
|
47309
47439
|
for (const { depositReserve, depositedAmount } of activeDeposits) {
|
|
47310
|
-
const
|
|
47440
|
+
const reserve = reservesMap.get(depositReserve);
|
|
47441
|
+
if (!reserve) {
|
|
47442
|
+
console.error(`Reserve ${depositReserve} not found`);
|
|
47443
|
+
process.exit(1);
|
|
47444
|
+
}
|
|
47445
|
+
const { collateralExchangeRate, liquidity } = reserve;
|
|
47311
47446
|
const supplyAmount = new decimal_js_1.Decimal(depositedAmount.toString()).div(collateralExchangeRate);
|
|
47312
47447
|
console.log(` - deposit[${i++}]: ${supplyAmount.toString()} ${liquidity.mintPubkey}`);
|
|
47313
47448
|
}
|
|
47314
47449
|
i = 0;
|
|
47315
47450
|
for (const { borrowReserve, borrowedAmountSf, cumulativeBorrowRateBsf, } of activeBorrows) {
|
|
47316
|
-
const
|
|
47451
|
+
const reserve = reservesMap.get(borrowReserve);
|
|
47452
|
+
if (!reserve) {
|
|
47453
|
+
console.error(`Reserve ${borrowReserve} not found`);
|
|
47454
|
+
process.exit(1);
|
|
47455
|
+
}
|
|
47456
|
+
const { cumulativeBorrowRate, liquidity } = reserve;
|
|
47317
47457
|
const obligationCumulativeBorrowRate = (0, glam_sdk_1.bfToDecimal)(cumulativeBorrowRateBsf);
|
|
47318
47458
|
const borrowAmount = new glam_sdk_1.Fraction(borrowedAmountSf)
|
|
47319
47459
|
.toDecimal()
|
|
@@ -47406,7 +47546,6 @@ function installKaminoLendCommands(klend, context) {
|
|
|
47406
47546
|
|
|
47407
47547
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
47408
47548
|
exports.installKaminoVaultsCommands = installKaminoVaultsCommands;
|
|
47409
|
-
const anchor_1 = __webpack_require__(4);
|
|
47410
47549
|
const utils_1 = __webpack_require__(100);
|
|
47411
47550
|
const glam_sdk_1 = __webpack_require__(1);
|
|
47412
47551
|
function installKaminoVaultsCommands(kvaults, context) {
|
|
@@ -47471,7 +47610,7 @@ function installKaminoVaultsCommands(kvaults, context) {
|
|
|
47471
47610
|
.action(async (vault, amount, options) => {
|
|
47472
47611
|
const vaultState = await context.glamClient.kaminoVaults.fetchAndParseVaultState(vault);
|
|
47473
47612
|
const { tokenMint, tokenMintDecimals, vaultLookupTable } = vaultState;
|
|
47474
|
-
const amountBN =
|
|
47613
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, tokenMintDecimals);
|
|
47475
47614
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.kaminoVaults.deposit(vault, amountBN, {
|
|
47476
47615
|
...context.txOptions,
|
|
47477
47616
|
lookupTables: [vaultLookupTable],
|
|
@@ -47489,7 +47628,7 @@ function installKaminoVaultsCommands(kvaults, context) {
|
|
|
47489
47628
|
.action(async (vault, amount, options) => {
|
|
47490
47629
|
const vaultState = await context.glamClient.kaminoVaults.fetchAndParseVaultState(vault);
|
|
47491
47630
|
const { sharesMintDecimals, vaultLookupTable } = vaultState;
|
|
47492
|
-
const amountBN =
|
|
47631
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, sharesMintDecimals);
|
|
47493
47632
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.kaminoVaults.withdraw(vault, amountBN, {
|
|
47494
47633
|
...context.txOptions,
|
|
47495
47634
|
lookupTables: [vaultLookupTable],
|
|
@@ -47521,7 +47660,12 @@ function installKaminoFarmsCommands(kfarms, context) {
|
|
|
47521
47660
|
const parsedFarms = await context.glamClient.kaminoFarm.fetchAndParseFarmStates(farmStates.map((f) => f.farmState));
|
|
47522
47661
|
for (let i = 0; i < farmStates.length; i++) {
|
|
47523
47662
|
const { pubkey: userState, farmState, unclaimedRewards, } = farmStates[i];
|
|
47524
|
-
const
|
|
47663
|
+
const parsedFarmState = parsedFarms.get(farmState);
|
|
47664
|
+
if (!parsedFarmState) {
|
|
47665
|
+
console.error(`Farm state ${farmState} not found`);
|
|
47666
|
+
process.exit(1);
|
|
47667
|
+
}
|
|
47668
|
+
const { rewards } = parsedFarmState;
|
|
47525
47669
|
for (const { index, mint } of rewards) {
|
|
47526
47670
|
console.log(`vaultFarmUser: ${userState}, reward token: ${mint}, unclaimed: ${unclaimedRewards[index]}`);
|
|
47527
47671
|
}
|
|
@@ -47721,50 +47865,17 @@ function installIntegrationCommands(integration, context) {
|
|
|
47721
47865
|
|
|
47722
47866
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
47723
47867
|
exports.installDelegateCommands = installDelegateCommands;
|
|
47724
|
-
const anchor_1 = __webpack_require__(4);
|
|
47725
47868
|
const glam_sdk_1 = __webpack_require__(1);
|
|
47726
47869
|
const utils_1 = __webpack_require__(100);
|
|
47727
|
-
|
|
47728
|
-
function validateProtocolName(input) {
|
|
47729
|
-
const protocol = input.replace(/\s+/g, "");
|
|
47730
|
-
const mapping = (0, glam_sdk_1.getProgramAndBitflagByProtocolName)();
|
|
47731
|
-
const entry = mapping[protocol];
|
|
47732
|
-
if (!entry) {
|
|
47733
|
-
console.error(`Unknown protocol name: ${protocol}. Allowed values: ${Object.keys(mapping).join(", ")}.`);
|
|
47734
|
-
process.exit(1);
|
|
47735
|
-
}
|
|
47736
|
-
return entry;
|
|
47737
|
-
}
|
|
47738
|
-
async function handleDelegatePermissions(operation, delegate, sIntegrationProgram, sProtocolBitflag, permissions, context, yes) {
|
|
47739
|
-
const integrationProgram = new web3_js_1.PublicKey(sIntegrationProgram);
|
|
47740
|
-
const protocolBitflag = parseInt(sProtocolBitflag, 2);
|
|
47741
|
-
// Find permissions defined by the protocol
|
|
47742
|
-
const protocolPermissions = (0, glam_sdk_1.getProtocolsAndPermissions)()[sIntegrationProgram]?.[sProtocolBitflag];
|
|
47743
|
-
if (!protocolPermissions) {
|
|
47744
|
-
console.error(`Protocol mapping not found for program ${sIntegrationProgram} and bitflag ${sProtocolBitflag}.`);
|
|
47745
|
-
process.exit(1);
|
|
47746
|
-
}
|
|
47747
|
-
const permissionNameToBitflag = {};
|
|
47748
|
-
for (const [permBitflagStr, name] of Object.entries(protocolPermissions.permissions)) {
|
|
47749
|
-
permissionNameToBitflag[name] = new anchor_1.BN(permBitflagStr);
|
|
47750
|
-
}
|
|
47751
|
-
// Validate input permissions
|
|
47752
|
-
const unknown = permissions.filter((p) => permissionNameToBitflag[p] === undefined);
|
|
47753
|
-
if (unknown.length) {
|
|
47754
|
-
const allowed = Object.values(protocolPermissions.permissions).join(", ");
|
|
47755
|
-
console.error(`Unknown permission name(s): ${unknown.join(", ")}. Allowed values: ${allowed}.`);
|
|
47756
|
-
process.exit(1);
|
|
47757
|
-
}
|
|
47758
|
-
const permissionsBitmask = permissions.reduce((mask, p) => mask.or(permissionNameToBitflag[p]), new anchor_1.BN(0));
|
|
47759
|
-
const permissionNames = permissions.join(", ");
|
|
47870
|
+
async function handleDelegatePermissions(operation, delegate, integrationProgram, protocolBitflag, protocolName, permissionsBitmask, permissionNames, context, yes) {
|
|
47760
47871
|
const action = operation === "grant" ? "Granted" : "Revoked";
|
|
47761
47872
|
const preposition = operation === "grant" ? "to" : "from";
|
|
47762
47873
|
await (0, utils_1.executeTxWithErrorHandling)(() => operation === "grant"
|
|
47763
47874
|
? context.glamClient.access.grantDelegatePermissions(delegate, integrationProgram, protocolBitflag, permissionsBitmask, context.txOptions)
|
|
47764
47875
|
: context.glamClient.access.revokeDelegatePermissions(delegate, integrationProgram, protocolBitflag, permissionsBitmask, context.txOptions), {
|
|
47765
47876
|
skip: yes,
|
|
47766
|
-
message: `Confirm ${operation === "grant" ? "granting" : "revoking"} ${delegate} "${permissionNames}" permissions for protocol "${
|
|
47767
|
-
}, (txSig) => `${action} ${delegate} "${permissionNames}" permissions ${preposition} ${integrationProgram} for protocol "${
|
|
47877
|
+
message: `Confirm ${operation === "grant" ? "granting" : "revoking"} ${delegate} "${permissionNames}" permissions for protocol "${protocolName}"?`,
|
|
47878
|
+
}, (txSig) => `${action} ${delegate} "${permissionNames}" permissions ${preposition} ${integrationProgram} for protocol "${protocolName}": ${txSig}`);
|
|
47768
47879
|
}
|
|
47769
47880
|
function installDelegateCommands(delegate, context) {
|
|
47770
47881
|
delegate
|
|
@@ -47790,22 +47901,42 @@ function installDelegateCommands(delegate, context) {
|
|
|
47790
47901
|
delegate
|
|
47791
47902
|
.command("grant")
|
|
47792
47903
|
.argument("<pubkey>", "Delegate pubkey", utils_1.validatePublicKey)
|
|
47793
|
-
.requiredOption("--protocol <name>", "Protocol name (e.g., DriftProtocol, KaminoLend, SplToken)"
|
|
47904
|
+
.requiredOption("--protocol <name>", "Protocol name (e.g., DriftProtocol, KaminoLend, SplToken)")
|
|
47794
47905
|
.argument("<permissions...>", "Permission names for the given protocol")
|
|
47795
47906
|
.option("-y, --yes", "Skip confirmation prompt")
|
|
47796
47907
|
.description("Grant delegate permissions for a single protocol")
|
|
47797
|
-
.action(async (delegate, permissions, { protocol
|
|
47798
|
-
|
|
47908
|
+
.action(async (delegate, permissions, { protocol, yes }) => {
|
|
47909
|
+
try {
|
|
47910
|
+
const { integrationProgram, protocolBitflag, permissionsBitmask } = (0, glam_sdk_1.parsePermissionNames)({
|
|
47911
|
+
protocolName: protocol,
|
|
47912
|
+
permissionNames: permissions,
|
|
47913
|
+
});
|
|
47914
|
+
await handleDelegatePermissions("grant", delegate, integrationProgram, protocolBitflag, protocol, permissionsBitmask, permissions, context, yes);
|
|
47915
|
+
}
|
|
47916
|
+
catch (e) {
|
|
47917
|
+
console.error(e);
|
|
47918
|
+
process.exit(1);
|
|
47919
|
+
}
|
|
47799
47920
|
});
|
|
47800
47921
|
delegate
|
|
47801
47922
|
.command("revoke")
|
|
47802
47923
|
.argument("<pubkey>", "Delegate pubkey", utils_1.validatePublicKey)
|
|
47803
|
-
.requiredOption("--protocol <name>", "Protocol name (e.g., DriftProtocol, KaminoLend, SplToken)"
|
|
47924
|
+
.requiredOption("--protocol <name>", "Protocol name (e.g., DriftProtocol, KaminoLend, SplToken)")
|
|
47804
47925
|
.argument("<permissions...>", "Permission names for the given protocol")
|
|
47805
47926
|
.option("-y, --yes", "Skip confirmation prompt")
|
|
47806
47927
|
.description("Revoke delegate permissions for a single protocol by name")
|
|
47807
|
-
.action(async (delegate, permissions, { protocol
|
|
47808
|
-
|
|
47928
|
+
.action(async (delegate, permissions, { protocol, yes }) => {
|
|
47929
|
+
try {
|
|
47930
|
+
const { integrationProgram, protocolBitflag, permissionsBitmask } = (0, glam_sdk_1.parsePermissionNames)({
|
|
47931
|
+
protocolName: protocol,
|
|
47932
|
+
permissionNames: permissions,
|
|
47933
|
+
});
|
|
47934
|
+
await handleDelegatePermissions("revoke", delegate, integrationProgram, protocolBitflag, protocol, permissionsBitmask, permissions, context, yes);
|
|
47935
|
+
}
|
|
47936
|
+
catch (e) {
|
|
47937
|
+
console.error(e);
|
|
47938
|
+
process.exit(1);
|
|
47939
|
+
}
|
|
47809
47940
|
});
|
|
47810
47941
|
delegate
|
|
47811
47942
|
.command("revoke-all")
|
|
@@ -47833,7 +47964,7 @@ const glam_sdk_1 = __webpack_require__(1);
|
|
|
47833
47964
|
const utils_1 = __webpack_require__(100);
|
|
47834
47965
|
async function findToken(jupApi, value) {
|
|
47835
47966
|
const tokenList = await jupApi.fetchTokensList();
|
|
47836
|
-
const tokenInfo = tokenList.find((t) => t.address === value || t.symbol.toLowerCase() === value.toLowerCase());
|
|
47967
|
+
const tokenInfo = tokenList.tokens.find((t) => t.address === value || t.symbol.toLowerCase() === value.toLowerCase());
|
|
47837
47968
|
if (!tokenInfo) {
|
|
47838
47969
|
console.error(`Unverified token: ${value}`);
|
|
47839
47970
|
process.exit(1);
|
|
@@ -47952,7 +48083,7 @@ function installJupiterCommands(program, context) {
|
|
|
47952
48083
|
const quoteParams = {
|
|
47953
48084
|
inputMint: tokenFrom.address,
|
|
47954
48085
|
outputMint: tokenTo.address,
|
|
47955
|
-
amount:
|
|
48086
|
+
amount: (0, glam_sdk_1.fromUiAmount)(amount, tokenFrom.decimals).toNumber(),
|
|
47956
48087
|
swapMode: "ExactIn",
|
|
47957
48088
|
slippageBps: parseInt(slippageBps),
|
|
47958
48089
|
excludeDexes: ["Obric V2"],
|
|
@@ -48004,7 +48135,7 @@ function installInvestCommands(invest, context) {
|
|
|
48004
48135
|
}
|
|
48005
48136
|
const name = metadata?.name || baseAssetMint.toBase58();
|
|
48006
48137
|
const symbol = metadata?.symbol || "Unknown token";
|
|
48007
|
-
const amountBN =
|
|
48138
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, baseAssetDecimals);
|
|
48008
48139
|
if (amountBN.lt(minSubscription)) {
|
|
48009
48140
|
console.error(`Amount must be at least ${minSubscription.toNumber() / 10 ** baseAssetDecimals} ${symbol}`);
|
|
48010
48141
|
process.exit(1);
|
|
@@ -48040,7 +48171,7 @@ function installInvestCommands(invest, context) {
|
|
|
48040
48171
|
.action(async (amount, options) => {
|
|
48041
48172
|
const { mint } = await (0, glam_sdk_1.fetchMintAndTokenProgram)(context.glamClient.connection, context.glamClient.mintPda);
|
|
48042
48173
|
const decimals = mint.decimals;
|
|
48043
|
-
const amountBN =
|
|
48174
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, decimals);
|
|
48044
48175
|
const stateModel = await context.glamClient.fetchStateModel();
|
|
48045
48176
|
const minRedemption = new anchor_1.BN(stateModel?.mintModel?.minRedemption || 0);
|
|
48046
48177
|
if (amountBN.lt(minRedemption)) {
|
|
@@ -48065,9 +48196,9 @@ function installInvestCommands(invest, context) {
|
|
|
48065
48196
|
}), { skip: true }, (txSig) => `${context.glamClient.signer} claimed tokens: ${txSig}`);
|
|
48066
48197
|
});
|
|
48067
48198
|
invest
|
|
48068
|
-
.command("cancel")
|
|
48199
|
+
.command("cancel-request")
|
|
48069
48200
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
48070
|
-
.description("Cancel a queued subscription or redemption that has not been fulfilled")
|
|
48201
|
+
.description("Cancel a queued subscription or redemption request that has not been fulfilled")
|
|
48071
48202
|
.action(async (options) => {
|
|
48072
48203
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.invest.cancel(context.txOptions), {
|
|
48073
48204
|
skip: options?.yes,
|
|
@@ -48252,7 +48383,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
48252
48383
|
exports.installVaultCommands = installVaultCommands;
|
|
48253
48384
|
const tslib_1 = __webpack_require__(2);
|
|
48254
48385
|
const glam_sdk_1 = __webpack_require__(1);
|
|
48255
|
-
const web3_js_1 = __webpack_require__(5);
|
|
48256
48386
|
const fs_1 = tslib_1.__importDefault(__webpack_require__(95));
|
|
48257
48387
|
const utils_1 = __webpack_require__(100);
|
|
48258
48388
|
const anchor_1 = __webpack_require__(4);
|
|
@@ -48302,7 +48432,7 @@ function installVaultCommands(program, context) {
|
|
|
48302
48432
|
stateModel.idStr,
|
|
48303
48433
|
stateModel.vault.toBase58(),
|
|
48304
48434
|
stateModel.launchDate,
|
|
48305
|
-
(0, glam_sdk_1.
|
|
48435
|
+
(0, glam_sdk_1.charsToString)(stateModel.name),
|
|
48306
48436
|
]);
|
|
48307
48437
|
});
|
|
48308
48438
|
});
|
|
@@ -48319,7 +48449,8 @@ function installVaultCommands(program, context) {
|
|
|
48319
48449
|
console.log(`Vault: ${stateModel.vault}`);
|
|
48320
48450
|
}
|
|
48321
48451
|
catch {
|
|
48322
|
-
|
|
48452
|
+
// @ts-expect-error
|
|
48453
|
+
context.glamClient.statePda = undefined;
|
|
48323
48454
|
console.error("Invalid GLAM state public key.");
|
|
48324
48455
|
process.exit(1);
|
|
48325
48456
|
}
|
|
@@ -48332,8 +48463,8 @@ function installVaultCommands(program, context) {
|
|
|
48332
48463
|
.description("Update the owner of a GLAM vault")
|
|
48333
48464
|
.action(async (newOwner, options) => {
|
|
48334
48465
|
const newPortfolioManagerName = options?.name
|
|
48335
|
-
? (0, glam_sdk_1.
|
|
48336
|
-
:
|
|
48466
|
+
? (0, glam_sdk_1.stringToChars)(options.name)
|
|
48467
|
+
: undefined;
|
|
48337
48468
|
const message = newPortfolioManagerName
|
|
48338
48469
|
? `Confirm transferring ownership to ${newOwner} (portfolio manager: ${options.name})?`
|
|
48339
48470
|
: `Confirm transferring ownership to ${newOwner}?`;
|
|
@@ -48352,7 +48483,7 @@ function installVaultCommands(program, context) {
|
|
|
48352
48483
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
48353
48484
|
.action(async (enabled, options) => {
|
|
48354
48485
|
const stateAccount = await context.glamClient.fetchStateAccount();
|
|
48355
|
-
const name = (0, glam_sdk_1.
|
|
48486
|
+
const name = (0, glam_sdk_1.charsToString)(stateAccount.name);
|
|
48356
48487
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.access.emergencyAccessUpdate({ stateEnabled: enabled }, context.txOptions), {
|
|
48357
48488
|
skip: options?.yes,
|
|
48358
48489
|
message: `Confirm ${enabled ? "enabling" : "disabling"} vault: ${name}`,
|
|
@@ -48389,7 +48520,7 @@ function installVaultCommands(program, context) {
|
|
|
48389
48520
|
return txSig;
|
|
48390
48521
|
}, {
|
|
48391
48522
|
skip: options?.yes,
|
|
48392
|
-
message: `Confirm initializing GLAM vault: ${(0, glam_sdk_1.
|
|
48523
|
+
message: `Confirm initializing GLAM vault: ${(0, glam_sdk_1.charsToString)(initStateParams.name)}`,
|
|
48393
48524
|
}, (txSig) => `GLAM vault initialized: ${txSig}`);
|
|
48394
48525
|
return;
|
|
48395
48526
|
}
|
|
@@ -48397,7 +48528,9 @@ function installVaultCommands(program, context) {
|
|
|
48397
48528
|
await (0, utils_1.executeTxWithErrorHandling)(async () => {
|
|
48398
48529
|
// mint.initializeWithStateParams creates state with default setup
|
|
48399
48530
|
// we update state with input after mint initialization to apply state params
|
|
48400
|
-
const txSig = await context.glamClient.mint.initializeWithStateParams(initMintParams,
|
|
48531
|
+
const txSig = await context.glamClient.mint.initializeWithStateParams(initMintParams,
|
|
48532
|
+
// @ts-expect-error
|
|
48533
|
+
initStateParams, context.txOptions);
|
|
48401
48534
|
context.cliConfig.glamState = context.glamClient.statePda;
|
|
48402
48535
|
console.log("State PDA:", context.glamClient.statePda.toBase58());
|
|
48403
48536
|
console.log("Vault PDA:", context.glamClient.vaultPda.toBase58());
|
|
@@ -48405,7 +48538,7 @@ function installVaultCommands(program, context) {
|
|
|
48405
48538
|
return txSig;
|
|
48406
48539
|
}, {
|
|
48407
48540
|
skip: options?.yes,
|
|
48408
|
-
message: `Confirm initializing GLAM tokenized vault: ${(0, glam_sdk_1.
|
|
48541
|
+
message: `Confirm initializing GLAM tokenized vault: ${(0, glam_sdk_1.charsToString)(initMintParams.name)}`,
|
|
48409
48542
|
}, (txSig) => `GLAM tokenized vault initialized: ${txSig}`);
|
|
48410
48543
|
});
|
|
48411
48544
|
program
|
|
@@ -48419,34 +48552,6 @@ function installVaultCommands(program, context) {
|
|
|
48419
48552
|
message: `Confirm extending GLAM state ${context.cliConfig.glamState} by ${bytes} bytes`,
|
|
48420
48553
|
}, (txSig) => `GLAM state ${context.cliConfig.glamState} extended: ${txSig}`);
|
|
48421
48554
|
});
|
|
48422
|
-
// program
|
|
48423
|
-
// .command("set-protocol-fees")
|
|
48424
|
-
// .argument(
|
|
48425
|
-
// "<state>",
|
|
48426
|
-
// "GLAM state public key for the tokenized vault",
|
|
48427
|
-
// validatePublicKey,
|
|
48428
|
-
// )
|
|
48429
|
-
// .argument("<base-fee-bps>", "Base fee in basis points", parseInt)
|
|
48430
|
-
// .argument("<flow-fee-bps>", "Flow fee in basis points", parseInt)
|
|
48431
|
-
// .option("-y, --yes", "Skip confirmation prompt")
|
|
48432
|
-
// .description("Set protocol fees for a GLAM tokenized vault")
|
|
48433
|
-
// .action(
|
|
48434
|
-
// async (
|
|
48435
|
-
// state: PublicKey,
|
|
48436
|
-
// baseFeeBps: number,
|
|
48437
|
-
// flowFeeBps: number,
|
|
48438
|
-
// options,
|
|
48439
|
-
// ) => {
|
|
48440
|
-
// await executeTxWithErrorHandling(
|
|
48441
|
-
// () => context.glamClient.fees.setProtocolFees(baseFeeBps, flowFeeBps),
|
|
48442
|
-
// {
|
|
48443
|
-
// skip: options?.yes,
|
|
48444
|
-
// message: `Confirm setting protocol base fee to ${baseFeeBps} and flow fee to ${flowFeeBps} for ${state}?`,
|
|
48445
|
-
// },
|
|
48446
|
-
// (txSig) => `Protocol fees updated for ${state}: ${txSig}`,
|
|
48447
|
-
// );
|
|
48448
|
-
// },
|
|
48449
|
-
// );
|
|
48450
48555
|
program
|
|
48451
48556
|
.command("close")
|
|
48452
48557
|
.argument("[state]", "Vault state public key", utils_1.validatePublicKey)
|
|
@@ -48459,7 +48564,7 @@ function installVaultCommands(program, context) {
|
|
|
48459
48564
|
cluster: context.cliConfig.cluster,
|
|
48460
48565
|
});
|
|
48461
48566
|
const stateModel = await glamClient.fetchStateModel();
|
|
48462
|
-
const preInstructions =
|
|
48567
|
+
const preInstructions = new Array();
|
|
48463
48568
|
if (stateModel.mint) {
|
|
48464
48569
|
const closeMintIx = await glamClient.mint.txBuilder.closeMintIx();
|
|
48465
48570
|
preInstructions.push(closeMintIx);
|
|
@@ -48482,7 +48587,7 @@ function installVaultCommands(program, context) {
|
|
|
48482
48587
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
48483
48588
|
.description("Wrap SOL")
|
|
48484
48589
|
.action(async (amount, options) => {
|
|
48485
|
-
const lamports =
|
|
48590
|
+
const lamports = (0, glam_sdk_1.fromUiAmount)(amount, 9);
|
|
48486
48591
|
if (lamports.lte(new anchor_1.BN(0))) {
|
|
48487
48592
|
console.error("Error: amount must be greater than 0");
|
|
48488
48593
|
process.exit(1);
|
|
@@ -48515,8 +48620,6 @@ function installVaultCommands(program, context) {
|
|
|
48515
48620
|
mints.push(glam_sdk_1.WSOL.toBase58());
|
|
48516
48621
|
}
|
|
48517
48622
|
const jupApi = context.glamClient.jupiterSwap.jupApi;
|
|
48518
|
-
const tokenPrices = await jupApi.fetchTokenPrices(mints);
|
|
48519
|
-
const mintToPrice = new Map(tokenPrices.map(({ mint, price }) => [mint, price]));
|
|
48520
48623
|
const tokenList = await jupApi.fetchTokensList();
|
|
48521
48624
|
// Define column widths
|
|
48522
48625
|
const colWidths = [12, 45, 15, 20];
|
|
@@ -48528,15 +48631,15 @@ function installVaultCommands(program, context) {
|
|
|
48528
48631
|
"SOL",
|
|
48529
48632
|
"N/A",
|
|
48530
48633
|
solUiAmount.toFixed(9).toString(),
|
|
48531
|
-
(
|
|
48634
|
+
((tokenList.getByMint(glam_sdk_1.WSOL)?.usdPrice || 0) * solUiAmount).toFixed(6),
|
|
48532
48635
|
]);
|
|
48533
48636
|
tokenAccounts.forEach((ta) => {
|
|
48534
48637
|
const { uiAmount, mint } = ta;
|
|
48535
48638
|
const mintStr = mint.toBase58();
|
|
48536
48639
|
if (all || uiAmount > 0) {
|
|
48537
|
-
const token = tokenList.
|
|
48640
|
+
const token = tokenList.getByMint(mintStr);
|
|
48538
48641
|
const tokenSymbol = token?.symbol === "SOL" ? "wSOL" : token?.symbol || "Unknown";
|
|
48539
|
-
const value =
|
|
48642
|
+
const value = (token?.usdPrice || 0) * uiAmount;
|
|
48540
48643
|
printRow([
|
|
48541
48644
|
tokenSymbol,
|
|
48542
48645
|
mintStr,
|
|
@@ -48547,8 +48650,8 @@ function installVaultCommands(program, context) {
|
|
|
48547
48650
|
});
|
|
48548
48651
|
});
|
|
48549
48652
|
program
|
|
48550
|
-
.command("
|
|
48551
|
-
.description("
|
|
48653
|
+
.command("list-assets")
|
|
48654
|
+
.description("List vault asset allowlist and corresponding token accounts")
|
|
48552
48655
|
.action(async () => {
|
|
48553
48656
|
const state = await context.glamClient.fetchStateAccount();
|
|
48554
48657
|
const mints = await (0, glam_sdk_1.fetchMintsAndTokenPrograms)(context.glamClient.connection, state.assets);
|
|
@@ -48564,10 +48667,10 @@ function installVaultCommands(program, context) {
|
|
|
48564
48667
|
console.log(JSON.stringify(data, null, 2));
|
|
48565
48668
|
});
|
|
48566
48669
|
program
|
|
48567
|
-
.command("
|
|
48670
|
+
.command("allowlist-asset")
|
|
48568
48671
|
.argument("<asset>", "Asset mint public key", utils_1.validatePublicKey)
|
|
48569
48672
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
48570
|
-
.description("Add
|
|
48673
|
+
.description("Add an asset to the allowlist")
|
|
48571
48674
|
.action(async (asset, options) => {
|
|
48572
48675
|
const state = await context.glamClient.fetchStateAccount();
|
|
48573
48676
|
const assetsSet = new glam_sdk_1.PkSet(state.assets);
|
|
@@ -48582,27 +48685,27 @@ function installVaultCommands(program, context) {
|
|
|
48582
48685
|
}, (txSig) => `${asset} added to allowlist: ${txSig}`);
|
|
48583
48686
|
});
|
|
48584
48687
|
program
|
|
48585
|
-
.command("
|
|
48688
|
+
.command("remove-asset")
|
|
48586
48689
|
.argument("<asset>", "Asset mint public key", utils_1.validatePublicKey)
|
|
48587
48690
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
48588
|
-
.description("
|
|
48691
|
+
.description("Remove an asset from the allowlist")
|
|
48589
48692
|
.action(async (asset, options) => {
|
|
48590
48693
|
const state = await context.glamClient.fetchStateAccount();
|
|
48591
48694
|
if (asset.equals(state.baseAssetMint)) {
|
|
48592
|
-
console.error("Base asset should not be
|
|
48695
|
+
console.error("Base asset should not be removed from allowlist");
|
|
48593
48696
|
process.exit(1);
|
|
48594
48697
|
}
|
|
48595
48698
|
const assetsSet = new glam_sdk_1.PkSet(state.assets);
|
|
48596
48699
|
const removed = assetsSet.delete(asset);
|
|
48597
48700
|
if (!removed) {
|
|
48598
|
-
console.error(`${asset} not found in allowlist, nothing to
|
|
48701
|
+
console.error(`${asset} not found in allowlist, nothing to remove`);
|
|
48599
48702
|
process.exit(1);
|
|
48600
48703
|
}
|
|
48601
48704
|
const assets = Array.from(assetsSet);
|
|
48602
48705
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.state.update({ assets }, context.txOptions), {
|
|
48603
48706
|
skip: options?.yes,
|
|
48604
|
-
message: `Confirm
|
|
48605
|
-
}, (txSig) => `${asset}
|
|
48707
|
+
message: `Confirm removing ${asset} from allowlist?`,
|
|
48708
|
+
}, (txSig) => `${asset} removed from allowlist: ${txSig}`);
|
|
48606
48709
|
});
|
|
48607
48710
|
program
|
|
48608
48711
|
.command("holdings")
|
|
@@ -48693,7 +48796,6 @@ module.exports = require("zlib");
|
|
|
48693
48796
|
|
|
48694
48797
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
48695
48798
|
exports.installManageCommands = installManageCommands;
|
|
48696
|
-
const anchor_1 = __webpack_require__(4);
|
|
48697
48799
|
const utils_1 = __webpack_require__(100);
|
|
48698
48800
|
const web3_js_1 = __webpack_require__(5);
|
|
48699
48801
|
const glam_sdk_1 = __webpack_require__(1);
|
|
@@ -48743,7 +48845,7 @@ function installManageCommands(manage, context) {
|
|
|
48743
48845
|
.description("Update the minimum subscription amount")
|
|
48744
48846
|
.action(async (amount, options) => {
|
|
48745
48847
|
const { baseAssetDecimals } = await context.glamClient.fetchStateModel();
|
|
48746
|
-
const amountBN =
|
|
48848
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, baseAssetDecimals);
|
|
48747
48849
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.mint.update({ minSubscription: amountBN }, context.txOptions), {
|
|
48748
48850
|
skip: options?.yes,
|
|
48749
48851
|
message: `Confirm updating minimum subscription amount to ${amount}`,
|
|
@@ -48756,7 +48858,7 @@ function installManageCommands(manage, context) {
|
|
|
48756
48858
|
.description("Update the minimum redemption amount")
|
|
48757
48859
|
.action(async (amount, options) => {
|
|
48758
48860
|
const { baseAssetDecimals } = await context.glamClient.fetchStateModel();
|
|
48759
|
-
const amountBN =
|
|
48861
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, baseAssetDecimals);
|
|
48760
48862
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.mint.update({ minRedemption: amountBN }, context.txOptions), {
|
|
48761
48863
|
skip: options?.yes,
|
|
48762
48864
|
message: `Confirm updating minimum redemption amount to ${amount}`,
|
|
@@ -48866,30 +48968,41 @@ function installCctpCommands(program, context) {
|
|
|
48866
48968
|
// https://developers.circle.com/cctp/cctp-supported-blockchains#cctp-v2-supported-domains
|
|
48867
48969
|
program
|
|
48868
48970
|
.command("bridge-usdc")
|
|
48869
|
-
.argument("<amount>", "USDC amount
|
|
48971
|
+
.argument("<amount>", "USDC amount", parseFloat)
|
|
48870
48972
|
.argument("<domain>", "CCTP domain", parseInt)
|
|
48871
|
-
.argument("<destination_address>", "EVM address")
|
|
48872
|
-
.option("--
|
|
48873
|
-
.option("--
|
|
48973
|
+
.argument("<destination_address>", "Recipient EVM address")
|
|
48974
|
+
.option("-d, --destination-caller <address>", "Destination caller address")
|
|
48975
|
+
.option("-m, --max-fee-bps <maxFeeBps>", "Max fee in basis points (default 1)", (val) => {
|
|
48976
|
+
const parsed = parseInt(val);
|
|
48977
|
+
return isNaN(parsed) ? 1 : parsed;
|
|
48978
|
+
})
|
|
48979
|
+
.option("-b, --base58", "Address is a base58 string")
|
|
48980
|
+
.option("-f, --fast", "Fast transfer (lower finality threshold)", false)
|
|
48874
48981
|
.option("-y, --yes", "Skip confirmation prompt", false)
|
|
48875
48982
|
.description("Bridge USDC to an EVM chain")
|
|
48876
|
-
.action(async (amount, domain, destinationAddress, { base58, fast, yes }) => {
|
|
48983
|
+
.action(async (amount, domain, destinationAddress, { destinationCaller, maxFeeBps, base58, fast, yes }) => {
|
|
48877
48984
|
const recipientPubkey = base58
|
|
48878
48985
|
? new web3_js_1.PublicKey(destinationAddress)
|
|
48879
48986
|
: (0, glam_sdk_2.evmAddressToPublicKey)(destinationAddress);
|
|
48987
|
+
const destinationCallerPubkey = destinationCaller
|
|
48988
|
+
? base58
|
|
48989
|
+
? new web3_js_1.PublicKey(destinationCaller)
|
|
48990
|
+
: (0, glam_sdk_2.evmAddressToPublicKey)(destinationCaller)
|
|
48991
|
+
: undefined;
|
|
48880
48992
|
const cctpPolicy = await context.glamClient.fetchProtocolPolicy(context.glamClient.extCctpProgram.programId, 0b01, glam_sdk_1.CctpPolicy);
|
|
48881
48993
|
if (cctpPolicy &&
|
|
48882
48994
|
!cctpPolicy.allowedDestinations.find((d) => d.domain === domain && d.address.equals(recipientPubkey))) {
|
|
48883
48995
|
console.error(`Destination (${domain}, ${destinationAddress}) not in allowlist`);
|
|
48884
48996
|
process.exit(1);
|
|
48885
48997
|
}
|
|
48886
|
-
const amountBN = new anchor_1.BN(amount * 10 ** 6);
|
|
48887
48998
|
// https://developers.circle.com/cctp/technical-guide#cctp-finality-thresholds
|
|
48888
|
-
const
|
|
48999
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, 6);
|
|
49000
|
+
const maxFee = amountBN.mul(new anchor_1.BN(maxFeeBps)).div(new anchor_1.BN(10000));
|
|
48889
49001
|
const minFinalityThreshold = fast ? 1000 : 2000;
|
|
48890
49002
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.cctp.bridgeUsdc(amountBN, domain, recipientPubkey, {
|
|
48891
49003
|
maxFee,
|
|
48892
49004
|
minFinalityThreshold,
|
|
49005
|
+
destinationCaller: destinationCallerPubkey,
|
|
48893
49006
|
}, context.txOptions), {
|
|
48894
49007
|
skip: yes,
|
|
48895
49008
|
message: `Confirm bridging ${amount} USDC to ${destinationAddress} (domain ${domain})`,
|
|
@@ -48897,7 +49010,7 @@ function installCctpCommands(program, context) {
|
|
|
48897
49010
|
});
|
|
48898
49011
|
program
|
|
48899
49012
|
.command("receive")
|
|
48900
|
-
.argument("<source_domain>", "
|
|
49013
|
+
.argument("<source_domain>", "Source domain", parseInt)
|
|
48901
49014
|
.option("-t, --txHash <txHash>", "Transaction hash hex string (start with 0x)")
|
|
48902
49015
|
.option("-n, --nonce <nonce>", "Nonce hex string (start with 0x)")
|
|
48903
49016
|
.description("Receive USDC from an EVM chain. Either txHash or nonce is required.")
|
|
@@ -48949,7 +49062,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
48949
49062
|
exports.installTransferCommands = installTransferCommands;
|
|
48950
49063
|
const glam_sdk_1 = __webpack_require__(1);
|
|
48951
49064
|
const utils_1 = __webpack_require__(100);
|
|
48952
|
-
const anchor_1 = __webpack_require__(4);
|
|
48953
49065
|
function installTransferCommands(program, context) {
|
|
48954
49066
|
program
|
|
48955
49067
|
.command("view-policy")
|
|
@@ -49010,7 +49122,7 @@ function installTransferCommands(program, context) {
|
|
|
49010
49122
|
.action(async (amount, destination, { token, yes }) => {
|
|
49011
49123
|
const assetLabel = token.equals(glam_sdk_1.WSOL) ? "wSOL" : token.toBase58();
|
|
49012
49124
|
const { mint } = await (0, glam_sdk_1.fetchMintAndTokenProgram)(context.glamClient.connection, token);
|
|
49013
|
-
const amountBN =
|
|
49125
|
+
const amountBN = (0, glam_sdk_1.fromUiAmount)(amount, mint.decimals);
|
|
49014
49126
|
await (0, utils_1.executeTxWithErrorHandling)(() => context.glamClient.vault.tokenTransfer(token, amountBN, destination, context.txOptions), {
|
|
49015
49127
|
skip: yes,
|
|
49016
49128
|
message: `Confirm transfer of ${amount} ${assetLabel} to ${destination}?`,
|
|
@@ -49031,8 +49143,8 @@ const utils_1 = __webpack_require__(100);
|
|
|
49031
49143
|
const glam_sdk_1 = __webpack_require__(1);
|
|
49032
49144
|
function installTimelockCommands(program, context) {
|
|
49033
49145
|
program
|
|
49034
|
-
.command("
|
|
49035
|
-
.description("
|
|
49146
|
+
.command("view")
|
|
49147
|
+
.description("View current timelock")
|
|
49036
49148
|
.action(async () => {
|
|
49037
49149
|
const stateModel = await context.glamClient.fetchStateModel();
|
|
49038
49150
|
if (!stateModel) {
|
|
@@ -49296,7 +49408,7 @@ function initialize(configPath, skipSimulation = false) {
|
|
|
49296
49408
|
const { cluster, glam_state } = cliConfig;
|
|
49297
49409
|
context.glamClient = new glam_sdk_1.GlamClient({
|
|
49298
49410
|
cluster,
|
|
49299
|
-
statePda: glam_state && new web3_js_1.PublicKey(glam_state),
|
|
49411
|
+
statePda: glam_state && glam_state !== "" ? new web3_js_1.PublicKey(glam_state) : undefined,
|
|
49300
49412
|
});
|
|
49301
49413
|
context.cliConfig = cliConfig;
|
|
49302
49414
|
context.txOptions = {
|
|
@@ -49332,7 +49444,7 @@ program
|
|
|
49332
49444
|
initialize(config, skipSimulation);
|
|
49333
49445
|
await (0, idl_1.idlCheck)(context.glamClient);
|
|
49334
49446
|
})
|
|
49335
|
-
.version("1.0.
|
|
49447
|
+
.version("1.0.7");
|
|
49336
49448
|
program
|
|
49337
49449
|
.command("env")
|
|
49338
49450
|
.description("Display current environment setup")
|
|
@@ -49352,7 +49464,7 @@ program
|
|
|
49352
49464
|
console.log("Invalid GLAM state account.");
|
|
49353
49465
|
}
|
|
49354
49466
|
else {
|
|
49355
|
-
console.log("Vault name:", (0, glam_sdk_1.
|
|
49467
|
+
console.log("Vault name:", (0, glam_sdk_1.charsToString)(stateAccount.name));
|
|
49356
49468
|
}
|
|
49357
49469
|
}
|
|
49358
49470
|
else {
|