@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
package/README.md
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @reflectmoney/stable.ts | Reflect SDK
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A TypeScript SDK for interacting with the Reflect programs on Solana. This SDK provides high-level abstractions for minting, redeeming and managing stablecoins, administrative operations, and protocol integrations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @reflectmoney/stable.ts
|
|
9
|
+
# or
|
|
10
|
+
yarn add @reflectmoney/stable.ts
|
|
11
|
+
```
|
|
4
12
|
|
|
5
13
|
## Overview
|
|
6
14
|
|
|
7
|
-
The Reflect
|
|
15
|
+
The Reflect SDK enables developers to interact with the protocol via three main Reflect stablecoins:
|
|
8
16
|
|
|
9
|
-
1. **USDC+ (
|
|
10
|
-
2. **JLP Hedged (
|
|
11
|
-
3. **LST Delta-Neutral (
|
|
17
|
+
1. **USDC+ (Index 0)**: Stablecoin backed by USDC deployed in various money markets
|
|
18
|
+
2. **JLP Hedged (Index 1)**: Stablecoin backed by the JLP token, neutralised with perpetual hedging strategies
|
|
19
|
+
3. **LST Delta-Neutral (Index 2)**: Stablecoin backed by LSTs hedged by perpetual futures position
|
|
12
20
|
|
|
13
21
|
## Architecture
|
|
14
22
|
|
|
@@ -17,148 +25,164 @@ The SDK is organized into several key components:
|
|
|
17
25
|
### Core Classes
|
|
18
26
|
|
|
19
27
|
#### `Stablecoin` (Abstract Base Class)
|
|
20
|
-
The foundation for all stablecoin implementations. Provides common interface for:
|
|
28
|
+
The foundation for all stablecoin implementations. Provides abstract functions and common interface for:
|
|
21
29
|
- minting,
|
|
22
30
|
- redemption,
|
|
23
31
|
- administrative operations.
|
|
24
32
|
|
|
25
33
|
**Key Methods:**
|
|
26
|
-
- `initialize()` - Initialize the stablecoin
|
|
34
|
+
- `initialize()` - Initialize and set-up the stablecoin (admin-only)
|
|
27
35
|
- `mint()` - Create mint instructions
|
|
28
36
|
- `redeem()` - Create redemption instructions
|
|
29
37
|
- `rebalance()` - Create rebalancing instructions (admin-only)
|
|
30
38
|
- `updateCap()` - Update supply cap (admin-only)
|
|
31
39
|
- `updateRecipients()` - Update fee recipients (admin-only)
|
|
32
40
|
|
|
33
|
-
#### `
|
|
34
|
-
Administrative client for protocol-level operations:
|
|
41
|
+
#### `ReflectKeeper`
|
|
42
|
+
Administrative client for protocol-level operations (admin-only):
|
|
35
43
|
- Protocol initialization
|
|
36
44
|
- Role and permission management
|
|
37
45
|
- Action freezing/unfreezing
|
|
38
46
|
- Admin account creation
|
|
39
47
|
|
|
40
48
|
**Key Methods:**
|
|
41
|
-
- `initializeMain()` - Initialize the main program
|
|
49
|
+
- `initializeMain()` - Initialize the main account with the program configuration
|
|
42
50
|
- `freezeProtocolAction()` - Freeze/unfreeze protocol actions
|
|
43
51
|
- `updateRoleHolderProtocol()` - Update protocol-level permissions
|
|
44
|
-
- `createAdminAccount()` -
|
|
52
|
+
- `createAdminAccount()` - Manage admin accounts
|
|
45
53
|
|
|
46
54
|
#### `PdaClient`
|
|
47
|
-
Utility class for deriving
|
|
48
|
-
-
|
|
49
|
-
-
|
|
55
|
+
Utility class for deriving PDAs:
|
|
56
|
+
- Configuration program accounts
|
|
57
|
+
- Stablecoin controllers
|
|
50
58
|
- Permission accounts
|
|
51
|
-
- External protocol integrations (Drift, Jupiter)
|
|
59
|
+
- External protocol integrations (Drift, Jupiter, Tokenised Bond)
|
|
52
60
|
|
|
53
61
|
#### `ReflectTokenisedBond`
|
|
54
|
-
Client for tokenized bonds program
|
|
62
|
+
Client for tokenized bonds program used for wrapping base stablecoins into yield-bearing receipts. Allows for:
|
|
55
63
|
- Vault creation and management
|
|
56
64
|
- Receipt token generation
|
|
57
65
|
- Deposit and withdrawal operations
|
|
58
66
|
|
|
59
67
|
### Stablecoin Implementations
|
|
60
68
|
|
|
61
|
-
#### `
|
|
62
|
-
|
|
69
|
+
#### `UsdcPlusStablecoin`
|
|
70
|
+
USDC+ is a stablecoin backed by USDC deployed in money markets. Implementation details:
|
|
71
|
+
- Live
|
|
63
72
|
- Strategy ID: 0
|
|
64
73
|
- Collateral: USDC
|
|
65
|
-
- Integrated with tokenised bonds program on the protocol level
|
|
74
|
+
- Integrated with tokenised bonds program on the protocol level.
|
|
75
|
+
- Users only receive the yield-bearing stablecoin.
|
|
76
|
+
- Doesn't require rebalancing, as hedge is always preserved.
|
|
66
77
|
|
|
67
|
-
#### `
|
|
68
|
-
|
|
78
|
+
#### `UsdjStablecoin`
|
|
79
|
+
Stablecoin backed by JLP neutralised with perpetual hedging:
|
|
80
|
+
- Coming soon
|
|
69
81
|
- Strategy ID: 1
|
|
70
82
|
- Collateral: JLP (Jupiter LP tokens)
|
|
83
|
+
- Requires manual wrapping via the Tokenised Bonds program.
|
|
84
|
+
- Requires rebalancing, currently permissioned.
|
|
85
|
+
|
|
71
86
|
|
|
72
87
|
#### `LstStablecoin`
|
|
73
88
|
Liquid staking token delta-neutral strategy:
|
|
89
|
+
- Live
|
|
74
90
|
- Strategy ID: 2
|
|
75
|
-
- Collateral: Various LSTs (mSOL, jitoSOL, etc.)
|
|
91
|
+
- Collateral: Various LSTs (mSOL, jitoSOL, etc.) - use `load()` functionality to fetch currently supported list of collateral assets.
|
|
92
|
+
- Requires manual wrapping via the Tokenised Bonds program.
|
|
93
|
+
- Requires rebalancing, currently permissioned.
|
|
76
94
|
|
|
77
|
-
##
|
|
95
|
+
## Usage
|
|
78
96
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
Follow snippets below to mint and redeem Reflect stablecoins. All Stablecoin subclasses expose methods following the same schema, so the code below works interchangeably with minor changes - simply change between the three:
|
|
98
|
+
```typescript
|
|
99
|
+
const stablecoin = new UsdcPlusStablecoin(connection);
|
|
100
|
+
const stablecoin = new UsdjStablecoin(connection);
|
|
101
|
+
const stablecoin = new LstStablecoin(connection);
|
|
83
102
|
```
|
|
84
103
|
|
|
85
|
-
## Quick Start
|
|
86
|
-
|
|
87
104
|
### Minting Stablecoins
|
|
88
105
|
|
|
89
106
|
```typescript
|
|
90
|
-
import {
|
|
107
|
+
import { UsdcPlusStablecoin } from '@reflectmoney/stable.ts';
|
|
91
108
|
import { PublicKey } from '@solana/web3.js';
|
|
92
109
|
import BN from 'bn.js';
|
|
93
110
|
|
|
94
|
-
|
|
111
|
+
// Use an actual user's public key, read from wallet adapter or local environment.
|
|
112
|
+
const user = Keypair.generate();
|
|
113
|
+
const stablecoin = new UsdcPlusStablecoin(connection);
|
|
95
114
|
|
|
96
|
-
// Load controller data
|
|
97
|
-
await
|
|
115
|
+
// Load controller data for most up-to-date stablecoin setup.
|
|
116
|
+
await stablecoin.load(connection);
|
|
98
117
|
|
|
99
118
|
// Mint stablecoins against LST collateral
|
|
100
|
-
const
|
|
119
|
+
const instructions = await stablecoin.mint(
|
|
101
120
|
userPublicKey,
|
|
102
|
-
new BN(
|
|
103
|
-
new BN(
|
|
104
|
-
new PublicKey("<jitoSOL mint>") // LST mint address
|
|
121
|
+
new BN(1000 * 1_000_000), // Deposit collateral of 1,000 USDC (6 decimals)
|
|
122
|
+
new BN(999 * 1_000_000), // Minimum received USDC+ (0.1% slippage protection)
|
|
105
123
|
);
|
|
124
|
+
|
|
125
|
+
const { blockhash } = await connection.getLatestBlockhash();
|
|
126
|
+
|
|
127
|
+
const {
|
|
128
|
+
value: lookupTable
|
|
129
|
+
} = await connection.getAddressLookupTable(
|
|
130
|
+
stablecoin.lookupTable
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const message = new TransactionMessage({
|
|
134
|
+
instructions,
|
|
135
|
+
payerKey: user.publicKey,
|
|
136
|
+
recentBlockhash: blockhash
|
|
137
|
+
}).compileToV0Message([lookupTable]);
|
|
138
|
+
|
|
139
|
+
const transaction = new VersionedTransaction(message);
|
|
140
|
+
|
|
141
|
+
// Transaction signature and landing logic, adjust for your needs.
|
|
142
|
+
transaction.sign([user]);
|
|
143
|
+
await connection.sendRawTransaction(transaction.serialize());
|
|
106
144
|
```
|
|
107
145
|
|
|
108
|
-
###
|
|
146
|
+
### Redeeming Stablecoins
|
|
109
147
|
|
|
110
148
|
```typescript
|
|
111
|
-
import {
|
|
149
|
+
import { UsdcPlusStablecoin } from '@reflectmoney/stable.ts';
|
|
150
|
+
import { PublicKey } from '@solana/web3.js';
|
|
151
|
+
import BN from 'bn.js';
|
|
112
152
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
153
|
+
// Use an actual user's public key, read from wallet adapter or local environment.
|
|
154
|
+
const user = Keypair.generate();
|
|
155
|
+
const stablecoin = new UsdcPlusStablecoin(connection);
|
|
117
156
|
|
|
118
|
-
//
|
|
119
|
-
|
|
157
|
+
// Load controller data for most up-to-date stablecoin setup.
|
|
158
|
+
await stablecoin.load(connection);
|
|
120
159
|
|
|
121
|
-
//
|
|
122
|
-
const
|
|
123
|
-
|
|
160
|
+
// Redeems USDC+ into USDC
|
|
161
|
+
const instructions = await stablecoin.redeem(
|
|
162
|
+
userPublicKey,
|
|
163
|
+
new BN(999 * 1_000_000), // Burn 1,000 of USDC+
|
|
164
|
+
new BN(1_000 * 1_000_000), // Minimum received USDC (USDC+ is yield bearing, so you'll receive more USDC over time)
|
|
165
|
+
);
|
|
124
166
|
|
|
125
|
-
|
|
167
|
+
const { blockhash } = await connection.getLatestBlockhash();
|
|
126
168
|
|
|
127
|
-
|
|
169
|
+
const {
|
|
170
|
+
value: lookupTable
|
|
171
|
+
} = await connection.getAddressLookupTable(
|
|
172
|
+
stablecoin.lookupTable
|
|
173
|
+
);
|
|
128
174
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async mint(signer: PublicKey, amount: BN, minimumReceived: BN, ...args: any[]): Promise<TransactionInstruction[]> {
|
|
143
|
-
// Custom minting logic
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async redeem(signer: PublicKey, amount: BN, minimumReceived: BN, ...args: any[]): Promise<TransactionInstruction[]> {
|
|
147
|
-
// Custom redemption logic
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async rebalance(signer: PublicKey): Promise<TransactionInstruction[]> {
|
|
151
|
-
// Custom rebalancing logic
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async constructAccounts<T>(signer: PublicKey, ...args: any[]): Promise<T> {
|
|
155
|
-
// Custom account construction
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async constructRemainingAccounts(): Promise<AccountMeta[]> {
|
|
159
|
-
// Custom remaining accounts
|
|
160
|
-
}
|
|
161
|
-
}
|
|
175
|
+
const message = new TransactionMessage({
|
|
176
|
+
instructions,
|
|
177
|
+
payerKey: user.publicKey,
|
|
178
|
+
recentBlockhash: blockhash
|
|
179
|
+
}).compileToV0Message([lookupTable]);
|
|
180
|
+
|
|
181
|
+
const transaction = new VersionedTransaction(message);
|
|
182
|
+
|
|
183
|
+
// Transaction signature and landing logic, adjust for your needs.
|
|
184
|
+
transaction.sign([user]);
|
|
185
|
+
await connection.sendRawTransaction(transaction.serialize());
|
|
162
186
|
```
|
|
163
187
|
|
|
164
188
|
### Integration with External Protocols
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { Action, Role, Update } from "../generated/reflect_main";
|
|
3
|
+
/**
|
|
4
|
+
* Administrative client for the Reflect protocol.
|
|
5
|
+
* Provides functionality for protocol-level administration including:
|
|
6
|
+
* - Protocol initialization and setup
|
|
7
|
+
* - Role and permission management
|
|
8
|
+
* - Action freezing/unfreezing
|
|
9
|
+
* - Admin account creation and management
|
|
10
|
+
*
|
|
11
|
+
* This class is used by protocol administrators to manage global settings,
|
|
12
|
+
* user permissions, and protocol-wide configurations.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ReflectAdmin {
|
|
15
|
+
/** Public key of the admin user */
|
|
16
|
+
private admin;
|
|
17
|
+
/** Public key of the main program account */
|
|
18
|
+
private main;
|
|
19
|
+
/** Solana connection instance for RPC communication */
|
|
20
|
+
private connection;
|
|
21
|
+
/**
|
|
22
|
+
* Creates a new ReflectAdmin instance.
|
|
23
|
+
*
|
|
24
|
+
* @param admin - Public key of the admin user
|
|
25
|
+
* @param connection - Solana connection instance
|
|
26
|
+
*/
|
|
27
|
+
constructor({ admin, connection }: {
|
|
28
|
+
admin: PublicKey;
|
|
29
|
+
connection: Connection;
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Creates the main program account. This is the initial step of protocol setup.
|
|
33
|
+
*
|
|
34
|
+
* @param admin - Public key of the initial admin
|
|
35
|
+
* @returns TransactionInstruction for initializing the main account
|
|
36
|
+
*/
|
|
37
|
+
static initializeMain(admin: PublicKey): import("@solana/web3.js").TransactionInstruction;
|
|
38
|
+
/**
|
|
39
|
+
* Freezes or unfreezes a specific protocol action.
|
|
40
|
+
*
|
|
41
|
+
* @param freeze - Whether to freeze (true) or unfreeze (false) the action
|
|
42
|
+
* @param action - The action to freeze/unfreeze
|
|
43
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
44
|
+
*/
|
|
45
|
+
freezeProtocolAction(freeze: boolean, action: Action): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
46
|
+
/**
|
|
47
|
+
* Freezes or unfreezes a specific DEX program.
|
|
48
|
+
*
|
|
49
|
+
* @param freeze - Whether to freeze (true) or unfreeze (false) the program
|
|
50
|
+
* @param programIndex - Index of the program to freeze/unfreeze
|
|
51
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
52
|
+
*/
|
|
53
|
+
freezeDex(freeze: boolean, programIndex: number): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new admin account with specified permissions.
|
|
56
|
+
*
|
|
57
|
+
* @param signer - Public key of the caller (must be existing admin)
|
|
58
|
+
* @param newAdmin - Public key of the new admin to create
|
|
59
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
60
|
+
*/
|
|
61
|
+
createAdminAccount(signer: PublicKey, newAdmin: PublicKey): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
62
|
+
/**
|
|
63
|
+
* Updates role holder permissions at the protocol level.
|
|
64
|
+
*
|
|
65
|
+
* @param signer - Public key of the admin signer
|
|
66
|
+
* @param adminToUpdate - Public key of the admin whose permissions are being updated
|
|
67
|
+
* @param affectedRole - The role being modified
|
|
68
|
+
* @param update - The type of update (Grant or Revoke)
|
|
69
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
70
|
+
*/
|
|
71
|
+
updateRoleHolderProtocol(signer: PublicKey, adminToUpdate: PublicKey, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
72
|
+
/**
|
|
73
|
+
* Updates role holder permissions for a specific strategy.
|
|
74
|
+
*
|
|
75
|
+
* @param signer - Public key of the admin signer
|
|
76
|
+
* @param strategyId - ID of the strategy to update permissions for
|
|
77
|
+
* @param adminToUpdate - Public key of the admin whose permissions are being updated
|
|
78
|
+
* @param affectedRole - The role being modified
|
|
79
|
+
* @param update - The type of update (Grant or Revoke)
|
|
80
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
81
|
+
*/
|
|
82
|
+
updateRoleHolderStrategy(signer: PublicKey, strategyId: number, adminToUpdate: PublicKey, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
83
|
+
/**
|
|
84
|
+
* Updates action role permissions for a specific strategy.
|
|
85
|
+
*
|
|
86
|
+
* @param signer - Public key of the admin signer
|
|
87
|
+
* @param strategyId - ID of the strategy to update permissions for
|
|
88
|
+
* @param action - The action being modified
|
|
89
|
+
* @param affectedRole - The role being modified
|
|
90
|
+
* @param update - The type of update (Grant or Revoke)
|
|
91
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
92
|
+
*/
|
|
93
|
+
updateActionRoleStrategy(signer: PublicKey, strategyId: number, action: Action, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
94
|
+
/**
|
|
95
|
+
* Updates action role permissions at the protocol level.
|
|
96
|
+
*
|
|
97
|
+
* @param signer - Public key of the admin signer
|
|
98
|
+
* @param action - The action being modified
|
|
99
|
+
* @param affectedRole - The role being modified
|
|
100
|
+
* @param update - The type of update (Grant or Revoke)
|
|
101
|
+
* @returns Promise resolving to a TransactionInstruction
|
|
102
|
+
*/
|
|
103
|
+
updateActionRoleProtocol(signer: PublicKey, action: Action, affectedRole: Role, update: Update): Promise<import("@solana/web3.js").TransactionInstruction>;
|
|
104
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
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.ReflectAdmin = void 0;
|
|
13
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
14
|
+
const reflect_main_1 = require("../generated/reflect_main");
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
34
|
+
constructor({ admin, connection }) {
|
|
35
|
+
this.admin = admin;
|
|
36
|
+
this.connection = connection;
|
|
37
|
+
this.main = PdaClient_1.PdaClient.deriveMain();
|
|
38
|
+
}
|
|
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
|
+
*/
|
|
45
|
+
static initializeMain(admin) {
|
|
46
|
+
const [main] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("main")], reflect_main_1.PROGRAM_ID);
|
|
47
|
+
const ix = (0, reflect_main_1.createInitMainInstruction)({
|
|
48
|
+
main,
|
|
49
|
+
admin,
|
|
50
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
51
|
+
creds: PdaClient_1.PdaClient.derivePermissions(admin)
|
|
52
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
53
|
+
return ix;
|
|
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
|
+
*/
|
|
62
|
+
freezeProtocolAction(freeze, action) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const ix = (0, reflect_main_1.createFreezeProtocolActionInstruction)({
|
|
65
|
+
admin: this.admin,
|
|
66
|
+
main: this.main,
|
|
67
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
68
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin),
|
|
69
|
+
}, {
|
|
70
|
+
freeze,
|
|
71
|
+
action
|
|
72
|
+
});
|
|
73
|
+
return ix;
|
|
74
|
+
});
|
|
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
|
+
*/
|
|
83
|
+
freezeDex(freeze, programIndex) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const ix = (0, reflect_main_1.createFreezeProgramInstruction)({
|
|
86
|
+
admin: this.admin,
|
|
87
|
+
main: this.main,
|
|
88
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
89
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(this.admin),
|
|
90
|
+
}, {
|
|
91
|
+
freeze,
|
|
92
|
+
programIndex
|
|
93
|
+
});
|
|
94
|
+
return ix;
|
|
95
|
+
});
|
|
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
|
+
*/
|
|
104
|
+
createAdminAccount(signer, newAdmin) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const ix = (0, reflect_main_1.createCreateAdminAccountInstruction)({
|
|
107
|
+
caller: signer,
|
|
108
|
+
newCreds: PdaClient_1.PdaClient.derivePermissions(newAdmin),
|
|
109
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
110
|
+
}, {
|
|
111
|
+
newAdmin
|
|
112
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
113
|
+
return ix;
|
|
114
|
+
});
|
|
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
|
+
*/
|
|
125
|
+
updateRoleHolderProtocol(signer, adminToUpdate, affectedRole, update) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const ix = (0, reflect_main_1.createUpdateRoleHolderProtocolInstruction)({
|
|
128
|
+
admin: signer,
|
|
129
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
130
|
+
main: PdaClient_1.PdaClient.deriveMain(),
|
|
131
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
132
|
+
updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate),
|
|
133
|
+
// Dummy strategy account.
|
|
134
|
+
strategy: PdaClient_1.PdaClient.deriveController(0)
|
|
135
|
+
}, {
|
|
136
|
+
update,
|
|
137
|
+
accessLevel: affectedRole,
|
|
138
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
139
|
+
return ix;
|
|
140
|
+
});
|
|
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
|
+
*/
|
|
152
|
+
updateRoleHolderStrategy(signer, strategyId, adminToUpdate, affectedRole, update) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const ix = (0, reflect_main_1.createUpdateRoleHolderStrategyInstruction)({
|
|
155
|
+
admin: signer,
|
|
156
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
157
|
+
main: PdaClient_1.PdaClient.deriveMain(),
|
|
158
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
159
|
+
updateAdminPermissions: PdaClient_1.PdaClient.derivePermissions(adminToUpdate),
|
|
160
|
+
strategy: PdaClient_1.PdaClient.deriveController(strategyId)
|
|
161
|
+
}, {
|
|
162
|
+
update,
|
|
163
|
+
role: affectedRole,
|
|
164
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
165
|
+
return ix;
|
|
166
|
+
});
|
|
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
|
+
*/
|
|
178
|
+
updateActionRoleStrategy(signer, strategyId, action, affectedRole, update) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const ix = (0, reflect_main_1.createUpdateActionRoleStrategyInstruction)({
|
|
181
|
+
admin: signer,
|
|
182
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
183
|
+
main: PdaClient_1.PdaClient.deriveMain(),
|
|
184
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
185
|
+
strategy: PdaClient_1.PdaClient.deriveController(strategyId)
|
|
186
|
+
}, {
|
|
187
|
+
update,
|
|
188
|
+
role: affectedRole,
|
|
189
|
+
action
|
|
190
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
191
|
+
return ix;
|
|
192
|
+
});
|
|
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
|
+
*/
|
|
203
|
+
updateActionRoleProtocol(signer, action, affectedRole, update) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
const ix = (0, reflect_main_1.createUpdateActionRoleProtocolInstruction)({
|
|
206
|
+
admin: signer,
|
|
207
|
+
adminPermissions: PdaClient_1.PdaClient.derivePermissions(signer),
|
|
208
|
+
main: PdaClient_1.PdaClient.deriveMain(),
|
|
209
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
210
|
+
}, {
|
|
211
|
+
action,
|
|
212
|
+
role: affectedRole,
|
|
213
|
+
update
|
|
214
|
+
}, reflect_main_1.PROGRAM_ID);
|
|
215
|
+
return ix;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.ReflectAdmin = ReflectAdmin;
|
|
@@ -28,6 +28,8 @@ export declare abstract class Stablecoin {
|
|
|
28
28
|
stablecoinMint: PublicKey;
|
|
29
29
|
/** Optional Drift client instance for DeFi operations */
|
|
30
30
|
driftClient?: DriftClient;
|
|
31
|
+
/** Lookup table with stablecoin-specific accounts. */
|
|
32
|
+
lookupTable: PublicKey;
|
|
31
33
|
/**
|
|
32
34
|
* Creates a new Stablecoin instance.
|
|
33
35
|
*
|
|
@@ -35,7 +37,7 @@ export declare abstract class Stablecoin {
|
|
|
35
37
|
* @param name - Human-readable name for the stablecoin
|
|
36
38
|
* @param connection - Solana connection instance
|
|
37
39
|
*/
|
|
38
|
-
constructor(index: number, name: string, connection: Connection);
|
|
40
|
+
constructor(index: number, name: string, connection: Connection, lookupTable: PublicKey);
|
|
39
41
|
/**
|
|
40
42
|
* Initializes token accounts for the specified owner and mints.
|
|
41
43
|
* Creates associated token accounts if they don't exist.
|
|
@@ -40,11 +40,12 @@ class Stablecoin {
|
|
|
40
40
|
* @param name - Human-readable name for the stablecoin
|
|
41
41
|
* @param connection - Solana connection instance
|
|
42
42
|
*/
|
|
43
|
-
constructor(index, name, connection) {
|
|
43
|
+
constructor(index, name, connection, lookupTable) {
|
|
44
44
|
this.index = index;
|
|
45
45
|
this.name = name;
|
|
46
46
|
this.connection = connection;
|
|
47
47
|
this.controller = PdaClient_1.PdaClient.deriveController(this.index);
|
|
48
|
+
this.lookupTable = lookupTable;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Initializes token accounts for the specified owner and mints.
|
package/dist/classes/index.d.ts
CHANGED
package/dist/classes/index.js
CHANGED
|
@@ -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("./ReflectKeeper"), exports);
|
|
18
18
|
__exportStar(require("./PdaClient"), exports);
|
|
19
19
|
__exportStar(require("./Stablecoin"), exports);
|
package/dist/constants/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LST_LOOKUP_TABLE = exports.JLP_LOOKUP_TABLE = exports.USDC_PLUS_LOOKUP_TABLE = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
exports.USDC_PLUS_LOOKUP_TABLE = new web3_js_1.PublicKey(0);
|
|
6
|
+
exports.JLP_LOOKUP_TABLE = new web3_js_1.PublicKey(0);
|
|
7
|
+
exports.LST_LOOKUP_TABLE = new web3_js_1.PublicKey(0);
|