@reflectmoney/stable.ts 1.0.1 → 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/README.md +108 -84
- package/dist/classes/ReflectKeeper.d.ts +104 -0
- package/dist/classes/ReflectKeeper.js +219 -0
- package/dist/classes/Stablecoin.d.ts +3 -1
- package/dist/classes/Stablecoin.js +2 -1
- package/dist/classes/index.d.ts +1 -1
- package/dist/classes/index.js +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/lookupTables.d.ts +4 -0
- package/dist/constants/lookupTables.js +7 -0
- package/dist/stablecoins/LstStablecoin.js +1 -1
- package/dist/stablecoins/UsdcPlusStablecoin.d.ts +66 -0
- package/dist/stablecoins/UsdcPlusStablecoin.js +197 -0
- package/dist/stablecoins/UsdjStablecoin.d.ts +1 -0
- package/dist/stablecoins/UsdjStablecoin.js +44 -0
- package/dist/stablecoins/index.d.ts +2 -2
- package/dist/stablecoins/index.js +2 -2
- package/package.json +1 -1
- package/dist/classes/Strategy.d.ts +0 -30
- package/dist/classes/Strategy.js +0 -196
- package/dist/generated/accounts/DriftJlpController.d.ts +0 -114
- package/dist/generated/accounts/DriftJlpController.js +0 -169
- package/dist/generated/accounts/DriftLstController.d.ts +0 -108
- package/dist/generated/accounts/DriftLstController.js +0 -165
- package/dist/generated/accounts/DriftUsdcController.d.ts +0 -102
- package/dist/generated/accounts/DriftUsdcController.js +0 -158
- package/dist/generated/accounts/Main.d.ts +0 -110
- package/dist/generated/accounts/Main.js +0 -165
- package/dist/generated/accounts/PerpMarket.d.ts +0 -226
- package/dist/generated/accounts/PerpMarket.js +0 -307
- package/dist/generated/accounts/PrelaunchOracle.d.ts +0 -130
- package/dist/generated/accounts/PrelaunchOracle.js +0 -224
- package/dist/generated/accounts/PythLazerOracle.d.ts +0 -124
- package/dist/generated/accounts/PythLazerOracle.js +0 -210
- package/dist/generated/accounts/RebalanceLst.d.ts +0 -111
- package/dist/generated/accounts/RebalanceLst.js +0 -175
- package/dist/generated/accounts/SpotMarket.d.ts +0 -377
- package/dist/generated/accounts/SpotMarket.js +0 -601
- package/dist/generated/accounts/User.d.ts +0 -221
- package/dist/generated/accounts/User.js +0 -331
- package/dist/generated/accounts/UserPermissions.d.ts +0 -106
- package/dist/generated/accounts/UserPermissions.js +0 -161
- package/dist/generated/accounts/UserStats.d.ts +0 -211
- package/dist/generated/accounts/UserStats.js +0 -323
- package/dist/generated/accounts/index.d.ts +0 -38
- package/dist/generated/accounts/index.js +0 -55
- package/dist/generated/errors/index.d.ts +0 -1024
- package/dist/generated/errors/index.js +0 -1761
- package/dist/generated/index.d.ts +0 -19
- package/dist/generated/index.js +0 -36
- package/dist/generated/instructions/addLstDrift.d.ts +0 -49
- package/dist/generated/instructions/addLstDrift.js +0 -106
- package/dist/generated/instructions/addSubAccount.d.ts +0 -54
- package/dist/generated/instructions/addSubAccount.js +0 -121
- package/dist/generated/instructions/adjustHedgeS2.d.ts +0 -69
- package/dist/generated/instructions/adjustHedgeS2.js +0 -157
- package/dist/generated/instructions/captureSpreadDrift.d.ts +0 -56
- package/dist/generated/instructions/captureSpreadDrift.js +0 -120
- package/dist/generated/instructions/createAdminAccount.d.ts +0 -53
- package/dist/generated/instructions/createAdminAccount.js +0 -95
- package/dist/generated/instructions/createUserStatsAccount.d.ts +0 -54
- package/dist/generated/instructions/createUserStatsAccount.js +0 -121
- package/dist/generated/instructions/depositDrift.d.ts +0 -73
- package/dist/generated/instructions/depositDrift.js +0 -142
- package/dist/generated/instructions/freezeProgram.d.ts +0 -54
- package/dist/generated/instructions/freezeProgram.js +0 -95
- package/dist/generated/instructions/freezeProtocolAction.d.ts +0 -55
- package/dist/generated/instructions/freezeProtocolAction.js +0 -96
- package/dist/generated/instructions/freezeStrategyAction.d.ts +0 -58
- package/dist/generated/instructions/freezeStrategyAction.js +0 -102
- package/dist/generated/instructions/index.d.ts +0 -41
- package/dist/generated/instructions/index.js +0 -57
- package/dist/generated/instructions/initDriftAccountsS1.d.ts +0 -56
- package/dist/generated/instructions/initDriftAccountsS1.js +0 -126
- package/dist/generated/instructions/initDriftControllerS1.d.ts +0 -60
- package/dist/generated/instructions/initDriftControllerS1.js +0 -108
- package/dist/generated/instructions/initDriftControllerS2.d.ts +0 -66
- package/dist/generated/instructions/initDriftControllerS2.js +0 -125
- package/dist/generated/instructions/initDriftControllerS3.d.ts +0 -58
- package/dist/generated/instructions/initDriftControllerS3.js +0 -103
- package/dist/generated/instructions/initMain.d.ts +0 -43
- package/dist/generated/instructions/initMain.js +0 -91
- package/dist/generated/instructions/mintDriftS1.d.ts +0 -90
- package/dist/generated/instructions/mintDriftS1.js +0 -184
- package/dist/generated/instructions/mintDriftS2.d.ts +0 -80
- package/dist/generated/instructions/mintDriftS2.js +0 -161
- package/dist/generated/instructions/mintDriftS3.d.ts +0 -86
- package/dist/generated/instructions/mintDriftS3.js +0 -174
- package/dist/generated/instructions/processSwapDeposit.d.ts +0 -79
- package/dist/generated/instructions/processSwapDeposit.js +0 -161
- package/dist/generated/instructions/processSwapDepositIntrospection.d.ts +0 -79
- package/dist/generated/instructions/processSwapDepositIntrospection.js +0 -161
- package/dist/generated/instructions/processSwapWithdraw.d.ts +0 -68
- package/dist/generated/instructions/processSwapWithdraw.js +0 -157
- package/dist/generated/instructions/processSwapWithdrawIntrospection.d.ts +0 -68
- package/dist/generated/instructions/processSwapWithdrawIntrospection.js +0 -157
- package/dist/generated/instructions/rebalanceJlp.d.ts +0 -81
- package/dist/generated/instructions/rebalanceJlp.js +0 -187
- package/dist/generated/instructions/redeem2DriftS2.d.ts +0 -80
- package/dist/generated/instructions/redeem2DriftS2.js +0 -161
- package/dist/generated/instructions/redeemDriftS1.d.ts +0 -91
- package/dist/generated/instructions/redeemDriftS1.js +0 -185
- package/dist/generated/instructions/redeemDriftS2.d.ts +0 -80
- package/dist/generated/instructions/redeemDriftS2.js +0 -161
- package/dist/generated/instructions/redeemDriftS3.d.ts +0 -87
- package/dist/generated/instructions/redeemDriftS3.js +0 -175
- package/dist/generated/instructions/settlePnl.d.ts +0 -55
- package/dist/generated/instructions/settlePnl.js +0 -114
- package/dist/generated/instructions/settlePnlMulti.d.ts +0 -65
- package/dist/generated/instructions/settlePnlMulti.js +0 -117
- package/dist/generated/instructions/suspendLstProtocol.d.ts +0 -54
- package/dist/generated/instructions/suspendLstProtocol.js +0 -96
- package/dist/generated/instructions/suspendLstStrategy.d.ts +0 -56
- package/dist/generated/instructions/suspendLstStrategy.js +0 -101
- package/dist/generated/instructions/swapOrca.d.ts +0 -78
- package/dist/generated/instructions/swapOrca.js +0 -153
- package/dist/generated/instructions/swapOrcaTwoHop.d.ts +0 -98
- package/dist/generated/instructions/swapOrcaTwoHop.js +0 -200
- package/dist/generated/instructions/updateActionRoleProtocol.d.ts +0 -58
- package/dist/generated/instructions/updateActionRoleProtocol.js +0 -99
- package/dist/generated/instructions/updateActionRoleStrategy.d.ts +0 -61
- package/dist/generated/instructions/updateActionRoleStrategy.js +0 -105
- package/dist/generated/instructions/updateAttenuation.d.ts +0 -56
- package/dist/generated/instructions/updateAttenuation.js +0 -100
- package/dist/generated/instructions/updateCap.d.ts +0 -55
- package/dist/generated/instructions/updateCap.js +0 -99
- package/dist/generated/instructions/updateRebalanceSlippage.d.ts +0 -55
- package/dist/generated/instructions/updateRebalanceSlippage.js +0 -99
- package/dist/generated/instructions/updateRecipients.d.ts +0 -56
- package/dist/generated/instructions/updateRecipients.js +0 -101
- package/dist/generated/instructions/updateRoleHolderProtocol.d.ts +0 -61
- package/dist/generated/instructions/updateRoleHolderProtocol.js +0 -109
- package/dist/generated/instructions/updateRoleHolderStrategy.d.ts +0 -62
- package/dist/generated/instructions/updateRoleHolderStrategy.js +0 -110
- package/dist/generated/types/AMM.d.ts +0 -102
- package/dist/generated/types/AMM.js +0 -127
- package/dist/generated/types/AccKey.d.ts +0 -15
- package/dist/generated/types/AccKey.js +0 -38
- package/dist/generated/types/AccessControl.d.ts +0 -18
- package/dist/generated/types/AccessControl.js +0 -43
- package/dist/generated/types/AccessMap.d.ts +0 -17
- package/dist/generated/types/AccessMap.js +0 -42
- package/dist/generated/types/Action.d.ts +0 -36
- package/dist/generated/types/Action.js +0 -63
- package/dist/generated/types/ActionMapping.d.ts +0 -19
- package/dist/generated/types/ActionMapping.js +0 -44
- package/dist/generated/types/AssetTier.d.ts +0 -23
- package/dist/generated/types/AssetTier.js +0 -50
- package/dist/generated/types/Attenuation.d.ts +0 -16
- package/dist/generated/types/Attenuation.js +0 -41
- package/dist/generated/types/BalanceType.d.ts +0 -20
- package/dist/generated/types/BalanceType.js +0 -47
- package/dist/generated/types/ContractTier.d.ts +0 -24
- package/dist/generated/types/ContractTier.js +0 -51
- package/dist/generated/types/ContractType.d.ts +0 -20
- package/dist/generated/types/ContractType.js +0 -47
- package/dist/generated/types/CorpAction.d.ts +0 -19
- package/dist/generated/types/CorpAction.js +0 -46
- package/dist/generated/types/CustodyInfo.d.ts +0 -20
- package/dist/generated/types/CustodyInfo.js +0 -45
- package/dist/generated/types/DirectionCollateral.d.ts +0 -20
- package/dist/generated/types/DirectionCollateral.js +0 -47
- package/dist/generated/types/DirectionPosition.d.ts +0 -20
- package/dist/generated/types/DirectionPosition.js +0 -47
- package/dist/generated/types/DriftControllerBase.d.ts +0 -15
- package/dist/generated/types/DriftControllerBase.js +0 -38
- package/dist/generated/types/DriftJlpControllerFixedAccounts.d.ts +0 -18
- package/dist/generated/types/DriftJlpControllerFixedAccounts.js +0 -43
- package/dist/generated/types/DriftLstData.d.ts +0 -17
- package/dist/generated/types/DriftLstData.js +0 -42
- package/dist/generated/types/Ema.d.ts +0 -17
- package/dist/generated/types/Ema.js +0 -42
- package/dist/generated/types/Externals.d.ts +0 -16
- package/dist/generated/types/Externals.js +0 -39
- package/dist/generated/types/HistoricalIndexData.d.ts +0 -19
- package/dist/generated/types/HistoricalIndexData.js +0 -44
- package/dist/generated/types/HistoricalOracleData.d.ts +0 -20
- package/dist/generated/types/HistoricalOracleData.js +0 -45
- package/dist/generated/types/Holding.d.ts +0 -21
- package/dist/generated/types/Holding.js +0 -46
- package/dist/generated/types/Holdings.d.ts +0 -17
- package/dist/generated/types/Holdings.js +0 -42
- package/dist/generated/types/InitControllerS2Args.d.ts +0 -23
- package/dist/generated/types/InitControllerS2Args.js +0 -48
- package/dist/generated/types/InsuranceClaim.d.ts +0 -19
- package/dist/generated/types/InsuranceClaim.js +0 -44
- package/dist/generated/types/InsuranceFund.d.ts +0 -24
- package/dist/generated/types/InsuranceFund.js +0 -49
- package/dist/generated/types/JlpRebalanceSettings.d.ts +0 -15
- package/dist/generated/types/JlpRebalanceSettings.js +0 -38
- package/dist/generated/types/KillSwitch.d.ts +0 -15
- package/dist/generated/types/KillSwitch.js +0 -38
- package/dist/generated/types/LevelRoles.d.ts +0 -16
- package/dist/generated/types/LevelRoles.js +0 -39
- package/dist/generated/types/MarketStatus.d.ts +0 -27
- package/dist/generated/types/MarketStatus.js +0 -54
- package/dist/generated/types/MarketType.d.ts +0 -20
- package/dist/generated/types/MarketType.js +0 -47
- package/dist/generated/types/MintJlpArgs.d.ts +0 -15
- package/dist/generated/types/MintJlpArgs.js +0 -38
- package/dist/generated/types/ModifyOrderParams.d.ts +0 -32
- package/dist/generated/types/ModifyOrderParams.js +0 -57
- package/dist/generated/types/ModifyOrderPolicy.d.ts +0 -20
- package/dist/generated/types/ModifyOrderPolicy.js +0 -47
- package/dist/generated/types/Movements.d.ts +0 -19
- package/dist/generated/types/Movements.js +0 -44
- package/dist/generated/types/OracleGuardRails.d.ts +0 -18
- package/dist/generated/types/OracleGuardRails.js +0 -43
- package/dist/generated/types/OracleSource.d.ts +0 -34
- package/dist/generated/types/OracleSource.js +0 -61
- package/dist/generated/types/OracleValidity.d.ts +0 -25
- package/dist/generated/types/OracleValidity.js +0 -52
- package/dist/generated/types/Order.d.ts +0 -43
- package/dist/generated/types/Order.js +0 -68
- package/dist/generated/types/OrderDirection.d.ts +0 -20
- package/dist/generated/types/OrderDirection.js +0 -47
- package/dist/generated/types/OrderParams.d.ts +0 -36
- package/dist/generated/types/OrderParams.js +0 -61
- package/dist/generated/types/OrderStatus.d.ts +0 -22
- package/dist/generated/types/OrderStatus.js +0 -49
- package/dist/generated/types/OrderTriggerCondition.d.ts +0 -22
- package/dist/generated/types/OrderTriggerCondition.js +0 -49
- package/dist/generated/types/OrderType.d.ts +0 -23
- package/dist/generated/types/OrderType.js +0 -50
- package/dist/generated/types/PermissionLevel.d.ts +0 -45
- package/dist/generated/types/PermissionLevel.js +0 -48
- package/dist/generated/types/PerpHedge.d.ts +0 -17
- package/dist/generated/types/PerpHedge.js +0 -42
- package/dist/generated/types/PerpPosition.d.ts +0 -29
- package/dist/generated/types/PerpPosition.js +0 -54
- package/dist/generated/types/PoolBalance.d.ts +0 -17
- package/dist/generated/types/PoolBalance.js +0 -42
- package/dist/generated/types/Position.d.ts +0 -20
- package/dist/generated/types/Position.js +0 -45
- package/dist/generated/types/PositionDirection.d.ts +0 -20
- package/dist/generated/types/PositionDirection.js +0 -47
- package/dist/generated/types/PositionDrift.d.ts +0 -18
- package/dist/generated/types/PositionDrift.js +0 -43
- package/dist/generated/types/PostOnlyParam.d.ts +0 -22
- package/dist/generated/types/PostOnlyParam.js +0 -49
- package/dist/generated/types/Price.d.ts +0 -41
- package/dist/generated/types/Price.js +0 -66
- package/dist/generated/types/PriceComp.d.ts +0 -19
- package/dist/generated/types/PriceComp.js +0 -44
- package/dist/generated/types/PriceDivergenceGuardRails.d.ts +0 -16
- package/dist/generated/types/PriceDivergenceGuardRails.js +0 -41
- package/dist/generated/types/PriceInfo.d.ts +0 -21
- package/dist/generated/types/PriceInfo.js +0 -46
- package/dist/generated/types/PriceStatus.d.ts +0 -22
- package/dist/generated/types/PriceStatus.js +0 -49
- package/dist/generated/types/PriceType.d.ts +0 -20
- package/dist/generated/types/PriceType.js +0 -47
- package/dist/generated/types/ProcessSwapDepositArgs.d.ts +0 -15
- package/dist/generated/types/ProcessSwapDepositArgs.js +0 -38
- package/dist/generated/types/ProcessSwapDepositIntrospectionArgs.d.ts +0 -15
- package/dist/generated/types/ProcessSwapDepositIntrospectionArgs.js +0 -38
- package/dist/generated/types/Program.d.ts +0 -19
- package/dist/generated/types/Program.js +0 -44
- package/dist/generated/types/ProgramStatus.d.ts +0 -20
- package/dist/generated/types/ProgramStatus.js +0 -47
- package/dist/generated/types/RebalanceConfig.d.ts +0 -15
- package/dist/generated/types/RebalanceConfig.js +0 -38
- package/dist/generated/types/Recipient.d.ts +0 -17
- package/dist/generated/types/Recipient.js +0 -42
- package/dist/generated/types/Recipients.d.ts +0 -17
- package/dist/generated/types/Recipients.js +0 -42
- package/dist/generated/types/RedeemJlpArgs.d.ts +0 -15
- package/dist/generated/types/RedeemJlpArgs.js +0 -38
- package/dist/generated/types/Role.d.ts +0 -25
- package/dist/generated/types/Role.js +0 -52
- package/dist/generated/types/ShiftCollateral.d.ts +0 -19
- package/dist/generated/types/ShiftCollateral.js +0 -44
- package/dist/generated/types/ShiftPosition.d.ts +0 -17
- package/dist/generated/types/ShiftPosition.js +0 -42
- package/dist/generated/types/ShortHolding.d.ts +0 -17
- package/dist/generated/types/ShortHolding.js +0 -42
- package/dist/generated/types/SplBase.d.ts +0 -17
- package/dist/generated/types/SplBase.js +0 -42
- package/dist/generated/types/SplMain.d.ts +0 -22
- package/dist/generated/types/SplMain.js +0 -47
- package/dist/generated/types/Spls.d.ts +0 -17
- package/dist/generated/types/Spls.js +0 -42
- package/dist/generated/types/SpotBalanceType.d.ts +0 -20
- package/dist/generated/types/SpotBalanceType.js +0 -47
- package/dist/generated/types/SpotPosition.d.ts +0 -23
- package/dist/generated/types/SpotPosition.js +0 -48
- package/dist/generated/types/Status.d.ts +0 -20
- package/dist/generated/types/Status.js +0 -47
- package/dist/generated/types/Strategy.d.ts +0 -31
- package/dist/generated/types/Strategy.js +0 -56
- package/dist/generated/types/StrategyRoleEntry.d.ts +0 -17
- package/dist/generated/types/StrategyRoleEntry.js +0 -42
- package/dist/generated/types/SubAccount.d.ts +0 -17
- package/dist/generated/types/SubAccount.js +0 -42
- package/dist/generated/types/Update.d.ts +0 -20
- package/dist/generated/types/Update.js +0 -47
- package/dist/generated/types/UserFees.d.ts +0 -20
- package/dist/generated/types/UserFees.js +0 -45
- package/dist/generated/types/ValidityGuardRails.d.ts +0 -18
- package/dist/generated/types/ValidityGuardRails.js +0 -43
- package/dist/generated/types/index.d.ts +0 -83
- package/dist/generated/types/index.js +0 -99
- package/dist/strategies/JlpStrategy.d.ts +0 -17
- package/dist/strategies/JlpStrategy.js +0 -337
- package/dist/strategies/LstStrategy.d.ts +0 -19
- package/dist/strategies/LstStrategy.js +0 -169
- package/dist/strategies/UsdcStrategy.d.ts +0 -12
- package/dist/strategies/UsdcStrategy.js +0 -89
- package/dist/strategies/index.d.ts +0 -3
- package/dist/strategies/index.js +0 -19
|
@@ -39,7 +39,7 @@ class LstStablecoin extends Stablecoin_1.Stablecoin {
|
|
|
39
39
|
* @param collateralMintsOverride - Optional override for collateral mint addresses
|
|
40
40
|
*/
|
|
41
41
|
constructor(connection, stablecoinMintOverride, collateralMintsOverride) {
|
|
42
|
-
super(2, "
|
|
42
|
+
super(2, "LST Delta-Neutral", connection, constants_1.LST_LOOKUP_TABLE);
|
|
43
43
|
this.driftClient = new sdk_1.DriftClient({
|
|
44
44
|
connection,
|
|
45
45
|
env: "mainnet-beta",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Stablecoin } from "../classes/Stablecoin";
|
|
2
|
+
import { AccountMeta, Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
+
import BN from "bn.js";
|
|
4
|
+
/**
|
|
5
|
+
* USDC+ Stablecoin implementation for the Reflect protocol.
|
|
6
|
+
* Extends the base Stablecoin class to provide USDC-specific functionality
|
|
7
|
+
* including initialization, minting, redemption, and rebalancing operations.
|
|
8
|
+
*/
|
|
9
|
+
export declare class UsdcPlusStablecoin extends Stablecoin {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new USDC+ Stablecoin instance.
|
|
12
|
+
*
|
|
13
|
+
* @param connection - Solana connection instance for RPC communication
|
|
14
|
+
* @param stablecoinMintOverride - Optional override for the stablecoin mint address
|
|
15
|
+
*/
|
|
16
|
+
constructor(connection: Connection, stablecoinMintOverride?: PublicKey);
|
|
17
|
+
/**
|
|
18
|
+
* Initializes the USDC stablecoin with the specified parameters.
|
|
19
|
+
* Creates receipt tokens, initializes vault, and initializes the stablecoin.
|
|
20
|
+
*
|
|
21
|
+
* @param signer - Public key of the signer/initializer
|
|
22
|
+
* @param mint - Public key of the mint to be used for the stablecoin
|
|
23
|
+
* @param cap - Maximum supply cap as a BN (Big Number)
|
|
24
|
+
* @param recipientAddresses - Array of recipient public keys for fee distribution
|
|
25
|
+
* @param recipientCuts - Array of fee cuts (percentages) corresponding to each recipient
|
|
26
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
27
|
+
*/
|
|
28
|
+
initialize(signer: PublicKey, mint: PublicKey, cap: BN, recipientAddresses: PublicKey[], recipientCuts: number[]): Promise<TransactionInstruction[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Constructs the required accounts for the InitDriftControllerS1 instruction.
|
|
31
|
+
*
|
|
32
|
+
* @param signer - Public key of the signer
|
|
33
|
+
* @returns Promise resolving to the constructed accounts object of type T
|
|
34
|
+
*/
|
|
35
|
+
constructAccounts<T>(signer: PublicKey): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Constructs remaining accounts for transactions.
|
|
38
|
+
* Currently returns an empty array as no additional accounts are needed.
|
|
39
|
+
*
|
|
40
|
+
* @returns Promise resolving to an empty array of AccountMeta objects
|
|
41
|
+
*/
|
|
42
|
+
constructRemainingAccounts(): Promise<AccountMeta[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a mint instruction for the USDC+ stablecoin.
|
|
45
|
+
*
|
|
46
|
+
* @param signer - Public key of the signer
|
|
47
|
+
* @param amount - Amount of USDC to deposit
|
|
48
|
+
* @param minimumReceived - Minimum amount of USDC+ stablecoins to receive (slippage protection)
|
|
49
|
+
* @returns Promise resolving to an array containing a single TransactionInstruction
|
|
50
|
+
*/
|
|
51
|
+
mint(signer: PublicKey, amount: BN | number, minimumReceived: BN | number): Promise<TransactionInstruction[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a redeem instruction for the USDC stablecoin.
|
|
54
|
+
* Currently returns a placeholder instruction - implementation needed.
|
|
55
|
+
*
|
|
56
|
+
* @returns Promise resolving to an array containing a single TransactionInstruction
|
|
57
|
+
*/
|
|
58
|
+
redeem(signer: PublicKey, amount: BN | number, minimumReceived: BN | number): Promise<TransactionInstruction[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a rebalance instruction for the USDC+ stablecoin.
|
|
61
|
+
* Currently returns an empty instruction, as the rebalance is unnecessary.
|
|
62
|
+
*
|
|
63
|
+
* @returns Promise resolving to an array containing a single, empty TransactionInstruction.
|
|
64
|
+
*/
|
|
65
|
+
rebalance(): Promise<TransactionInstruction[]>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UsdcPlusStablecoin = void 0;
|
|
13
|
+
const Stablecoin_1 = require("../classes/Stablecoin");
|
|
14
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
15
|
+
const classes_1 = require("../classes");
|
|
16
|
+
const constants_1 = require("../constants");
|
|
17
|
+
const reflect_main_1 = require("../generated/reflect_main");
|
|
18
|
+
const sdk_1 = require("@drift-labs/sdk");
|
|
19
|
+
const constants_2 = require("../constants");
|
|
20
|
+
const ReflectTokenisedBond_1 = require("../classes/ReflectTokenisedBond");
|
|
21
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
22
|
+
const __1 = require("..");
|
|
23
|
+
const reflect_tokenised_bonds_1 = require("../generated/reflect_tokenised_bonds");
|
|
24
|
+
/**
|
|
25
|
+
* USDC+ Stablecoin implementation for the Reflect protocol.
|
|
26
|
+
* Extends the base Stablecoin class to provide USDC-specific functionality
|
|
27
|
+
* including initialization, minting, redemption, and rebalancing operations.
|
|
28
|
+
*/
|
|
29
|
+
class UsdcPlusStablecoin extends Stablecoin_1.Stablecoin {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new USDC+ Stablecoin instance.
|
|
32
|
+
*
|
|
33
|
+
* @param connection - Solana connection instance for RPC communication
|
|
34
|
+
* @param stablecoinMintOverride - Optional override for the stablecoin mint address
|
|
35
|
+
*/
|
|
36
|
+
constructor(connection, stablecoinMintOverride) {
|
|
37
|
+
super(0, "USDC Money Market", connection, constants_2.USDC_PLUS_LOOKUP_TABLE);
|
|
38
|
+
this.collaterals = [{ mint: constants_1.USDC_MINT, oracle: "" }];
|
|
39
|
+
// Otherwise has to be loaded first.
|
|
40
|
+
if (stablecoinMintOverride)
|
|
41
|
+
this.stablecoinMint = stablecoinMintOverride;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Initializes the USDC stablecoin with the specified parameters.
|
|
45
|
+
* Creates receipt tokens, initializes vault, and initializes the stablecoin.
|
|
46
|
+
*
|
|
47
|
+
* @param signer - Public key of the signer/initializer
|
|
48
|
+
* @param mint - Public key of the mint to be used for the stablecoin
|
|
49
|
+
* @param cap - Maximum supply cap as a BN (Big Number)
|
|
50
|
+
* @param recipientAddresses - Array of recipient public keys for fee distribution
|
|
51
|
+
* @param recipientCuts - Array of fee cuts (percentages) corresponding to each recipient
|
|
52
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
53
|
+
*/
|
|
54
|
+
initialize(signer, mint, cap, recipientAddresses, recipientCuts) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const vault = classes_1.PdaClient.deriveLpVault(0);
|
|
57
|
+
const lp = new ReflectTokenisedBond_1.ReflectTokenisedBond(this.connection);
|
|
58
|
+
const { instructions: receiptIx, signers: [receiptKeypair] } = yield lp.createReceiptToken(this.connection, signer, vault);
|
|
59
|
+
const vaultIx = yield lp.initializeVault(signer, mint, receiptKeypair.publicKey);
|
|
60
|
+
const ix = (0, reflect_main_1.createInitDriftControllerS1Instruction)({
|
|
61
|
+
admin: signer,
|
|
62
|
+
adminPermissions: classes_1.PdaClient.derivePermissions(signer),
|
|
63
|
+
main: classes_1.PdaClient.deriveMain(),
|
|
64
|
+
driftUsdcController: this.controller,
|
|
65
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
66
|
+
}, {
|
|
67
|
+
mint,
|
|
68
|
+
cap,
|
|
69
|
+
recipientAddresses,
|
|
70
|
+
recipientCuts,
|
|
71
|
+
lpReciptMint: receiptKeypair.publicKey,
|
|
72
|
+
vault
|
|
73
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
74
|
+
return [...receiptIx, vaultIx, ix];
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Constructs the required accounts for the InitDriftControllerS1 instruction.
|
|
79
|
+
*
|
|
80
|
+
* @param signer - Public key of the signer
|
|
81
|
+
* @returns Promise resolving to the constructed accounts object of type T
|
|
82
|
+
*/
|
|
83
|
+
constructAccounts(signer) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const userAccount = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, this.controller);
|
|
86
|
+
const userStats = (0, sdk_1.getUserStatsAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID, this.controller);
|
|
87
|
+
const anchorRemainingAccounts = yield this.constructRemainingAccounts();
|
|
88
|
+
const { referrer } = yield (0, sdk_1.fetchUserStatsAccount)(this.connection, this.driftClient.program, userAccount);
|
|
89
|
+
const referrerUser = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, referrer);
|
|
90
|
+
const referrerUserStats = (0, sdk_1.getUserStatsAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID, referrer);
|
|
91
|
+
const userUsdcAta = (0, spl_token_1.getAssociatedTokenAddressSync)(this.controller, signer, true);
|
|
92
|
+
const vault = classes_1.PdaClient.deriveLpVault(0);
|
|
93
|
+
const { depositTokenMint: intermediaryMint, receiptTokenMint } = yield reflect_tokenised_bonds_1.Vault
|
|
94
|
+
.fromAccountAddress(this.connection, vault);
|
|
95
|
+
const userReceiptAta = (0, spl_token_1.getAssociatedTokenAddressSync)(receiptTokenMint, signer, true);
|
|
96
|
+
const controllerIntermediaryAta = (0, spl_token_1.getAssociatedTokenAddressSync)(intermediaryMint, this.controller, true);
|
|
97
|
+
const controllerReceiptAta = (0, spl_token_1.getAssociatedTokenAddressSync)(receiptTokenMint, this.controller, true);
|
|
98
|
+
const controllerUsdcAta = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.USDC_MINT, this.controller, true);
|
|
99
|
+
const spotMarketVault = yield (0, sdk_1.getSpotMarketVaultPublicKey)(constants_1.DRIFT_PROGRAM_ID, 0);
|
|
100
|
+
const driftState = yield (0, sdk_1.getDriftStateAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID);
|
|
101
|
+
const vaultPool = classes_1.PdaClient.deriveLpVaultPool(0);
|
|
102
|
+
const accounts = {
|
|
103
|
+
clock: web3_js_1.SYSVAR_CLOCK_PUBKEY,
|
|
104
|
+
controllerIntermediaryAta,
|
|
105
|
+
controllerReceiptAta,
|
|
106
|
+
controllerUsdcAta,
|
|
107
|
+
drift: constants_1.DRIFT_PROGRAM_ID,
|
|
108
|
+
driftVault: constants_1.DRIFT_VAULT,
|
|
109
|
+
intermediaryMint,
|
|
110
|
+
lpPoolIntermediaryAta: vaultPool,
|
|
111
|
+
lpProgram: __1.TOKENISED_BONDS_PROGRAM_ID,
|
|
112
|
+
main: classes_1.PdaClient.deriveMain(),
|
|
113
|
+
receiptMint: receiptTokenMint,
|
|
114
|
+
referrerUser,
|
|
115
|
+
referrerUserStats,
|
|
116
|
+
spotMarketVault,
|
|
117
|
+
state: driftState,
|
|
118
|
+
usdcController: this.controller,
|
|
119
|
+
user: signer,
|
|
120
|
+
userAccount,
|
|
121
|
+
userReceiptAta,
|
|
122
|
+
userStats,
|
|
123
|
+
userUsdcAta,
|
|
124
|
+
vault,
|
|
125
|
+
adminPermissions: null,
|
|
126
|
+
anchorRemainingAccounts,
|
|
127
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
128
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
|
|
129
|
+
};
|
|
130
|
+
return accounts;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Constructs remaining accounts for transactions.
|
|
135
|
+
* Currently returns an empty array as no additional accounts are needed.
|
|
136
|
+
*
|
|
137
|
+
* @returns Promise resolving to an empty array of AccountMeta objects
|
|
138
|
+
*/
|
|
139
|
+
constructRemainingAccounts() {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
return [];
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
;
|
|
145
|
+
/**
|
|
146
|
+
* Creates a mint instruction for the USDC+ stablecoin.
|
|
147
|
+
*
|
|
148
|
+
* @param signer - Public key of the signer
|
|
149
|
+
* @param amount - Amount of USDC to deposit
|
|
150
|
+
* @param minimumReceived - Minimum amount of USDC+ stablecoins to receive (slippage protection)
|
|
151
|
+
* @returns Promise resolving to an array containing a single TransactionInstruction
|
|
152
|
+
*/
|
|
153
|
+
mint(signer, amount, minimumReceived) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const accounts = yield this.constructAccounts(signer);
|
|
156
|
+
const ix = (0, reflect_main_1.createMintDriftS1Instruction)(accounts, {
|
|
157
|
+
minUsdcAmount: minimumReceived,
|
|
158
|
+
usdcAmount: amount
|
|
159
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
160
|
+
return [ix];
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creates a redeem instruction for the USDC stablecoin.
|
|
165
|
+
* Currently returns a placeholder instruction - implementation needed.
|
|
166
|
+
*
|
|
167
|
+
* @returns Promise resolving to an array containing a single TransactionInstruction
|
|
168
|
+
*/
|
|
169
|
+
redeem(signer, amount, minimumReceived) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const accounts = yield this.constructAccounts(signer);
|
|
172
|
+
const ix = (0, reflect_main_1.createRedeemDriftS1Instruction)(accounts, {
|
|
173
|
+
canChill: false,
|
|
174
|
+
minLstRedeem: minimumReceived,
|
|
175
|
+
rusdBurnAmount: amount
|
|
176
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
177
|
+
return [ix];
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Creates a rebalance instruction for the USDC+ stablecoin.
|
|
182
|
+
* Currently returns an empty instruction, as the rebalance is unnecessary.
|
|
183
|
+
*
|
|
184
|
+
* @returns Promise resolving to an array containing a single, empty TransactionInstruction.
|
|
185
|
+
*/
|
|
186
|
+
rebalance() {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
const ix = new web3_js_1.TransactionInstruction({
|
|
189
|
+
programId: web3_js_1.Keypair.generate().publicKey,
|
|
190
|
+
data: Buffer.from(""),
|
|
191
|
+
keys: []
|
|
192
|
+
});
|
|
193
|
+
return [ix];
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.UsdcPlusStablecoin = UsdcPlusStablecoin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import {Stablecoin} from "../classes/Stablecoin";
|
|
3
|
+
// import {PdaClient} from "../classes/PdaClient";
|
|
4
|
+
// import {
|
|
5
|
+
// createInitDriftControllerS2Instruction,
|
|
6
|
+
// createMintDriftS2Instruction,
|
|
7
|
+
// createRebalanceJlpInstruction,
|
|
8
|
+
// createRedeemDriftS2Instruction,
|
|
9
|
+
// createRedeem2DriftS2Instruction,
|
|
10
|
+
// DriftJlpController,
|
|
11
|
+
// MintDriftS2InstructionAccounts, PerpHedge,
|
|
12
|
+
// PROGRAM_ID
|
|
13
|
+
// } from "../generated/reflect_main";
|
|
14
|
+
// import {
|
|
15
|
+
// AccountMeta,
|
|
16
|
+
// Connection,
|
|
17
|
+
// Keypair,
|
|
18
|
+
// PublicKey,
|
|
19
|
+
// SystemProgram,
|
|
20
|
+
// Transaction,
|
|
21
|
+
// TransactionInstruction
|
|
22
|
+
// } from "@solana/web3.js";
|
|
23
|
+
// import {JLP_MINT, DRIFT_PROGRAM_ID, JUPITER_PROGRAM_ID, USDC_MINT} from "../constants";
|
|
24
|
+
// import {getAccount, getAssociatedTokenAddressSync, getMint, TOKEN_PROGRAM_ID} from "@solana/spl-token";
|
|
25
|
+
// import {
|
|
26
|
+
// getDriftSignerPublicKey,
|
|
27
|
+
// getDriftStateAccountPublicKey,
|
|
28
|
+
// getPerpMarketPublicKeySync,
|
|
29
|
+
// getSpotMarketPublicKey,
|
|
30
|
+
// getSpotMarketPublicKeySync, getSpotMarketVaultPublicKey,
|
|
31
|
+
// getUserAccountPublicKeySync,
|
|
32
|
+
// getUserStatsAccountPublicKey,
|
|
33
|
+
// PerpMarkets,
|
|
34
|
+
// SpotMarkets,
|
|
35
|
+
// MarginCategory,
|
|
36
|
+
// getTokenAmount,
|
|
37
|
+
// SpotBalanceType
|
|
38
|
+
// } from "@drift-labs/sdk";
|
|
39
|
+
// import BN, { min } from "bn.js";
|
|
40
|
+
// import {AnchorProvider, Program} from "@coral-xyz/anchor";
|
|
41
|
+
// import {type Perpetuals, IDL} from "../idl/perpetuals";
|
|
42
|
+
// import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
|
|
43
|
+
// import { JlpPoolInfo, JlpComponent } from "../types";
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./UsdjStablecoin";
|
|
2
2
|
export * from "./LstStablecoin";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./UsdcPlusStablecoin";
|
|
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./UsdjStablecoin"), exports);
|
|
18
18
|
__exportStar(require("./LstStablecoin"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./UsdcPlusStablecoin"), exports);
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AccountMeta, Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import BN from "bn.js";
|
|
3
|
-
import { DriftClient } from "@drift-labs/sdk";
|
|
4
|
-
import { Action } from "../generated";
|
|
5
|
-
import { StablecoinMetadata } from "../types";
|
|
6
|
-
export declare abstract class Strategy {
|
|
7
|
-
index: number;
|
|
8
|
-
name: string;
|
|
9
|
-
connection: Connection;
|
|
10
|
-
controller: PublicKey;
|
|
11
|
-
collateralMints: PublicKey[];
|
|
12
|
-
stablecoinMint: PublicKey;
|
|
13
|
-
driftClient?: DriftClient;
|
|
14
|
-
constructor(index: number, name: string, connection: Connection);
|
|
15
|
-
initializeTokenAccounts(owner: PublicKey, mints: PublicKey[], signer: PublicKey): Promise<TransactionInstruction[]>;
|
|
16
|
-
updateCap(signer: PublicKey, newCap: BN | number): Promise<TransactionInstruction>;
|
|
17
|
-
freezeCollateral(signer: PublicKey, freeze: boolean, mint: PublicKey): Promise<TransactionInstruction>;
|
|
18
|
-
freezeCollateralStrategy(signer: PublicKey, freeze: boolean, mint: PublicKey): Promise<TransactionInstruction>;
|
|
19
|
-
updateRecipients(signer: PublicKey, recipients: Map<PublicKey, number>): Promise<TransactionInstruction>;
|
|
20
|
-
initializeStrategyDriftAccount(signer: PublicKey, subAccountId?: number): Promise<TransactionInstruction>;
|
|
21
|
-
initializeStrategyDriftStatsAccount(signer: PublicKey): Promise<TransactionInstruction>;
|
|
22
|
-
freeze(signer: PublicKey, freeze: boolean, action: Action): Promise<TransactionInstruction>;
|
|
23
|
-
initializeStablecoin(signer: PublicKey, tokenKeypair: Keypair, metadata?: StablecoinMetadata): Promise<TransactionInstruction[]>;
|
|
24
|
-
abstract constructAccounts<T>(signer: PublicKey, ...args: any[]): Promise<T>;
|
|
25
|
-
abstract constructRemainingAccounts(): Promise<AccountMeta[]>;
|
|
26
|
-
abstract initialize(signer: PublicKey, ...args: any[]): Promise<TransactionInstruction[]>;
|
|
27
|
-
abstract mint(signer: PublicKey, amount: BN | number, minimumReceived: BN | number, ...args: any[]): Promise<TransactionInstruction[]>;
|
|
28
|
-
abstract redeem(signer: PublicKey, amount: BN | number, minimumReceived: BN | number, ...args: any[]): Promise<TransactionInstruction[]>;
|
|
29
|
-
abstract rebalance(signer: PublicKey): Promise<TransactionInstruction[]>;
|
|
30
|
-
}
|
package/dist/classes/Strategy.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Strategy = void 0;
|
|
13
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
14
|
-
const sdk_1 = require("@drift-labs/sdk");
|
|
15
|
-
const generated_1 = require("../generated");
|
|
16
|
-
const PdaClient_1 = require("./PdaClient");
|
|
17
|
-
const spl_token_1 = require("@solana/spl-token");
|
|
18
|
-
const constants_1 = require("../constants");
|
|
19
|
-
const mpl_token_metadata_1 = require("@metaplex-foundation/mpl-token-metadata");
|
|
20
|
-
class Strategy {
|
|
21
|
-
constructor(index, name, connection) {
|
|
22
|
-
this.index = index;
|
|
23
|
-
this.name = name;
|
|
24
|
-
this.connection = connection;
|
|
25
|
-
this.controller = PdaClient_1.PdaClient.deriveController(this.index);
|
|
26
|
-
}
|
|
27
|
-
initializeTokenAccounts(owner, mints, signer) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const instructions = [];
|
|
30
|
-
for (const mint of mints) {
|
|
31
|
-
const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(mint, owner, true);
|
|
32
|
-
let isInitialized = false;
|
|
33
|
-
try {
|
|
34
|
-
let account = yield this.connection.getAccountInfo(ata);
|
|
35
|
-
isInitialized = account !== null;
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
isInitialized = false;
|
|
39
|
-
}
|
|
40
|
-
if (!isInitialized) {
|
|
41
|
-
instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(signer, ata, owner, mint));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return instructions;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
updateCap(signer, newCap) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const ix = (0, generated_1.createUpdateCapInstruction)({
|
|
50
|
-
admin: signer,
|
|
51
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
52
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
53
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
54
|
-
strategy: this.controller
|
|
55
|
-
}, {
|
|
56
|
-
newCap,
|
|
57
|
-
}, generated_1.PROGRAM_ID);
|
|
58
|
-
return ix;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
freezeCollateral(signer, freeze, mint) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
const ix = (0, generated_1.createSuspendLstProtocolInstruction)({
|
|
64
|
-
admin: signer,
|
|
65
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
66
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
67
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
68
|
-
}, {
|
|
69
|
-
freeze,
|
|
70
|
-
lstMint: mint
|
|
71
|
-
}, generated_1.PROGRAM_ID);
|
|
72
|
-
return ix;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
freezeCollateralStrategy(signer, freeze, mint) {
|
|
76
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
const ix = (0, generated_1.createSuspendLstStrategyInstruction)({
|
|
78
|
-
admin: signer,
|
|
79
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
80
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
81
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
82
|
-
strategy: this.controller
|
|
83
|
-
}, {
|
|
84
|
-
freeze,
|
|
85
|
-
lstMint: mint
|
|
86
|
-
}, generated_1.PROGRAM_ID);
|
|
87
|
-
return ix;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
updateRecipients(signer, recipients) {
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const ix = (0, generated_1.createUpdateRecipientsInstruction)({
|
|
93
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
94
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
95
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
96
|
-
admin: signer,
|
|
97
|
-
strategy: this.controller
|
|
98
|
-
}, {
|
|
99
|
-
recipientAddresses: [...recipients.keys()],
|
|
100
|
-
recipientCuts: [...recipients.values()],
|
|
101
|
-
}, generated_1.PROGRAM_ID);
|
|
102
|
-
return ix;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
initializeStrategyDriftAccount(signer_1) {
|
|
106
|
-
return __awaiter(this, arguments, void 0, function* (signer, subAccountId = 0) {
|
|
107
|
-
const userAccount = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, this.controller, subAccountId);
|
|
108
|
-
const userStats = (0, sdk_1.getUserStatsAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID, this.controller);
|
|
109
|
-
const [_, controllerBump] = PdaClient_1.PdaClient.deriveControllerWithBump(this.index);
|
|
110
|
-
const ix = (0, generated_1.createAddSubAccountInstruction)({
|
|
111
|
-
admin: signer,
|
|
112
|
-
drift: constants_1.DRIFT_PROGRAM_ID,
|
|
113
|
-
state: yield (0, sdk_1.getDriftStateAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID),
|
|
114
|
-
userStats,
|
|
115
|
-
userAccount,
|
|
116
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
117
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
118
|
-
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
119
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
120
|
-
lstController: this.controller
|
|
121
|
-
}, generated_1.PROGRAM_ID);
|
|
122
|
-
return ix;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
initializeStrategyDriftStatsAccount(signer) {
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
const userAccount = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, this.controller, 0);
|
|
128
|
-
const userStats = (0, sdk_1.getUserStatsAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID, this.controller);
|
|
129
|
-
const [_, controllerBump] = PdaClient_1.PdaClient.deriveControllerWithBump(this.index);
|
|
130
|
-
const ix = (0, generated_1.createCreateUserStatsAccountInstruction)({
|
|
131
|
-
admin: signer,
|
|
132
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
133
|
-
drift: constants_1.DRIFT_PROGRAM_ID,
|
|
134
|
-
userStats,
|
|
135
|
-
userAccount,
|
|
136
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
137
|
-
controller: this.controller,
|
|
138
|
-
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
139
|
-
state: yield (0, sdk_1.getDriftStateAccountPublicKey)(constants_1.DRIFT_PROGRAM_ID),
|
|
140
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
141
|
-
}, generated_1.PROGRAM_ID);
|
|
142
|
-
return ix;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
freeze(signer, freeze, action) {
|
|
146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
const ix = (0, generated_1.createFreezeStrategyActionInstruction)({
|
|
148
|
-
admin: signer,
|
|
149
|
-
main: PdaClient_1.PdaClient.deriveMain(),
|
|
150
|
-
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
151
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
|
152
|
-
strategy: this.controller,
|
|
153
|
-
}, {
|
|
154
|
-
freeze,
|
|
155
|
-
action,
|
|
156
|
-
strategyId: this.index
|
|
157
|
-
});
|
|
158
|
-
return ix;
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
initializeStablecoin(signer, tokenKeypair, metadata) {
|
|
162
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
const instructions = [];
|
|
164
|
-
const createAccountInstruction = web3_js_1.SystemProgram.createAccount({
|
|
165
|
-
lamports: yield this.connection.getMinimumBalanceForRentExemption(spl_token_1.MINT_SIZE),
|
|
166
|
-
space: spl_token_1.MINT_SIZE,
|
|
167
|
-
fromPubkey: signer,
|
|
168
|
-
newAccountPubkey: tokenKeypair.publicKey,
|
|
169
|
-
programId: spl_token_1.TOKEN_PROGRAM_ID
|
|
170
|
-
});
|
|
171
|
-
instructions.push(createAccountInstruction);
|
|
172
|
-
const initializeMintInstruction = (0, spl_token_1.createInitializeMint2Instruction)(tokenKeypair.publicKey, 6, signer, signer);
|
|
173
|
-
instructions.push(initializeMintInstruction);
|
|
174
|
-
if (metadata) {
|
|
175
|
-
const createMetadataInstruction = (0, mpl_token_metadata_1.createCreateMetadataAccountV3Instruction)({
|
|
176
|
-
metadata: PdaClient_1.PdaClient.deriveMetadataAccount(tokenKeypair.publicKey),
|
|
177
|
-
mint: tokenKeypair.publicKey,
|
|
178
|
-
mintAuthority: signer,
|
|
179
|
-
payer: signer,
|
|
180
|
-
updateAuthority: signer
|
|
181
|
-
}, {
|
|
182
|
-
createMetadataAccountArgsV3: {
|
|
183
|
-
data: metadata,
|
|
184
|
-
isMutable: true,
|
|
185
|
-
collectionDetails: null
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
instructions.push(createMetadataInstruction);
|
|
189
|
-
}
|
|
190
|
-
const setAuthorityInstruction = (0, spl_token_1.createSetAuthorityInstruction)(tokenKeypair.publicKey, signer, spl_token_1.AuthorityType.MintTokens, this.controller);
|
|
191
|
-
instructions.push(setAuthorityInstruction);
|
|
192
|
-
return instructions;
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
exports.Strategy = Strategy;
|