@reflectmoney/stable.ts 1.0.0 → 1.0.2
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 +178 -7
- package/dist/classes/PdaClient.d.ts +112 -0
- package/dist/classes/PdaClient.js +112 -0
- package/dist/classes/ReflectAdmin.d.ts +87 -2
- package/dist/classes/ReflectAdmin.js +84 -1
- package/dist/classes/ReflectTokenisedBond.d.ts +57 -0
- package/dist/classes/ReflectTokenisedBond.js +56 -0
- package/dist/classes/Stablecoin.d.ts +139 -1
- package/dist/classes/Stablecoin.js +83 -1
- package/dist/stablecoins/LstStablecoin.d.ts +47 -0
- package/dist/stablecoins/LstStablecoin.js +46 -0
- 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
|
@@ -13,13 +13,35 @@ exports.ReflectAdmin = void 0;
|
|
|
13
13
|
const web3_js_1 = require("@solana/web3.js");
|
|
14
14
|
const reflect_main_1 = require("../generated/reflect_main");
|
|
15
15
|
const PdaClient_1 = require("./PdaClient");
|
|
16
|
+
/**
|
|
17
|
+
* Administrative client for the Reflect protocol.
|
|
18
|
+
* Provides functionality for protocol-level administration including:
|
|
19
|
+
* - Protocol initialization and setup
|
|
20
|
+
* - Role and permission management
|
|
21
|
+
* - Action freezing/unfreezing
|
|
22
|
+
* - Admin account creation and management
|
|
23
|
+
*
|
|
24
|
+
* This class is used by protocol administrators to manage global settings,
|
|
25
|
+
* user permissions, and protocol-wide configurations.
|
|
26
|
+
*/
|
|
16
27
|
class ReflectAdmin {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new ReflectAdmin instance.
|
|
30
|
+
*
|
|
31
|
+
* @param admin - Public key of the admin user
|
|
32
|
+
* @param connection - Solana connection instance
|
|
33
|
+
*/
|
|
17
34
|
constructor({ admin, connection }) {
|
|
18
35
|
this.admin = admin;
|
|
19
36
|
this.connection = connection;
|
|
20
37
|
this.main = PdaClient_1.PdaClient.deriveMain();
|
|
21
38
|
}
|
|
22
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Creates the main program account. This is the initial step of protocol setup.
|
|
41
|
+
*
|
|
42
|
+
* @param admin - Public key of the initial admin
|
|
43
|
+
* @returns TransactionInstruction for initializing the main account
|
|
44
|
+
*/
|
|
23
45
|
static initializeMain(admin) {
|
|
24
46
|
const [main] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("main")], reflect_main_1.PROGRAM_ID);
|
|
25
47
|
const ix = (0, reflect_main_1.createInitMainInstruction)({
|
|
@@ -30,6 +52,13 @@ class ReflectAdmin {
|
|
|
30
52
|
}, reflect_main_1.PROGRAM_ID);
|
|
31
53
|
return ix;
|
|
32
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Freezes or unfreezes a specific protocol action.
|
|
57
|
+
*
|
|
58
|
+
* @param freeze - Whether to freeze (true) or unfreeze (false) the action
|
|
59
|
+
* @param action - The action to freeze/unfreeze
|
|
60
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
61
|
+
*/
|
|
33
62
|
freezeProtocolAction(freeze, action) {
|
|
34
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
35
64
|
const ix = (0, reflect_main_1.createFreezeProtocolActionInstruction)({
|
|
@@ -44,6 +73,13 @@ class ReflectAdmin {
|
|
|
44
73
|
return ix;
|
|
45
74
|
});
|
|
46
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Freezes or unfreezes a specific DEX program.
|
|
78
|
+
*
|
|
79
|
+
* @param freeze - Whether to freeze (true) or unfreeze (false) the program
|
|
80
|
+
* @param programIndex - Index of the program to freeze/unfreeze
|
|
81
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
82
|
+
*/
|
|
47
83
|
freezeDex(freeze, programIndex) {
|
|
48
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
85
|
const ix = (0, reflect_main_1.createFreezeProgramInstruction)({
|
|
@@ -55,8 +91,16 @@ class ReflectAdmin {
|
|
|
55
91
|
freeze,
|
|
56
92
|
programIndex
|
|
57
93
|
});
|
|
94
|
+
return ix;
|
|
58
95
|
});
|
|
59
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Creates a new admin account with specified permissions.
|
|
99
|
+
*
|
|
100
|
+
* @param signer - Public key of the caller (must be existing admin)
|
|
101
|
+
* @param newAdmin - Public key of the new admin to create
|
|
102
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
103
|
+
*/
|
|
60
104
|
createAdminAccount(signer, newAdmin) {
|
|
61
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
106
|
const ix = (0, reflect_main_1.createCreateAdminAccountInstruction)({
|
|
@@ -69,6 +113,15 @@ class ReflectAdmin {
|
|
|
69
113
|
return ix;
|
|
70
114
|
});
|
|
71
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Updates role holder permissions at the protocol level.
|
|
118
|
+
*
|
|
119
|
+
* @param signer - Public key of the admin signer
|
|
120
|
+
* @param adminToUpdate - Public key of the admin whose permissions are being updated
|
|
121
|
+
* @param affectedRole - The role being modified
|
|
122
|
+
* @param update - The type of update (Grant or Revoke)
|
|
123
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
124
|
+
*/
|
|
72
125
|
updateRoleHolderProtocol(signer, adminToUpdate, affectedRole, update) {
|
|
73
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
127
|
const ix = (0, reflect_main_1.createUpdateRoleHolderProtocolInstruction)({
|
|
@@ -86,6 +139,16 @@ class ReflectAdmin {
|
|
|
86
139
|
return ix;
|
|
87
140
|
});
|
|
88
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Updates role holder permissions for a specific strategy.
|
|
144
|
+
*
|
|
145
|
+
* @param signer - Public key of the admin signer
|
|
146
|
+
* @param strategyId - ID of the strategy to update permissions for
|
|
147
|
+
* @param adminToUpdate - Public key of the admin whose permissions are being updated
|
|
148
|
+
* @param affectedRole - The role being modified
|
|
149
|
+
* @param update - The type of update (Grant or Revoke)
|
|
150
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
151
|
+
*/
|
|
89
152
|
updateRoleHolderStrategy(signer, strategyId, adminToUpdate, affectedRole, update) {
|
|
90
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
154
|
const ix = (0, reflect_main_1.createUpdateRoleHolderStrategyInstruction)({
|
|
@@ -102,6 +165,16 @@ class ReflectAdmin {
|
|
|
102
165
|
return ix;
|
|
103
166
|
});
|
|
104
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Updates action role permissions for a specific strategy.
|
|
170
|
+
*
|
|
171
|
+
* @param signer - Public key of the admin signer
|
|
172
|
+
* @param strategyId - ID of the strategy to update permissions for
|
|
173
|
+
* @param action - The action being modified
|
|
174
|
+
* @param affectedRole - The role being modified
|
|
175
|
+
* @param update - The type of update (Grant or Revoke)
|
|
176
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
177
|
+
*/
|
|
105
178
|
updateActionRoleStrategy(signer, strategyId, action, affectedRole, update) {
|
|
106
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
180
|
const ix = (0, reflect_main_1.createUpdateActionRoleStrategyInstruction)({
|
|
@@ -115,8 +188,18 @@ class ReflectAdmin {
|
|
|
115
188
|
role: affectedRole,
|
|
116
189
|
action
|
|
117
190
|
}, reflect_main_1.PROGRAM_ID);
|
|
191
|
+
return ix;
|
|
118
192
|
});
|
|
119
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Updates action role permissions at the protocol level.
|
|
196
|
+
*
|
|
197
|
+
* @param signer - Public key of the admin signer
|
|
198
|
+
* @param action - The action being modified
|
|
199
|
+
* @param affectedRole - The role being modified
|
|
200
|
+
* @param update - The type of update (Grant or Revoke)
|
|
201
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
202
|
+
*/
|
|
120
203
|
updateActionRoleProtocol(signer, action, affectedRole, update) {
|
|
121
204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
205
|
const ix = (0, reflect_main_1.createUpdateActionRoleProtocolInstruction)({
|
|
@@ -2,15 +2,72 @@ import { Connection } from "@solana/web3.js";
|
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
3
|
import BN from "bn.js";
|
|
4
4
|
import { Keypair } from "@solana/web3.js";
|
|
5
|
+
/**
|
|
6
|
+
* Client class for interacting with the Reflect Tokenised Bonds program.
|
|
7
|
+
* Provides functionality for creating and managing tokenized bond vaults,
|
|
8
|
+
* including receipt token creation, vault initialization, deposits, and withdrawals.
|
|
9
|
+
*
|
|
10
|
+
* This class handles the tokenized bonds aspect of the Reflect protocol,
|
|
11
|
+
* allowing users to deposit assets and receive receipt tokens representing
|
|
12
|
+
* their share of the vault.
|
|
13
|
+
*/
|
|
5
14
|
export declare class ReflectTokenisedBond {
|
|
15
|
+
/** Solana connection instance for RPC communication */
|
|
6
16
|
connection: Connection;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new ReflectTokenisedBond instance.
|
|
19
|
+
*
|
|
20
|
+
* @param connection - Solana connection instance
|
|
21
|
+
*/
|
|
7
22
|
constructor(connection: Connection);
|
|
23
|
+
/**
|
|
24
|
+
* Creates a receipt token for a vault.
|
|
25
|
+
* Generates a new keypair for the receipt token mint and creates the necessary instructions.
|
|
26
|
+
*
|
|
27
|
+
* @param connection - Solana connection instance
|
|
28
|
+
* @param signer - Public key of the transaction signer
|
|
29
|
+
* @param vault - Public key of the vault account
|
|
30
|
+
* @returns Promise resolving to an object containing instructions and signers
|
|
31
|
+
*/
|
|
8
32
|
createReceiptToken(connection: Connection, signer: PublicKey, vault: PublicKey): Promise<{
|
|
9
33
|
instructions: import("@solana/web3.js").TransactionInstruction[];
|
|
10
34
|
signers: Keypair[];
|
|
11
35
|
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Initializes the tokenized bonds program.
|
|
38
|
+
* Creates the config and admin accounts for the program.
|
|
39
|
+
*
|
|
40
|
+
* @param signer - Public key of the admin signer
|
|
41
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
42
|
+
*/
|
|
12
43
|
initialize(signer: PublicKey): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
44
|
+
/**
|
|
45
|
+
* Initializes a new vault with specified deposit and receipt mints.
|
|
46
|
+
*
|
|
47
|
+
* @param signer - Public key of the admin signer
|
|
48
|
+
* @param depositMint - Public key of the deposit token mint
|
|
49
|
+
* @param receiptMint - Public key of the receipt token mint
|
|
50
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
51
|
+
*/
|
|
13
52
|
initializeVault(signer: PublicKey, depositMint: PublicKey, receiptMint: PublicKey): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
53
|
+
/**
|
|
54
|
+
* Creates a deposit instruction for a vault.
|
|
55
|
+
* Allows users to deposit assets and receive receipt tokens.
|
|
56
|
+
*
|
|
57
|
+
* @param signer - Public key of the user making the deposit
|
|
58
|
+
* @param vaultId - Numeric identifier for the vault
|
|
59
|
+
* @param amount - Amount of deposit tokens to deposit
|
|
60
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
61
|
+
*/
|
|
14
62
|
deposit(signer: PublicKey, vaultId: number, amount: BN): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a withdrawal instruction for a vault.
|
|
65
|
+
* Allows users to burn receipt tokens and receive back their deposit tokens.
|
|
66
|
+
*
|
|
67
|
+
* @param signer - Public key of the user making the withdrawal
|
|
68
|
+
* @param vaultId - Numeric identifier for the vault
|
|
69
|
+
* @param amount - Amount of receipt tokens to burn for withdrawal
|
|
70
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
71
|
+
*/
|
|
15
72
|
withdraw(signer: PublicKey, vaultId: number, amount: BN): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
16
73
|
}
|
|
@@ -15,10 +15,33 @@ const PdaClient_1 = require("./PdaClient");
|
|
|
15
15
|
const web3_js_1 = require("@solana/web3.js");
|
|
16
16
|
const spl_token_1 = require("@solana/spl-token");
|
|
17
17
|
const web3_js_2 = require("@solana/web3.js");
|
|
18
|
+
/**
|
|
19
|
+
* Client class for interacting with the Reflect Tokenised Bonds program.
|
|
20
|
+
* Provides functionality for creating and managing tokenized bond vaults,
|
|
21
|
+
* including receipt token creation, vault initialization, deposits, and withdrawals.
|
|
22
|
+
*
|
|
23
|
+
* This class handles the tokenized bonds aspect of the Reflect protocol,
|
|
24
|
+
* allowing users to deposit assets and receive receipt tokens representing
|
|
25
|
+
* their share of the vault.
|
|
26
|
+
*/
|
|
18
27
|
class ReflectTokenisedBond {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new ReflectTokenisedBond instance.
|
|
30
|
+
*
|
|
31
|
+
* @param connection - Solana connection instance
|
|
32
|
+
*/
|
|
19
33
|
constructor(connection) {
|
|
20
34
|
this.connection = connection;
|
|
21
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a receipt token for a vault.
|
|
38
|
+
* Generates a new keypair for the receipt token mint and creates the necessary instructions.
|
|
39
|
+
*
|
|
40
|
+
* @param connection - Solana connection instance
|
|
41
|
+
* @param signer - Public key of the transaction signer
|
|
42
|
+
* @param vault - Public key of the vault account
|
|
43
|
+
* @returns Promise resolving to an object containing instructions and signers
|
|
44
|
+
*/
|
|
22
45
|
createReceiptToken(connection, signer, vault) {
|
|
23
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
47
|
const keypair = web3_js_2.Keypair.generate();
|
|
@@ -37,6 +60,13 @@ class ReflectTokenisedBond {
|
|
|
37
60
|
};
|
|
38
61
|
});
|
|
39
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Initializes the tokenized bonds program.
|
|
65
|
+
* Creates the config and admin accounts for the program.
|
|
66
|
+
*
|
|
67
|
+
* @param signer - Public key of the admin signer
|
|
68
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
69
|
+
*/
|
|
40
70
|
initialize(signer) {
|
|
41
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
72
|
const config = PdaClient_1.PdaClient.deriveLpConfig();
|
|
@@ -50,6 +80,14 @@ class ReflectTokenisedBond {
|
|
|
50
80
|
return ix;
|
|
51
81
|
});
|
|
52
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Initializes a new vault with specified deposit and receipt mints.
|
|
85
|
+
*
|
|
86
|
+
* @param signer - Public key of the admin signer
|
|
87
|
+
* @param depositMint - Public key of the deposit token mint
|
|
88
|
+
* @param receiptMint - Public key of the receipt token mint
|
|
89
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
90
|
+
*/
|
|
53
91
|
initializeVault(signer, depositMint, receiptMint) {
|
|
54
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
93
|
const config = PdaClient_1.PdaClient.deriveLpConfig();
|
|
@@ -68,6 +106,15 @@ class ReflectTokenisedBond {
|
|
|
68
106
|
return ix;
|
|
69
107
|
});
|
|
70
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates a deposit instruction for a vault.
|
|
111
|
+
* Allows users to deposit assets and receive receipt tokens.
|
|
112
|
+
*
|
|
113
|
+
* @param signer - Public key of the user making the deposit
|
|
114
|
+
* @param vaultId - Numeric identifier for the vault
|
|
115
|
+
* @param amount - Amount of deposit tokens to deposit
|
|
116
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
117
|
+
*/
|
|
71
118
|
deposit(signer, vaultId, amount) {
|
|
72
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
120
|
const vault = PdaClient_1.PdaClient.deriveLpVault(0);
|
|
@@ -95,6 +142,15 @@ class ReflectTokenisedBond {
|
|
|
95
142
|
return ix;
|
|
96
143
|
});
|
|
97
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Creates a withdrawal instruction for a vault.
|
|
147
|
+
* Allows users to burn receipt tokens and receive back their deposit tokens.
|
|
148
|
+
*
|
|
149
|
+
* @param signer - Public key of the user making the withdrawal
|
|
150
|
+
* @param vaultId - Numeric identifier for the vault
|
|
151
|
+
* @param amount - Amount of receipt tokens to burn for withdrawal
|
|
152
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
153
|
+
*/
|
|
98
154
|
withdraw(signer, vaultId, amount) {
|
|
99
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
156
|
const vault = PdaClient_1.PdaClient.deriveLpVault(0);
|
|
@@ -3,28 +3,166 @@ import BN from "bn.js";
|
|
|
3
3
|
import { DriftClient } from "@drift-labs/sdk";
|
|
4
4
|
import { Action } from "../generated/reflect_main";
|
|
5
5
|
import { StablecoinMetadata, Collateral } from "../types";
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for all stablecoin implementations in the Reflect protocol.
|
|
8
|
+
* Provides common functionality for managing stablecoins including initialization,
|
|
9
|
+
* minting, redemption, rebalancing, and administrative operations.
|
|
10
|
+
*
|
|
11
|
+
* This class serves as the foundation for different stablecoin strategies:
|
|
12
|
+
* - USDC+ (Strategy 0): Simple USDC-backed stablecoin
|
|
13
|
+
* - JLP Hedged (Strategy 1): Jupiter LP token with perpetual hedging
|
|
14
|
+
* - LST Delta-Neutral (Strategy 2): Liquid staking tokens with delta-neutral strategies
|
|
15
|
+
*/
|
|
6
16
|
export declare abstract class Stablecoin {
|
|
17
|
+
/** Unique index identifier for the stablecoin strategy */
|
|
7
18
|
index: number;
|
|
19
|
+
/** Human-readable name of the stablecoin */
|
|
8
20
|
name: string;
|
|
21
|
+
/** Solana connection instance for RPC communication */
|
|
9
22
|
connection: Connection;
|
|
23
|
+
/** Public key of the controller account for this stablecoin */
|
|
10
24
|
controller: PublicKey;
|
|
25
|
+
/** Array of collateral assets backing this stablecoin */
|
|
11
26
|
collaterals: Collateral[];
|
|
27
|
+
/** Public key of the stablecoin mint */
|
|
12
28
|
stablecoinMint: PublicKey;
|
|
29
|
+
/** Optional Drift client instance for DeFi operations */
|
|
13
30
|
driftClient?: DriftClient;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new Stablecoin instance.
|
|
33
|
+
*
|
|
34
|
+
* @param index - Unique strategy index (0: USDC+, 1: JLP, 2: LST)
|
|
35
|
+
* @param name - Human-readable name for the stablecoin
|
|
36
|
+
* @param connection - Solana connection instance
|
|
37
|
+
*/
|
|
14
38
|
constructor(index: number, name: string, connection: Connection);
|
|
39
|
+
/**
|
|
40
|
+
* Initializes token accounts for the specified owner and mints.
|
|
41
|
+
* Creates associated token accounts if they don't exist.
|
|
42
|
+
*
|
|
43
|
+
* @param owner - Public key of the token account owner
|
|
44
|
+
* @param mints - Array of mint public keys to create accounts for
|
|
45
|
+
* @param signer - Public key of the transaction signer
|
|
46
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
47
|
+
*/
|
|
15
48
|
initializeTokenAccounts(owner: PublicKey, mints: PublicKey[], signer: PublicKey): Promise<TransactionInstruction[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Updates the supply cap for this stablecoin strategy.
|
|
51
|
+
*
|
|
52
|
+
* @param signer - Public key of the admin signer
|
|
53
|
+
* @param newCap - New maximum supply cap as BN or number
|
|
54
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
55
|
+
*/
|
|
16
56
|
updateCap(signer: PublicKey, newCap: BN | number): Promise<TransactionInstruction>;
|
|
57
|
+
/**
|
|
58
|
+
* Updates the recipient addresses and their fee cuts for this stablecoin.
|
|
59
|
+
*
|
|
60
|
+
* @param signer - Public key of the admin signer
|
|
61
|
+
* @param recipients - Map of recipient public keys to their fee (in basepoints)
|
|
62
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
63
|
+
*/
|
|
17
64
|
updateRecipients(signer: PublicKey, recipients: Map<PublicKey, number>): Promise<TransactionInstruction>;
|
|
65
|
+
/**
|
|
66
|
+
* Initializes a Drift sub-account for this stablecoin controller.
|
|
67
|
+
*
|
|
68
|
+
* @param signer - Public key of the admin signer
|
|
69
|
+
* @param subAccountId - Sub-account identifier (default: 0)
|
|
70
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
71
|
+
*/
|
|
18
72
|
initializeStablecoinDriftAccount(signer: PublicKey, subAccountId?: number): Promise<TransactionInstruction>;
|
|
73
|
+
/**
|
|
74
|
+
* Initializes the Drift user stats account for this stablecoin controller.
|
|
75
|
+
*
|
|
76
|
+
* @param signer - Public key of the admin signer
|
|
77
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
78
|
+
*/
|
|
19
79
|
initializeStablecoinDriftStatsAccount(signer: PublicKey): Promise<TransactionInstruction>;
|
|
80
|
+
/**
|
|
81
|
+
* Freezes or unfreezes a specific action for this stablecoin strategy.
|
|
82
|
+
*
|
|
83
|
+
* @param signer - Public key of the admin signer
|
|
84
|
+
* @param freeze - Whether to freeze (true) or unfreeze (false) the action
|
|
85
|
+
* @param action - The action to freeze/unfreeze
|
|
86
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
87
|
+
*/
|
|
20
88
|
freeze(signer: PublicKey, freeze: boolean, action: Action): Promise<TransactionInstruction>;
|
|
89
|
+
/**
|
|
90
|
+
* Initializes the stablecoin mint with optional metadata.
|
|
91
|
+
*
|
|
92
|
+
* @param signer - Public key of the admin signer
|
|
93
|
+
* @param tokenKeypair - Keypair for the new mint account
|
|
94
|
+
* @param metadata - Optional metadata for the stablecoin
|
|
95
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
96
|
+
*/
|
|
21
97
|
initializeStablecoin(signer: PublicKey, tokenKeypair: Keypair, metadata?: StablecoinMetadata): Promise<TransactionInstruction[]>;
|
|
98
|
+
/**
|
|
99
|
+
* Updates the rebalance slippage tolerance for this stablecoin strategy.
|
|
100
|
+
*
|
|
101
|
+
* @param signer - Public key of the admin signer
|
|
102
|
+
* @param slippage - New slippage tolerance value
|
|
103
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
104
|
+
*/
|
|
22
105
|
updateRebalanceSlippage(signer: PublicKey, slippage: number): Promise<TransactionInstruction>;
|
|
23
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Fetches the current price of a collateral asset from Pyth oracle.
|
|
108
|
+
*
|
|
109
|
+
* @param mint - Public key of the collateral mint
|
|
110
|
+
* @returns Promise resolving to the collateral price data
|
|
111
|
+
*/
|
|
112
|
+
getCollateralPrice(mint: PublicKey): Promise<import("axios").AxiosResponse<any, any>>;
|
|
113
|
+
/**
|
|
114
|
+
* Abstract method to construct required accounts for transactions.
|
|
115
|
+
* Must be implemented by concrete stablecoin classes.
|
|
116
|
+
*
|
|
117
|
+
* @param signer - Public key of the transaction signer
|
|
118
|
+
* @param args - Additional arguments specific to the stablecoin implementation
|
|
119
|
+
* @returns Promise resolving to the constructed accounts object of type T
|
|
120
|
+
*/
|
|
24
121
|
abstract constructAccounts<T>(signer: PublicKey, ...args: any[]): Promise<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Abstract method to construct remaining accounts for transactions.
|
|
124
|
+
* Must be implemented by concrete stablecoin classes.
|
|
125
|
+
*
|
|
126
|
+
* @returns Promise resolving to an array of AccountMeta objects
|
|
127
|
+
*/
|
|
25
128
|
abstract constructRemainingAccounts(): Promise<AccountMeta[]>;
|
|
129
|
+
/**
|
|
130
|
+
* Abstract method to initialize the stablecoin strategy.
|
|
131
|
+
* Must be implemented by concrete stablecoin classes.
|
|
132
|
+
*
|
|
133
|
+
* @param signer - Public key of the admin signer
|
|
134
|
+
* @param args - Additional arguments specific to the stablecoin implementation
|
|
135
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
136
|
+
*/
|
|
26
137
|
abstract initialize(signer: PublicKey, ...args: any[]): Promise<TransactionInstruction[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Abstract method to create mint instructions for the stablecoin.
|
|
140
|
+
* Must be implemented by concrete stablecoin classes.
|
|
141
|
+
*
|
|
142
|
+
* @param signer - Public key of the user minting stablecoins
|
|
143
|
+
* @param amount - Amount of stablecoins to mint
|
|
144
|
+
* @param minimumReceived - Minimum amount of stablecoins to receive (slippage protection)
|
|
145
|
+
* @param args - Additional arguments specific to the stablecoin implementation
|
|
146
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
147
|
+
*/
|
|
27
148
|
abstract mint(signer: PublicKey, amount: BN | number, minimumReceived: BN | number, ...args: any[]): Promise<TransactionInstruction[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Abstract method to create redeem instructions for the stablecoin.
|
|
151
|
+
* Must be implemented by concrete stablecoin classes.
|
|
152
|
+
*
|
|
153
|
+
* @param signer - Public key of the user redeeming stablecoins
|
|
154
|
+
* @param amount - Amount of stablecoins to redeem
|
|
155
|
+
* @param minimumReceived - Minimum amount of collateral to receive (slippage protection)
|
|
156
|
+
* @param args - Additional arguments specific to the stablecoin implementation
|
|
157
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
158
|
+
*/
|
|
28
159
|
abstract redeem(signer: PublicKey, amount: BN | number, minimumReceived: BN | number, ...args: any[]): Promise<TransactionInstruction[]>;
|
|
160
|
+
/**
|
|
161
|
+
* Abstract method to create rebalance instructions for the stablecoin.
|
|
162
|
+
* Must be implemented by concrete stablecoin classes.
|
|
163
|
+
*
|
|
164
|
+
* @param signer - Public key of the admin signer
|
|
165
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
166
|
+
*/
|
|
29
167
|
abstract rebalance(signer: PublicKey): Promise<TransactionInstruction[]>;
|
|
30
168
|
}
|
|
@@ -22,13 +22,39 @@ const constants_1 = require("../constants");
|
|
|
22
22
|
const mpl_token_metadata_1 = require("@metaplex-foundation/mpl-token-metadata");
|
|
23
23
|
const axios_1 = __importDefault(require("axios"));
|
|
24
24
|
const PYTH_API_URL = "https://xc-mainnet.pyth.network/api/v1/price_feed/";
|
|
25
|
+
/**
|
|
26
|
+
* Abstract base class for all stablecoin implementations in the Reflect protocol.
|
|
27
|
+
* Provides common functionality for managing stablecoins including initialization,
|
|
28
|
+
* minting, redemption, rebalancing, and administrative operations.
|
|
29
|
+
*
|
|
30
|
+
* This class serves as the foundation for different stablecoin strategies:
|
|
31
|
+
* - USDC+ (Strategy 0): Simple USDC-backed stablecoin
|
|
32
|
+
* - JLP Hedged (Strategy 1): Jupiter LP token with perpetual hedging
|
|
33
|
+
* - LST Delta-Neutral (Strategy 2): Liquid staking tokens with delta-neutral strategies
|
|
34
|
+
*/
|
|
25
35
|
class Stablecoin {
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new Stablecoin instance.
|
|
38
|
+
*
|
|
39
|
+
* @param index - Unique strategy index (0: USDC+, 1: JLP, 2: LST)
|
|
40
|
+
* @param name - Human-readable name for the stablecoin
|
|
41
|
+
* @param connection - Solana connection instance
|
|
42
|
+
*/
|
|
26
43
|
constructor(index, name, connection) {
|
|
27
44
|
this.index = index;
|
|
28
45
|
this.name = name;
|
|
29
46
|
this.connection = connection;
|
|
30
47
|
this.controller = PdaClient_1.PdaClient.deriveController(this.index);
|
|
31
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Initializes token accounts for the specified owner and mints.
|
|
51
|
+
* Creates associated token accounts if they don't exist.
|
|
52
|
+
*
|
|
53
|
+
* @param owner - Public key of the token account owner
|
|
54
|
+
* @param mints - Array of mint public keys to create accounts for
|
|
55
|
+
* @param signer - Public key of the transaction signer
|
|
56
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
57
|
+
*/
|
|
32
58
|
initializeTokenAccounts(owner, mints, signer) {
|
|
33
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
60
|
const instructions = [];
|
|
@@ -49,6 +75,13 @@ class Stablecoin {
|
|
|
49
75
|
return instructions;
|
|
50
76
|
});
|
|
51
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Updates the supply cap for this stablecoin strategy.
|
|
80
|
+
*
|
|
81
|
+
* @param signer - Public key of the admin signer
|
|
82
|
+
* @param newCap - New maximum supply cap as BN or number
|
|
83
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
84
|
+
*/
|
|
52
85
|
updateCap(signer, newCap) {
|
|
53
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
87
|
const ix = (0, reflect_main_1.createUpdateCapInstruction)({
|
|
@@ -63,6 +96,13 @@ class Stablecoin {
|
|
|
63
96
|
return ix;
|
|
64
97
|
});
|
|
65
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Updates the recipient addresses and their fee cuts for this stablecoin.
|
|
101
|
+
*
|
|
102
|
+
* @param signer - Public key of the admin signer
|
|
103
|
+
* @param recipients - Map of recipient public keys to their fee (in basepoints)
|
|
104
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
105
|
+
*/
|
|
66
106
|
updateRecipients(signer, recipients) {
|
|
67
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
108
|
const ix = (0, reflect_main_1.createUpdateRecipientsInstruction)({
|
|
@@ -78,6 +118,13 @@ class Stablecoin {
|
|
|
78
118
|
return ix;
|
|
79
119
|
});
|
|
80
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Initializes a Drift sub-account for this stablecoin controller.
|
|
123
|
+
*
|
|
124
|
+
* @param signer - Public key of the admin signer
|
|
125
|
+
* @param subAccountId - Sub-account identifier (default: 0)
|
|
126
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
127
|
+
*/
|
|
81
128
|
initializeStablecoinDriftAccount(signer_1) {
|
|
82
129
|
return __awaiter(this, arguments, void 0, function* (signer, subAccountId = 0) {
|
|
83
130
|
const userAccount = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, this.controller, subAccountId);
|
|
@@ -97,6 +144,12 @@ class Stablecoin {
|
|
|
97
144
|
return ix;
|
|
98
145
|
});
|
|
99
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Initializes the Drift user stats account for this stablecoin controller.
|
|
149
|
+
*
|
|
150
|
+
* @param signer - Public key of the admin signer
|
|
151
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
152
|
+
*/
|
|
100
153
|
initializeStablecoinDriftStatsAccount(signer) {
|
|
101
154
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
155
|
const userAccount = (0, sdk_1.getUserAccountPublicKeySync)(constants_1.DRIFT_PROGRAM_ID, this.controller, 0);
|
|
@@ -115,6 +168,14 @@ class Stablecoin {
|
|
|
115
168
|
return ix;
|
|
116
169
|
});
|
|
117
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Freezes or unfreezes a specific action for this stablecoin strategy.
|
|
173
|
+
*
|
|
174
|
+
* @param signer - Public key of the admin signer
|
|
175
|
+
* @param freeze - Whether to freeze (true) or unfreeze (false) the action
|
|
176
|
+
* @param action - The action to freeze/unfreeze
|
|
177
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
178
|
+
*/
|
|
118
179
|
freeze(signer, freeze, action) {
|
|
119
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
181
|
const ix = (0, reflect_main_1.createFreezeStrategyActionInstruction)({
|
|
@@ -131,6 +192,14 @@ class Stablecoin {
|
|
|
131
192
|
return ix;
|
|
132
193
|
});
|
|
133
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Initializes the stablecoin mint with optional metadata.
|
|
197
|
+
*
|
|
198
|
+
* @param signer - Public key of the admin signer
|
|
199
|
+
* @param tokenKeypair - Keypair for the new mint account
|
|
200
|
+
* @param metadata - Optional metadata for the stablecoin
|
|
201
|
+
* @returns Promise resolving to an array of TransactionInstruction objects
|
|
202
|
+
*/
|
|
134
203
|
initializeStablecoin(signer, tokenKeypair, metadata) {
|
|
135
204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
205
|
const instructions = [];
|
|
@@ -165,6 +234,13 @@ class Stablecoin {
|
|
|
165
234
|
return instructions;
|
|
166
235
|
});
|
|
167
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Updates the rebalance slippage tolerance for this stablecoin strategy.
|
|
239
|
+
*
|
|
240
|
+
* @param signer - Public key of the admin signer
|
|
241
|
+
* @param slippage - New slippage tolerance value
|
|
242
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
243
|
+
*/
|
|
168
244
|
updateRebalanceSlippage(signer, slippage) {
|
|
169
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
170
246
|
const ix = (0, reflect_main_1.createUpdateRebalanceSlippageInstruction)({
|
|
@@ -179,6 +255,12 @@ class Stablecoin {
|
|
|
179
255
|
return ix;
|
|
180
256
|
});
|
|
181
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Fetches the current price of a collateral asset from Pyth oracle.
|
|
260
|
+
*
|
|
261
|
+
* @param mint - Public key of the collateral mint
|
|
262
|
+
* @returns Promise resolving to the collateral price data
|
|
263
|
+
*/
|
|
182
264
|
getCollateralPrice(mint) {
|
|
183
265
|
return __awaiter(this, void 0, void 0, function* () {
|
|
184
266
|
var _a;
|
|
@@ -186,7 +268,7 @@ class Stablecoin {
|
|
|
186
268
|
if (!oracle) {
|
|
187
269
|
throw new Error(`Oracle not found for collateral ${mint.toBase58()}`);
|
|
188
270
|
}
|
|
189
|
-
axios_1.default.get(`${PYTH_API_URL}${oracle}`);
|
|
271
|
+
return axios_1.default.get(`${PYTH_API_URL}${oracle}`);
|
|
190
272
|
});
|
|
191
273
|
}
|
|
192
274
|
}
|