@glamsystems/glam-cli 1.0.3-alpha.5 → 1.0.3
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 +965 -950
- package/package.json +2 -2
package/main.js
CHANGED
|
@@ -110,7 +110,7 @@ module.exports = require("@coral-xyz/anchor");
|
|
|
110
110
|
/* 5 */
|
|
111
111
|
/***/ ((module) => {
|
|
112
112
|
|
|
113
|
-
module.exports = /*#__PURE__*/JSON.parse('{"address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz","metadata":{"name":"glam_protocol","version":"1.0.1","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_vault_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"input_token_program"},{"kind":"account","path":"input_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"output_vault_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"output_token_program"},{"kind":"account","path":"output_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"input_mint"},{"name":"output_mint"},{"name":"input_stake_pool","optional":true},{"name":"output_stake_pool","optional":true},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"input_token_program"},{"name":"output_token_program"}],"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":"system_transfer","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":"InvalidVoteSide","msg":"Invalid vote side"},{"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"}]}');
|
|
113
|
+
module.exports = /*#__PURE__*/JSON.parse('{"address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz","metadata":{"name":"glam_protocol","version":"1.0.1","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_vault_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"input_token_program"},{"kind":"account","path":"input_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"output_vault_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"output_token_program"},{"kind":"account","path":"output_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"input_mint"},{"name":"output_mint"},{"name":"input_stake_pool","optional":true},{"name":"output_stake_pool","optional":true},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"input_token_program"},{"name":"output_token_program"}],"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","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":"InvalidVoteSide","msg":"Invalid vote side"},{"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"}]}');
|
|
114
114
|
|
|
115
115
|
/***/ }),
|
|
116
116
|
/* 6 */
|
|
@@ -122,7 +122,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"address":"gConFzxKL9USmwTdJoeQJvfKmq
|
|
|
122
122
|
/* 7 */
|
|
123
123
|
/***/ ((module) => {
|
|
124
124
|
|
|
125
|
-
module.exports = /*#__PURE__*/JSON.parse('{"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh","metadata":{"name":"glam_mint","version":"1.0.1","spec":"0.1.0","description":"GLAM mint program"},"instructions":[{"name":"burn_tokens","discriminator":[76,15,51,254,229,215,121,66],"accounts":[{"name":"glam_state"},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"from_token_account","writable":true},{"name":"from"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}],"args":[{"name":"amount","type":"u64"}]},{"name":"cancel","discriminator":[232,219,223,41,219,236,220,190],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"user"},{"name":"recover_token_mint"},{"name":"user_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"user"},{"kind":"account","path":"recover_token_program"},{"kind":"account","path":"recover_token_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"recover_token_program"},{"kind":"account","path":"recover_token_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"recover_token_program"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],"args":[]},{"name":"claim","discriminator":[62,198,214,193,213,159,108,210],"accounts":[{"name":"glam_state"},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"claim_user"},{"name":"claim_token_mint"},{"name":"claim_user_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"claim_user"},{"kind":"account","path":"claim_token_program"},{"kind":"account","path":"claim_token_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"claim_token_program"},{"kind":"account","path":"claim_token_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"claim_user_policy","writable":true,"optional":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"claim_token_program"},{"name":"glam_policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],"args":[]},{"name":"claim_fees","discriminator":[82,251,233,156,12,52,184,202],"accounts":[{"name":"glam_state"},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer","writable":true,"signer":true},{"name":"deposit_asset"},{"name":"vault_deposit_ata","docs":["To pay out fees"],"writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"protocol_fee_authority","docs":["To receive protocol fee"]},{"name":"protocol_fee_authority_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"protocol_fee_authority"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"manager_fee_authority","docs":["To receive manager fee"]},{"name":"manager_fee_authority_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"manager_fee_authority"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"deposit_token_program"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}],"args":[]},{"name":"close_mint","discriminator":[149,251,157,212,65,181,235,129],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"request_queue","writable":true,"optional":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"extra_metas_account","writable":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[]},{"name":"crystallize_fees","discriminator":[78,0,111,26,7,12,41,249],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"glam_mint","writable":true},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer","writable":true,"signer":true},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}],"args":[]},{"name":"emergency_update_mint","discriminator":[141,210,26,160,120,140,28,239],"accounts":[{"name":"glam_state"},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint"},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}}],"args":[{"name":"args","type":{"defined":{"name":"EmergencyUpdateMintArgs"}}}]},{"name":"force_transfer_tokens","discriminator":[185,34,78,211,192,13,160,37],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"from_token_account","writable":true},{"name":"to_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"to"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"from"},{"name":"to"},{"name":"to_policy_account","writable":true,"optional":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"}],"args":[{"name":"amount","type":"u64"}]},{"name":"fulfill","discriminator":[143,2,52,206,174,164,247,72],"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"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"asset"},{"name":"vault_asset_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_asset_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"deposit_token_program"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"limit","type":{"option":"u32"}}]},{"name":"initialize_mint","docs":["Initialize a new GLAM mint with extensions and metadata.","","- `mint_model` - Configuration model containing mint parameters and metadata","- `created_key` - 8-byte key used in the GLAM state PDA derivation","- `account_type` - Fund (for tokenized vault mint) or Mint","- `decimals` - Decimals of new mint"],"discriminator":[209,42,195,4,129,85,209,44],"accounts":[{"name":"glam_state","writable":true},{"name":"signer","writable":true,"signer":true},{"name":"new_mint","writable":true},{"name":"request_queue","writable":true,"optional":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"new_mint"}]}},{"name":"extra_metas_account","writable":true},{"name":"base_asset_mint"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"mint_model","type":{"defined":{"name":"MintModel"}}},{"name":"created_key","type":{"array":["u8",8]}},{"name":"account_type","type":{"defined":{"name":"AccountType"}}},{"name":"decimals","type":{"option":"u8"}}]},{"name":"mint_tokens","discriminator":[59,132,24,246,122,39,8,243],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"mint_to","writable":true,"pda":{"seeds":[{"kind":"account","path":"recipient"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"recipient","writable":true},{"name":"policy_account","writable":true,"optional":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"}],"args":[{"name":"amount","type":"u64"}]},{"name":"price_drift_users","docs":["Extra accounts for pricing N drift users under the same user stats:","- user_stats x 1","- drift_user x N","- markets and oracles used by all drift users (no specific order)"],"discriminator":[12,5,143,51,101,81,200,150],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[{"name":"num_users","type":"u8"}]},{"name":"price_drift_vault_depositors","docs":["Extra accounts for pricing N vault depositors:","- (vault_depositor, drift_vault, drift_user) x N","- spot_market used by drift users of vaults (no specific order)","- perp markets used by drift users of vaults (no specific order)","- oracles of spot markets and perp markets (no specific order)"],"discriminator":[234,16,238,70,189,23,98,160],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[{"name":"num_vault_depositors","type":"u8"},{"name":"num_spot_markets","type":"u8"},{"name":"num_perp_markets","type":"u8"}]},{"name":"price_kamino_obligations","docs":["Prices Kamino obligations. Reserves and obligations must be refreshed in the same slot before calling this ix.","","Extra accounts for pricing N kamino obligations:","- obligations x N"],"discriminator":[166,110,234,179,240,179,69,246],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[]},{"name":"price_kamino_vault_shares","docs":["Prices Kamino vault shares.","- `num_vaults` Number of kamino vaults to price.","","Extra accounts for pricing N kamino vault shares:","- (kvault_share_ata, kvault_share_mint, kvault_state, kvault_deposit_token_oracle) x N","- reserve x M","- M = number of reserves used by all kvaults\' allocations","- reserve pubkeys must follow the same order of reserves used by each allocation"],"discriminator":[112,92,238,224,145,105,38,249],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[{"name":"num_vaults","type":"u8"}]},{"name":"price_vault_tokens","docs":["Prices vault SOL balance and tokens it holds.","","Args:","- `denom`: Denomination of the price.","- `agg_indexes`: Indexes of the aggregation oracles for the tokens (must follow the same order of mints in extra accounts). If aggregation oracle is not used for token #`i`, `agg_indexes[i]` should be set to -1.","","Extra accounts for pricing N tokens:","- (ata, mint, oracle) x N","- optional oracle mapping (only add it if any token uses an agg oracle)"],"discriminator":[54,42,16,199,20,183,50,137],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[{"name":"agg_indexes","type":{"vec":{"array":["i16",4]}}}]},{"name":"queued_redeem","discriminator":[82,242,202,93,170,196,215,113],"accounts":[{"name":"glam_state"},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"signer_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],"args":[{"name":"amount_in","type":"u64"}]},{"name":"queued_subscribe","discriminator":[107,180,212,63,146,0,159,255],"accounts":[{"name":"glam_state"},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"deposit_asset"},{"name":"escrow_deposit_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer_deposit_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"deposit_token_program"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],"args":[{"name":"amount_in","type":"u64"}]},{"name":"set_mint_policy","discriminator":[12,208,252,52,166,250,137,169],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"policy","type":{"defined":{"name":"MintPolicy"}}}]},{"name":"set_protocol_fees","discriminator":[49,143,189,18,56,206,158,226],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint"},{"name":"signer","writable":true,"signer":true},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"base_fee_bps","type":"u16"},{"name":"flow_fee_bps","type":"u16"}]},{"name":"set_token_accounts_states","discriminator":[50,133,45,86,117,66,115,195],"accounts":[{"name":"glam_state"},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}],"args":[{"name":"frozen","type":"bool"}]},{"name":"subscribe","discriminator":[254,28,191,138,156,179,183,53],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"signer_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"deposit_asset"},{"name":"vault_deposit_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer_deposit_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer_policy","writable":true,"optional":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"deposit_token_program"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"amount_in","type":"u64"}]},{"name":"update_mint","discriminator":[212,203,57,78,75,245,222,5],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"mint_model","type":{"defined":{"name":"MintModel"}}}]},{"name":"update_mint_apply_timelock","discriminator":[223,241,80,24,120,25,82,134],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"request_queue","optional":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[]},{"name":"validate_aum","docs":["Validates AUM of the vault and emits AumRecord event."],"discriminator":[101,15,233,89,134,123,224,99],"accounts":[{"name":"glam_state"},{"name":"signer","writable":true,"signer":true},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[]}],"accounts":[{"name":"GlobalConfig","discriminator":[149,8,156,202,160,252,176,217]},{"name":"RequestQueue","discriminator":[172,124,172,253,233,63,70,234]},{"name":"StateAccount","discriminator":[142,247,54,95,85,133,249,103]}],"events":[{"name":"AumRecord","discriminator":[162,116,55,29,223,230,239,205]},{"name":"PricedProtocolRecord","discriminator":[232,89,187,82,49,200,127,132]}],"errors":[{"code":6000,"name":"InvalidAuthority","msg":"Invalid authority"},{"code":6001,"name":"UnauthorizedSigner","msg":"Signer is not authorized"},{"code":6002,"name":"ActionPaused","msg":"Requested action is paused"},{"code":6003,"name":"InvalidAsset","msg":"Asset not allowed to subscribe"},{"code":6004,"name":"MaxCapExceeded","msg":"Max cap exceeded"},{"code":6005,"name":"InvalidAmount","msg":"Invalid amount for subscription or redemption"},{"code":6006,"name":"NewRequestNotAllowed","msg":"New request is not allowed"},{"code":6007,"name":"RequestNotClaimable","msg":"Request is not claimable"},{"code":6008,"name":"RequestNotCancellable","msg":"Request is not cancellable"},{"code":6009,"name":"RequestNotFound","msg":"Request not found"},{"code":6010,"name":"RequestQueueNotEmpty","msg":"Request queue not empty"},{"code":6011,"name":"InvalidRequestQueueData","msg":"Invalid request queue data"},{"code":6012,"name":"RequestQueueFull","msg":"Request queue full"},{"code":6013,"name":"ProtocolFeesNotCrystallized","msg":"Protocol fees should be crystallized before updating"}],"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":"AssetMeta","type":{"kind":"struct","fields":[{"name":"asset","type":"pubkey"},{"name":"decimals","type":"u8"},{"name":"oracle","type":"pubkey"},{"name":"oracle_source","type":{"defined":{"name":"OracleSource"}}},{"name":"max_age_seconds","type":"u16"},{"name":"priority","type":"u8"},{"name":"padding","type":{"array":["u8",3]}}]}},{"name":"AumRecord","type":{"kind":"struct","fields":[{"name":"base_asset_amount","type":"i128"}]}},{"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":"EmergencyUpdateMintArgs","type":{"kind":"struct","fields":[{"name":"request_type","type":{"defined":{"name":"RequestType"}}},{"name":"set_paused","type":"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":"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":"GlobalConfig","type":{"kind":"struct","fields":[{"name":"admin","docs":["The authority that can modify the config"],"type":"pubkey"},{"name":"fee_authority","docs":["The authority that can modify fee structure of individual glam state and claim protocol fees"],"type":"pubkey"},{"name":"referrer","type":"pubkey"},{"name":"base_fee_bps","type":"u16"},{"name":"flow_fee_bps","type":"u16"},{"name":"asset_metas","type":{"vec":{"defined":{"name":"AssetMeta"}}}}]}},{"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":"ManagementFee","type":{"kind":"struct","fields":[{"name":"fee_bps","type":"u16"}]}},{"name":"MintModel","type":{"kind":"struct","fields":[{"name":"symbol","type":{"option":"string"}},{"name":"name","type":{"option":{"array":["u8",32]}}},{"name":"uri","type":{"option":"string"}},{"name":"year_in_seconds","type":{"option":"u32"}},{"name":"permanent_delegate","type":{"option":"pubkey"}},{"name":"default_account_state_frozen","type":{"option":"bool"}},{"name":"fee_structure","type":{"option":{"defined":{"name":"FeeStructure"}}}},{"name":"notify_and_settle","type":{"option":{"defined":{"name":"NotifyAndSettle"}}}},{"name":"lockup_period","type":{"option":"u32"}},{"name":"max_cap","type":{"option":"u64"}},{"name":"min_subscription","type":{"option":"u64"}},{"name":"min_redemption","type":{"option":"u64"}},{"name":"allowlist","type":{"option":{"vec":"pubkey"}}},{"name":"blocklist","type":{"option":{"vec":"pubkey"}}}]}},{"name":"MintPolicy","type":{"kind":"struct","fields":[{"name":"lockup_period","type":"u32"},{"name":"max_cap","type":"u64"},{"name":"min_subscription","type":"u64"},{"name":"min_redemption","type":"u64"},{"name":"reserved","type":"u64"},{"name":"allowlist","type":{"option":{"vec":"pubkey"}}},{"name":"blocklist","type":{"option":{"vec":"pubkey"}}}]}},{"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":"OracleSource","type":{"kind":"enum","variants":[{"name":"Pyth"},{"name":"Switchboard"},{"name":"QuoteAsset"},{"name":"Pyth1K"},{"name":"Pyth1M"},{"name":"PythStableCoin"},{"name":"Prelaunch"},{"name":"PythPull"},{"name":"Pyth1KPull"},{"name":"Pyth1MPull"},{"name":"PythStableCoinPull"},{"name":"SwitchboardOnDemand"},{"name":"PythLazer"},{"name":"PythLazer1K"},{"name":"PythLazer1M"},{"name":"PythLazerStableCoin"},{"name":"NotSet"},{"name":"LstPoolState"},{"name":"MarinadeState"},{"name":"BaseAsset"},{"name":"ChainlinkRWA"}]}},{"name":"PendingRequest","type":{"kind":"struct","fields":[{"name":"user","type":"pubkey"},{"name":"incoming","type":"u64"},{"name":"outgoing","type":"u64"},{"name":"created_at","type":"u64"},{"name":"fulfilled_at","type":"u64"},{"name":"time_unit","type":"u8"},{"name":"request_type","type":{"defined":{"name":"RequestType"}}},{"name":"reserved","type":{"array":["u8",6]}}]}},{"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":"PricedProtocolRecord","type":{"kind":"struct","fields":[{"name":"base_asset_amount","type":"i128"}]}},{"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":"RequestQueue","type":{"kind":"struct","fields":[{"name":"glam_state","type":"pubkey"},{"name":"glam_mint","type":"pubkey"},{"name":"subscription_paused","type":"bool"},{"name":"redemption_paused","type":"bool"},{"name":"data","type":{"vec":{"defined":{"name":"PendingRequest"}}}}]}},{"name":"RequestType","type":{"kind":"enum","variants":[{"name":"Subscription"},{"name":"Redemption"}]}},{"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":"TimeUnit","type":{"kind":"enum","variants":[{"name":"Second"},{"name":"Slot"}]}},{"name":"ValuationModel","type":{"kind":"enum","variants":[{"name":"Continuous"},{"name":"Periodic"}]}}],"constants":[{"name":"PROTO_MINT","type":"u16","value":"1"},{"name":"PROTO_MINT_PERM_BURN_TOKENS","type":"u64","value":"2"},{"name":"PROTO_MINT_PERM_CANCEL_REQUEST","type":"u64","value":"128"},{"name":"PROTO_MINT_PERM_CLAIM_FEES","type":"u64","value":"16"},{"name":"PROTO_MINT_PERM_CLAIM_REQUEST","type":"u64","value":"256"},{"name":"PROTO_MINT_PERM_EMERGENCY_UPDATE","type":"u64","value":"64"},{"name":"PROTO_MINT_PERM_FORCE_TRANSFER_TOKENS","type":"u64","value":"4"},{"name":"PROTO_MINT_PERM_FULFILL","type":"u64","value":"32"},{"name":"PROTO_MINT_PERM_MINT_TOKENS","type":"u64","value":"1"},{"name":"PROTO_MINT_PERM_SET_TOKEN_ACCOUNT_STATE","type":"u64","value":"8"}]}');
|
|
125
|
+
module.exports = /*#__PURE__*/JSON.parse('{"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh","metadata":{"name":"glam_mint","version":"1.0.1","spec":"0.1.0","description":"GLAM mint program"},"instructions":[{"name":"burn_tokens","discriminator":[76,15,51,254,229,215,121,66],"accounts":[{"name":"glam_state"},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"from_token_account","writable":true},{"name":"from"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}],"args":[{"name":"amount","type":"u64"}]},{"name":"cancel","discriminator":[232,219,223,41,219,236,220,190],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"user"},{"name":"recover_token_mint"},{"name":"user_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"user"},{"kind":"account","path":"recover_token_program"},{"kind":"account","path":"recover_token_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"recover_token_program"},{"kind":"account","path":"recover_token_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"recover_token_program"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],"args":[]},{"name":"claim","discriminator":[62,198,214,193,213,159,108,210],"accounts":[{"name":"glam_state"},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"claim_user"},{"name":"claim_token_mint"},{"name":"claim_user_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"claim_user"},{"kind":"account","path":"claim_token_program"},{"kind":"account","path":"claim_token_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"claim_token_program"},{"kind":"account","path":"claim_token_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"claim_user_policy","writable":true,"optional":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"claim_token_program"},{"name":"glam_policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],"args":[]},{"name":"claim_fees","discriminator":[82,251,233,156,12,52,184,202],"accounts":[{"name":"glam_state"},{"name":"glam_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer","writable":true,"signer":true},{"name":"deposit_asset"},{"name":"vault_deposit_ata","docs":["To pay out fees"],"writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"protocol_fee_authority","docs":["To receive protocol fee"]},{"name":"protocol_fee_authority_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"protocol_fee_authority"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"manager_fee_authority","docs":["To receive manager fee"]},{"name":"manager_fee_authority_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"manager_fee_authority"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"deposit_token_program"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}],"args":[]},{"name":"close_mint","discriminator":[149,251,157,212,65,181,235,129],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"request_queue","writable":true,"optional":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"extra_metas_account","writable":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[]},{"name":"crystallize_fees","discriminator":[78,0,111,26,7,12,41,249],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"glam_mint","writable":true},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer","writable":true,"signer":true},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}],"args":[]},{"name":"emergency_update_mint","discriminator":[141,210,26,160,120,140,28,239],"accounts":[{"name":"glam_state"},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint"},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}}],"args":[{"name":"args","type":{"defined":{"name":"EmergencyUpdateMintArgs"}}}]},{"name":"force_transfer_tokens","discriminator":[185,34,78,211,192,13,160,37],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"from_token_account","writable":true},{"name":"to_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"to"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"from"},{"name":"to"},{"name":"to_policy_account","writable":true,"optional":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"}],"args":[{"name":"amount","type":"u64"}]},{"name":"fulfill","discriminator":[143,2,52,206,174,164,247,72],"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"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"asset"},{"name":"vault_asset_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_asset_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"deposit_token_program"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"limit","type":{"option":"u32"}}]},{"name":"initialize_mint","docs":["Initialize a new GLAM mint with extensions and metadata.","","- `mint_model` - Configuration model containing mint parameters and metadata","- `created_key` - 8-byte key used in the GLAM state PDA derivation","- `account_type` - Fund (for tokenized vault mint) or Mint","- `decimals` - Decimals of new mint"],"discriminator":[209,42,195,4,129,85,209,44],"accounts":[{"name":"glam_state","writable":true},{"name":"signer","writable":true,"signer":true},{"name":"new_mint","writable":true},{"name":"request_queue","writable":true,"optional":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"new_mint"}]}},{"name":"extra_metas_account","writable":true},{"name":"base_asset_mint"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"mint_model","type":{"defined":{"name":"MintModel"}}},{"name":"created_key","type":{"array":["u8",8]}},{"name":"account_type","type":{"defined":{"name":"AccountType"}}},{"name":"decimals","type":{"option":"u8"}}]},{"name":"mint_tokens","discriminator":[59,132,24,246,122,39,8,243],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"mint_to","writable":true,"pda":{"seeds":[{"kind":"account","path":"recipient"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"recipient","writable":true},{"name":"policy_account","writable":true,"optional":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"}],"args":[{"name":"amount","type":"u64"}]},{"name":"price_drift_users","docs":["Extra accounts for pricing N drift users under the same user stats:","- user_stats x 1","- drift_user x N","- markets and oracles used by all drift users (no specific order)"],"discriminator":[12,5,143,51,101,81,200,150],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[{"name":"num_users","type":"u8"}]},{"name":"price_drift_vault_depositors","docs":["Extra accounts for pricing N vault depositors:","- (vault_depositor, drift_vault, drift_user) x N","- spot_market used by drift users of vaults (no specific order)","- perp markets used by drift users of vaults (no specific order)","- oracles of spot markets and perp markets (no specific order)"],"discriminator":[234,16,238,70,189,23,98,160],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[{"name":"num_vault_depositors","type":"u8"},{"name":"num_spot_markets","type":"u8"},{"name":"num_perp_markets","type":"u8"}]},{"name":"price_kamino_obligations","docs":["Prices Kamino obligations. Reserves and obligations must be refreshed in the same slot before calling this ix.","","Extra accounts for pricing N kamino obligations:","- obligations x N"],"discriminator":[166,110,234,179,240,179,69,246],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[]},{"name":"price_kamino_vault_shares","docs":["Prices Kamino vault shares.","- `num_vaults` Number of kamino vaults to price.","","Extra accounts for pricing N kamino vault shares:","- (kvault_share_ata, kvault_share_mint, kvault_state, kvault_deposit_token_oracle) x N","- reserve x M","- M = number of reserves used by all kvaults\' allocations","- reserve pubkeys must follow the same order of reserves used by each allocation"],"discriminator":[112,92,238,224,145,105,38,249],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[{"name":"num_vaults","type":"u8"}]},{"name":"price_stake_accounts","discriminator":[119,137,9,15,196,73,30,27],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[]},{"name":"price_vault_tokens","docs":["Prices vault SOL balance and tokens it holds.","","Args:","- `denom`: Denomination of the price.","- `agg_indexes`: Indexes of the aggregation oracles for the tokens (must follow the same order of mints in extra accounts). If aggregation oracle is not used for token #`i`, `agg_indexes[i]` should be set to -1.","","Extra accounts for pricing N tokens:","- (ata, mint, oracle) x N","- optional oracle mapping (only add it if any token uses an agg oracle)"],"discriminator":[54,42,16,199,20,183,50,137],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"signer","writable":true,"signer":true},{"name":"sol_usd_oracle"},{"name":"base_asset_oracle"},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[{"name":"agg_indexes","type":{"vec":{"array":["i16",4]}}}]},{"name":"queued_redeem","discriminator":[82,242,202,93,170,196,215,113],"accounts":[{"name":"glam_state"},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"signer_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],"args":[{"name":"amount_in","type":"u64"}]},{"name":"queued_subscribe","discriminator":[107,180,212,63,146,0,159,255],"accounts":[{"name":"glam_state"},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","writable":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"deposit_asset"},{"name":"escrow_deposit_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer_deposit_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"deposit_token_program"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}],"args":[{"name":"amount_in","type":"u64"}]},{"name":"set_mint_policy","discriminator":[12,208,252,52,166,250,137,169],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"policy","type":{"defined":{"name":"MintPolicy"}}}]},{"name":"set_protocol_fees","discriminator":[49,143,189,18,56,206,158,226],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_mint"},{"name":"signer","writable":true,"signer":true},{"name":"glam_config","pda":{"seeds":[{"kind":"const","value":[103,108,111,98,97,108,45,99,111,110,102,105,103]}],"program":{"kind":"const","value":[10,11,0,83,72,16,46,144,46,42,79,22,157,123,21,242,192,146,1,78,88,59,102,9,190,226,92,189,187,232,83,220]}}},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"base_fee_bps","type":"u16"},{"name":"flow_fee_bps","type":"u16"}]},{"name":"set_token_accounts_states","discriminator":[50,133,45,86,117,66,115,195],"accounts":[{"name":"glam_state"},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"}],"args":[{"name":"frozen","type":"bool"}]},{"name":"subscribe","discriminator":[254,28,191,138,156,179,183,53],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_vault","pda":{"seeds":[{"kind":"const","value":[118,97,117,108,116]},{"kind":"account","path":"glam_state"}],"program":{"kind":"const","value":[227,199,235,230,176,132,243,117,43,131,173,18,78,255,26,50,209,135,86,219,140,126,61,255,0,218,252,224,172,8,223,207]}}},{"name":"glam_mint","writable":true},{"name":"glam_escrow","pda":{"seeds":[{"kind":"const","value":[101,115,99,114,111,119]},{"kind":"account","path":"glam_mint"}]}},{"name":"request_queue","pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"signer","writable":true,"signer":true},{"name":"signer_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"escrow_mint_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_escrow"},{"kind":"account","path":"token_2022_program"},{"kind":"account","path":"glam_mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"deposit_asset"},{"name":"vault_deposit_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"glam_vault"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer_deposit_ata","writable":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"account","path":"deposit_token_program"},{"kind":"account","path":"deposit_asset"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"signer_policy","writable":true,"optional":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"deposit_token_program"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"policies_program","address":"po1iCYakK3gHCLbuju4wGzFowTMpAJxkqK1iwUqMonY"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"amount_in","type":"u64"}]},{"name":"update_mint","discriminator":[212,203,57,78,75,245,222,5],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[{"name":"mint_model","type":{"defined":{"name":"MintModel"}}}]},{"name":"update_mint_apply_timelock","discriminator":[223,241,80,24,120,25,82,134],"accounts":[{"name":"glam_state","writable":true},{"name":"glam_signer","writable":true,"signer":true},{"name":"glam_mint","writable":true},{"name":"request_queue","optional":true,"pda":{"seeds":[{"kind":"const","value":[114,101,113,117,101,115,116,45,113,117,101,117,101]},{"kind":"account","path":"glam_mint"}]}},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_2022_program","address":"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"},{"name":"glam_protocol","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"}],"args":[]},{"name":"validate_aum","docs":["Validates AUM of the vault and emits AumRecord event."],"discriminator":[101,15,233,89,134,123,224,99],"accounts":[{"name":"glam_state"},{"name":"signer","writable":true,"signer":true},{"name":"event_authority","optional":true,"pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"event_program","optional":true,"address":"GM1NtvvnSXUptTrMCqbogAdZJydZSNv98DoU5AZVLmGh"}],"args":[]}],"accounts":[{"name":"GlobalConfig","discriminator":[149,8,156,202,160,252,176,217]},{"name":"RequestQueue","discriminator":[172,124,172,253,233,63,70,234]},{"name":"StateAccount","discriminator":[142,247,54,95,85,133,249,103]}],"events":[{"name":"AumRecord","discriminator":[162,116,55,29,223,230,239,205]},{"name":"PricedProtocolRecord","discriminator":[232,89,187,82,49,200,127,132]}],"errors":[{"code":6000,"name":"InvalidAuthority","msg":"Invalid authority"},{"code":6001,"name":"UnauthorizedSigner","msg":"Signer is not authorized"},{"code":6002,"name":"ActionPaused","msg":"Requested action is paused"},{"code":6003,"name":"InvalidAsset","msg":"Asset not allowed to subscribe"},{"code":6004,"name":"MaxCapExceeded","msg":"Max cap exceeded"},{"code":6005,"name":"InvalidAmount","msg":"Invalid amount for subscription or redemption"},{"code":6006,"name":"NewRequestNotAllowed","msg":"New request is not allowed"},{"code":6007,"name":"RequestNotClaimable","msg":"Request is not claimable"},{"code":6008,"name":"RequestNotCancellable","msg":"Request is not cancellable"},{"code":6009,"name":"RequestNotFound","msg":"Request not found"},{"code":6010,"name":"RequestQueueNotEmpty","msg":"Request queue not empty"},{"code":6011,"name":"InvalidRequestQueueData","msg":"Invalid request queue data"},{"code":6012,"name":"RequestQueueFull","msg":"Request queue full"},{"code":6013,"name":"ProtocolFeesNotCrystallized","msg":"Protocol fees should be crystallized before updating"}],"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":"AssetMeta","type":{"kind":"struct","fields":[{"name":"asset","type":"pubkey"},{"name":"decimals","type":"u8"},{"name":"oracle","type":"pubkey"},{"name":"oracle_source","type":{"defined":{"name":"OracleSource"}}},{"name":"max_age_seconds","type":"u16"},{"name":"priority","type":"u8"},{"name":"padding","type":{"array":["u8",3]}}]}},{"name":"AumRecord","type":{"kind":"struct","fields":[{"name":"base_asset_amount","type":"i128"}]}},{"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":"EmergencyUpdateMintArgs","type":{"kind":"struct","fields":[{"name":"request_type","type":{"defined":{"name":"RequestType"}}},{"name":"set_paused","type":"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":"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":"GlobalConfig","type":{"kind":"struct","fields":[{"name":"admin","docs":["The authority that can modify the config"],"type":"pubkey"},{"name":"fee_authority","docs":["The authority that can modify fee structure of individual glam state and claim protocol fees"],"type":"pubkey"},{"name":"referrer","type":"pubkey"},{"name":"base_fee_bps","type":"u16"},{"name":"flow_fee_bps","type":"u16"},{"name":"asset_metas","type":{"vec":{"defined":{"name":"AssetMeta"}}}}]}},{"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":"ManagementFee","type":{"kind":"struct","fields":[{"name":"fee_bps","type":"u16"}]}},{"name":"MintModel","type":{"kind":"struct","fields":[{"name":"symbol","type":{"option":"string"}},{"name":"name","type":{"option":{"array":["u8",32]}}},{"name":"uri","type":{"option":"string"}},{"name":"year_in_seconds","type":{"option":"u32"}},{"name":"permanent_delegate","type":{"option":"pubkey"}},{"name":"default_account_state_frozen","type":{"option":"bool"}},{"name":"fee_structure","type":{"option":{"defined":{"name":"FeeStructure"}}}},{"name":"notify_and_settle","type":{"option":{"defined":{"name":"NotifyAndSettle"}}}},{"name":"lockup_period","type":{"option":"u32"}},{"name":"max_cap","type":{"option":"u64"}},{"name":"min_subscription","type":{"option":"u64"}},{"name":"min_redemption","type":{"option":"u64"}},{"name":"allowlist","type":{"option":{"vec":"pubkey"}}},{"name":"blocklist","type":{"option":{"vec":"pubkey"}}}]}},{"name":"MintPolicy","type":{"kind":"struct","fields":[{"name":"lockup_period","type":"u32"},{"name":"max_cap","type":"u64"},{"name":"min_subscription","type":"u64"},{"name":"min_redemption","type":"u64"},{"name":"reserved","type":"u64"},{"name":"allowlist","type":{"option":{"vec":"pubkey"}}},{"name":"blocklist","type":{"option":{"vec":"pubkey"}}}]}},{"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":"OracleSource","type":{"kind":"enum","variants":[{"name":"Pyth"},{"name":"Switchboard"},{"name":"QuoteAsset"},{"name":"Pyth1K"},{"name":"Pyth1M"},{"name":"PythStableCoin"},{"name":"Prelaunch"},{"name":"PythPull"},{"name":"Pyth1KPull"},{"name":"Pyth1MPull"},{"name":"PythStableCoinPull"},{"name":"SwitchboardOnDemand"},{"name":"PythLazer"},{"name":"PythLazer1K"},{"name":"PythLazer1M"},{"name":"PythLazerStableCoin"},{"name":"NotSet"},{"name":"LstPoolState"},{"name":"MarinadeState"},{"name":"BaseAsset"},{"name":"ChainlinkRWA"}]}},{"name":"PendingRequest","type":{"kind":"struct","fields":[{"name":"user","type":"pubkey"},{"name":"incoming","type":"u64"},{"name":"outgoing","type":"u64"},{"name":"created_at","type":"u64"},{"name":"fulfilled_at","type":"u64"},{"name":"time_unit","type":"u8"},{"name":"request_type","type":{"defined":{"name":"RequestType"}}},{"name":"reserved","type":{"array":["u8",6]}}]}},{"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":"PricedProtocolRecord","type":{"kind":"struct","fields":[{"name":"base_asset_amount","type":"i128"}]}},{"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":"RequestQueue","type":{"kind":"struct","fields":[{"name":"glam_state","type":"pubkey"},{"name":"glam_mint","type":"pubkey"},{"name":"subscription_paused","type":"bool"},{"name":"redemption_paused","type":"bool"},{"name":"data","type":{"vec":{"defined":{"name":"PendingRequest"}}}}]}},{"name":"RequestType","type":{"kind":"enum","variants":[{"name":"Subscription"},{"name":"Redemption"}]}},{"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":"TimeUnit","type":{"kind":"enum","variants":[{"name":"Second"},{"name":"Slot"}]}},{"name":"ValuationModel","type":{"kind":"enum","variants":[{"name":"Continuous"},{"name":"Periodic"}]}}],"constants":[{"name":"PROTO_MINT","type":"u16","value":"1"},{"name":"PROTO_MINT_PERM_BURN_TOKENS","type":"u64","value":"2"},{"name":"PROTO_MINT_PERM_CANCEL_REQUEST","type":"u64","value":"128"},{"name":"PROTO_MINT_PERM_CLAIM_FEES","type":"u64","value":"16"},{"name":"PROTO_MINT_PERM_CLAIM_REQUEST","type":"u64","value":"256"},{"name":"PROTO_MINT_PERM_EMERGENCY_UPDATE","type":"u64","value":"64"},{"name":"PROTO_MINT_PERM_FORCE_TRANSFER_TOKENS","type":"u64","value":"4"},{"name":"PROTO_MINT_PERM_FULFILL","type":"u64","value":"32"},{"name":"PROTO_MINT_PERM_MINT_TOKENS","type":"u64","value":"1"},{"name":"PROTO_MINT_PERM_SET_TOKEN_ACCOUNT_STATE","type":"u64","value":"8"}]}');
|
|
126
126
|
|
|
127
127
|
/***/ }),
|
|
128
128
|
/* 8 */
|
|
@@ -152,7 +152,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"address":"G1NTMNMgmgJAWAD9G3toFVMtNc
|
|
|
152
152
|
/* 12 */
|
|
153
153
|
/***/ ((module) => {
|
|
154
154
|
|
|
155
|
-
module.exports = /*#__PURE__*/JSON.parse('{"address":"G1NTstCVkEhGVQPnPe6r7yEyRTvnp3ta63AFkEKxqg25","metadata":{"name":"ext_stake_pool","version":"0.1.0","spec":"0.1.0","description":"GLAM extension for SPL stake pool programs"},"instructions":[{"name":"deposit_sol","discriminator":[108,81,78,117,125,155,56,200],"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"}],"program":{"kind":"account","path":"glam_protocol_program"}}},{"name":"glam_signer","writable":true,"signer":true},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"cpi_program"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"stake_pool","writable":true},{"name":"stake_pool_withdraw_authority"},{"name":"reserve_stake","writable":true},{"name":"pool_tokens_to","writable":true},{"name":"fee_account","writable":true},{"name":"referrer_pool_tokens_account","writable":true},{"name":"pool_mint","writable":true},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"token_program"}],"args":[{"name":"lamports","type":"u64"}]},{"name":"deposit_stake","discriminator":[160,167,9,220,74,243,228,43],"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"}],"program":{"kind":"account","path":"glam_protocol_program"}}},{"name":"glam_signer","writable":true,"signer":true},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"cpi_program"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"stake_pool","writable":true},{"name":"validator_list","writable":true},{"name":"stake_pool_withdraw_authority"},{"name":"deposit_stake","writable":true},{"name":"validator_stake_account","writable":true},{"name":"reserve_stake_account","writable":true},{"name":"pool_tokens_to","writable":true},{"name":"fee_account","writable":true},{"name":"referrer_pool_tokens_account","writable":true},{"name":"pool_mint","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"},{"name":"token_program"},{"name":"stake_program","address":"Stake11111111111111111111111111111111111111"}],"args":[]},{"name":"withdraw_sol","discriminator":[145,131,74,136,65,137,42,38],"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"}],"program":{"kind":"account","path":"glam_protocol_program"}}},{"name":"glam_signer","writable":true,"signer":true},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"cpi_program"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"stake_pool","writable":true},{"name":"stake_pool_withdraw_authority"},{"name":"pool_tokens_from","writable":true},{"name":"reserve_stake","writable":true},{"name":"fee_account","writable":true},{"name":"pool_mint","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"},{"name":"stake_program","address":"Stake11111111111111111111111111111111111111"},{"name":"token_program"}],"args":[{"name":"pool_tokens","type":"u64"}]},{"name":"withdraw_stake","discriminator":[153,8,22,138,105,176,87,66],"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"}],"program":{"kind":"account","path":"glam_protocol_program"}}},{"name":"glam_signer","writable":true,"signer":true},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"cpi_program"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"stake_pool","writable":true},{"name":"validator_list","writable":true},{"name":"stake_pool_withdraw_authority"},{"name":"validator_stake_account","writable":true},{"name":"stake","writable":true},{"name":"pool_tokens_from","writable":true},{"name":"fee_account","writable":true},{"name":"pool_mint","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"token_program"},{"name":"stake_program","address":"Stake11111111111111111111111111111111111111"}],"args":[{"name":"pool_tokens","type":"u64"}]}],"accounts":[{"name":"StateAccount","discriminator":[142,247,54,95,85,133,249,103]}],"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":"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":"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":"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":"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":"TimeUnit","type":{"kind":"enum","variants":[{"name":"Second"},{"name":"Slot"}]}},{"name":"ValuationModel","type":{"kind":"enum","variants":[{"name":"Continuous"},{"name":"Periodic"}]}}],"constants":[{"name":"PROTO_SANCTUM","type":"u16","value":"2"},{"name":"PROTO_STAKE_POOL","type":"u16","value":"1"},{"name":"SANCTUM_PERM_DEPOSIT_SOL","type":"u64","value":"1"},{"name":"SANCTUM_PERM_DEPOSIT_STAKE","type":"u64","value":"2"},{"name":"SANCTUM_PERM_WITHDRAW_SOL","type":"u64","value":"4"},{"name":"SANCTUM_PERM_WITHDRAW_STAKE","type":"u64","value":"8"},{"name":"STAKE_POOL_PERM_DEPOSIT_SOL","type":"u64","value":"1"},{"name":"STAKE_POOL_PERM_DEPOSIT_STAKE","type":"u64","value":"2"},{"name":"STAKE_POOL_PERM_WITHDRAW_SOL","type":"u64","value":"4"},{"name":"STAKE_POOL_PERM_WITHDRAW_STAKE","type":"u64","value":"8"}]}');
|
|
155
|
+
module.exports = /*#__PURE__*/JSON.parse('{"address":"G1NTstCVkEhGVQPnPe6r7yEyRTvnp3ta63AFkEKxqg25","metadata":{"name":"ext_stake_pool","version":"0.1.0","spec":"0.1.0","description":"GLAM extension for SPL stake pool programs"},"instructions":[{"name":"deposit_sol","discriminator":[108,81,78,117,125,155,56,200],"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"}],"program":{"kind":"account","path":"glam_protocol_program"}}},{"name":"glam_signer","writable":true,"signer":true},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"cpi_program"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"stake_pool","writable":true},{"name":"stake_pool_withdraw_authority"},{"name":"reserve_stake","writable":true},{"name":"pool_tokens_to","writable":true},{"name":"fee_account","writable":true},{"name":"pool_mint","writable":true},{"name":"token_program"}],"args":[{"name":"lamports","type":"u64"}]},{"name":"deposit_stake","discriminator":[160,167,9,220,74,243,228,43],"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"}],"program":{"kind":"account","path":"glam_protocol_program"}}},{"name":"glam_signer","writable":true,"signer":true},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"cpi_program"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"stake_pool","writable":true},{"name":"validator_list","writable":true},{"name":"stake_pool_deposit_authority"},{"name":"stake_pool_withdraw_authority"},{"name":"deposit_stake","writable":true},{"name":"validator_stake_account","writable":true},{"name":"reserve_stake_account","writable":true},{"name":"pool_tokens_to","writable":true},{"name":"fee_account","writable":true},{"name":"pool_mint","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"},{"name":"token_program"},{"name":"stake_program","address":"Stake11111111111111111111111111111111111111"}],"args":[]},{"name":"withdraw_sol","discriminator":[145,131,74,136,65,137,42,38],"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"}],"program":{"kind":"account","path":"glam_protocol_program"}}},{"name":"glam_signer","writable":true,"signer":true},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"cpi_program"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"stake_pool","writable":true},{"name":"stake_pool_withdraw_authority"},{"name":"pool_tokens_from","writable":true},{"name":"reserve_stake","writable":true},{"name":"fee_account","writable":true},{"name":"pool_mint","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"stake_history","address":"SysvarStakeHistory1111111111111111111111111"},{"name":"stake_program","address":"Stake11111111111111111111111111111111111111"},{"name":"token_program"}],"args":[{"name":"pool_tokens","type":"u64"}]},{"name":"withdraw_stake","discriminator":[153,8,22,138,105,176,87,66],"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"}],"program":{"kind":"account","path":"glam_protocol_program"}}},{"name":"glam_signer","writable":true,"signer":true},{"name":"integration_authority","pda":{"seeds":[{"kind":"const","value":[105,110,116,101,103,114,97,116,105,111,110,45,97,117,116,104,111,114,105,116,121]}]}},{"name":"cpi_program"},{"name":"glam_protocol_program","address":"GLAMpaME8wdTEzxtiYEAa5yD8fZbxZiz2hNtV58RZiEz"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"stake_pool","writable":true},{"name":"validator_list","writable":true},{"name":"stake_pool_withdraw_authority"},{"name":"validator_stake_account","writable":true},{"name":"stake","writable":true},{"name":"pool_tokens_from","writable":true},{"name":"fee_account","writable":true},{"name":"pool_mint","writable":true},{"name":"clock","address":"SysvarC1ock11111111111111111111111111111111"},{"name":"token_program"},{"name":"stake_program","address":"Stake11111111111111111111111111111111111111"}],"args":[{"name":"pool_tokens","type":"u64"}]}],"accounts":[{"name":"StateAccount","discriminator":[142,247,54,95,85,133,249,103]}],"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":"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":"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":"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":"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":"TimeUnit","type":{"kind":"enum","variants":[{"name":"Second"},{"name":"Slot"}]}},{"name":"ValuationModel","type":{"kind":"enum","variants":[{"name":"Continuous"},{"name":"Periodic"}]}}],"constants":[{"name":"PROTO_SANCTUM","type":"u16","value":"2"},{"name":"PROTO_SANCTUM_MULTI","type":"u16","value":"4"},{"name":"PROTO_STAKE_POOL","type":"u16","value":"1"},{"name":"STAKE_POOL_PERM_DEPOSIT_SOL","type":"u64","value":"1"},{"name":"STAKE_POOL_PERM_DEPOSIT_STAKE","type":"u64","value":"2"},{"name":"STAKE_POOL_PERM_WITHDRAW_SOL","type":"u64","value":"4"},{"name":"STAKE_POOL_PERM_WITHDRAW_STAKE","type":"u64","value":"8"}]}');
|
|
156
156
|
|
|
157
157
|
/***/ }),
|
|
158
158
|
/* 13 */
|
|
@@ -1007,7 +1007,7 @@ async function fetchMintAndTokenProgram(connection, mintPubkey) {
|
|
|
1007
1007
|
|
|
1008
1008
|
|
|
1009
1009
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1010
|
-
exports.PROGRAM_AND_BITFLAG_BY_PROTOCOL_NAME = exports.PROTOCOL_NAME_BY_PROGRAM_AND_BITFLAG = exports.PROTOCOLS_AND_PERMISSIONS = exports.DRIFT_POOL_MAPPING = exports.CCTP_DOMAIN_MAPPING = exports.GLAM_REFERRER = exports.
|
|
1010
|
+
exports.PROGRAM_AND_BITFLAG_BY_PROTOCOL_NAME = exports.PROTOCOL_NAME_BY_PROGRAM_AND_BITFLAG = exports.PROTOCOLS_AND_PERMISSIONS = exports.DRIFT_POOL_MAPPING = exports.CCTP_DOMAIN_MAPPING = exports.GLAM_REFERRER = exports.MESSAGE_TRANSMITTER_V2 = exports.TOKEN_MESSENGER_MINTER_V2 = exports.ALT_PROGRAM_ID = exports.MEMO_PROGRAM = exports.KAMINO_FARM_PROGRAM = exports.KAMINO_VAULTS_PROGRAM = exports.KAMINO_LENDING_PROGRAM = exports.METEORA_DLMM_PROGRAM = exports.TRANSFER_HOOK_PROGRAM = exports.MERKLE_DISTRIBUTOR_PROGRAM = exports.JUP_VOTE_PROGRAM = exports.GOVERNANCE_PROGRAM_ID = exports.SANCTUM_STAKE_POOL_PROGRAM_ID = exports.JUPITER_PROGRAM_ID = exports.DRIFT_VAULTS_PROGRAM_ID = exports.DRIFT_PROGRAM_ID = exports.MARINADE_PROGRAM_ID = exports.JUP = exports.USDC_DEVNET = exports.USDC = exports.MSOL = exports.WSOL = exports.MARINADE_NATIVE_STAKE_AUTHORITY = exports.JITO_TIP_DEFAULT = exports.JUPITER_API_DEFAULT = exports.DRIFT_VAULT_DEPOSITOR_SIZE = exports.KAMINO_RESERVE_SIZE = exports.KAMINO_OBTRIGATION_SIZE = exports.METEORA_POSITION_SIZE = exports.STAKE_ACCOUNT_SIZE = exports.SEED_INTEGRATION_AUTHORITY = exports.SEED_GLOBAL_CONFIG = exports.SEED_EXTRA_ACCOUNT_METAS = exports.SEED_ACCOUNT_POLICY = exports.SEED_REQUEST_QUEUE = exports.SEED_ESCROW = exports.SEED_MINT = exports.SEED_METADATA = exports.SEED_VAULT = exports.SEED_STATE = void 0;
|
|
1011
1011
|
const web3_js_1 = __webpack_require__(16);
|
|
1012
1012
|
exports.SEED_STATE = "state"; // protocol program
|
|
1013
1013
|
exports.SEED_VAULT = "vault"; // protocol program
|
|
@@ -1026,7 +1026,6 @@ exports.KAMINO_RESERVE_SIZE = 8624;
|
|
|
1026
1026
|
exports.DRIFT_VAULT_DEPOSITOR_SIZE = 272;
|
|
1027
1027
|
exports.JUPITER_API_DEFAULT = "https://lite-api.jup.ag";
|
|
1028
1028
|
exports.JITO_TIP_DEFAULT = new web3_js_1.PublicKey("96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5");
|
|
1029
|
-
exports.KAMINO_SCOPE_PRICES = new web3_js_1.PublicKey("3NJYftD5sjVfxSnUdZ1wVML8f3aC6mp1CXCL6L7TnU8C");
|
|
1030
1029
|
exports.MARINADE_NATIVE_STAKE_AUTHORITY = new web3_js_1.PublicKey("stWirqFCf2Uts1JBL1Jsd3r6VBWhgnpdPxCTe1MFjrq");
|
|
1031
1030
|
/**
|
|
1032
1031
|
* Token mints. If no devnet version is defined, assume mainnet and devnet addresses are the same.
|
|
@@ -1046,7 +1045,6 @@ exports.JUP = new web3_js_1.PublicKey("JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDv
|
|
|
1046
1045
|
exports.MARINADE_PROGRAM_ID = new web3_js_1.PublicKey("MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD");
|
|
1047
1046
|
exports.DRIFT_PROGRAM_ID = new web3_js_1.PublicKey("dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH");
|
|
1048
1047
|
exports.DRIFT_VAULTS_PROGRAM_ID = new web3_js_1.PublicKey("vAuLTsyrvSfZRuRB3XgvkPwNGgYSs9YRYymVebLKoxR");
|
|
1049
|
-
exports.DRIFT_DISTRIBUTOR_PROGRAM = new web3_js_1.PublicKey("E7HtfkEMhmn9uwL7EFNydcXBWy5WCYN1vFmKKjipEH1x");
|
|
1050
1048
|
exports.JUPITER_PROGRAM_ID = new web3_js_1.PublicKey("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4");
|
|
1051
1049
|
exports.SANCTUM_STAKE_POOL_PROGRAM_ID = new web3_js_1.PublicKey("SP12tWFxD9oJsVWNavTTBZvMbA6gkAmxtVgxdqvyvhY");
|
|
1052
1050
|
exports.GOVERNANCE_PROGRAM_ID = new web3_js_1.PublicKey("GovaE4iu227srtG2s3tZzB4RmWBzw8sTwrCLZz7kN7rY");
|
|
@@ -1061,11 +1059,6 @@ exports.MEMO_PROGRAM = new web3_js_1.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWC
|
|
|
1061
1059
|
exports.ALT_PROGRAM_ID = new web3_js_1.PublicKey("AddressLookupTab1e1111111111111111111111111");
|
|
1062
1060
|
exports.TOKEN_MESSENGER_MINTER_V2 = new web3_js_1.PublicKey("CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe");
|
|
1063
1061
|
exports.MESSAGE_TRANSMITTER_V2 = new web3_js_1.PublicKey("CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC");
|
|
1064
|
-
/**
|
|
1065
|
-
* Stake pools
|
|
1066
|
-
*/
|
|
1067
|
-
exports.JITO_STAKE_POOL = new web3_js_1.PublicKey("Jito4APyf642JPZPx3hGc6WWJ8zPKtRbRs4P815Awbb");
|
|
1068
|
-
exports.JUPSOL_STAKE_POOL = new web3_js_1.PublicKey("8VpRhuxa7sUUepdY3kQiTmX9rS5vx4WgaXiAnXq4KCtr");
|
|
1069
1062
|
/**
|
|
1070
1063
|
* Referrers
|
|
1071
1064
|
*/
|
|
@@ -4057,8 +4050,11 @@ class BaseTxBuilder {
|
|
|
4057
4050
|
constructor(base) {
|
|
4058
4051
|
this.base = base;
|
|
4059
4052
|
}
|
|
4060
|
-
|
|
4061
|
-
|
|
4053
|
+
/**
|
|
4054
|
+
* Build a transaction with the given instructions. Pre and post instructions in txOptions are preserved.
|
|
4055
|
+
*/
|
|
4056
|
+
build(ixs, txOptions = {}) {
|
|
4057
|
+
const tx = new web3_js_1.Transaction().add(...(txOptions.preInstructions || []), ...ixs, ...(txOptions.postInstructions || []));
|
|
4062
4058
|
return tx;
|
|
4063
4059
|
}
|
|
4064
4060
|
}
|
|
@@ -4096,122 +4092,485 @@ const web3_js_1 = __webpack_require__(16);
|
|
|
4096
4092
|
const types_1 = __webpack_require__(43);
|
|
4097
4093
|
const driftLayouts_1 = __webpack_require__(55);
|
|
4098
4094
|
const user_1 = __webpack_require__(45);
|
|
4095
|
+
const base_1 = __webpack_require__(52);
|
|
4099
4096
|
const constants_1 = __webpack_require__(25);
|
|
4100
4097
|
const spl_token_1 = __webpack_require__(17);
|
|
4101
4098
|
const anchor_1 = __webpack_require__(4);
|
|
4102
4099
|
const common_1 = __webpack_require__(19);
|
|
4103
4100
|
const DRIFT_SIGNER = new web3_js_1.PublicKey("JCNCMFXo5M5qwUPg2Utu1u6YWp3MbygxqBsBeXXJfrw");
|
|
4104
4101
|
const DRIFT_MARGIN_PRECISION = 10000;
|
|
4105
|
-
class
|
|
4106
|
-
constructor(base, vault) {
|
|
4102
|
+
class TxBuilder extends base_1.BaseTxBuilder {
|
|
4103
|
+
constructor(base, vault, drift) {
|
|
4104
|
+
super(base);
|
|
4107
4105
|
this.base = base;
|
|
4108
4106
|
this.vault = vault;
|
|
4109
|
-
this.
|
|
4110
|
-
this.perpMarkets = new Map();
|
|
4111
|
-
this.marketConfigs = null;
|
|
4112
|
-
/*
|
|
4113
|
-
* Utils
|
|
4114
|
-
*/
|
|
4115
|
-
this.getMarketPda = (marketType, marketIndex) => web3_js_1.PublicKey.findProgramAddressSync([
|
|
4116
|
-
Buffer.from(`${marketType === types_1.MarketType.PERP ? "perp" : "spot"}_market`),
|
|
4117
|
-
new anchor.BN(marketIndex).toArrayLike(Buffer, "le", 2),
|
|
4118
|
-
], constants_1.DRIFT_PROGRAM_ID)[0];
|
|
4119
|
-
this.getUserPda = (authority, subAccountId = 0) => web3_js_1.PublicKey.findProgramAddressSync([
|
|
4120
|
-
Buffer.from("user"),
|
|
4121
|
-
authority.toBuffer(),
|
|
4122
|
-
new anchor.BN(subAccountId).toArrayLike(Buffer, "le", 2),
|
|
4123
|
-
], constants_1.DRIFT_PROGRAM_ID)[0];
|
|
4124
|
-
this.getUserStatsPda = (authority) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("user_stats"), authority.toBuffer()], constants_1.DRIFT_PROGRAM_ID)[0];
|
|
4125
|
-
this.marketTypeEquals = (a, b) => a && Object.keys(a)[0] === Object.keys(b)[0];
|
|
4107
|
+
this.drift = drift;
|
|
4126
4108
|
}
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4109
|
+
async initializeUserStatsIx(glamSigner) {
|
|
4110
|
+
const { userStats } = this.drift.getDriftUserPdas();
|
|
4111
|
+
return await this.base.extDriftProgram.methods
|
|
4112
|
+
.initializeUserStats()
|
|
4113
|
+
.accounts({
|
|
4114
|
+
glamState: this.base.statePda,
|
|
4115
|
+
glamSigner,
|
|
4116
|
+
state: this.drift.driftStatePda,
|
|
4117
|
+
userStats,
|
|
4118
|
+
})
|
|
4119
|
+
.instruction();
|
|
4133
4120
|
}
|
|
4134
|
-
async
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4121
|
+
async initializeUserIx(glamSigner, subAccountId) {
|
|
4122
|
+
const name = `GLAM *.+ ${subAccountId}`
|
|
4123
|
+
.split("")
|
|
4124
|
+
.map((char) => char.charCodeAt(0))
|
|
4125
|
+
.concat(Array(24).fill(0));
|
|
4126
|
+
const { user, userStats } = this.drift.getDriftUserPdas(subAccountId);
|
|
4127
|
+
const { user: referrer, userStats: referrerStats } = this.drift.getGlamReferrerPdas();
|
|
4128
|
+
const remainingAccounts = [
|
|
4129
|
+
{ pubkey: referrer, isWritable: true, isSigner: false },
|
|
4130
|
+
{ pubkey: referrerStats, isWritable: true, isSigner: false },
|
|
4131
|
+
];
|
|
4132
|
+
return await this.base.extDriftProgram.methods
|
|
4133
|
+
.initializeUser(subAccountId, name)
|
|
4134
|
+
.accounts({
|
|
4135
|
+
glamState: this.base.statePda,
|
|
4136
|
+
user,
|
|
4137
|
+
userStats,
|
|
4138
|
+
state: this.drift.driftStatePda,
|
|
4139
|
+
glamSigner,
|
|
4140
|
+
})
|
|
4141
|
+
.remainingAccounts(remainingAccounts)
|
|
4142
|
+
.instruction();
|
|
4138
4143
|
}
|
|
4139
|
-
async
|
|
4140
|
-
const
|
|
4141
|
-
return await this.base.
|
|
4144
|
+
async updateUserPoolIdIx(subAccountId, poolId) {
|
|
4145
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4146
|
+
return await this.base.extDriftProgram.methods
|
|
4147
|
+
.updateUserPoolId(subAccountId, poolId)
|
|
4148
|
+
.accounts({
|
|
4149
|
+
glamState: this.base.statePda,
|
|
4150
|
+
user,
|
|
4151
|
+
})
|
|
4152
|
+
.instruction();
|
|
4142
4153
|
}
|
|
4143
|
-
async
|
|
4144
|
-
const
|
|
4145
|
-
|
|
4154
|
+
async initializeIxs(subAccountId, glamSigner) {
|
|
4155
|
+
const ixs = [];
|
|
4156
|
+
// Create userStats account if it doesn't exist
|
|
4157
|
+
const { userStats } = this.drift.getDriftUserPdas();
|
|
4158
|
+
const userStatsInfo = await this.base.provider.connection.getAccountInfo(userStats);
|
|
4159
|
+
if (!userStatsInfo) {
|
|
4160
|
+
ixs.push(await this.initializeUserStatsIx(glamSigner));
|
|
4161
|
+
}
|
|
4162
|
+
// Initialize user (aka sub-account)
|
|
4163
|
+
ixs.push(await this.initializeUserIx(glamSigner, subAccountId));
|
|
4164
|
+
return ixs;
|
|
4146
4165
|
}
|
|
4147
|
-
async
|
|
4148
|
-
const
|
|
4149
|
-
|
|
4166
|
+
async initializeTx(subAccountId, txOptions = {}) {
|
|
4167
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4168
|
+
const ixs = await this.initializeIxs(subAccountId, glamSigner);
|
|
4169
|
+
const tx = this.build(ixs, txOptions);
|
|
4170
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4150
4171
|
}
|
|
4151
|
-
async
|
|
4152
|
-
const
|
|
4153
|
-
|
|
4172
|
+
async depositIxs(amount, marketIndex, subAccountId, glamSigner) {
|
|
4173
|
+
const { user, userStats } = this.drift.getDriftUserPdas(subAccountId);
|
|
4174
|
+
const { mint, oracle, tokenProgram, marketPda, vault: driftVault, name, } = await this.drift.fetchAndParseSpotMarket(marketIndex);
|
|
4175
|
+
console.log(`Spot market ${marketIndex} mint ${mint}, oracle: ${oracle}, marketPda: ${marketPda}, vault: ${driftVault}`);
|
|
4176
|
+
const preInstructions = [];
|
|
4177
|
+
const postInstructions = [];
|
|
4178
|
+
// If drift user doesn't exist, prepend initialization ixs
|
|
4179
|
+
if (!(await this.drift.fetchDriftUser(subAccountId))) {
|
|
4180
|
+
// Only add ix to initialize user stats if subAccountId is 0
|
|
4181
|
+
if (subAccountId === 0) {
|
|
4182
|
+
preInstructions.push(await this.initializeUserStatsIx(glamSigner));
|
|
4183
|
+
}
|
|
4184
|
+
preInstructions.push(await this.initializeUserIx(glamSigner, subAccountId));
|
|
4185
|
+
// If market name ends with "-N", it means we're depositing to an isolated pool
|
|
4186
|
+
const isolatedPoolMatch = name.match(/-(\d+)$/);
|
|
4187
|
+
if (isolatedPoolMatch) {
|
|
4188
|
+
const poolId = parseInt(isolatedPoolMatch[1]);
|
|
4189
|
+
preInstructions.push(await this.updateUserPoolIdIx(subAccountId, poolId));
|
|
4190
|
+
}
|
|
4191
|
+
}
|
|
4192
|
+
if (mint.equals(constants_1.WSOL)) {
|
|
4193
|
+
const wrapSolIxs = await this.vault.maybeWrapSol(amount, glamSigner);
|
|
4194
|
+
preInstructions.push(...wrapSolIxs);
|
|
4195
|
+
// If we need to wrap SOL, it means the wSOL balance will be drained,
|
|
4196
|
+
// and we close the wSOL token account for convenience
|
|
4197
|
+
const tokenAccount = this.base.getVaultAta(constants_1.WSOL);
|
|
4198
|
+
const closeTokenAccountIx = await this.base.extSplProgram.methods
|
|
4199
|
+
.tokenCloseAccount()
|
|
4200
|
+
.accounts({
|
|
4201
|
+
glamState: this.base.statePda,
|
|
4202
|
+
glamSigner,
|
|
4203
|
+
tokenAccount,
|
|
4204
|
+
cpiProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4205
|
+
})
|
|
4206
|
+
.instruction();
|
|
4207
|
+
postInstructions.push(closeTokenAccountIx);
|
|
4208
|
+
}
|
|
4209
|
+
const remainingAccounts = [
|
|
4210
|
+
{ pubkey: new web3_js_1.PublicKey(oracle), isSigner: false, isWritable: false },
|
|
4211
|
+
{ pubkey: new web3_js_1.PublicKey(marketPda), isSigner: false, isWritable: true },
|
|
4212
|
+
];
|
|
4213
|
+
if (tokenProgram.equals(spl_token_1.TOKEN_2022_PROGRAM_ID)) {
|
|
4214
|
+
remainingAccounts.push({
|
|
4215
|
+
pubkey: mint,
|
|
4216
|
+
isSigner: false,
|
|
4217
|
+
isWritable: false,
|
|
4218
|
+
});
|
|
4219
|
+
}
|
|
4220
|
+
const ix = await this.base.extDriftProgram.methods
|
|
4221
|
+
.deposit(marketIndex, amount, false)
|
|
4222
|
+
.accounts({
|
|
4223
|
+
glamState: this.base.statePda,
|
|
4224
|
+
glamSigner,
|
|
4225
|
+
state: this.drift.driftStatePda,
|
|
4226
|
+
user,
|
|
4227
|
+
userStats,
|
|
4228
|
+
spotMarketVault: driftVault,
|
|
4229
|
+
userTokenAccount: this.base.getVaultAta(mint, tokenProgram),
|
|
4230
|
+
tokenProgram,
|
|
4231
|
+
})
|
|
4232
|
+
.remainingAccounts(remainingAccounts)
|
|
4233
|
+
.instruction();
|
|
4234
|
+
return [...preInstructions, ix, ...postInstructions];
|
|
4154
4235
|
}
|
|
4155
|
-
async
|
|
4156
|
-
const
|
|
4157
|
-
|
|
4236
|
+
async depositTx(amount, marketIndex, subAccountId, txOptions = {}) {
|
|
4237
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4238
|
+
const ixs = await this.depositIxs(amount, marketIndex, subAccountId, glamSigner);
|
|
4239
|
+
const tx = this.build(ixs, txOptions);
|
|
4240
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4158
4241
|
}
|
|
4159
|
-
async
|
|
4160
|
-
const
|
|
4161
|
-
|
|
4242
|
+
async withdrawIxs(amount, marketIndex, subAccountId, glamSigner) {
|
|
4243
|
+
const { user, userStats } = this.drift.getDriftUserPdas(subAccountId);
|
|
4244
|
+
const { mint, tokenProgram, vault: driftVault, } = await this.drift.fetchAndParseSpotMarket(marketIndex);
|
|
4245
|
+
const glamVault = this.base.vaultPda;
|
|
4246
|
+
const glamVaultAta = this.base.getVaultAta(mint, tokenProgram);
|
|
4247
|
+
const remainingAccounts = await this.drift.composeRemainingAccounts(subAccountId, types_1.MarketType.SPOT, marketIndex);
|
|
4248
|
+
if (tokenProgram.equals(spl_token_1.TOKEN_2022_PROGRAM_ID)) {
|
|
4249
|
+
remainingAccounts.push({
|
|
4250
|
+
pubkey: mint,
|
|
4251
|
+
isSigner: false,
|
|
4252
|
+
isWritable: false,
|
|
4253
|
+
});
|
|
4254
|
+
}
|
|
4255
|
+
// Create vault ata in case it doesn't exist
|
|
4256
|
+
const preIx = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(glamSigner, glamVaultAta, glamVault, mint, tokenProgram);
|
|
4257
|
+
const ix = await this.base.extDriftProgram.methods
|
|
4258
|
+
.withdraw(marketIndex, amount, false)
|
|
4259
|
+
.accounts({
|
|
4260
|
+
glamState: this.base.statePda,
|
|
4261
|
+
glamSigner,
|
|
4262
|
+
state: this.drift.driftStatePda,
|
|
4263
|
+
user,
|
|
4264
|
+
userStats,
|
|
4265
|
+
spotMarketVault: driftVault,
|
|
4266
|
+
userTokenAccount: glamVaultAta,
|
|
4267
|
+
driftSigner: DRIFT_SIGNER,
|
|
4268
|
+
tokenProgram,
|
|
4269
|
+
})
|
|
4270
|
+
.remainingAccounts(remainingAccounts)
|
|
4271
|
+
.instruction();
|
|
4272
|
+
return [preIx, ix];
|
|
4162
4273
|
}
|
|
4163
|
-
async
|
|
4164
|
-
const
|
|
4165
|
-
|
|
4274
|
+
async withdrawTx(amount, marketIndex, subAccountId, txOptions = {}) {
|
|
4275
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4276
|
+
const ixs = await this.withdrawIxs(amount, marketIndex, subAccountId, glamSigner);
|
|
4277
|
+
const tx = this.build(ixs, txOptions);
|
|
4278
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4166
4279
|
}
|
|
4167
|
-
async
|
|
4168
|
-
|
|
4169
|
-
|
|
4280
|
+
async updateUserCustomMarginRatioIx(maxLeverage, // 1=1x, 2=2x ... 50=50x leverage
|
|
4281
|
+
subAccountId, glamSigner) {
|
|
4282
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4283
|
+
// https://github.com/drift-labs/protocol-v2/blob/babed162b08b1fe34e49a81c5aa3e4ec0a88ecdf/programs/drift/src/math/constants.rs#L183-L184
|
|
4284
|
+
// 0 means No Limit
|
|
4285
|
+
const marginRatio = maxLeverage === 0 ? 0 : DRIFT_MARGIN_PRECISION / maxLeverage;
|
|
4286
|
+
return await this.base.extDriftProgram.methods
|
|
4287
|
+
.updateUserCustomMarginRatio(subAccountId, marginRatio)
|
|
4288
|
+
.accounts({
|
|
4289
|
+
glamState: this.base.statePda,
|
|
4290
|
+
glamSigner,
|
|
4291
|
+
user,
|
|
4292
|
+
})
|
|
4293
|
+
.instruction();
|
|
4170
4294
|
}
|
|
4171
|
-
async
|
|
4172
|
-
|
|
4173
|
-
|
|
4295
|
+
async updateUserCustomMarginRatioTx(maxLeverage, // 1=1x, 2=2x ... 50=50x leverage
|
|
4296
|
+
subAccountId = 0, txOptions = {}) {
|
|
4297
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4298
|
+
const ix = await this.updateUserCustomMarginRatioIx(maxLeverage, subAccountId, glamSigner);
|
|
4299
|
+
const tx = this.build([ix], txOptions);
|
|
4300
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4174
4301
|
}
|
|
4175
|
-
async
|
|
4176
|
-
const
|
|
4177
|
-
return await this.base.
|
|
4302
|
+
async updateUserMarginTradingEnabledIx(marginTradingEnabled, subAccountId, glamSigner) {
|
|
4303
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4304
|
+
return await this.base.extDriftProgram.methods
|
|
4305
|
+
.updateUserMarginTradingEnabled(subAccountId, marginTradingEnabled)
|
|
4306
|
+
.accounts({
|
|
4307
|
+
glamState: this.base.statePda,
|
|
4308
|
+
glamSigner,
|
|
4309
|
+
user,
|
|
4310
|
+
})
|
|
4311
|
+
.instruction();
|
|
4178
4312
|
}
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4313
|
+
async updateUserMarginTradingEnabledTx(marginTradingEnabled, subAccountId = 0, txOptions = {}) {
|
|
4314
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4315
|
+
const ix = await this.updateUserMarginTradingEnabledIx(marginTradingEnabled, subAccountId, glamSigner);
|
|
4316
|
+
const tx = this.build([ix], txOptions);
|
|
4317
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4184
4318
|
}
|
|
4185
|
-
|
|
4186
|
-
const
|
|
4187
|
-
return
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
}
|
|
4319
|
+
async updateUserDelegateIx(delegate, subAccountId, glamSigner) {
|
|
4320
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4321
|
+
return await this.base.extDriftProgram.methods
|
|
4322
|
+
.updateUserDelegate(subAccountId, new web3_js_1.PublicKey(delegate))
|
|
4323
|
+
.accounts({
|
|
4324
|
+
glamState: this.base.statePda,
|
|
4325
|
+
glamSigner,
|
|
4326
|
+
user,
|
|
4327
|
+
})
|
|
4328
|
+
.instruction();
|
|
4194
4329
|
}
|
|
4195
|
-
|
|
4196
|
-
const
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
poolId: driftSpotMarket.poolId,
|
|
4201
|
-
marketPda: driftSpotMarket.marketPda,
|
|
4202
|
-
oracle: driftSpotMarket.oracle,
|
|
4203
|
-
oracleSource: types_1.OracleSource.get(driftSpotMarket.oracleSource),
|
|
4204
|
-
vault: driftSpotMarket.vault,
|
|
4205
|
-
mint: driftSpotMarket.mint,
|
|
4206
|
-
decimals: driftSpotMarket.decimals,
|
|
4207
|
-
tokenProgram: driftSpotMarket.tokenProgram === 0
|
|
4208
|
-
? spl_token_1.TOKEN_PROGRAM_ID
|
|
4209
|
-
: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
4210
|
-
cumulativeDepositInterest: driftSpotMarket.cumulativeDepositInterest,
|
|
4211
|
-
cumulativeBorrowInterest: driftSpotMarket.cumulativeBorrowInterest,
|
|
4212
|
-
};
|
|
4330
|
+
async updateUserDelegateTx(delegate, subAccountId = 0, txOptions = {}) {
|
|
4331
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4332
|
+
const ix = await this.updateUserDelegateIx(delegate, subAccountId, glamSigner);
|
|
4333
|
+
const tx = this.build([ix], txOptions);
|
|
4334
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4213
4335
|
}
|
|
4214
|
-
|
|
4336
|
+
async deleteUserIx(subAccountId, glamSigner) {
|
|
4337
|
+
const { user, userStats } = this.drift.getDriftUserPdas(subAccountId);
|
|
4338
|
+
return await this.base.extDriftProgram.methods
|
|
4339
|
+
.deleteUser()
|
|
4340
|
+
.accounts({
|
|
4341
|
+
glamState: this.base.statePda,
|
|
4342
|
+
state: this.drift.driftStatePda,
|
|
4343
|
+
user,
|
|
4344
|
+
userStats,
|
|
4345
|
+
glamSigner,
|
|
4346
|
+
})
|
|
4347
|
+
.instruction();
|
|
4348
|
+
}
|
|
4349
|
+
async deleteUserTx(subAccountId, txOptions = {}) {
|
|
4350
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4351
|
+
const ix = await this.deleteUserIx(subAccountId, glamSigner);
|
|
4352
|
+
const tx = this.build([ix], txOptions);
|
|
4353
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4354
|
+
}
|
|
4355
|
+
async placeOrderIx(orderParams, subAccountId, glamSigner) {
|
|
4356
|
+
const { marketIndex, marketType } = orderParams;
|
|
4357
|
+
const { user: referrer, userStats: referrerStats } = this.drift.getGlamReferrerPdas();
|
|
4358
|
+
const remainingAccounts = (await this.drift.composeRemainingAccounts(subAccountId, marketType, marketIndex)).concat([
|
|
4359
|
+
{ pubkey: referrer, isWritable: true, isSigner: false },
|
|
4360
|
+
{ pubkey: referrerStats, isWritable: true, isSigner: false },
|
|
4361
|
+
]);
|
|
4362
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4363
|
+
return await this.base.extDriftProgram.methods
|
|
4364
|
+
.placeOrders([orderParams])
|
|
4365
|
+
.accounts({
|
|
4366
|
+
glamState: this.base.statePda,
|
|
4367
|
+
glamSigner,
|
|
4368
|
+
user,
|
|
4369
|
+
state: this.drift.driftStatePda,
|
|
4370
|
+
})
|
|
4371
|
+
.remainingAccounts(remainingAccounts)
|
|
4372
|
+
.instruction();
|
|
4373
|
+
}
|
|
4374
|
+
async placeOrderTx(orderParams, subAccountId, txOptions = {}) {
|
|
4375
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4376
|
+
const ix = await this.placeOrderIx(orderParams, subAccountId, glamSigner);
|
|
4377
|
+
const tx = this.build([ix], txOptions);
|
|
4378
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4379
|
+
}
|
|
4380
|
+
async modifyOrderIx(modifyOrderParams, orderId, marketIndex, marketType, subAccountId, glamSigner) {
|
|
4381
|
+
const remainingAccounts = await this.drift.composeRemainingAccounts(subAccountId, marketType, marketIndex);
|
|
4382
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4383
|
+
return await this.base.extDriftProgram.methods
|
|
4384
|
+
.modifyOrder(orderId, modifyOrderParams)
|
|
4385
|
+
.accounts({
|
|
4386
|
+
glamState: this.base.statePda,
|
|
4387
|
+
glamSigner,
|
|
4388
|
+
user,
|
|
4389
|
+
state: this.drift.driftStatePda,
|
|
4390
|
+
})
|
|
4391
|
+
.remainingAccounts(remainingAccounts)
|
|
4392
|
+
.instruction();
|
|
4393
|
+
}
|
|
4394
|
+
async modifyOrderTx(modifyOrderParams, orderId, marketIndex, marketType, subAccountId, txOptions = {}) {
|
|
4395
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4396
|
+
const ix = await this.modifyOrderIx(modifyOrderParams, orderId, marketIndex, marketType, subAccountId, glamSigner);
|
|
4397
|
+
const tx = this.build([ix], txOptions);
|
|
4398
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4399
|
+
}
|
|
4400
|
+
async cancelOrdersIx(marketType, marketIndex, direction, subAccountId, glamSigner) {
|
|
4401
|
+
const remainingAccounts = await this.drift.composeRemainingAccounts(subAccountId, marketType, marketIndex);
|
|
4402
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4403
|
+
return await this.base.extDriftProgram.methods
|
|
4404
|
+
.cancelOrders(marketType, marketIndex, direction)
|
|
4405
|
+
.accounts({
|
|
4406
|
+
glamState: this.base.statePda,
|
|
4407
|
+
glamSigner,
|
|
4408
|
+
user,
|
|
4409
|
+
state: this.drift.driftStatePda,
|
|
4410
|
+
})
|
|
4411
|
+
.remainingAccounts(remainingAccounts)
|
|
4412
|
+
.instruction();
|
|
4413
|
+
}
|
|
4414
|
+
async cancelOrdersTx(marketType, marketIndex, direction, subAccountId = 0, txOptions = {}) {
|
|
4415
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4416
|
+
const ix = await this.cancelOrdersIx(marketType, marketIndex, direction, subAccountId, glamSigner);
|
|
4417
|
+
const tx = this.build([ix], txOptions);
|
|
4418
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4419
|
+
}
|
|
4420
|
+
async cancelOrdersByIdsIx(orderIds, subAccountId, glamSigner) {
|
|
4421
|
+
const remainingAccounts = await this.drift.composeRemainingAccounts(subAccountId);
|
|
4422
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4423
|
+
return await this.base.extDriftProgram.methods
|
|
4424
|
+
.cancelOrdersByIds(orderIds)
|
|
4425
|
+
.accounts({
|
|
4426
|
+
glamState: this.base.statePda,
|
|
4427
|
+
glamSigner,
|
|
4428
|
+
user,
|
|
4429
|
+
state: this.drift.driftStatePda,
|
|
4430
|
+
})
|
|
4431
|
+
.remainingAccounts(remainingAccounts)
|
|
4432
|
+
.instruction();
|
|
4433
|
+
}
|
|
4434
|
+
async cancelOrdersByIdsTx(orderIds, subAccountId = 0, txOptions = {}) {
|
|
4435
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4436
|
+
const ix = await this.cancelOrdersByIdsIx(orderIds, subAccountId, glamSigner);
|
|
4437
|
+
const tx = this.build([ix], txOptions);
|
|
4438
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4439
|
+
}
|
|
4440
|
+
async settlePnlIx(marketIndex, subAccountId, glamSigner) {
|
|
4441
|
+
const { vault: driftVault } = await this.drift.fetchAndParseSpotMarket(0);
|
|
4442
|
+
const remainingAccounts = await this.drift.composeRemainingAccounts(subAccountId, types_1.MarketType.PERP, marketIndex);
|
|
4443
|
+
const { user } = this.drift.getDriftUserPdas(subAccountId);
|
|
4444
|
+
return await this.base.extDriftProgram.methods
|
|
4445
|
+
.settlePnl(marketIndex)
|
|
4446
|
+
.accounts({
|
|
4447
|
+
glamState: this.base.statePda,
|
|
4448
|
+
glamSigner,
|
|
4449
|
+
user,
|
|
4450
|
+
state: this.drift.driftStatePda,
|
|
4451
|
+
spotMarketVault: driftVault,
|
|
4452
|
+
})
|
|
4453
|
+
.remainingAccounts(remainingAccounts)
|
|
4454
|
+
.instruction();
|
|
4455
|
+
}
|
|
4456
|
+
async settlePnlTx(marketIndex, subAccountId = 0, txOptions = {}) {
|
|
4457
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
4458
|
+
const ix = await this.settlePnlIx(marketIndex, subAccountId, glamSigner);
|
|
4459
|
+
const tx = this.build([ix], txOptions);
|
|
4460
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4461
|
+
}
|
|
4462
|
+
}
|
|
4463
|
+
class DriftClient {
|
|
4464
|
+
constructor(base, vault) {
|
|
4465
|
+
this.base = base;
|
|
4466
|
+
this.vault = vault;
|
|
4467
|
+
this.spotMarkets = new Map();
|
|
4468
|
+
this.perpMarkets = new Map();
|
|
4469
|
+
this.marketConfigs = null;
|
|
4470
|
+
/*
|
|
4471
|
+
* Utils
|
|
4472
|
+
*/
|
|
4473
|
+
this.getMarketPda = (marketType, marketIndex) => web3_js_1.PublicKey.findProgramAddressSync([
|
|
4474
|
+
Buffer.from(`${marketType === types_1.MarketType.PERP ? "perp" : "spot"}_market`),
|
|
4475
|
+
new anchor.BN(marketIndex).toArrayLike(Buffer, "le", 2),
|
|
4476
|
+
], constants_1.DRIFT_PROGRAM_ID)[0];
|
|
4477
|
+
this.getUserPda = (authority, subAccountId = 0) => web3_js_1.PublicKey.findProgramAddressSync([
|
|
4478
|
+
Buffer.from("user"),
|
|
4479
|
+
authority.toBuffer(),
|
|
4480
|
+
new anchor.BN(subAccountId).toArrayLike(Buffer, "le", 2),
|
|
4481
|
+
], constants_1.DRIFT_PROGRAM_ID)[0];
|
|
4482
|
+
this.getUserStatsPda = (authority) => web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("user_stats"), authority.toBuffer()], constants_1.DRIFT_PROGRAM_ID)[0];
|
|
4483
|
+
this.marketTypeEquals = (a, b) => a && Object.keys(a)[0] === Object.keys(b)[0];
|
|
4484
|
+
this.txBuilder = new TxBuilder(base, vault, this);
|
|
4485
|
+
}
|
|
4486
|
+
/*
|
|
4487
|
+
* Client methods
|
|
4488
|
+
*/
|
|
4489
|
+
async initialize(subAccountId = 0, txOptions = {}) {
|
|
4490
|
+
const tx = await this.txBuilder.initializeTx(subAccountId, txOptions);
|
|
4491
|
+
return await this.base.sendAndConfirm(tx);
|
|
4492
|
+
}
|
|
4493
|
+
async updateUserCustomMarginRatio(maxLeverage, // 1=1x, 2=2x ... 50=50x leverage
|
|
4494
|
+
subAccountId = 0) {
|
|
4495
|
+
const tx = await this.txBuilder.updateUserCustomMarginRatioTx(maxLeverage, subAccountId);
|
|
4496
|
+
return await this.base.sendAndConfirm(tx);
|
|
4497
|
+
}
|
|
4498
|
+
async updateUserMarginTradingEnabled(marginTradingEnabled, subAccountId = 0, txOptions = {}) {
|
|
4499
|
+
const tx = await this.txBuilder.updateUserMarginTradingEnabledTx(marginTradingEnabled, subAccountId, txOptions);
|
|
4500
|
+
return await this.base.sendAndConfirm(tx);
|
|
4501
|
+
}
|
|
4502
|
+
async updateUserDelegate(delegate, subAccountId = 0) {
|
|
4503
|
+
const tx = await this.txBuilder.updateUserDelegateTx(new web3_js_1.PublicKey(delegate), subAccountId);
|
|
4504
|
+
return await this.base.sendAndConfirm(tx);
|
|
4505
|
+
}
|
|
4506
|
+
async deleteUser(subAccountId = 0, txOptions = {}) {
|
|
4507
|
+
const tx = await this.txBuilder.deleteUserTx(subAccountId, txOptions);
|
|
4508
|
+
return await this.base.sendAndConfirm(tx);
|
|
4509
|
+
}
|
|
4510
|
+
async deposit(amount, marketIndex = 1, subAccountId = 0, txOptions = {}) {
|
|
4511
|
+
const tx = await this.txBuilder.depositTx(amount, marketIndex, subAccountId, txOptions);
|
|
4512
|
+
return await this.base.sendAndConfirm(tx);
|
|
4513
|
+
}
|
|
4514
|
+
async withdraw(amount, marketIndex = 1, subAccountId = 0, txOptions = {}) {
|
|
4515
|
+
const tx = await this.txBuilder.withdrawTx(amount, marketIndex, subAccountId, txOptions);
|
|
4516
|
+
return await this.base.sendAndConfirm(tx);
|
|
4517
|
+
}
|
|
4518
|
+
async placeOrder(orderParams, subAccountId = 0, txOptions = {}) {
|
|
4519
|
+
const tx = await this.txBuilder.placeOrderTx(orderParams, subAccountId, txOptions);
|
|
4520
|
+
return await this.base.sendAndConfirm(tx);
|
|
4521
|
+
}
|
|
4522
|
+
async modifyOrder(modifyOrderParams, orderId, marketIndex, marketType, subAccountId = 0, txOptions = {}) {
|
|
4523
|
+
const tx = await this.txBuilder.modifyOrderTx(modifyOrderParams, orderId, marketIndex, marketType, subAccountId, txOptions);
|
|
4524
|
+
return await this.base.sendAndConfirm(tx);
|
|
4525
|
+
}
|
|
4526
|
+
async cancelOrders(marketType, marketIndex, direction, subAccountId = 0, txOptions = {}) {
|
|
4527
|
+
const tx = await this.txBuilder.cancelOrdersTx(marketType, marketIndex, direction, subAccountId, txOptions);
|
|
4528
|
+
return await this.base.sendAndConfirm(tx);
|
|
4529
|
+
}
|
|
4530
|
+
async cancelOrdersByIds(orderIds, subAccountId = 0, txOptions = {}) {
|
|
4531
|
+
const tx = await this.txBuilder.cancelOrdersByIdsTx(orderIds, subAccountId, txOptions);
|
|
4532
|
+
return await this.base.sendAndConfirm(tx);
|
|
4533
|
+
}
|
|
4534
|
+
async settlePnl(marketIndex, subAccountId = 0, txOptions = {}) {
|
|
4535
|
+
const tx = await this.txBuilder.settlePnlTx(marketIndex, subAccountId, txOptions);
|
|
4536
|
+
return await this.base.sendAndConfirm(tx);
|
|
4537
|
+
}
|
|
4538
|
+
getGlamReferrerPdas() {
|
|
4539
|
+
return {
|
|
4540
|
+
user: this.getUserPda(constants_1.GLAM_REFERRER, 0),
|
|
4541
|
+
userStats: this.getUserStatsPda(constants_1.GLAM_REFERRER),
|
|
4542
|
+
};
|
|
4543
|
+
}
|
|
4544
|
+
parsePerpMarket(address, data) {
|
|
4545
|
+
const perpMarket = driftLayouts_1.DriftPerpMarket.decode(address, data);
|
|
4546
|
+
return {
|
|
4547
|
+
name: perpMarket.nameStr,
|
|
4548
|
+
marketPda: perpMarket.marketPda,
|
|
4549
|
+
marketIndex: perpMarket.marketIndex,
|
|
4550
|
+
oracle: perpMarket.oracle,
|
|
4551
|
+
oracleSource: types_1.OracleSource.get(perpMarket.oracleSource),
|
|
4552
|
+
};
|
|
4553
|
+
}
|
|
4554
|
+
parseSpotMarket(address, data) {
|
|
4555
|
+
const driftSpotMarket = driftLayouts_1.DriftSpotMarket.decode(address, data);
|
|
4556
|
+
return {
|
|
4557
|
+
name: driftSpotMarket.nameStr,
|
|
4558
|
+
marketIndex: driftSpotMarket.marketIndex,
|
|
4559
|
+
poolId: driftSpotMarket.poolId,
|
|
4560
|
+
marketPda: driftSpotMarket.marketPda,
|
|
4561
|
+
oracle: driftSpotMarket.oracle,
|
|
4562
|
+
oracleSource: types_1.OracleSource.get(driftSpotMarket.oracleSource),
|
|
4563
|
+
vault: driftSpotMarket.vault,
|
|
4564
|
+
mint: driftSpotMarket.mint,
|
|
4565
|
+
decimals: driftSpotMarket.decimals,
|
|
4566
|
+
tokenProgram: driftSpotMarket.tokenProgram === 0
|
|
4567
|
+
? spl_token_1.TOKEN_PROGRAM_ID
|
|
4568
|
+
: spl_token_1.TOKEN_2022_PROGRAM_ID,
|
|
4569
|
+
cumulativeDepositInterest: driftSpotMarket.cumulativeDepositInterest,
|
|
4570
|
+
cumulativeBorrowInterest: driftSpotMarket.cumulativeBorrowInterest,
|
|
4571
|
+
};
|
|
4572
|
+
}
|
|
4573
|
+
calcSpotBalance(scaledBalance, scaledBalanceType, decimals, cumulativeDepositInterest, cumulativeBorrowInterest) {
|
|
4215
4574
|
const precisionAdjustment = new anchor_1.BN(10 ** (19 - decimals));
|
|
4216
4575
|
let interest = cumulativeDepositInterest;
|
|
4217
4576
|
if (scaledBalanceType === types_1.SpotBalanceType.BORROW) {
|
|
@@ -4482,375 +4841,20 @@ class DriftClient {
|
|
|
4482
4841
|
isSigner: false,
|
|
4483
4842
|
})));
|
|
4484
4843
|
}
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
// amountUnlocked: BN,
|
|
4492
|
-
// amountLocked: BN,
|
|
4493
|
-
// proof: number[][],
|
|
4494
|
-
// txOptions: TxOptions = {},
|
|
4495
|
-
// ) {
|
|
4496
|
-
// const glamSigner = txOptions.signer || this.base.signer;
|
|
4497
|
-
// const vault = this.base.vaultPda;
|
|
4498
|
-
// const vaultAta = this.base.getVaultAta(DRIFT);
|
|
4499
|
-
// const distributorAta = this.base.getAta(DRIFT, distributor);
|
|
4500
|
-
// const preInstructions = [
|
|
4501
|
-
// createAssociatedTokenAccountIdempotentInstruction(
|
|
4502
|
-
// glamSigner,
|
|
4503
|
-
// vaultAta,
|
|
4504
|
-
// vault,
|
|
4505
|
-
// DRIFT,
|
|
4506
|
-
// ),
|
|
4507
|
-
// ];
|
|
4508
|
-
// const tx = await this.base.extDriftProgram.methods
|
|
4509
|
-
// .distributorNewClaim(amountUnlocked, amountLocked, proof)
|
|
4510
|
-
// .accounts({
|
|
4511
|
-
// glamState: this.base.statePda,
|
|
4512
|
-
// glamSigner,
|
|
4513
|
-
// distributor,
|
|
4514
|
-
// claimStatus: this.getClaimStatus(vault, distributor),
|
|
4515
|
-
// from: distributorAta,
|
|
4516
|
-
// to: vaultAta,
|
|
4517
|
-
// tokenProgram: TOKEN_PROGRAM_ID,
|
|
4518
|
-
// })
|
|
4519
|
-
// .preInstructions(preInstructions)
|
|
4520
|
-
// .transaction();
|
|
4521
|
-
// const vTx = await this.base.intoVersionedTransaction(tx, { ...txOptions });
|
|
4522
|
-
// return await this.base.sendAndConfirm(vTx);
|
|
4523
|
-
// }
|
|
4524
|
-
async initializeUserStatsIx(glamSigner) {
|
|
4525
|
-
const { userStats } = this.getDriftUserPdas();
|
|
4526
|
-
return await this.base.extDriftProgram.methods
|
|
4527
|
-
.initializeUserStats()
|
|
4528
|
-
.accounts({
|
|
4529
|
-
glamState: this.base.statePda,
|
|
4530
|
-
glamSigner,
|
|
4531
|
-
state: this.driftStatePda,
|
|
4532
|
-
userStats,
|
|
4533
|
-
})
|
|
4534
|
-
.instruction();
|
|
4535
|
-
}
|
|
4536
|
-
async initializeUserIx(glamSigner, subAccountId) {
|
|
4537
|
-
const name = `GLAM *.+ ${subAccountId}`
|
|
4538
|
-
.split("")
|
|
4539
|
-
.map((char) => char.charCodeAt(0))
|
|
4540
|
-
.concat(Array(24).fill(0));
|
|
4541
|
-
const { user, userStats } = this.getDriftUserPdas(subAccountId);
|
|
4542
|
-
const { user: referrer, userStats: referrerStats } = this.getGlamReferrerPdas();
|
|
4543
|
-
const remainingAccounts = [
|
|
4544
|
-
{ pubkey: referrer, isWritable: true, isSigner: false },
|
|
4545
|
-
{ pubkey: referrerStats, isWritable: true, isSigner: false },
|
|
4546
|
-
];
|
|
4547
|
-
return await this.base.extDriftProgram.methods
|
|
4548
|
-
.initializeUser(subAccountId, name)
|
|
4549
|
-
.accounts({
|
|
4550
|
-
glamState: this.base.statePda,
|
|
4551
|
-
user,
|
|
4552
|
-
userStats,
|
|
4553
|
-
state: this.driftStatePda,
|
|
4554
|
-
glamSigner,
|
|
4555
|
-
})
|
|
4556
|
-
.remainingAccounts(remainingAccounts)
|
|
4557
|
-
.instruction();
|
|
4558
|
-
}
|
|
4559
|
-
async updateUserPoolIdIx(subAccountId, poolId) {
|
|
4560
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4561
|
-
return await this.base.extDriftProgram.methods
|
|
4562
|
-
.updateUserPoolId(subAccountId, poolId)
|
|
4563
|
-
.accounts({
|
|
4564
|
-
glamState: this.base.statePda,
|
|
4565
|
-
user,
|
|
4566
|
-
})
|
|
4567
|
-
.instruction();
|
|
4844
|
+
}
|
|
4845
|
+
exports.DriftClient = DriftClient;
|
|
4846
|
+
class DriftVaultsClient {
|
|
4847
|
+
constructor(base, drift) {
|
|
4848
|
+
this.base = base;
|
|
4849
|
+
this.drift = drift;
|
|
4568
4850
|
}
|
|
4569
|
-
async
|
|
4570
|
-
const
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
const { userStats } = this.getDriftUserPdas();
|
|
4574
|
-
const userStatsInfo = await this.base.provider.connection.getAccountInfo(userStats);
|
|
4575
|
-
if (!userStatsInfo) {
|
|
4576
|
-
tx.add(await this.initializeUserStatsIx(glamSigner));
|
|
4851
|
+
async fetchUserPositions(user) {
|
|
4852
|
+
const accountInfo = await this.base.provider.connection.getAccountInfo(user);
|
|
4853
|
+
if (!accountInfo) {
|
|
4854
|
+
throw new Error(`Drift user ${user} account not found for vault.`);
|
|
4577
4855
|
}
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4581
|
-
}
|
|
4582
|
-
async updateUserCustomMarginRatioIx(maxLeverage, // 1=1x, 2=2x ... 50=50x leverage
|
|
4583
|
-
subAccountId = 0, txOptions = {}) {
|
|
4584
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4585
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4586
|
-
// https://github.com/drift-labs/protocol-v2/blob/babed162b08b1fe34e49a81c5aa3e4ec0a88ecdf/programs/drift/src/math/constants.rs#L183-L184
|
|
4587
|
-
// 0 means No Limit
|
|
4588
|
-
const marginRatio = maxLeverage === 0 ? 0 : DRIFT_MARGIN_PRECISION / maxLeverage;
|
|
4589
|
-
return await this.base.extDriftProgram.methods
|
|
4590
|
-
.updateUserCustomMarginRatio(subAccountId, marginRatio)
|
|
4591
|
-
.accounts({
|
|
4592
|
-
glamState: this.base.statePda,
|
|
4593
|
-
glamSigner,
|
|
4594
|
-
user,
|
|
4595
|
-
})
|
|
4596
|
-
.instruction();
|
|
4597
|
-
}
|
|
4598
|
-
async updateUserCustomMarginRatioTx(maxLeverage, // 1=1x, 2=2x ... 50=50x leverage
|
|
4599
|
-
subAccountId = 0, txOptions = {}) {
|
|
4600
|
-
const tx = new web3_js_1.Transaction().add(await this.updateUserCustomMarginRatioIx(maxLeverage, subAccountId, txOptions));
|
|
4601
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4602
|
-
}
|
|
4603
|
-
async updateUserMarginTradingEnabledIx(marginTradingEnabled, subAccountId = 0, txOptions = {}) {
|
|
4604
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4605
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4606
|
-
return await this.base.extDriftProgram.methods
|
|
4607
|
-
.updateUserMarginTradingEnabled(subAccountId, marginTradingEnabled)
|
|
4608
|
-
.accounts({
|
|
4609
|
-
glamState: this.base.statePda,
|
|
4610
|
-
glamSigner,
|
|
4611
|
-
user,
|
|
4612
|
-
})
|
|
4613
|
-
.instruction();
|
|
4614
|
-
}
|
|
4615
|
-
async updateUserMarginTradingEnabledTx(marginTradingEnabled, subAccountId = 0, txOptions = {}) {
|
|
4616
|
-
const tx = new web3_js_1.Transaction().add(...(txOptions.preInstructions || []), await this.updateUserMarginTradingEnabledIx(marginTradingEnabled, subAccountId, txOptions));
|
|
4617
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4618
|
-
}
|
|
4619
|
-
async updateUserDelegateIx(delegate, subAccountId = 0, txOptions = {}) {
|
|
4620
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4621
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4622
|
-
return await this.base.extDriftProgram.methods
|
|
4623
|
-
.updateUserDelegate(subAccountId, new web3_js_1.PublicKey(delegate))
|
|
4624
|
-
.accounts({
|
|
4625
|
-
glamState: this.base.statePda,
|
|
4626
|
-
glamSigner,
|
|
4627
|
-
user,
|
|
4628
|
-
})
|
|
4629
|
-
.instruction();
|
|
4630
|
-
}
|
|
4631
|
-
async updateUserDelegateTx(delegate, subAccountId = 0, txOptions = {}) {
|
|
4632
|
-
const tx = new web3_js_1.Transaction().add(await this.updateUserDelegateIx(delegate, subAccountId, txOptions));
|
|
4633
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4634
|
-
}
|
|
4635
|
-
async deleteUserTx(subAccountId = 0, txOptions = {}) {
|
|
4636
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4637
|
-
const { user, userStats } = this.getDriftUserPdas(subAccountId);
|
|
4638
|
-
const tx = await this.base.extDriftProgram.methods
|
|
4639
|
-
.deleteUser()
|
|
4640
|
-
.accounts({
|
|
4641
|
-
glamState: this.base.statePda,
|
|
4642
|
-
state: this.driftStatePda,
|
|
4643
|
-
user,
|
|
4644
|
-
userStats,
|
|
4645
|
-
glamSigner,
|
|
4646
|
-
})
|
|
4647
|
-
.transaction();
|
|
4648
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4649
|
-
}
|
|
4650
|
-
async depositTx(amount, marketIndex = 1, subAccountId = 0, txOptions = {}) {
|
|
4651
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4652
|
-
const { user, userStats } = this.getDriftUserPdas(subAccountId);
|
|
4653
|
-
const { mint, oracle, tokenProgram, marketPda, vault: driftVault, name, } = await this.fetchAndParseSpotMarket(marketIndex);
|
|
4654
|
-
console.log(`Spot market ${marketIndex} mint ${mint}, oracle: ${oracle}, marketPda: ${marketPda}, vault: ${driftVault}`);
|
|
4655
|
-
const preInstructions = [];
|
|
4656
|
-
const postInstructions = [];
|
|
4657
|
-
// If drift user doesn't exist, prepend initialization ixs
|
|
4658
|
-
if (!(await this.fetchDriftUser(subAccountId))) {
|
|
4659
|
-
// Only add ix to initialize user stats if subAccountId is 0
|
|
4660
|
-
if (subAccountId === 0) {
|
|
4661
|
-
preInstructions.push(await this.initializeUserStatsIx(glamSigner));
|
|
4662
|
-
}
|
|
4663
|
-
preInstructions.push(await this.initializeUserIx(glamSigner, subAccountId));
|
|
4664
|
-
// If market name ends with "-N", it means we're depositing to an isolated pool
|
|
4665
|
-
const isolatedPoolMatch = name.match(/-(\d+)$/);
|
|
4666
|
-
if (isolatedPoolMatch) {
|
|
4667
|
-
const poolId = parseInt(isolatedPoolMatch[1]);
|
|
4668
|
-
preInstructions.push(await this.updateUserPoolIdIx(subAccountId, poolId));
|
|
4669
|
-
}
|
|
4670
|
-
}
|
|
4671
|
-
if (mint.equals(constants_1.WSOL)) {
|
|
4672
|
-
const wrapSolIxs = await this.vault.maybeWrapSol(amount, glamSigner);
|
|
4673
|
-
preInstructions.push(...wrapSolIxs);
|
|
4674
|
-
// If we need to wrap SOL, it means the wSOL balance will be drained,
|
|
4675
|
-
// and we close the wSOL token account for convenience
|
|
4676
|
-
const tokenAccount = this.base.getVaultAta(constants_1.WSOL);
|
|
4677
|
-
const closeTokenAccountIx = await this.base.extSplProgram.methods
|
|
4678
|
-
.tokenCloseAccount()
|
|
4679
|
-
.accounts({
|
|
4680
|
-
glamState: this.base.statePda,
|
|
4681
|
-
glamSigner,
|
|
4682
|
-
tokenAccount,
|
|
4683
|
-
cpiProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4684
|
-
})
|
|
4685
|
-
.instruction();
|
|
4686
|
-
postInstructions.push(closeTokenAccountIx);
|
|
4687
|
-
}
|
|
4688
|
-
const remainingAccounts = [
|
|
4689
|
-
{ pubkey: new web3_js_1.PublicKey(oracle), isSigner: false, isWritable: false },
|
|
4690
|
-
{ pubkey: new web3_js_1.PublicKey(marketPda), isSigner: false, isWritable: true },
|
|
4691
|
-
];
|
|
4692
|
-
if (tokenProgram.equals(spl_token_1.TOKEN_2022_PROGRAM_ID)) {
|
|
4693
|
-
remainingAccounts.push({
|
|
4694
|
-
pubkey: mint,
|
|
4695
|
-
isSigner: false,
|
|
4696
|
-
isWritable: false,
|
|
4697
|
-
});
|
|
4698
|
-
}
|
|
4699
|
-
const tx = await this.base.extDriftProgram.methods
|
|
4700
|
-
.deposit(marketIndex, amount, false)
|
|
4701
|
-
.accounts({
|
|
4702
|
-
glamState: this.base.statePda,
|
|
4703
|
-
glamSigner,
|
|
4704
|
-
state: this.driftStatePda,
|
|
4705
|
-
user,
|
|
4706
|
-
userStats,
|
|
4707
|
-
spotMarketVault: driftVault,
|
|
4708
|
-
userTokenAccount: this.base.getVaultAta(mint, tokenProgram),
|
|
4709
|
-
tokenProgram,
|
|
4710
|
-
})
|
|
4711
|
-
.remainingAccounts(remainingAccounts)
|
|
4712
|
-
.preInstructions(preInstructions)
|
|
4713
|
-
.postInstructions(postInstructions)
|
|
4714
|
-
.transaction();
|
|
4715
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4716
|
-
}
|
|
4717
|
-
async withdrawTx(amount, marketIndex = 1, subAccountId = 0, txOptions = {}) {
|
|
4718
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4719
|
-
const { user, userStats } = this.getDriftUserPdas(subAccountId);
|
|
4720
|
-
const { mint, tokenProgram, vault: driftVault, } = await this.fetchAndParseSpotMarket(marketIndex);
|
|
4721
|
-
const glamVault = this.base.vaultPda;
|
|
4722
|
-
const glamVaultAta = this.base.getVaultAta(mint, tokenProgram);
|
|
4723
|
-
const remainingAccounts = await this.composeRemainingAccounts(subAccountId, types_1.MarketType.SPOT, marketIndex);
|
|
4724
|
-
if (tokenProgram.equals(spl_token_1.TOKEN_2022_PROGRAM_ID)) {
|
|
4725
|
-
remainingAccounts.push({
|
|
4726
|
-
pubkey: mint,
|
|
4727
|
-
isSigner: false,
|
|
4728
|
-
isWritable: false,
|
|
4729
|
-
});
|
|
4730
|
-
}
|
|
4731
|
-
// Create vault ata in case it doesn't exist
|
|
4732
|
-
const preInstructions = [
|
|
4733
|
-
(0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(glamSigner, glamVaultAta, glamVault, mint, tokenProgram),
|
|
4734
|
-
];
|
|
4735
|
-
const tx = await this.base.extDriftProgram.methods
|
|
4736
|
-
.withdraw(marketIndex, amount, false)
|
|
4737
|
-
.accounts({
|
|
4738
|
-
glamState: this.base.statePda,
|
|
4739
|
-
glamSigner,
|
|
4740
|
-
state: this.driftStatePda,
|
|
4741
|
-
user,
|
|
4742
|
-
userStats,
|
|
4743
|
-
spotMarketVault: driftVault,
|
|
4744
|
-
userTokenAccount: glamVaultAta,
|
|
4745
|
-
driftSigner: DRIFT_SIGNER,
|
|
4746
|
-
tokenProgram,
|
|
4747
|
-
})
|
|
4748
|
-
.remainingAccounts(remainingAccounts)
|
|
4749
|
-
.preInstructions(preInstructions)
|
|
4750
|
-
.transaction();
|
|
4751
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4752
|
-
}
|
|
4753
|
-
async placeOrderTx(orderParams, subAccountId = 0, txOptions = {}) {
|
|
4754
|
-
const { marketIndex, marketType } = orderParams;
|
|
4755
|
-
const { user: referrer, userStats: referrerStats } = this.getGlamReferrerPdas();
|
|
4756
|
-
const remainingAccounts = (await this.composeRemainingAccounts(subAccountId, marketType, marketIndex)).concat([
|
|
4757
|
-
{ pubkey: referrer, isWritable: true, isSigner: false },
|
|
4758
|
-
{ pubkey: referrerStats, isWritable: true, isSigner: false },
|
|
4759
|
-
]);
|
|
4760
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4761
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4762
|
-
const tx = await this.base.extDriftProgram.methods
|
|
4763
|
-
.placeOrders([orderParams])
|
|
4764
|
-
.accounts({
|
|
4765
|
-
glamState: this.base.statePda,
|
|
4766
|
-
glamSigner,
|
|
4767
|
-
user,
|
|
4768
|
-
state: this.driftStatePda,
|
|
4769
|
-
})
|
|
4770
|
-
.remainingAccounts(remainingAccounts)
|
|
4771
|
-
.transaction();
|
|
4772
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4773
|
-
}
|
|
4774
|
-
async modifyOrderTx(modifyOrderParams, orderId, marketIndex, marketType, subAccountId = 0, txOptions = {}) {
|
|
4775
|
-
const remainingAccounts = await this.composeRemainingAccounts(subAccountId, marketType, marketIndex);
|
|
4776
|
-
const signer = txOptions.signer || this.base.signer;
|
|
4777
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4778
|
-
const tx = await this.base.extDriftProgram.methods
|
|
4779
|
-
.modifyOrder(orderId, modifyOrderParams)
|
|
4780
|
-
.accounts({
|
|
4781
|
-
glamState: this.base.statePda,
|
|
4782
|
-
glamSigner: signer,
|
|
4783
|
-
user,
|
|
4784
|
-
state: this.driftStatePda,
|
|
4785
|
-
})
|
|
4786
|
-
.remainingAccounts(remainingAccounts)
|
|
4787
|
-
.transaction();
|
|
4788
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4789
|
-
}
|
|
4790
|
-
async cancelOrdersTx(marketType, marketIndex, direction, subAccountId = 0, txOptions = {}) {
|
|
4791
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4792
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4793
|
-
const remainingAccounts = await this.composeRemainingAccounts(subAccountId, marketType, marketIndex);
|
|
4794
|
-
const tx = await this.base.extDriftProgram.methods
|
|
4795
|
-
.cancelOrders(marketType, marketIndex, direction)
|
|
4796
|
-
.accounts({
|
|
4797
|
-
glamState: this.base.statePda,
|
|
4798
|
-
glamSigner,
|
|
4799
|
-
user,
|
|
4800
|
-
state: this.driftStatePda,
|
|
4801
|
-
})
|
|
4802
|
-
.remainingAccounts(remainingAccounts)
|
|
4803
|
-
.transaction();
|
|
4804
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4805
|
-
}
|
|
4806
|
-
async cancelOrdersByIdsTx(orderIds, subAccountId = 0, txOptions = {}) {
|
|
4807
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4808
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4809
|
-
const remainingAccounts = await this.composeRemainingAccounts(subAccountId);
|
|
4810
|
-
const tx = await this.base.extDriftProgram.methods
|
|
4811
|
-
.cancelOrdersByIds(orderIds)
|
|
4812
|
-
.accounts({
|
|
4813
|
-
glamState: this.base.statePda,
|
|
4814
|
-
glamSigner,
|
|
4815
|
-
user,
|
|
4816
|
-
state: this.driftStatePda,
|
|
4817
|
-
})
|
|
4818
|
-
.remainingAccounts(remainingAccounts)
|
|
4819
|
-
.transaction();
|
|
4820
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4821
|
-
}
|
|
4822
|
-
async settlePnlTx(marketIndex, subAccountId = 0, txOptions = {}) {
|
|
4823
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
4824
|
-
const { user } = this.getDriftUserPdas(subAccountId);
|
|
4825
|
-
const { vault: driftVault } = await this.fetchAndParseSpotMarket(0);
|
|
4826
|
-
const remainingAccounts = await this.composeRemainingAccounts(subAccountId, types_1.MarketType.PERP, marketIndex);
|
|
4827
|
-
const tx = await this.base.extDriftProgram.methods
|
|
4828
|
-
.settlePnl(marketIndex)
|
|
4829
|
-
.accounts({
|
|
4830
|
-
glamState: this.base.statePda,
|
|
4831
|
-
glamSigner,
|
|
4832
|
-
user,
|
|
4833
|
-
state: this.driftStatePda,
|
|
4834
|
-
spotMarketVault: driftVault,
|
|
4835
|
-
})
|
|
4836
|
-
.remainingAccounts(remainingAccounts)
|
|
4837
|
-
.transaction();
|
|
4838
|
-
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
4839
|
-
}
|
|
4840
|
-
}
|
|
4841
|
-
exports.DriftClient = DriftClient;
|
|
4842
|
-
class DriftVaultsClient {
|
|
4843
|
-
constructor(base, drift) {
|
|
4844
|
-
this.base = base;
|
|
4845
|
-
this.drift = drift;
|
|
4846
|
-
}
|
|
4847
|
-
async fetchUserPositions(user) {
|
|
4848
|
-
const accountInfo = await this.base.provider.connection.getAccountInfo(user);
|
|
4849
|
-
if (!accountInfo) {
|
|
4850
|
-
throw new Error(`Drift user ${user} account not found for vault.`);
|
|
4851
|
-
}
|
|
4852
|
-
const { spotPositions, perpPositions } = (0, user_1.decodeUser)(accountInfo.data);
|
|
4853
|
-
return { perpPositions, spotPositions };
|
|
4856
|
+
const { spotPositions, perpPositions } = (0, user_1.decodeUser)(accountInfo.data);
|
|
4857
|
+
return { perpPositions, spotPositions };
|
|
4854
4858
|
}
|
|
4855
4859
|
getDepositorPda(driftVault) {
|
|
4856
4860
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
@@ -5240,6 +5244,9 @@ async function fetchTokenPrices(pubkeys) {
|
|
|
5240
5244
|
async function fetchTokensList() {
|
|
5241
5245
|
const response = await fetch(`${JUPITER_API}/tokens/v2/tag?query=verified`);
|
|
5242
5246
|
const data = await response.json();
|
|
5247
|
+
if (!response.ok) {
|
|
5248
|
+
throw new Error(`Failed to fetch tokens list and prices from Jupiter: ${response.status} ${data?.message}`);
|
|
5249
|
+
}
|
|
5243
5250
|
const tokenList = data?.map((t) => ({
|
|
5244
5251
|
address: t.id,
|
|
5245
5252
|
name: t.name,
|
|
@@ -5248,6 +5255,7 @@ async function fetchTokensList() {
|
|
|
5248
5255
|
logoURI: t.icon,
|
|
5249
5256
|
tags: t.tags,
|
|
5250
5257
|
usdPrice: t.usdPrice,
|
|
5258
|
+
slot: t.priceBlockId,
|
|
5251
5259
|
}));
|
|
5252
5260
|
return tokenList;
|
|
5253
5261
|
}
|
|
@@ -6484,7 +6492,7 @@ class TxBuilder extends base_1.BaseTxBuilder {
|
|
|
6484
6492
|
}
|
|
6485
6493
|
async update(params, txOptions) {
|
|
6486
6494
|
const ix = await this.updateIx(params, txOptions.signer);
|
|
6487
|
-
const tx = this.build(ix, txOptions);
|
|
6495
|
+
const tx = this.build([ix], txOptions);
|
|
6488
6496
|
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
6489
6497
|
}
|
|
6490
6498
|
async updateIx(params, signer) {
|
|
@@ -6595,111 +6603,22 @@ exports.KaminoVaultsClient = exports.KaminoFarmClient = exports.KaminoLendingCli
|
|
|
6595
6603
|
const tslib_1 = __webpack_require__(2);
|
|
6596
6604
|
const anchor_1 = __webpack_require__(4);
|
|
6597
6605
|
const web3_js_1 = __webpack_require__(16);
|
|
6606
|
+
const base_1 = __webpack_require__(52);
|
|
6598
6607
|
const borsh = tslib_1.__importStar(__webpack_require__(21));
|
|
6599
6608
|
const accounts_1 = __webpack_require__(24);
|
|
6600
6609
|
const spl_token_1 = __webpack_require__(17);
|
|
6601
6610
|
const constants_1 = __webpack_require__(25);
|
|
6602
6611
|
const kaminoLayouts_1 = __webpack_require__(65);
|
|
6603
6612
|
const rpc_1 = __webpack_require__(38);
|
|
6604
|
-
const decimal_js_1 = tslib_1.__importDefault(__webpack_require__(47));
|
|
6605
6613
|
const utils_1 = __webpack_require__(23);
|
|
6606
|
-
const FractionDecimal = decimal_js_1.default.clone({ precision: 40 });
|
|
6607
|
-
const MULTIPLIER = new FractionDecimal(2).pow(60);
|
|
6608
6614
|
const DEFAULT_OBLIGATION_ARGS = { tag: 0, id: 0 };
|
|
6609
6615
|
const EVENT_AUTHORITY = new web3_js_1.PublicKey("24tHwQyJJ9akVXxnvkekGfAoeUJXXS7mE6kQNioNySsK");
|
|
6610
|
-
class
|
|
6611
|
-
constructor(base, vault) {
|
|
6616
|
+
class TxBuilder extends base_1.BaseTxBuilder {
|
|
6617
|
+
constructor(base, vault, klend) {
|
|
6618
|
+
super(base);
|
|
6612
6619
|
this.base = base;
|
|
6613
6620
|
this.vault = vault;
|
|
6614
|
-
this.
|
|
6615
|
-
this.obligations = new utils_1.PkMap();
|
|
6616
|
-
}
|
|
6617
|
-
/**
|
|
6618
|
-
* Initializes Kamino user metadata
|
|
6619
|
-
*
|
|
6620
|
-
* @param market Lending market
|
|
6621
|
-
* @param referrer Referrer user metadata
|
|
6622
|
-
* @param txOptions
|
|
6623
|
-
* @returns
|
|
6624
|
-
*/
|
|
6625
|
-
async initUserMetadata(txOptions = {}) {
|
|
6626
|
-
const tx = await this.initUserMetadataTx(txOptions);
|
|
6627
|
-
return await this.base.sendAndConfirm(tx);
|
|
6628
|
-
}
|
|
6629
|
-
/**
|
|
6630
|
-
* Deposits asset to the lending market.
|
|
6631
|
-
*
|
|
6632
|
-
* @param market Lending market
|
|
6633
|
-
* @param asset Asset mint
|
|
6634
|
-
* @param amount Amount to deposit
|
|
6635
|
-
* @param txOptions
|
|
6636
|
-
* @returns
|
|
6637
|
-
*/
|
|
6638
|
-
async deposit(market, asset, amount, txOptions = {}) {
|
|
6639
|
-
const tx = await this.depositTx(new web3_js_1.PublicKey(market), new web3_js_1.PublicKey(asset), new anchor_1.BN(amount), txOptions);
|
|
6640
|
-
return await this.base.sendAndConfirm(tx);
|
|
6641
|
-
}
|
|
6642
|
-
/**
|
|
6643
|
-
* Withdraws asset from the lending market.
|
|
6644
|
-
*
|
|
6645
|
-
* @param market Lending market
|
|
6646
|
-
* @param asset Asset mint
|
|
6647
|
-
* @param amount Amount to deposit
|
|
6648
|
-
* @param txOptions
|
|
6649
|
-
* @returns
|
|
6650
|
-
*/
|
|
6651
|
-
async withdraw(market, asset, amount, txOptions = {}) {
|
|
6652
|
-
const tx = await this.withdrawTx(new web3_js_1.PublicKey(market), new web3_js_1.PublicKey(asset), new anchor_1.BN(amount), txOptions);
|
|
6653
|
-
return await this.base.sendAndConfirm(tx);
|
|
6654
|
-
}
|
|
6655
|
-
/**
|
|
6656
|
-
* Borrows asset from the lending market.
|
|
6657
|
-
*
|
|
6658
|
-
* @param market Lending market
|
|
6659
|
-
* @param asset Asset mint
|
|
6660
|
-
* @param amount Amount to borrow
|
|
6661
|
-
* @param txOptions
|
|
6662
|
-
* @returns
|
|
6663
|
-
*/
|
|
6664
|
-
async borrow(market, asset, amount, txOptions = {}) {
|
|
6665
|
-
const tx = await this.borrowTx(new web3_js_1.PublicKey(market), new web3_js_1.PublicKey(asset), new anchor_1.BN(amount), txOptions);
|
|
6666
|
-
return await this.base.sendAndConfirm(tx);
|
|
6667
|
-
}
|
|
6668
|
-
/**
|
|
6669
|
-
* Repays asset to the lending market.
|
|
6670
|
-
*
|
|
6671
|
-
* @param market
|
|
6672
|
-
* @param asset
|
|
6673
|
-
* @param amount
|
|
6674
|
-
* @param txOptions
|
|
6675
|
-
* @returns
|
|
6676
|
-
*/
|
|
6677
|
-
async repay(market, asset, amount, txOptions = {}) {
|
|
6678
|
-
const tx = await this.repayTx(new web3_js_1.PublicKey(market), new web3_js_1.PublicKey(asset), new anchor_1.BN(amount), txOptions);
|
|
6679
|
-
return await this.base.sendAndConfirm(tx);
|
|
6680
|
-
}
|
|
6681
|
-
getUserMetadataPda(owner) {
|
|
6682
|
-
const [userMetadataPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("user_meta"), owner.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
6683
|
-
return userMetadataPda;
|
|
6684
|
-
}
|
|
6685
|
-
getObligationPda(owner, market, args = DEFAULT_OBLIGATION_ARGS) {
|
|
6686
|
-
const seed = [
|
|
6687
|
-
Buffer.from([args.tag]),
|
|
6688
|
-
Buffer.from([args.id]),
|
|
6689
|
-
owner.toBuffer(),
|
|
6690
|
-
market.toBuffer(),
|
|
6691
|
-
web3_js_1.PublicKey.default.toBuffer(),
|
|
6692
|
-
web3_js_1.PublicKey.default.toBuffer(),
|
|
6693
|
-
];
|
|
6694
|
-
const [obligation, _] = web3_js_1.PublicKey.findProgramAddressSync(seed, constants_1.KAMINO_LENDING_PROGRAM);
|
|
6695
|
-
return obligation;
|
|
6696
|
-
}
|
|
6697
|
-
// seeds = [BASE_SEED_USER_STATE, farm_state.key().as_ref(), delegatee.key().as_ref()],
|
|
6698
|
-
// for a delegated farm, the delegatee is the obligation, the owner (of farm user state) is the vault PDA
|
|
6699
|
-
// for an un-delegated farm, the delegatee and the owner are the same (vault PDA)
|
|
6700
|
-
getFarmUserState(farmUser, farm) {
|
|
6701
|
-
const [obligationFarm] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("user"), farm.toBuffer(), farmUser.toBuffer()], constants_1.KAMINO_FARM_PROGRAM);
|
|
6702
|
-
return obligationFarm;
|
|
6621
|
+
this.klend = klend;
|
|
6703
6622
|
}
|
|
6704
6623
|
refreshObligationIx(accounts, programId = constants_1.KAMINO_LENDING_PROGRAM) {
|
|
6705
6624
|
const keys = [
|
|
@@ -6824,12 +6743,12 @@ class KaminoLendingClient {
|
|
|
6824
6743
|
return [farmCollateral]
|
|
6825
6744
|
.filter((farm) => !!farm)
|
|
6826
6745
|
.map((farm) => {
|
|
6827
|
-
const obligationFarmUserState = this.getFarmUserState(obligation, farm);
|
|
6746
|
+
const obligationFarmUserState = this.klend.getFarmUserState(obligation, farm);
|
|
6828
6747
|
return this.refreshObligationFarmsForReserveIx({ mode: 0 }, {
|
|
6829
6748
|
crank: this.base.signer, // Must be signer
|
|
6830
6749
|
baseAccounts: {
|
|
6831
6750
|
obligation,
|
|
6832
|
-
lendingMarketAuthority: this.getMarketAuthority(lendingMarket),
|
|
6751
|
+
lendingMarketAuthority: this.klend.getMarketAuthority(lendingMarket),
|
|
6833
6752
|
reserve: parsedReserve.address,
|
|
6834
6753
|
reserveFarmState: farm,
|
|
6835
6754
|
obligationFarmUserState,
|
|
@@ -6850,12 +6769,12 @@ class KaminoLendingClient {
|
|
|
6850
6769
|
return [farmDebt]
|
|
6851
6770
|
.filter((farm) => !!farm)
|
|
6852
6771
|
.map((farm) => {
|
|
6853
|
-
const obligationFarmUserState = this.getFarmUserState(obligation, farm);
|
|
6772
|
+
const obligationFarmUserState = this.klend.getFarmUserState(obligation, farm);
|
|
6854
6773
|
return this.refreshObligationFarmsForReserveIx({ mode: 1 }, {
|
|
6855
6774
|
crank: this.base.signer, // Must be signer
|
|
6856
6775
|
baseAccounts: {
|
|
6857
6776
|
obligation,
|
|
6858
|
-
lendingMarketAuthority: this.getMarketAuthority(lendingMarket),
|
|
6777
|
+
lendingMarketAuthority: this.klend.getMarketAuthority(lendingMarket),
|
|
6859
6778
|
reserve: parsedReserve.address,
|
|
6860
6779
|
reserveFarmState: farm,
|
|
6861
6780
|
obligationFarmUserState,
|
|
@@ -6869,156 +6788,12 @@ class KaminoLendingClient {
|
|
|
6869
6788
|
})
|
|
6870
6789
|
.flat();
|
|
6871
6790
|
}
|
|
6872
|
-
getMarketAuthority(market) {
|
|
6873
|
-
const [authority, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("lma"), market.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
6874
|
-
return authority;
|
|
6875
|
-
}
|
|
6876
|
-
reservePdas(market, mint) {
|
|
6877
|
-
const [liquiditySupplyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reserve_liq_supply"), market.toBuffer(), mint.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
6878
|
-
const [collateralMint] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reserve_coll_mint"), market.toBuffer(), mint.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
6879
|
-
const [collateralSupplyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reserve_coll_supply"), market.toBuffer(), mint.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
6880
|
-
const [feeVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fee_receiver"), market.toBuffer(), mint.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
6881
|
-
return {
|
|
6882
|
-
liquiditySupplyVault,
|
|
6883
|
-
collateralMint,
|
|
6884
|
-
collateralSupplyVault,
|
|
6885
|
-
feeVault,
|
|
6886
|
-
};
|
|
6887
|
-
}
|
|
6888
|
-
parseObligation(obligation, data) {
|
|
6889
|
-
const { lendingMarket, deposits: _deposits, borrows: _borrows, } = kaminoLayouts_1.Obligation.decode(obligation, data);
|
|
6890
|
-
// Map decoded deposits to the expected format, filtering out empty deposits
|
|
6891
|
-
const deposits = _deposits
|
|
6892
|
-
.filter(({ depositReserve }) => !depositReserve.equals(web3_js_1.PublicKey.default))
|
|
6893
|
-
.map(({ depositReserve, depositedAmount, marketValueSf }) => {
|
|
6894
|
-
return {
|
|
6895
|
-
reserve: depositReserve,
|
|
6896
|
-
depositedAmount,
|
|
6897
|
-
marketValueSf,
|
|
6898
|
-
};
|
|
6899
|
-
});
|
|
6900
|
-
// Map decoded borrows to the expected format, filtering out empty borrows
|
|
6901
|
-
const borrows = _borrows
|
|
6902
|
-
.filter(({ borrowReserve }) => !borrowReserve.equals(web3_js_1.PublicKey.default))
|
|
6903
|
-
.map(({ borrowReserve, borrowedAmountSf, marketValueSf, cumulativeBorrowRateBsf, }) => {
|
|
6904
|
-
return {
|
|
6905
|
-
reserve: borrowReserve,
|
|
6906
|
-
borrowedAmountSf,
|
|
6907
|
-
marketValueSf,
|
|
6908
|
-
cumulativeBorrowRateBsf,
|
|
6909
|
-
};
|
|
6910
|
-
});
|
|
6911
|
-
return {
|
|
6912
|
-
address: obligation,
|
|
6913
|
-
lendingMarket,
|
|
6914
|
-
deposits,
|
|
6915
|
-
borrows,
|
|
6916
|
-
};
|
|
6917
|
-
}
|
|
6918
|
-
/**
|
|
6919
|
-
* Fetches and parses an obligation account
|
|
6920
|
-
*/
|
|
6921
|
-
async fetchAndParseObligation(obligation) {
|
|
6922
|
-
const cached = this.obligations.get(obligation);
|
|
6923
|
-
if (cached) {
|
|
6924
|
-
return cached;
|
|
6925
|
-
}
|
|
6926
|
-
const obligationAccount = await this.base.provider.connection.getAccountInfo(obligation);
|
|
6927
|
-
if (!obligationAccount) {
|
|
6928
|
-
throw new Error("Obligation account not found");
|
|
6929
|
-
}
|
|
6930
|
-
const parsedObligation = this.parseObligation(obligation, obligationAccount.data);
|
|
6931
|
-
this.obligations.set(obligation, parsedObligation);
|
|
6932
|
-
return parsedObligation;
|
|
6933
|
-
}
|
|
6934
|
-
parseReserve(pubkey, data) {
|
|
6935
|
-
const { lendingMarket, farmCollateral, farmDebt, liquidity: { mintPubkey, mintDecimals }, config: { tokenInfo: { scopeConfiguration: { priceFeed }, }, }, collateralExchangeRate, cumulativeBorrowRate, } = kaminoLayouts_1.Reserve.decode(pubkey, data);
|
|
6936
|
-
return {
|
|
6937
|
-
address: pubkey,
|
|
6938
|
-
market: lendingMarket,
|
|
6939
|
-
farmCollateral: farmCollateral.equals(web3_js_1.PublicKey.default)
|
|
6940
|
-
? null
|
|
6941
|
-
: farmCollateral,
|
|
6942
|
-
farmDebt: farmDebt.equals(web3_js_1.PublicKey.default) ? null : farmDebt,
|
|
6943
|
-
liquidityMint: mintPubkey,
|
|
6944
|
-
liquidityMintDecimals: mintDecimals.toNumber(),
|
|
6945
|
-
scopePriceFeed: priceFeed,
|
|
6946
|
-
...this.reservePdas(lendingMarket, mintPubkey),
|
|
6947
|
-
collateralExchangeRate,
|
|
6948
|
-
cumulativeBorrowRate,
|
|
6949
|
-
};
|
|
6950
|
-
}
|
|
6951
|
-
async fetchAndParseReserves(reserves) {
|
|
6952
|
-
const requestReservesSet = new utils_1.PkSet(reserves);
|
|
6953
|
-
const cachedReservesSet = new utils_1.PkSet(Array.from(this.reserves.pkKeys()));
|
|
6954
|
-
// If all requested reserves are cached, return data from cache
|
|
6955
|
-
if (cachedReservesSet.includes(requestReservesSet)) {
|
|
6956
|
-
return Array.from(this.reserves.values()).filter(({ address }) => requestReservesSet.has(address));
|
|
6957
|
-
}
|
|
6958
|
-
// Only fetch reserves that are not cached
|
|
6959
|
-
const reservesToFetch = Array.from(requestReservesSet).filter((r) => !cachedReservesSet.has(r));
|
|
6960
|
-
if (process.env.NODE_ENV !== "production") {
|
|
6961
|
-
console.log("Fetching reserves:", reservesToFetch.map((r) => r.toBase58()));
|
|
6962
|
-
}
|
|
6963
|
-
const reserveAccounts = await this.base.provider.connection.getMultipleAccountsInfo(reservesToFetch);
|
|
6964
|
-
if (reserveAccounts.some((a) => !a)) {
|
|
6965
|
-
throw new Error("Not all reserves can be found");
|
|
6966
|
-
}
|
|
6967
|
-
reserveAccounts.forEach((account, i) => {
|
|
6968
|
-
const parsedReserve = this.parseReserve(reservesToFetch[i], account.data);
|
|
6969
|
-
this.reserves.set(reservesToFetch[i], parsedReserve);
|
|
6970
|
-
});
|
|
6971
|
-
// Return requested reserves
|
|
6972
|
-
return Array.from(this.reserves.values()).filter(({ address }) => requestReservesSet.has(address));
|
|
6973
|
-
}
|
|
6974
|
-
/**
|
|
6975
|
-
* Finds and parses a reserve account for a given market and asset
|
|
6976
|
-
*
|
|
6977
|
-
* @param market The lending market public key
|
|
6978
|
-
* @param asset The asset public key
|
|
6979
|
-
* @returns The parsed reserve account
|
|
6980
|
-
*/
|
|
6981
|
-
async findAndParseReserve(market, asset) {
|
|
6982
|
-
const accounts = await this.base.provider.connection.getProgramAccounts(constants_1.KAMINO_LENDING_PROGRAM, {
|
|
6983
|
-
filters: [
|
|
6984
|
-
{ dataSize: constants_1.KAMINO_RESERVE_SIZE },
|
|
6985
|
-
{ memcmp: { offset: 32, bytes: market.toBase58() } },
|
|
6986
|
-
{ memcmp: { offset: 128, bytes: asset.toBase58() } },
|
|
6987
|
-
],
|
|
6988
|
-
});
|
|
6989
|
-
if (accounts.length === 0) {
|
|
6990
|
-
throw new Error("Reserve not found");
|
|
6991
|
-
}
|
|
6992
|
-
const parsedReserve = this.parseReserve(accounts[0].pubkey, accounts[0].account.data);
|
|
6993
|
-
this.reserves.set(accounts[0].pubkey, parsedReserve);
|
|
6994
|
-
return parsedReserve;
|
|
6995
|
-
}
|
|
6996
|
-
/**
|
|
6997
|
-
* Finds and parses Kamino obligations for a given owner and market (optional)
|
|
6998
|
-
*/
|
|
6999
|
-
async findAndParseObligations(owner, market) {
|
|
7000
|
-
const accounts = await this.base.provider.connection.getProgramAccounts(constants_1.KAMINO_LENDING_PROGRAM, {
|
|
7001
|
-
filters: [
|
|
7002
|
-
{ dataSize: constants_1.KAMINO_OBTRIGATION_SIZE },
|
|
7003
|
-
{ memcmp: { offset: 64, bytes: owner.toBase58() } },
|
|
7004
|
-
...(market
|
|
7005
|
-
? [{ memcmp: { offset: 32, bytes: market.toBase58() } }]
|
|
7006
|
-
: []),
|
|
7007
|
-
],
|
|
7008
|
-
});
|
|
7009
|
-
// Parse obligations and cache them
|
|
7010
|
-
return accounts.map((a) => {
|
|
7011
|
-
const parsedObligation = this.parseObligation(a.pubkey, a.account.data);
|
|
7012
|
-
this.obligations.set(a.pubkey, parsedObligation);
|
|
7013
|
-
return parsedObligation;
|
|
7014
|
-
});
|
|
7015
|
-
}
|
|
7016
6791
|
/**
|
|
7017
6792
|
* Returns two instructions that refresh reserves in batch and refresh obligation
|
|
7018
6793
|
*/
|
|
7019
6794
|
async refreshReservesAndObligationIxs(obligation, targetReserve) {
|
|
7020
6795
|
// Get a set of reserves to refresh
|
|
7021
|
-
const { deposits, borrows, lendingMarket } = await this.fetchAndParseObligation(obligation);
|
|
6796
|
+
const { deposits, borrows, lendingMarket } = await this.klend.fetchAndParseObligation(obligation);
|
|
7022
6797
|
const reservesInUse = deposits
|
|
7023
6798
|
.map(({ reserve }) => reserve)
|
|
7024
6799
|
.concat(borrows.map(({ reserve }) => reserve));
|
|
@@ -7026,7 +6801,7 @@ class KaminoLendingClient {
|
|
|
7026
6801
|
const reservesSet = new utils_1.PkSet();
|
|
7027
6802
|
reservesInUse.forEach((reserve) => reservesSet.add(reserve));
|
|
7028
6803
|
reservesSet.add(targetReserve.address);
|
|
7029
|
-
const parsedReserves = await this.fetchAndParseReserves(Array.from(reservesSet));
|
|
6804
|
+
const parsedReserves = await this.klend.fetchAndParseReserves(Array.from(reservesSet));
|
|
7030
6805
|
const refreshReservesIx = this.refreshReservesBatchIx(parsedReserves, false);
|
|
7031
6806
|
// Refresh obligation with reserves in use (exclude target reserve)
|
|
7032
6807
|
const refreshObligationIx = this.refreshObligationIx({
|
|
@@ -7046,7 +6821,7 @@ class KaminoLendingClient {
|
|
|
7046
6821
|
if (!farmState) {
|
|
7047
6822
|
return { farmUser: null, initIx: null };
|
|
7048
6823
|
}
|
|
7049
|
-
const farmUser = this.getFarmUserState(obligation, farmState);
|
|
6824
|
+
const farmUser = this.klend.getFarmUserState(obligation, farmState);
|
|
7050
6825
|
const farmUserAccount = await this.base.provider.connection.getAccountInfo(farmUser);
|
|
7051
6826
|
const initIx = farmUserAccount
|
|
7052
6827
|
? null
|
|
@@ -7056,7 +6831,7 @@ class KaminoLendingClient {
|
|
|
7056
6831
|
glamState: this.base.statePda,
|
|
7057
6832
|
glamSigner: signer || this.base.signer,
|
|
7058
6833
|
obligation,
|
|
7059
|
-
lendingMarketAuthority: this.getMarketAuthority(market),
|
|
6834
|
+
lendingMarketAuthority: this.klend.getMarketAuthority(market),
|
|
7060
6835
|
reserve: address,
|
|
7061
6836
|
reserveFarmState: farmState,
|
|
7062
6837
|
obligationFarm: farmUser,
|
|
@@ -7069,7 +6844,7 @@ class KaminoLendingClient {
|
|
|
7069
6844
|
async initUserMetadataTx(txOptions = {}) {
|
|
7070
6845
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
7071
6846
|
const vault = this.base.vaultPda;
|
|
7072
|
-
const userMetadata = this.getUserMetadataPda(vault);
|
|
6847
|
+
const userMetadata = this.klend.getUserMetadataPda(vault);
|
|
7073
6848
|
const lookupTable = new web3_js_1.PublicKey(0); // FIXME: create lookup table
|
|
7074
6849
|
const tx = await this.base.extKaminoProgram.methods
|
|
7075
6850
|
.lendingInitUserMetadata(lookupTable)
|
|
@@ -7080,16 +6855,14 @@ class KaminoLendingClient {
|
|
|
7080
6855
|
referrerUserMetadata: null,
|
|
7081
6856
|
})
|
|
7082
6857
|
.transaction();
|
|
7083
|
-
|
|
7084
|
-
return vTx;
|
|
6858
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
7085
6859
|
}
|
|
7086
|
-
async
|
|
7087
|
-
const glamSigner = txOptions.signer || this.base.signer;
|
|
6860
|
+
async depositIxs(market, asset, amount, glamSigner) {
|
|
7088
6861
|
const vault = this.base.vaultPda;
|
|
7089
|
-
const userMetadata = this.getUserMetadataPda(vault);
|
|
7090
|
-
const obligation = this.getObligationPda(vault, market);
|
|
7091
|
-
const preInstructions =
|
|
7092
|
-
const postInstructions =
|
|
6862
|
+
const userMetadata = this.klend.getUserMetadataPda(vault);
|
|
6863
|
+
const obligation = this.klend.getObligationPda(vault, market);
|
|
6864
|
+
const preInstructions = [];
|
|
6865
|
+
const postInstructions = [];
|
|
7093
6866
|
const [userMetadataAccount, obligationAccount] = await this.base.provider.connection.getMultipleAccountsInfo([
|
|
7094
6867
|
userMetadata,
|
|
7095
6868
|
obligation,
|
|
@@ -7121,7 +6894,7 @@ class KaminoLendingClient {
|
|
|
7121
6894
|
})
|
|
7122
6895
|
.instruction());
|
|
7123
6896
|
}
|
|
7124
|
-
const depositReserve = await this.findAndParseReserve(market, asset);
|
|
6897
|
+
const depositReserve = await this.klend.findAndParseReserve(market, asset);
|
|
7125
6898
|
const { farmUser: obligationFarmUser, initIx } = await this.initObligationFarmUserForReserveIx(obligation, depositReserve, 0, // collateral farm
|
|
7126
6899
|
glamSigner);
|
|
7127
6900
|
if (initIx) {
|
|
@@ -7166,14 +6939,14 @@ class KaminoLendingClient {
|
|
|
7166
6939
|
// postInstructions.push(closeIx);
|
|
7167
6940
|
// }
|
|
7168
6941
|
}
|
|
7169
|
-
const
|
|
6942
|
+
const ix = await this.base.extKaminoProgram.methods
|
|
7170
6943
|
.lendingDepositReserveLiquidityAndObligationCollateralV2(amount)
|
|
7171
6944
|
.accounts({
|
|
7172
6945
|
glamState: this.base.statePda,
|
|
7173
6946
|
glamSigner,
|
|
7174
6947
|
obligation,
|
|
7175
6948
|
lendingMarket: market,
|
|
7176
|
-
lendingMarketAuthority: this.getMarketAuthority(market),
|
|
6949
|
+
lendingMarketAuthority: this.klend.getMarketAuthority(market),
|
|
7177
6950
|
reserve: depositReserve.address,
|
|
7178
6951
|
reserveLiquidityMint: asset,
|
|
7179
6952
|
reserveLiquiditySupply: depositReserve.liquiditySupplyVault,
|
|
@@ -7188,175 +6961,416 @@ class KaminoLendingClient {
|
|
|
7188
6961
|
reserveFarmState: depositReserve.farmCollateral,
|
|
7189
6962
|
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
7190
6963
|
})
|
|
7191
|
-
.
|
|
7192
|
-
|
|
7193
|
-
.transaction();
|
|
7194
|
-
const vTx = await this.base.intoVersionedTransaction(tx, txOptions);
|
|
7195
|
-
return vTx;
|
|
6964
|
+
.instruction();
|
|
6965
|
+
return [...preInstructions, ix, ...postInstructions];
|
|
7196
6966
|
}
|
|
7197
|
-
async
|
|
6967
|
+
async depositTx(market, asset, amount, txOptions = {}) {
|
|
7198
6968
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
6969
|
+
const ixs = await this.depositIxs(market, asset, amount, glamSigner);
|
|
6970
|
+
const tx = this.build(ixs, txOptions);
|
|
6971
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
6972
|
+
}
|
|
6973
|
+
async withdrawIxs(market, asset, amount, glamSigner) {
|
|
7199
6974
|
const vault = this.base.vaultPda;
|
|
7200
|
-
const obligation = this.getObligationPda(vault, market);
|
|
6975
|
+
const obligation = this.klend.getObligationPda(vault, market);
|
|
7201
6976
|
const preInstructions = [];
|
|
7202
6977
|
const postInstructions = [];
|
|
7203
|
-
const withdrawReserve = await this.findAndParseReserve(market, asset);
|
|
6978
|
+
const withdrawReserve = await this.klend.findAndParseReserve(market, asset);
|
|
7204
6979
|
const { farmUser: obligationFarmUser, initIx } = await this.initObligationFarmUserForReserveIx(obligation, withdrawReserve, 0, // collateral farm
|
|
7205
6980
|
glamSigner);
|
|
7206
6981
|
if (initIx) {
|
|
7207
6982
|
preInstructions.push(initIx);
|
|
7208
6983
|
}
|
|
7209
|
-
const ixs = await this.refreshReservesAndObligationIxs(obligation, withdrawReserve);
|
|
7210
|
-
preInstructions.push(...ixs);
|
|
7211
|
-
if (withdrawReserve.farmCollateral) {
|
|
7212
|
-
const ixs = this.refreshObligationCollateralFarmsForReservesIxs(obligation, market, [withdrawReserve]);
|
|
7213
|
-
preInstructions.push(...ixs);
|
|
7214
|
-
postInstructions.push(...ixs); // farms must be refreshed after withdraw
|
|
6984
|
+
const ixs = await this.refreshReservesAndObligationIxs(obligation, withdrawReserve);
|
|
6985
|
+
preInstructions.push(...ixs);
|
|
6986
|
+
if (withdrawReserve.farmCollateral) {
|
|
6987
|
+
const ixs = this.refreshObligationCollateralFarmsForReservesIxs(obligation, market, [withdrawReserve]);
|
|
6988
|
+
preInstructions.push(...ixs);
|
|
6989
|
+
postInstructions.push(...ixs); // farms must be refreshed after withdraw
|
|
6990
|
+
}
|
|
6991
|
+
// Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
|
|
6992
|
+
const { tokenProgram } = await (0, accounts_1.fetchMintAndTokenProgram)(this.base.provider.connection, asset);
|
|
6993
|
+
const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
|
|
6994
|
+
const createAtaIx = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
|
|
6995
|
+
preInstructions.unshift(createAtaIx);
|
|
6996
|
+
// When all assets are being withdrawn from a market, the klend program attempts to close the
|
|
6997
|
+
// obligation account, which requires the system program. We always pass the system program
|
|
6998
|
+
// account as a remaining account just in case.
|
|
6999
|
+
const withdrawIx = await this.base.extKaminoProgram.methods
|
|
7000
|
+
.lendingWithdrawObligationCollateralAndRedeemReserveCollateralV2(amount)
|
|
7001
|
+
.accounts({
|
|
7002
|
+
glamState: this.base.statePda,
|
|
7003
|
+
glamSigner,
|
|
7004
|
+
obligation,
|
|
7005
|
+
lendingMarket: market,
|
|
7006
|
+
lendingMarketAuthority: this.klend.getMarketAuthority(market),
|
|
7007
|
+
withdrawReserve: withdrawReserve.address,
|
|
7008
|
+
reserveLiquidityMint: asset,
|
|
7009
|
+
reserveSourceCollateral: withdrawReserve.collateralSupplyVault,
|
|
7010
|
+
reserveCollateralMint: withdrawReserve.collateralMint,
|
|
7011
|
+
reserveLiquiditySupply: withdrawReserve.liquiditySupplyVault,
|
|
7012
|
+
userDestinationLiquidity,
|
|
7013
|
+
placeholderUserDestinationCollateral: null,
|
|
7014
|
+
collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
7015
|
+
liquidityTokenProgram: tokenProgram,
|
|
7016
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
7017
|
+
obligationFarmUserState: obligationFarmUser,
|
|
7018
|
+
reserveFarmState: withdrawReserve.farmCollateral,
|
|
7019
|
+
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
7020
|
+
})
|
|
7021
|
+
.remainingAccounts([
|
|
7022
|
+
{
|
|
7023
|
+
pubkey: web3_js_1.SystemProgram.programId,
|
|
7024
|
+
isSigner: false,
|
|
7025
|
+
isWritable: false,
|
|
7026
|
+
},
|
|
7027
|
+
])
|
|
7028
|
+
.instruction();
|
|
7029
|
+
// The final instructions in the tx:
|
|
7030
|
+
// - refreshReserve * N
|
|
7031
|
+
// - refreshObligation
|
|
7032
|
+
// - refreshObligationFarmsForReserve (if farm exists)
|
|
7033
|
+
// - withdrawIx
|
|
7034
|
+
// - refreshObligationFarmsForReserve (if farm exists)
|
|
7035
|
+
return [...preInstructions, withdrawIx, ...postInstructions];
|
|
7036
|
+
}
|
|
7037
|
+
async withdrawTx(market, asset, amount, txOptions = {}) {
|
|
7038
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
7039
|
+
const ixs = await this.withdrawIxs(market, asset, amount, glamSigner);
|
|
7040
|
+
const tx = this.build(ixs, txOptions);
|
|
7041
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
7042
|
+
}
|
|
7043
|
+
async borrowIxs(market, asset, amount, glamSigner) {
|
|
7044
|
+
const vault = this.base.vaultPda;
|
|
7045
|
+
const obligation = this.klend.getObligationPda(vault, market);
|
|
7046
|
+
const preInstructions = [];
|
|
7047
|
+
const postInstructions = [];
|
|
7048
|
+
const borrowReserve = await this.klend.findAndParseReserve(market, asset);
|
|
7049
|
+
const { farmUser: obligationFarmUser, initIx } = await this.initObligationFarmUserForReserveIx(obligation, borrowReserve, 1, // debt farm
|
|
7050
|
+
glamSigner);
|
|
7051
|
+
if (initIx) {
|
|
7052
|
+
preInstructions.push(initIx);
|
|
7053
|
+
}
|
|
7054
|
+
const ixs = await this.refreshReservesAndObligationIxs(obligation, borrowReserve);
|
|
7055
|
+
preInstructions.push(...ixs);
|
|
7056
|
+
if (borrowReserve.farmDebt) {
|
|
7057
|
+
const ixs = this.refreshObligationDebtFarmsForReservesIxs(obligation, market, [borrowReserve]);
|
|
7058
|
+
preInstructions.push(...ixs);
|
|
7059
|
+
postInstructions.push(...ixs); // farms must be refreshed after borrow
|
|
7060
|
+
}
|
|
7061
|
+
// Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
|
|
7062
|
+
const { tokenProgram } = await (0, accounts_1.fetchMintAndTokenProgram)(this.base.provider.connection, asset);
|
|
7063
|
+
const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
|
|
7064
|
+
const createAtaIx = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
|
|
7065
|
+
preInstructions.unshift(createAtaIx);
|
|
7066
|
+
const borrowIx = await this.base.extKaminoProgram.methods
|
|
7067
|
+
.lendingBorrowObligationLiquidityV2(amount)
|
|
7068
|
+
.accounts({
|
|
7069
|
+
glamState: this.base.statePda,
|
|
7070
|
+
glamSigner,
|
|
7071
|
+
obligation,
|
|
7072
|
+
lendingMarket: market,
|
|
7073
|
+
lendingMarketAuthority: this.klend.getMarketAuthority(market),
|
|
7074
|
+
borrowReserve: borrowReserve.address,
|
|
7075
|
+
borrowReserveLiquidityMint: asset,
|
|
7076
|
+
reserveSourceLiquidity: borrowReserve.liquiditySupplyVault,
|
|
7077
|
+
borrowReserveLiquidityFeeReceiver: borrowReserve.feeVault,
|
|
7078
|
+
userDestinationLiquidity,
|
|
7079
|
+
referrerTokenState: null,
|
|
7080
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
7081
|
+
tokenProgram,
|
|
7082
|
+
obligationFarmUserState: obligationFarmUser,
|
|
7083
|
+
reserveFarmState: borrowReserve.farmDebt,
|
|
7084
|
+
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
7085
|
+
})
|
|
7086
|
+
.instruction();
|
|
7087
|
+
return [...preInstructions, borrowIx];
|
|
7088
|
+
}
|
|
7089
|
+
async borrowTx(market, asset, amount, txOptions = {}) {
|
|
7090
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
7091
|
+
const ixs = await this.borrowIxs(market, asset, amount, glamSigner);
|
|
7092
|
+
const tx = this.build(ixs, txOptions);
|
|
7093
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
7094
|
+
}
|
|
7095
|
+
async repayIxs(market, asset, amount, glamSigner) {
|
|
7096
|
+
const vault = this.base.vaultPda;
|
|
7097
|
+
const obligation = this.klend.getObligationPda(vault, market);
|
|
7098
|
+
const preInstructions = [];
|
|
7099
|
+
const repayReserve = await this.klend.findAndParseReserve(market, asset);
|
|
7100
|
+
const { farmUser: obligationFarmUser, initIx } = await this.initObligationFarmUserForReserveIx(obligation, repayReserve, 1, // debt farm
|
|
7101
|
+
glamSigner);
|
|
7102
|
+
if (initIx) {
|
|
7103
|
+
preInstructions.push(initIx);
|
|
7104
|
+
}
|
|
7105
|
+
const ixs = await this.refreshReservesAndObligationIxs(obligation, repayReserve);
|
|
7106
|
+
preInstructions.push(...ixs);
|
|
7107
|
+
const { tokenProgram } = await (0, accounts_1.fetchMintAndTokenProgram)(this.base.provider.connection, asset);
|
|
7108
|
+
const repayIx = await this.base.extKaminoProgram.methods
|
|
7109
|
+
.lendingRepayObligationLiquidityV2(amount)
|
|
7110
|
+
.accounts({
|
|
7111
|
+
glamState: this.base.statePda,
|
|
7112
|
+
glamSigner,
|
|
7113
|
+
obligation,
|
|
7114
|
+
lendingMarket: market,
|
|
7115
|
+
lendingMarketAuthority: this.klend.getMarketAuthority(market),
|
|
7116
|
+
repayReserve: repayReserve.address,
|
|
7117
|
+
reserveLiquidityMint: asset,
|
|
7118
|
+
reserveDestinationLiquidity: repayReserve.liquiditySupplyVault,
|
|
7119
|
+
userSourceLiquidity: this.base.getVaultAta(asset, tokenProgram),
|
|
7120
|
+
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
7121
|
+
tokenProgram,
|
|
7122
|
+
obligationFarmUserState: obligationFarmUser,
|
|
7123
|
+
reserveFarmState: repayReserve.farmDebt,
|
|
7124
|
+
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
7125
|
+
})
|
|
7126
|
+
.instruction();
|
|
7127
|
+
return [...preInstructions, repayIx];
|
|
7128
|
+
}
|
|
7129
|
+
async repayTx(market, asset, amount, txOptions = {}) {
|
|
7130
|
+
const glamSigner = txOptions.signer || this.base.signer;
|
|
7131
|
+
const ixs = await this.repayIxs(market, asset, amount, glamSigner);
|
|
7132
|
+
const tx = this.build(ixs, txOptions);
|
|
7133
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
7134
|
+
}
|
|
7135
|
+
}
|
|
7136
|
+
class KaminoLendingClient {
|
|
7137
|
+
constructor(base, vault) {
|
|
7138
|
+
this.base = base;
|
|
7139
|
+
this.vault = vault;
|
|
7140
|
+
this.reserves = new utils_1.PkMap();
|
|
7141
|
+
this.obligations = new utils_1.PkMap();
|
|
7142
|
+
this.txBuilder = new TxBuilder(base, vault, this);
|
|
7143
|
+
}
|
|
7144
|
+
/**
|
|
7145
|
+
* Initializes Kamino user metadata
|
|
7146
|
+
*
|
|
7147
|
+
* @param market Lending market
|
|
7148
|
+
* @param referrer Referrer user metadata
|
|
7149
|
+
* @param txOptions
|
|
7150
|
+
* @returns
|
|
7151
|
+
*/
|
|
7152
|
+
async initUserMetadata(txOptions = {}) {
|
|
7153
|
+
const tx = await this.txBuilder.initUserMetadataTx(txOptions);
|
|
7154
|
+
return await this.base.sendAndConfirm(tx);
|
|
7155
|
+
}
|
|
7156
|
+
/**
|
|
7157
|
+
* Deposits asset to the lending market.
|
|
7158
|
+
*
|
|
7159
|
+
* @param market Lending market
|
|
7160
|
+
* @param asset Asset mint
|
|
7161
|
+
* @param amount Amount to deposit
|
|
7162
|
+
* @param txOptions
|
|
7163
|
+
* @returns
|
|
7164
|
+
*/
|
|
7165
|
+
async deposit(market, asset, amount, txOptions = {}) {
|
|
7166
|
+
const tx = await this.txBuilder.depositTx(new web3_js_1.PublicKey(market), new web3_js_1.PublicKey(asset), new anchor_1.BN(amount), txOptions);
|
|
7167
|
+
return await this.base.sendAndConfirm(tx);
|
|
7168
|
+
}
|
|
7169
|
+
/**
|
|
7170
|
+
* Withdraws asset from the lending market.
|
|
7171
|
+
*
|
|
7172
|
+
* @param market Lending market
|
|
7173
|
+
* @param asset Asset mint
|
|
7174
|
+
* @param amount Amount to deposit
|
|
7175
|
+
* @param txOptions
|
|
7176
|
+
* @returns
|
|
7177
|
+
*/
|
|
7178
|
+
async withdraw(market, asset, amount, txOptions = {}) {
|
|
7179
|
+
const tx = await this.txBuilder.withdrawTx(new web3_js_1.PublicKey(market), new web3_js_1.PublicKey(asset), new anchor_1.BN(amount), txOptions);
|
|
7180
|
+
return await this.base.sendAndConfirm(tx);
|
|
7181
|
+
}
|
|
7182
|
+
/**
|
|
7183
|
+
* Borrows asset from the lending market.
|
|
7184
|
+
*
|
|
7185
|
+
* @param market Lending market
|
|
7186
|
+
* @param asset Asset mint
|
|
7187
|
+
* @param amount Amount to borrow
|
|
7188
|
+
* @param txOptions
|
|
7189
|
+
* @returns
|
|
7190
|
+
*/
|
|
7191
|
+
async borrow(market, asset, amount, txOptions = {}) {
|
|
7192
|
+
const tx = await this.txBuilder.borrowTx(new web3_js_1.PublicKey(market), new web3_js_1.PublicKey(asset), new anchor_1.BN(amount), txOptions);
|
|
7193
|
+
return await this.base.sendAndConfirm(tx);
|
|
7194
|
+
}
|
|
7195
|
+
/**
|
|
7196
|
+
* Repays asset to the lending market.
|
|
7197
|
+
*
|
|
7198
|
+
* @param market
|
|
7199
|
+
* @param asset
|
|
7200
|
+
* @param amount
|
|
7201
|
+
* @param txOptions
|
|
7202
|
+
* @returns
|
|
7203
|
+
*/
|
|
7204
|
+
async repay(market, asset, amount, txOptions = {}) {
|
|
7205
|
+
const tx = await this.txBuilder.repayTx(new web3_js_1.PublicKey(market), new web3_js_1.PublicKey(asset), new anchor_1.BN(amount), txOptions);
|
|
7206
|
+
return await this.base.sendAndConfirm(tx);
|
|
7207
|
+
}
|
|
7208
|
+
getUserMetadataPda(owner) {
|
|
7209
|
+
const [userMetadataPda] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("user_meta"), owner.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
7210
|
+
return userMetadataPda;
|
|
7211
|
+
}
|
|
7212
|
+
getObligationPda(owner, market, args = DEFAULT_OBLIGATION_ARGS) {
|
|
7213
|
+
const seed = [
|
|
7214
|
+
Buffer.from([args.tag]),
|
|
7215
|
+
Buffer.from([args.id]),
|
|
7216
|
+
owner.toBuffer(),
|
|
7217
|
+
market.toBuffer(),
|
|
7218
|
+
web3_js_1.PublicKey.default.toBuffer(),
|
|
7219
|
+
web3_js_1.PublicKey.default.toBuffer(),
|
|
7220
|
+
];
|
|
7221
|
+
const [obligation, _] = web3_js_1.PublicKey.findProgramAddressSync(seed, constants_1.KAMINO_LENDING_PROGRAM);
|
|
7222
|
+
return obligation;
|
|
7223
|
+
}
|
|
7224
|
+
// seeds = [BASE_SEED_USER_STATE, farm_state.key().as_ref(), delegatee.key().as_ref()],
|
|
7225
|
+
// for a delegated farm, the delegatee is the obligation, the owner (of farm user state) is the vault PDA
|
|
7226
|
+
// for an un-delegated farm, the delegatee and the owner are the same (vault PDA)
|
|
7227
|
+
getFarmUserState(farmUser, farm) {
|
|
7228
|
+
const [obligationFarm] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("user"), farm.toBuffer(), farmUser.toBuffer()], constants_1.KAMINO_FARM_PROGRAM);
|
|
7229
|
+
return obligationFarm;
|
|
7230
|
+
}
|
|
7231
|
+
getMarketAuthority(market) {
|
|
7232
|
+
const [authority, _] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("lma"), market.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
7233
|
+
return authority;
|
|
7234
|
+
}
|
|
7235
|
+
reservePdas(market, mint) {
|
|
7236
|
+
const [liquiditySupplyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reserve_liq_supply"), market.toBuffer(), mint.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
7237
|
+
const [collateralMint] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reserve_coll_mint"), market.toBuffer(), mint.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
7238
|
+
const [collateralSupplyVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("reserve_coll_supply"), market.toBuffer(), mint.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
7239
|
+
const [feeVault] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("fee_receiver"), market.toBuffer(), mint.toBuffer()], constants_1.KAMINO_LENDING_PROGRAM);
|
|
7240
|
+
return {
|
|
7241
|
+
liquiditySupplyVault,
|
|
7242
|
+
collateralMint,
|
|
7243
|
+
collateralSupplyVault,
|
|
7244
|
+
feeVault,
|
|
7245
|
+
};
|
|
7246
|
+
}
|
|
7247
|
+
parseObligation(obligation, data) {
|
|
7248
|
+
const { lendingMarket, deposits: _deposits, borrows: _borrows, } = kaminoLayouts_1.Obligation.decode(obligation, data);
|
|
7249
|
+
// Map decoded deposits to the expected format, filtering out empty deposits
|
|
7250
|
+
const deposits = _deposits
|
|
7251
|
+
.filter(({ depositReserve }) => !depositReserve.equals(web3_js_1.PublicKey.default))
|
|
7252
|
+
.map(({ depositReserve, depositedAmount, marketValueSf }) => {
|
|
7253
|
+
return {
|
|
7254
|
+
reserve: depositReserve,
|
|
7255
|
+
depositedAmount,
|
|
7256
|
+
marketValueSf,
|
|
7257
|
+
};
|
|
7258
|
+
});
|
|
7259
|
+
// Map decoded borrows to the expected format, filtering out empty borrows
|
|
7260
|
+
const borrows = _borrows
|
|
7261
|
+
.filter(({ borrowReserve }) => !borrowReserve.equals(web3_js_1.PublicKey.default))
|
|
7262
|
+
.map(({ borrowReserve, borrowedAmountSf, marketValueSf, cumulativeBorrowRateBsf, }) => {
|
|
7263
|
+
return {
|
|
7264
|
+
reserve: borrowReserve,
|
|
7265
|
+
borrowedAmountSf,
|
|
7266
|
+
marketValueSf,
|
|
7267
|
+
cumulativeBorrowRateBsf,
|
|
7268
|
+
};
|
|
7269
|
+
});
|
|
7270
|
+
return {
|
|
7271
|
+
address: obligation,
|
|
7272
|
+
lendingMarket,
|
|
7273
|
+
deposits,
|
|
7274
|
+
borrows,
|
|
7275
|
+
};
|
|
7276
|
+
}
|
|
7277
|
+
/**
|
|
7278
|
+
* Fetches and parses an obligation account
|
|
7279
|
+
*/
|
|
7280
|
+
async fetchAndParseObligation(obligation) {
|
|
7281
|
+
const cached = this.obligations.get(obligation);
|
|
7282
|
+
if (cached) {
|
|
7283
|
+
return cached;
|
|
7284
|
+
}
|
|
7285
|
+
const obligationAccount = await this.base.provider.connection.getAccountInfo(obligation);
|
|
7286
|
+
if (!obligationAccount) {
|
|
7287
|
+
throw new Error("Obligation account not found");
|
|
7215
7288
|
}
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
const createAtaIx = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
|
|
7220
|
-
preInstructions.unshift(createAtaIx);
|
|
7221
|
-
// When all assets are being withdrawn from a market, the klend program attempts to close the
|
|
7222
|
-
// obligation account, which requires the system program. We always pass the system program
|
|
7223
|
-
// account as a remaining account just in case.
|
|
7224
|
-
const withdrawIx = await this.base.extKaminoProgram.methods
|
|
7225
|
-
.lendingWithdrawObligationCollateralAndRedeemReserveCollateralV2(amount)
|
|
7226
|
-
.accounts({
|
|
7227
|
-
glamState: this.base.statePda,
|
|
7228
|
-
glamSigner,
|
|
7229
|
-
obligation,
|
|
7230
|
-
lendingMarket: market,
|
|
7231
|
-
lendingMarketAuthority: this.getMarketAuthority(market),
|
|
7232
|
-
withdrawReserve: withdrawReserve.address,
|
|
7233
|
-
reserveLiquidityMint: asset,
|
|
7234
|
-
reserveSourceCollateral: withdrawReserve.collateralSupplyVault,
|
|
7235
|
-
reserveCollateralMint: withdrawReserve.collateralMint,
|
|
7236
|
-
reserveLiquiditySupply: withdrawReserve.liquiditySupplyVault,
|
|
7237
|
-
userDestinationLiquidity,
|
|
7238
|
-
placeholderUserDestinationCollateral: null,
|
|
7239
|
-
collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
7240
|
-
liquidityTokenProgram: tokenProgram,
|
|
7241
|
-
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
7242
|
-
obligationFarmUserState: obligationFarmUser,
|
|
7243
|
-
reserveFarmState: withdrawReserve.farmCollateral,
|
|
7244
|
-
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
7245
|
-
})
|
|
7246
|
-
.remainingAccounts([
|
|
7247
|
-
{
|
|
7248
|
-
pubkey: web3_js_1.SystemProgram.programId,
|
|
7249
|
-
isSigner: false,
|
|
7250
|
-
isWritable: false,
|
|
7251
|
-
},
|
|
7252
|
-
])
|
|
7253
|
-
.instruction();
|
|
7254
|
-
// The final instructions in the tx:
|
|
7255
|
-
// - refreshReserve * N
|
|
7256
|
-
// - refreshObligation
|
|
7257
|
-
// - refreshObligationFarmsForReserve (if farm exists)
|
|
7258
|
-
// - withdrawIx
|
|
7259
|
-
// - refreshObligationFarmsForReserve (if farm exists)
|
|
7260
|
-
const tx = new web3_js_1.Transaction();
|
|
7261
|
-
tx.add(...preInstructions, withdrawIx, ...postInstructions);
|
|
7262
|
-
const vTx = await this.base.intoVersionedTransaction(tx, txOptions);
|
|
7263
|
-
return vTx;
|
|
7289
|
+
const parsedObligation = this.parseObligation(obligation, obligationAccount.data);
|
|
7290
|
+
this.obligations.set(obligation, parsedObligation);
|
|
7291
|
+
return parsedObligation;
|
|
7264
7292
|
}
|
|
7265
|
-
|
|
7266
|
-
const
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7293
|
+
parseReserve(pubkey, data) {
|
|
7294
|
+
const { lendingMarket, farmCollateral, farmDebt, liquidity: { mintPubkey, mintDecimals }, config: { tokenInfo: { scopeConfiguration: { priceFeed }, }, }, collateralExchangeRate, cumulativeBorrowRate, } = kaminoLayouts_1.Reserve.decode(pubkey, data);
|
|
7295
|
+
return {
|
|
7296
|
+
address: pubkey,
|
|
7297
|
+
market: lendingMarket,
|
|
7298
|
+
farmCollateral: farmCollateral.equals(web3_js_1.PublicKey.default)
|
|
7299
|
+
? null
|
|
7300
|
+
: farmCollateral,
|
|
7301
|
+
farmDebt: farmDebt.equals(web3_js_1.PublicKey.default) ? null : farmDebt,
|
|
7302
|
+
liquidityMint: mintPubkey,
|
|
7303
|
+
liquidityMintDecimals: mintDecimals.toNumber(),
|
|
7304
|
+
scopePriceFeed: priceFeed,
|
|
7305
|
+
...this.reservePdas(lendingMarket, mintPubkey),
|
|
7306
|
+
collateralExchangeRate,
|
|
7307
|
+
cumulativeBorrowRate,
|
|
7308
|
+
};
|
|
7309
|
+
}
|
|
7310
|
+
async fetchAndParseReserves(reserves) {
|
|
7311
|
+
const requestReservesSet = new utils_1.PkSet(reserves);
|
|
7312
|
+
const cachedReservesSet = new utils_1.PkSet(Array.from(this.reserves.pkKeys()));
|
|
7313
|
+
// If all requested reserves are cached, return data from cache
|
|
7314
|
+
if (cachedReservesSet.includes(requestReservesSet)) {
|
|
7315
|
+
return Array.from(this.reserves.values()).filter(({ address }) => requestReservesSet.has(address));
|
|
7276
7316
|
}
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
if (
|
|
7280
|
-
|
|
7281
|
-
preInstructions.push(...ixs);
|
|
7282
|
-
postInstructions.push(...ixs); // farms must be refreshed after borrow
|
|
7317
|
+
// Only fetch reserves that are not cached
|
|
7318
|
+
const reservesToFetch = Array.from(requestReservesSet).filter((r) => !cachedReservesSet.has(r));
|
|
7319
|
+
if (process.env.NODE_ENV !== "production") {
|
|
7320
|
+
console.log("Fetching reserves:", reservesToFetch.map((r) => r.toBase58()));
|
|
7283
7321
|
}
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
.
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
obligation,
|
|
7295
|
-
lendingMarket: market,
|
|
7296
|
-
lendingMarketAuthority: this.getMarketAuthority(market),
|
|
7297
|
-
borrowReserve: borrowReserve.address,
|
|
7298
|
-
borrowReserveLiquidityMint: asset,
|
|
7299
|
-
reserveSourceLiquidity: borrowReserve.liquiditySupplyVault,
|
|
7300
|
-
borrowReserveLiquidityFeeReceiver: borrowReserve.feeVault,
|
|
7301
|
-
userDestinationLiquidity,
|
|
7302
|
-
referrerTokenState: null,
|
|
7303
|
-
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
7304
|
-
tokenProgram,
|
|
7305
|
-
obligationFarmUserState: obligationFarmUser,
|
|
7306
|
-
reserveFarmState: borrowReserve.farmDebt,
|
|
7307
|
-
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
7308
|
-
})
|
|
7309
|
-
.instruction();
|
|
7310
|
-
// The final instructions in the tx:
|
|
7311
|
-
// - refreshReserve * N
|
|
7312
|
-
// - refreshObligation
|
|
7313
|
-
// - borrowObligationLiquidityV2
|
|
7314
|
-
const tx = new web3_js_1.Transaction();
|
|
7315
|
-
tx.add(...preInstructions, borrowIx);
|
|
7316
|
-
const vTx = await this.base.intoVersionedTransaction(tx, txOptions);
|
|
7317
|
-
return vTx;
|
|
7322
|
+
const reserveAccounts = await this.base.provider.connection.getMultipleAccountsInfo(reservesToFetch);
|
|
7323
|
+
if (reserveAccounts.some((a) => !a)) {
|
|
7324
|
+
throw new Error("Not all reserves can be found");
|
|
7325
|
+
}
|
|
7326
|
+
reserveAccounts.forEach((account, i) => {
|
|
7327
|
+
const parsedReserve = this.parseReserve(reservesToFetch[i], account.data);
|
|
7328
|
+
this.reserves.set(reservesToFetch[i], parsedReserve);
|
|
7329
|
+
});
|
|
7330
|
+
// Return requested reserves
|
|
7331
|
+
return Array.from(this.reserves.values()).filter(({ address }) => requestReservesSet.has(address));
|
|
7318
7332
|
}
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7333
|
+
/**
|
|
7334
|
+
* Finds and parses a reserve account for a given market and asset
|
|
7335
|
+
*
|
|
7336
|
+
* @param market The lending market public key
|
|
7337
|
+
* @param asset The asset public key
|
|
7338
|
+
* @returns The parsed reserve account
|
|
7339
|
+
*/
|
|
7340
|
+
async findAndParseReserve(market, asset) {
|
|
7341
|
+
const accounts = await this.base.provider.connection.getProgramAccounts(constants_1.KAMINO_LENDING_PROGRAM, {
|
|
7342
|
+
filters: [
|
|
7343
|
+
{ dataSize: constants_1.KAMINO_RESERVE_SIZE },
|
|
7344
|
+
{ memcmp: { offset: 32, bytes: market.toBase58() } },
|
|
7345
|
+
{ memcmp: { offset: 128, bytes: asset.toBase58() } },
|
|
7346
|
+
],
|
|
7347
|
+
});
|
|
7348
|
+
if (accounts.length === 0) {
|
|
7349
|
+
throw new Error("Reserve not found");
|
|
7329
7350
|
}
|
|
7330
|
-
const
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
// - refreshReserve * N
|
|
7354
|
-
// - refreshObligation
|
|
7355
|
-
// - repayObligationLiquidityV2
|
|
7356
|
-
const tx = new web3_js_1.Transaction();
|
|
7357
|
-
tx.add(...preInstructions, repayIx);
|
|
7358
|
-
const vTx = await this.base.intoVersionedTransaction(tx, txOptions);
|
|
7359
|
-
return vTx;
|
|
7351
|
+
const parsedReserve = this.parseReserve(accounts[0].pubkey, accounts[0].account.data);
|
|
7352
|
+
this.reserves.set(accounts[0].pubkey, parsedReserve);
|
|
7353
|
+
return parsedReserve;
|
|
7354
|
+
}
|
|
7355
|
+
/**
|
|
7356
|
+
* Finds and parses Kamino obligations for a given owner and market (optional)
|
|
7357
|
+
*/
|
|
7358
|
+
async findAndParseObligations(owner, market) {
|
|
7359
|
+
const accounts = await this.base.provider.connection.getProgramAccounts(constants_1.KAMINO_LENDING_PROGRAM, {
|
|
7360
|
+
filters: [
|
|
7361
|
+
{ dataSize: constants_1.KAMINO_OBTRIGATION_SIZE },
|
|
7362
|
+
{ memcmp: { offset: 64, bytes: owner.toBase58() } },
|
|
7363
|
+
...(market
|
|
7364
|
+
? [{ memcmp: { offset: 32, bytes: market.toBase58() } }]
|
|
7365
|
+
: []),
|
|
7366
|
+
],
|
|
7367
|
+
});
|
|
7368
|
+
// Parse obligations and cache them
|
|
7369
|
+
return accounts.map((a) => {
|
|
7370
|
+
const parsedObligation = this.parseObligation(a.pubkey, a.account.data);
|
|
7371
|
+
this.obligations.set(a.pubkey, parsedObligation);
|
|
7372
|
+
return parsedObligation;
|
|
7373
|
+
});
|
|
7360
7374
|
}
|
|
7361
7375
|
}
|
|
7362
7376
|
exports.KaminoLendingClient = KaminoLendingClient;
|
|
@@ -8363,11 +8377,12 @@ const spl_token_1 = __webpack_require__(17);
|
|
|
8363
8377
|
const constants_1 = __webpack_require__(25);
|
|
8364
8378
|
const jupiter_1 = __webpack_require__(57);
|
|
8365
8379
|
class Holding {
|
|
8366
|
-
constructor(mintAddress, decimals, amount, price, protocol, protocolMeta = {}) {
|
|
8380
|
+
constructor(mintAddress, decimals, amount, price, priceMeta = {}, protocol, protocolMeta = {}) {
|
|
8367
8381
|
this.mintAddress = mintAddress;
|
|
8368
8382
|
this.decimals = decimals;
|
|
8369
8383
|
this.amount = amount;
|
|
8370
8384
|
this.price = price;
|
|
8385
|
+
this.priceMeta = priceMeta;
|
|
8371
8386
|
this.protocol = protocol;
|
|
8372
8387
|
this.protocolMeta = protocolMeta;
|
|
8373
8388
|
this.uiAmount = (0, utils_1.toUiAmount)(this.amount, this.decimals);
|
|
@@ -8506,9 +8521,9 @@ class PriceClient {
|
|
|
8506
8521
|
const tokenMint = new web3_js_1.PublicKey(item.address);
|
|
8507
8522
|
tokenPricesMap.set(tokenMint, item);
|
|
8508
8523
|
});
|
|
8509
|
-
const tokenHoldings = this.getTokenHoldings(tokenPubkeys, accountsDataMap, tokenPricesMap);
|
|
8510
|
-
const driftSpotHoldings = this.getDriftSpotHoldings(driftPubkeys.pkKeys(), driftSpotMarketsMap, accountsDataMap, tokenPricesMap);
|
|
8511
|
-
const kaminoLendHoldings = this.getKaminoLendHoldings(kaminoPubkeys.pkKeys(), kaminoReservesMap, accountsDataMap, tokenPricesMap);
|
|
8524
|
+
const tokenHoldings = this.getTokenHoldings(tokenPubkeys, accountsDataMap, tokenPricesMap, "Jupiter");
|
|
8525
|
+
const driftSpotHoldings = this.getDriftSpotHoldings(driftPubkeys.pkKeys(), driftSpotMarketsMap, accountsDataMap, tokenPricesMap, "Jupiter");
|
|
8526
|
+
const kaminoLendHoldings = this.getKaminoLendHoldings(kaminoPubkeys.pkKeys(), kaminoReservesMap, accountsDataMap, tokenPricesMap, "Jupiter");
|
|
8512
8527
|
const timestamp = accountsDataMap
|
|
8513
8528
|
.get(web3_js_1.SYSVAR_CLOCK_PUBKEY)
|
|
8514
8529
|
.readUInt32LE(32);
|
|
@@ -8569,7 +8584,7 @@ class PriceClient {
|
|
|
8569
8584
|
}
|
|
8570
8585
|
return obligationReservesMap;
|
|
8571
8586
|
}
|
|
8572
|
-
getTokenHoldings(tokenAccountPubkeys, accountsDataMap, tokenPricesMap) {
|
|
8587
|
+
getTokenHoldings(tokenAccountPubkeys, accountsDataMap, tokenPricesMap, priceSource) {
|
|
8573
8588
|
const holdings = [];
|
|
8574
8589
|
if (tokenAccountPubkeys.length === 0) {
|
|
8575
8590
|
return holdings;
|
|
@@ -8579,7 +8594,10 @@ class PriceClient {
|
|
|
8579
8594
|
const tokenInfo = tokenPricesMap.get(mint);
|
|
8580
8595
|
if (tokenInfo) {
|
|
8581
8596
|
const { decimals, usdPrice } = tokenInfo;
|
|
8582
|
-
const holding = new Holding(mint, decimals, new anchor_1.BN(amount), usdPrice,
|
|
8597
|
+
const holding = new Holding(mint, decimals, new anchor_1.BN(amount), usdPrice, {
|
|
8598
|
+
slot: tokenInfo.slot,
|
|
8599
|
+
source: priceSource,
|
|
8600
|
+
}, "Token", {
|
|
8583
8601
|
tokenAccount: pubkey,
|
|
8584
8602
|
});
|
|
8585
8603
|
holdings.push(holding);
|
|
@@ -8587,7 +8605,7 @@ class PriceClient {
|
|
|
8587
8605
|
}
|
|
8588
8606
|
return holdings;
|
|
8589
8607
|
}
|
|
8590
|
-
getDriftSpotHoldings(userPubkeys, spotMarketsMap, accountsDataMap, tokenPricesMap) {
|
|
8608
|
+
getDriftSpotHoldings(userPubkeys, spotMarketsMap, accountsDataMap, tokenPricesMap, priceSource) {
|
|
8591
8609
|
const holdings = [];
|
|
8592
8610
|
for (const userPda of userPubkeys) {
|
|
8593
8611
|
const { spotPositions } = (0, utils_1.decodeUser)(accountsDataMap.get(userPda));
|
|
@@ -8599,7 +8617,10 @@ class PriceClient {
|
|
|
8599
8617
|
: cumulativeDepositInterest;
|
|
8600
8618
|
const amount = this.drift.calcSpotBalanceBn(scaledBalance, decimals, interest);
|
|
8601
8619
|
const direction = Object.keys(balanceType)[0];
|
|
8602
|
-
const holding = new Holding(mint, decimals, amount, tokenPricesMap.get(mint).usdPrice,
|
|
8620
|
+
const holding = new Holding(mint, decimals, amount, tokenPricesMap.get(mint).usdPrice, {
|
|
8621
|
+
slot: tokenPricesMap.get(mint).slot,
|
|
8622
|
+
source: priceSource,
|
|
8623
|
+
}, "DriftProtocol", {
|
|
8603
8624
|
user: userPda,
|
|
8604
8625
|
marketIndex: marketIndex,
|
|
8605
8626
|
direction: direction,
|
|
@@ -8609,7 +8630,7 @@ class PriceClient {
|
|
|
8609
8630
|
}
|
|
8610
8631
|
return holdings;
|
|
8611
8632
|
}
|
|
8612
|
-
getKaminoLendHoldings(obligationPubkeys, reservesMap, accountsDataMap, tokenPricesMap) {
|
|
8633
|
+
getKaminoLendHoldings(obligationPubkeys, reservesMap, accountsDataMap, tokenPricesMap, priceSource) {
|
|
8613
8634
|
const holdings = [];
|
|
8614
8635
|
for (const obligation of obligationPubkeys) {
|
|
8615
8636
|
const { deposits, borrows } = this.klend.parseObligation(obligation, accountsDataMap.get(obligation));
|
|
@@ -8619,7 +8640,10 @@ class PriceClient {
|
|
|
8619
8640
|
.div(parsedReserve.collateralExchangeRate)
|
|
8620
8641
|
.floor();
|
|
8621
8642
|
const amount = new anchor_1.BN(supplyAmount.toString());
|
|
8622
|
-
const holding = new Holding(parsedReserve.liquidityMint, parsedReserve.liquidityMintDecimals, amount, tokenPricesMap.get(parsedReserve.liquidityMint).usdPrice,
|
|
8643
|
+
const holding = new Holding(parsedReserve.liquidityMint, parsedReserve.liquidityMintDecimals, amount, tokenPricesMap.get(parsedReserve.liquidityMint).usdPrice, {
|
|
8644
|
+
slot: tokenPricesMap.get(parsedReserve.liquidityMint).slot,
|
|
8645
|
+
source: priceSource,
|
|
8646
|
+
}, "KaminoLend", {
|
|
8623
8647
|
obligation,
|
|
8624
8648
|
market: parsedReserve.market,
|
|
8625
8649
|
reserve,
|
|
@@ -8636,7 +8660,10 @@ class PriceClient {
|
|
|
8636
8660
|
.div(obligationCumulativeBorrowRate)
|
|
8637
8661
|
.ceil();
|
|
8638
8662
|
const amount = new anchor_1.BN(borrowAmount.toString());
|
|
8639
|
-
const holding = new Holding(parsedReserve.liquidityMint, parsedReserve.liquidityMintDecimals, amount, tokenPricesMap.get(parsedReserve.liquidityMint).usdPrice,
|
|
8663
|
+
const holding = new Holding(parsedReserve.liquidityMint, parsedReserve.liquidityMintDecimals, amount, tokenPricesMap.get(parsedReserve.liquidityMint).usdPrice, {
|
|
8664
|
+
slot: tokenPricesMap.get(parsedReserve.liquidityMint).slot,
|
|
8665
|
+
source: priceSource,
|
|
8666
|
+
}, "KaminoLend", {
|
|
8640
8667
|
obligation,
|
|
8641
8668
|
market: parsedReserve.market,
|
|
8642
8669
|
reserve,
|
|
@@ -8673,10 +8700,10 @@ class PriceClient {
|
|
|
8673
8700
|
});
|
|
8674
8701
|
// Refresh reserves in batch
|
|
8675
8702
|
const parsedReserves = await this.klend.fetchAndParseReserves(Array.from(reservesSet));
|
|
8676
|
-
ixs.push(this.klend.refreshReservesBatchIx(parsedReserves, false));
|
|
8703
|
+
ixs.push(this.klend.txBuilder.refreshReservesBatchIx(parsedReserves, false));
|
|
8677
8704
|
// Refresh obligations
|
|
8678
8705
|
parsedObligations.forEach(({ address: obligation, lendingMarket }) => {
|
|
8679
|
-
ixs.push(this.klend.refreshObligationIx({
|
|
8706
|
+
ixs.push(this.klend.txBuilder.refreshObligationIx({
|
|
8680
8707
|
obligation,
|
|
8681
8708
|
lendingMarket,
|
|
8682
8709
|
reserves: Array.from(obligationReservesMap.get(obligation) || []),
|
|
@@ -8761,7 +8788,7 @@ class PriceClient {
|
|
|
8761
8788
|
}
|
|
8762
8789
|
}
|
|
8763
8790
|
const parsedReserves = await this.klend.fetchAndParseReserves(reserves);
|
|
8764
|
-
const refreshReservesIx = this.klend.refreshReservesBatchIx(parsedReserves, false);
|
|
8791
|
+
const refreshReservesIx = this.klend.txBuilder.refreshReservesBatchIx(parsedReserves, false);
|
|
8765
8792
|
const preInstructions = [refreshReservesIx];
|
|
8766
8793
|
const priceIx = await this.base.mintProgram.methods
|
|
8767
8794
|
.priceKaminoVaultShares(shareAtas.length)
|
|
@@ -8894,33 +8921,26 @@ class PriceClient {
|
|
|
8894
8921
|
* Returns an instruction that prices stake accounts.
|
|
8895
8922
|
* If there are no stake accounts, returns null.
|
|
8896
8923
|
*/
|
|
8897
|
-
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
.accounts({
|
|
8909
|
-
glamState: this.base.statePda,
|
|
8910
|
-
solUsdOracle: SOL_ORACLE,
|
|
8911
|
-
baseAssetOracle: await this.getbaseAssetOracle(),
|
|
8924
|
+
async priceStakeAccountsIx() {
|
|
8925
|
+
const stakes = await (0, utils_1.findStakeAccounts)(this.base.connection, this.base.vaultPda);
|
|
8926
|
+
if (stakes.length === 0) {
|
|
8927
|
+
return null;
|
|
8928
|
+
}
|
|
8929
|
+
const priceStakesIx = await this.base.mintProgram.methods
|
|
8930
|
+
.priceStakeAccounts()
|
|
8931
|
+
.accounts({
|
|
8932
|
+
glamState: this.base.statePda,
|
|
8933
|
+
solUsdOracle: assets_1.SOL_ORACLE,
|
|
8934
|
+
baseAssetOracle: await this.getbaseAssetOracle(),
|
|
8912
8935
|
})
|
|
8913
|
-
|
|
8914
|
-
stakes.map((pubkey) => ({
|
|
8936
|
+
.remainingAccounts(stakes.map((pubkey) => ({
|
|
8915
8937
|
pubkey,
|
|
8916
8938
|
isSigner: false,
|
|
8917
8939
|
isWritable: false,
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
return priceStakesIx;
|
|
8940
|
+
})))
|
|
8941
|
+
.instruction();
|
|
8942
|
+
return priceStakesIx;
|
|
8922
8943
|
}
|
|
8923
|
-
*/
|
|
8924
8944
|
/**
|
|
8925
8945
|
* Returns an instruction that prices Meteora positions.
|
|
8926
8946
|
* If there are no Meteora positions, returns null.
|
|
@@ -8983,6 +9003,15 @@ class PriceClient {
|
|
|
8983
9003
|
pricingIxs.push(...ixs);
|
|
8984
9004
|
}
|
|
8985
9005
|
}
|
|
9006
|
+
const nativeIntegrationAcl = integrationAcls.find((acl) => acl.integrationProgram.equals(this.base.protocolProgram.programId));
|
|
9007
|
+
if (nativeIntegrationAcl) {
|
|
9008
|
+
// stake program
|
|
9009
|
+
if (nativeIntegrationAcl.protocolsBitmask & 0b10) {
|
|
9010
|
+
const ix = await this.priceStakeAccountsIx();
|
|
9011
|
+
if (ix)
|
|
9012
|
+
pricingIxs.push(ix);
|
|
9013
|
+
}
|
|
9014
|
+
}
|
|
8986
9015
|
return pricingIxs.filter(Boolean);
|
|
8987
9016
|
}
|
|
8988
9017
|
async validateAumIx() {
|
|
@@ -9554,7 +9583,7 @@ class TxBuilder extends base_1.BaseTxBuilder {
|
|
|
9554
9583
|
}
|
|
9555
9584
|
async closeMint(txOptions = {}) {
|
|
9556
9585
|
const ix = await this.closeMintIx(txOptions.signer);
|
|
9557
|
-
const tx = this.build(ix, txOptions);
|
|
9586
|
+
const tx = this.build([ix], txOptions);
|
|
9558
9587
|
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
9559
9588
|
}
|
|
9560
9589
|
}
|
|
@@ -9700,7 +9729,7 @@ const models_1 = __webpack_require__(14);
|
|
|
9700
9729
|
class TxBuilder extends base_1.BaseTxBuilder {
|
|
9701
9730
|
async emergencyAccessUpdate(args, txOptions = {}) {
|
|
9702
9731
|
const ix = await this.emergencyAccessUpdateIx(args, txOptions.signer);
|
|
9703
|
-
const tx = this.build(ix, txOptions);
|
|
9732
|
+
const tx = this.build([ix], txOptions);
|
|
9704
9733
|
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
9705
9734
|
}
|
|
9706
9735
|
async emergencyAccessUpdateIx(args, signer) {
|
|
@@ -9980,10 +10009,9 @@ class StakingClient {
|
|
|
9980
10009
|
const txSig = await this.base.sendAndConfirm(tx);
|
|
9981
10010
|
return { newStake, txSig };
|
|
9982
10011
|
}
|
|
9983
|
-
async
|
|
9984
|
-
const
|
|
9985
|
-
|
|
9986
|
-
return { newStake, txSig };
|
|
10012
|
+
async move(sourceStake, destinationStake, amount, txOptions = {}) {
|
|
10013
|
+
const tx = await this.moveStakeTx(sourceStake, destinationStake, amount, txOptions);
|
|
10014
|
+
return await this.base.sendAndConfirm(tx);
|
|
9987
10015
|
}
|
|
9988
10016
|
/*
|
|
9989
10017
|
* Utils
|
|
@@ -10118,7 +10146,6 @@ class StakingClient {
|
|
|
10118
10146
|
stakePoolWithdrawAuthority: withdrawAuthority,
|
|
10119
10147
|
reserveStake,
|
|
10120
10148
|
feeAccount,
|
|
10121
|
-
referrerPoolTokensAccount: poolTokensTo,
|
|
10122
10149
|
poolTokensTo,
|
|
10123
10150
|
poolMint,
|
|
10124
10151
|
tokenProgram,
|
|
@@ -10131,7 +10158,7 @@ class StakingClient {
|
|
|
10131
10158
|
}
|
|
10132
10159
|
async stakePoolDepositStakeTx(stakePool, stakeAccount, txOptions = {}) {
|
|
10133
10160
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
10134
|
-
const { programId: stakePoolProgram, poolMint, withdrawAuthority, feeAccount, validatorList, tokenProgramId: tokenProgram, reserveStake, } = await this.getStakePoolAccountData(stakePool);
|
|
10161
|
+
const { programId: stakePoolProgram, poolMint, depositAuthority, withdrawAuthority, feeAccount, validatorList, tokenProgramId: tokenProgram, reserveStake, } = await this.getStakePoolAccountData(stakePool);
|
|
10135
10162
|
const glamVault = this.base.vaultPda;
|
|
10136
10163
|
const poolTokensTo = this.base.getVaultAta(poolMint, tokenProgram);
|
|
10137
10164
|
// All stake accounts owned by the stake pool withdraw authority
|
|
@@ -10153,6 +10180,7 @@ class StakingClient {
|
|
|
10153
10180
|
glamState: this.base.statePda,
|
|
10154
10181
|
cpiProgram: stakePoolProgram,
|
|
10155
10182
|
stakePool,
|
|
10183
|
+
stakePoolDepositAuthority: depositAuthority,
|
|
10156
10184
|
stakePoolWithdrawAuthority: withdrawAuthority,
|
|
10157
10185
|
validatorList,
|
|
10158
10186
|
validatorStakeAccount,
|
|
@@ -10161,7 +10189,6 @@ class StakingClient {
|
|
|
10161
10189
|
poolTokensTo,
|
|
10162
10190
|
poolMint,
|
|
10163
10191
|
feeAccount,
|
|
10164
|
-
referrerPoolTokensAccount: poolTokensTo,
|
|
10165
10192
|
tokenProgram,
|
|
10166
10193
|
})
|
|
10167
10194
|
.preInstructions([
|
|
@@ -10184,7 +10211,6 @@ class StakingClient {
|
|
|
10184
10211
|
const postInstructions = deactivate
|
|
10185
10212
|
? [
|
|
10186
10213
|
await this.base.protocolProgram.methods
|
|
10187
|
-
// @ts-ignore
|
|
10188
10214
|
.stakeDeactivate()
|
|
10189
10215
|
.accounts({
|
|
10190
10216
|
glamSigner,
|
|
@@ -10219,7 +10245,6 @@ class StakingClient {
|
|
|
10219
10245
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
10220
10246
|
const [stakeAccount, createStakeAccountIx] = await this.createStakeAccount(glamSigner);
|
|
10221
10247
|
const initStakeIx = await this.base.protocolProgram.methods
|
|
10222
|
-
// @ts-ignore
|
|
10223
10248
|
.stakeInitialize()
|
|
10224
10249
|
.accounts({
|
|
10225
10250
|
glamState: this.base.statePda,
|
|
@@ -10236,7 +10261,6 @@ class StakingClient {
|
|
|
10236
10261
|
})
|
|
10237
10262
|
.instruction();
|
|
10238
10263
|
const tx = await this.base.protocolProgram.methods
|
|
10239
|
-
// @ts-ignore
|
|
10240
10264
|
.stakeDelegateStake()
|
|
10241
10265
|
.accounts({
|
|
10242
10266
|
glamState: this.base.statePda,
|
|
@@ -10255,7 +10279,6 @@ class StakingClient {
|
|
|
10255
10279
|
}
|
|
10256
10280
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
10257
10281
|
const tx = await this.base.protocolProgram.methods
|
|
10258
|
-
// @ts-ignore
|
|
10259
10282
|
.stakeDeactivate()
|
|
10260
10283
|
.accounts({
|
|
10261
10284
|
glamState: this.base.statePda,
|
|
@@ -10281,7 +10304,6 @@ class StakingClient {
|
|
|
10281
10304
|
}
|
|
10282
10305
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
10283
10306
|
const tx = await this.base.protocolProgram.methods
|
|
10284
|
-
// @ts-ignore
|
|
10285
10307
|
.stakeWithdraw(lamports)
|
|
10286
10308
|
.accounts({
|
|
10287
10309
|
glamSigner,
|
|
@@ -10299,7 +10321,6 @@ class StakingClient {
|
|
|
10299
10321
|
async mergeStakeTx(destinationStake, sourceStake, txOptions = {}) {
|
|
10300
10322
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
10301
10323
|
const tx = await this.base.protocolProgram.methods
|
|
10302
|
-
// @ts-ignore
|
|
10303
10324
|
.stakeMerge()
|
|
10304
10325
|
.accounts({
|
|
10305
10326
|
glamSigner,
|
|
@@ -10314,7 +10335,6 @@ class StakingClient {
|
|
|
10314
10335
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
10315
10336
|
const [newStake, createStakeAccountIx] = await this.createStakeAccount(glamSigner);
|
|
10316
10337
|
const tx = await this.base.protocolProgram.methods
|
|
10317
|
-
// @ts-ignore
|
|
10318
10338
|
.stakeSplit(lamports)
|
|
10319
10339
|
.accounts({
|
|
10320
10340
|
glamSigner,
|
|
@@ -10327,24 +10347,18 @@ class StakingClient {
|
|
|
10327
10347
|
const vTx = await this.base.intoVersionedTransaction(tx, txOptions);
|
|
10328
10348
|
return { tx: vTx, newStake };
|
|
10329
10349
|
}
|
|
10330
|
-
async
|
|
10350
|
+
async moveStakeTx(sourceStake, destinationStake, amount, txOptions = {}) {
|
|
10331
10351
|
const glamSigner = txOptions.signer || this.base.signer;
|
|
10332
|
-
const [newStake, createStakeAccountIx] = await this.createStakeAccount(glamSigner);
|
|
10333
10352
|
const tx = await this.base.protocolProgram.methods
|
|
10334
|
-
|
|
10335
|
-
.stakeRedelegate()
|
|
10353
|
+
.stakeMove(true, amount)
|
|
10336
10354
|
.accounts({
|
|
10337
10355
|
glamSigner,
|
|
10338
10356
|
glamState: this.base.statePda,
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
newStake,
|
|
10342
|
-
stakeConfig: web3_js_1.STAKE_CONFIG_ID,
|
|
10357
|
+
sourceStake,
|
|
10358
|
+
destinationStake,
|
|
10343
10359
|
})
|
|
10344
|
-
.preInstructions([createStakeAccountIx])
|
|
10345
10360
|
.transaction();
|
|
10346
|
-
|
|
10347
|
-
return { tx: vTx, newStake };
|
|
10361
|
+
return await this.base.intoVersionedTransaction(tx, txOptions);
|
|
10348
10362
|
}
|
|
10349
10363
|
}
|
|
10350
10364
|
exports.StakingClient = StakingClient;
|
|
@@ -10418,7 +10432,8 @@ class CctpClient {
|
|
|
10418
10432
|
const ix = await this.buildReceiveMessageIx(sourceDomain, message);
|
|
10419
10433
|
receiveMessageIxs.push(ix);
|
|
10420
10434
|
}
|
|
10421
|
-
const
|
|
10435
|
+
const createUsdcAtaIx = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(this.base.signer, this.base.getVaultAta(constants_1.USDC), this.base.vaultPda, constants_1.USDC);
|
|
10436
|
+
const tx = new web3_js_1.Transaction().add(createUsdcAtaIx, ...receiveMessageIxs);
|
|
10422
10437
|
const vTx = await this.base.intoVersionedTransaction(tx, txOptions);
|
|
10423
10438
|
return await this.base.sendAndConfirm(vTx);
|
|
10424
10439
|
}
|
|
@@ -11514,7 +11529,7 @@ function installDriftProtocolCommands(drift, context) {
|
|
|
11514
11529
|
.description("Update a drift user's pool ID")
|
|
11515
11530
|
.action(async (subAccountId, poolId) => {
|
|
11516
11531
|
try {
|
|
11517
|
-
const tx = new web3_js_1.Transaction().add(await context.glamClient.drift.updateUserPoolIdIx(subAccountId, poolId));
|
|
11532
|
+
const tx = new web3_js_1.Transaction().add(await context.glamClient.drift.txBuilder.updateUserPoolIdIx(subAccountId, poolId));
|
|
11518
11533
|
const vTx = await context.glamClient.intoVersionedTransaction(tx, context.txOptions);
|
|
11519
11534
|
const txSig = await context.glamClient.sendAndConfirm(vTx);
|
|
11520
11535
|
console.log(`Updated drift user's pool ID: ${txSig}`);
|
|
@@ -14150,7 +14165,7 @@ program
|
|
|
14150
14165
|
initialize(config, skipSimulation);
|
|
14151
14166
|
await (0, idl_1.idlCheck)(context.glamClient);
|
|
14152
14167
|
})
|
|
14153
|
-
.version("1.0.3
|
|
14168
|
+
.version("1.0.3");
|
|
14154
14169
|
program
|
|
14155
14170
|
.command("env")
|
|
14156
14171
|
.description("Display current environment setup")
|