@raac/rpc 2.0.0-beta.22 → 2.0.0-beta.23
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/dist/artifacts/core/psm/v2/PSMVaultV2.sol/PSMVaultV2.json +2373 -0
- package/dist/artifacts/core/psm/v3/PSMVaultV3.sol/PSMVaultV3.json +2373 -0
- package/dist/configs/chains/1.json +1 -0
- package/dist/configs/chains/11155111.json +17 -2
- package/dist/contracts/psm/_helpers.js +32 -2
- package/dist/contracts/psm/getVaultInfo.js +3 -1
- package/dist/contracts/psm/getVaultSettings.js +15 -4
- package/dist/types/configs/chains/index.d.ts +2 -0
- package/dist/types/configs/index.d.ts +1 -0
- package/dist/types/contracts/psm/_helpers.d.ts +13 -0
- package/dist/types/contracts/psm/getVaultInfo.d.ts +2 -0
- package/dist/types/contracts/psm/getVaultSettings.d.ts +6 -0
- package/dist/types/utils/artifacts.d.ts +6 -1
- package/dist/types/utils/contracts.d.ts +2 -0
- package/dist/utils/artifacts.js +10 -1
- package/package.json +1 -1
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
"psm": {
|
|
134
134
|
"rpsm-susds": {
|
|
135
135
|
"id": "rpsm-sUSDS",
|
|
136
|
+
"version": "1.0.0",
|
|
136
137
|
"name": "RAAC Peg Stability Module sUSDS",
|
|
137
138
|
"contract": "0xB2102B4d8802648EC6A9e89ACD46b4B799833469",
|
|
138
139
|
"rateProvider": "0x9a6b5BDA2128e6341175c79E43Cd2A7E0C5F5b21"
|
|
@@ -188,9 +188,10 @@
|
|
|
188
188
|
"psm": {
|
|
189
189
|
"rpsm-susds": {
|
|
190
190
|
"id": "rpsm-sUSDS",
|
|
191
|
+
"version": "1.0.0",
|
|
191
192
|
"name": "RAAC Peg Stability Module sUSDS",
|
|
192
|
-
"contract": "
|
|
193
|
-
"rateProvider": "
|
|
193
|
+
"contract": "0x1c7Dfbc9bea1d8b6eb33ce8C715dC5313DC3d8B8",
|
|
194
|
+
"rateProvider": "0xC0508Cf612C507E22E75C89501E7A1F64D634bd9"
|
|
194
195
|
}
|
|
195
196
|
},
|
|
196
197
|
"pools": {
|
|
@@ -317,6 +318,20 @@
|
|
|
317
318
|
"decimals": 6,
|
|
318
319
|
"contract": "0xBBfc1B017954e2F65378b189735dd7be279AbC2A"
|
|
319
320
|
},
|
|
321
|
+
"usds": {
|
|
322
|
+
"id": "usds",
|
|
323
|
+
"name": "USDS",
|
|
324
|
+
"symbol": "USDS",
|
|
325
|
+
"decimals": 18,
|
|
326
|
+
"contract": "0x169e984ec1F8111fA0fe570dD2630621688e82F4"
|
|
327
|
+
},
|
|
328
|
+
"susds": {
|
|
329
|
+
"id": "susds",
|
|
330
|
+
"name": "Savings USDS",
|
|
331
|
+
"symbol": "sUSDS",
|
|
332
|
+
"decimals": 18,
|
|
333
|
+
"contract": "0xAADD480013475e416cAC2F511697060c920bEE67"
|
|
334
|
+
},
|
|
320
335
|
"rtoken": {
|
|
321
336
|
"id": "rtoken",
|
|
322
337
|
"name": "RToken",
|
|
@@ -4,7 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolvePsmVault = resolvePsmVault;
|
|
7
|
+
exports.getPsmVaultMajor = getPsmVaultMajor;
|
|
7
8
|
exports.getPsmVaultContract = getPsmVaultContract;
|
|
9
|
+
exports.getPairingToken = getPairingToken;
|
|
10
|
+
exports.getPairingTokenDecimals = getPairingTokenDecimals;
|
|
8
11
|
exports.getPsmRateProviderContract = getPsmRateProviderContract;
|
|
9
12
|
exports.getDefaultProvider = getDefaultProvider;
|
|
10
13
|
exports.getTokenReaderContract = getTokenReaderContract;
|
|
@@ -29,11 +32,38 @@ function resolvePsmVault(chainId, vaultKeyOrAddress) {
|
|
|
29
32
|
throw new Error(`PSM vault "${vaultKeyOrAddress}" not configured for chain ${chainId}`);
|
|
30
33
|
return { key, entry: psm[key] };
|
|
31
34
|
}
|
|
35
|
+
/** The first PSMVault major that calls the pairing token `pairingToken` instead of `savingsToken`. */
|
|
36
|
+
const PAIRING_TOKEN_RENAME_MAJOR = 3;
|
|
37
|
+
/**
|
|
38
|
+
* Major version of the vault's implementation, from the config entry's `version`.
|
|
39
|
+
* @throws When the version is missing, malformed, or has no ABI in this library.
|
|
40
|
+
*/
|
|
41
|
+
function getPsmVaultMajor(entry) {
|
|
42
|
+
const major = Number(entry.version?.split(".")[0]);
|
|
43
|
+
if (!Number.isInteger(major) || !(major in artifacts_1.PSM_VAULT_ABIS)) {
|
|
44
|
+
throw new Error(`PSM vault ${entry.contract} has unsupported version "${entry.version}"`);
|
|
45
|
+
}
|
|
46
|
+
return major;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The vault contract with the ABI of its configured version. Typed as the V1 surface, which every version shares
|
|
50
|
+
* except the pairing token getters; read those through `getPairingToken` and `getPairingTokenDecimals`.
|
|
51
|
+
*/
|
|
32
52
|
function getPsmVaultContract(chainId, vaultKeyOrAddress, providerOrSigner) {
|
|
33
|
-
const {
|
|
34
|
-
const abi =
|
|
53
|
+
const { entry } = resolvePsmVault(chainId, vaultKeyOrAddress);
|
|
54
|
+
const abi = artifacts_1.PSM_VAULT_ABIS[getPsmVaultMajor(entry)];
|
|
35
55
|
return new ethers_1.ethers.Contract(entry.contract, abi, providerOrSigner);
|
|
36
56
|
}
|
|
57
|
+
/** The vault's pairing token address: `pairingToken()` from V3 on, `savingsToken()` before. */
|
|
58
|
+
function getPairingToken(vault, major) {
|
|
59
|
+
return major >= PAIRING_TOKEN_RENAME_MAJOR ? vault.pairingToken() : vault.savingsToken();
|
|
60
|
+
}
|
|
61
|
+
/** The vault's cached pairing token decimals: `pairingTokenDecimals()` from V3 on, `savingsTokenDecimals()` before. */
|
|
62
|
+
function getPairingTokenDecimals(vault, major) {
|
|
63
|
+
return major >= PAIRING_TOKEN_RENAME_MAJOR
|
|
64
|
+
? vault.pairingTokenDecimals()
|
|
65
|
+
: vault.savingsTokenDecimals();
|
|
66
|
+
}
|
|
37
67
|
function getPsmRateProviderContract(chainId, vaultKeyOrAddress, providerOrSigner) {
|
|
38
68
|
const { entry } = resolvePsmVault(chainId, vaultKeyOrAddress);
|
|
39
69
|
const abi = (0, artifacts_1.getABI)("rateprovider");
|
|
@@ -19,6 +19,7 @@ async function getVaultInfo(chainId, vaultKeyOrAddress, userAddress, provider) {
|
|
|
19
19
|
const contractAddress = entry.contract;
|
|
20
20
|
try {
|
|
21
21
|
const vault = (0, _helpers_1.getPsmVaultContract)(chainId, vaultKeyOrAddress, provider);
|
|
22
|
+
const major = (0, _helpers_1.getPsmVaultMajor)(entry);
|
|
22
23
|
const [totalAssets, totalSupply, vaultDecimals, depositCap, swapFee, computeWithdrawFee, withdrawTime, withdrawTimeLimit, dripRate, dripEnd, pendingRewards, vaultComposition, minWithdrawFee, maxWithdrawFee, rebalancer, baseAssetModule, reserveRatioFloor, rebalanceThreshold, dripDuration, paused, circuitBreakerEnabled, navFloor, savingsToken, baseAsset,] = await Promise.all([
|
|
23
24
|
vault.totalAssets(),
|
|
24
25
|
vault.totalSupply(),
|
|
@@ -42,7 +43,7 @@ async function getVaultInfo(chainId, vaultKeyOrAddress, userAddress, provider) {
|
|
|
42
43
|
vault.paused(),
|
|
43
44
|
vault.circuitBreakerEnabled(),
|
|
44
45
|
vault.navFloor(),
|
|
45
|
-
|
|
46
|
+
(0, _helpers_1.getPairingToken)(vault, major),
|
|
46
47
|
vault.asset(),
|
|
47
48
|
]);
|
|
48
49
|
const savingsTokenContract = (0, _helpers_1.getTokenReaderContract)(savingsToken, provider);
|
|
@@ -80,6 +81,7 @@ async function getVaultInfo(chainId, vaultKeyOrAddress, userAddress, provider) {
|
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
return {
|
|
84
|
+
version: entry.version,
|
|
83
85
|
totalAssets: (0, amount_1.toTokenAmount)(chainId, "pmusd", totalAssets),
|
|
84
86
|
totalSupply: (0, amount_1.toAmount)(totalSupply, Number(vaultDecimals), entry.id),
|
|
85
87
|
depositCap: (0, amount_1.toTokenAmount)(chainId, "susds", depositCap),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVaultSettings = getVaultSettings;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
4
5
|
const _helpers_1 = require("./_helpers");
|
|
5
6
|
const rpcError_1 = require("../../utils/rpcError");
|
|
7
|
+
const EIP1967_ADMIN_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
6
8
|
/**
|
|
7
9
|
* Reads a PSM vault's settings from its storage getters only. Unlike `getVaultInfo`, nothing here touches the rate
|
|
8
10
|
* provider, so it still answers when the savings token price is stale (`StalePrice`), which is when an operator
|
|
@@ -14,8 +16,10 @@ const rpcError_1 = require("../../utils/rpcError");
|
|
|
14
16
|
async function getVaultSettings(chainId, vaultKeyOrAddress, provider) {
|
|
15
17
|
const { entry } = (0, _helpers_1.resolvePsmVault)(chainId, vaultKeyOrAddress);
|
|
16
18
|
try {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
+
const reader = provider ?? (0, _helpers_1.getDefaultProvider)(chainId);
|
|
20
|
+
const vault = (0, _helpers_1.getPsmVaultContract)(chainId, vaultKeyOrAddress, reader);
|
|
21
|
+
const major = (0, _helpers_1.getPsmVaultMajor)(entry);
|
|
22
|
+
const [paused, swapFee, minWithdrawFee, maxWithdrawFee, withdrawTime, withdrawTimeLimit, circuitBreakerEnabled, navFloor, reserveRatioFloor, rebalanceThreshold, depositCap, savingsTokenDecimals, baseAsset, savingsToken, rateProvider, rebalancer, baseAssetModule, adminSlot,] = await Promise.all([
|
|
19
23
|
vault.paused(),
|
|
20
24
|
vault.swapFee(),
|
|
21
25
|
vault.minWithdrawFee(),
|
|
@@ -27,14 +31,19 @@ async function getVaultSettings(chainId, vaultKeyOrAddress, provider) {
|
|
|
27
31
|
vault.reserveRatioFloor(),
|
|
28
32
|
vault.rebalanceThreshold(),
|
|
29
33
|
vault.depositCap(),
|
|
30
|
-
|
|
34
|
+
(0, _helpers_1.getPairingTokenDecimals)(vault, major),
|
|
31
35
|
vault.baseAsset(),
|
|
32
|
-
|
|
36
|
+
(0, _helpers_1.getPairingToken)(vault, major),
|
|
33
37
|
vault.rateProvider(),
|
|
34
38
|
vault.rebalancer(),
|
|
35
39
|
vault.baseAssetModule(),
|
|
40
|
+
reader.getStorage(entry.contract, EIP1967_ADMIN_SLOT),
|
|
36
41
|
]);
|
|
42
|
+
const admin = ethers_1.ethers.getAddress(ethers_1.ethers.dataSlice(adminSlot, 12));
|
|
43
|
+
const proxyAdmin = admin === ethers_1.ethers.ZeroAddress ? null : admin;
|
|
44
|
+
const proxyAdminOwner = proxyAdmin && (await new ethers_1.ethers.Contract(proxyAdmin, ["function owner() view returns (address)"], reader).owner());
|
|
37
45
|
return {
|
|
46
|
+
version: entry.version,
|
|
38
47
|
paused,
|
|
39
48
|
swapFee,
|
|
40
49
|
minWithdrawFee,
|
|
@@ -52,6 +61,8 @@ async function getVaultSettings(chainId, vaultKeyOrAddress, provider) {
|
|
|
52
61
|
rateProvider,
|
|
53
62
|
rebalancer,
|
|
54
63
|
baseAssetModule,
|
|
64
|
+
proxyAdmin,
|
|
65
|
+
proxyAdminOwner,
|
|
55
66
|
};
|
|
56
67
|
}
|
|
57
68
|
catch (error) {
|
|
@@ -131,6 +131,7 @@ declare const chains: {
|
|
|
131
131
|
psm: {
|
|
132
132
|
"rpsm-susds": {
|
|
133
133
|
id: string;
|
|
134
|
+
version: string;
|
|
134
135
|
name: string;
|
|
135
136
|
contract: string;
|
|
136
137
|
rateProvider: string;
|
|
@@ -398,6 +399,7 @@ export declare const configs: {
|
|
|
398
399
|
psm: {
|
|
399
400
|
"rpsm-susds": {
|
|
400
401
|
id: string;
|
|
402
|
+
version: string;
|
|
401
403
|
name: string;
|
|
402
404
|
contract: string;
|
|
403
405
|
rateProvider: string;
|
|
@@ -11,7 +11,20 @@ export declare function resolvePsmVault(chainId: ChainId, vaultKeyOrAddress: str
|
|
|
11
11
|
key: string;
|
|
12
12
|
entry: PsmVaultEntry;
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Major version of the vault's implementation, from the config entry's `version`.
|
|
16
|
+
* @throws When the version is missing, malformed, or has no ABI in this library.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getPsmVaultMajor(entry: PsmVaultEntry): number;
|
|
19
|
+
/**
|
|
20
|
+
* The vault contract with the ABI of its configured version. Typed as the V1 surface, which every version shares
|
|
21
|
+
* except the pairing token getters; read those through `getPairingToken` and `getPairingTokenDecimals`.
|
|
22
|
+
*/
|
|
14
23
|
export declare function getPsmVaultContract(chainId: ChainId, vaultKeyOrAddress: string, providerOrSigner?: Provider | Signer): PSMVault;
|
|
24
|
+
/** The vault's pairing token address: `pairingToken()` from V3 on, `savingsToken()` before. */
|
|
25
|
+
export declare function getPairingToken(vault: PSMVault, major: number): Promise<string>;
|
|
26
|
+
/** The vault's cached pairing token decimals: `pairingTokenDecimals()` from V3 on, `savingsTokenDecimals()` before. */
|
|
27
|
+
export declare function getPairingTokenDecimals(vault: PSMVault, major: number): Promise<bigint>;
|
|
15
28
|
export declare function getPsmRateProviderContract(chainId: ChainId, vaultKeyOrAddress: string, providerOrSigner?: Provider | Signer): RateProvider;
|
|
16
29
|
export declare function getDefaultProvider(chainId: ChainId): Provider;
|
|
17
30
|
export declare function getTokenReaderContract(address: string, providerOrSigner?: Provider | Signer): ethers.Contract;
|
|
@@ -11,6 +11,8 @@ export interface PsmVaultUserInfo {
|
|
|
11
11
|
baseAssetAllowance: TokenAmount;
|
|
12
12
|
}
|
|
13
13
|
export interface PsmVaultInfo {
|
|
14
|
+
/** Implementation semver from the chain config; its major decides which getters were called. */
|
|
15
|
+
version: string;
|
|
14
16
|
totalAssets: TokenAmount;
|
|
15
17
|
totalSupply: TokenAmount;
|
|
16
18
|
depositCap: TokenAmount;
|
|
@@ -2,6 +2,8 @@ import { Provider } from "ethers";
|
|
|
2
2
|
import { ChainId } from "../../configs/chains";
|
|
3
3
|
/** The governance-controlled settings of a PSM vault, as stored. */
|
|
4
4
|
export interface PsmVaultSettings {
|
|
5
|
+
/** Implementation semver from the chain config; its major decides which getters were called. */
|
|
6
|
+
version: string;
|
|
5
7
|
paused: boolean;
|
|
6
8
|
/** Basis points (of 10_000). */
|
|
7
9
|
swapFee: bigint;
|
|
@@ -26,6 +28,10 @@ export interface PsmVaultSettings {
|
|
|
26
28
|
rateProvider: string;
|
|
27
29
|
rebalancer: string;
|
|
28
30
|
baseAssetModule: string;
|
|
31
|
+
/** The ProxyAdmin that can upgrade the vault, read from the EIP-1967 admin slot; null when the vault is not a proxy. */
|
|
32
|
+
proxyAdmin: string | null;
|
|
33
|
+
/** Who owns the ProxyAdmin, i.e. who can upgrade the vault; null when the vault is not a proxy. */
|
|
34
|
+
proxyAdminOwner: string | null;
|
|
29
35
|
}
|
|
30
36
|
/**
|
|
31
37
|
* Reads a PSM vault's settings from its storage getters only. Unlike `getVaultInfo`, nothing here touches the rate
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import PSMVaultArtifact from "../artifacts/core/psm/PSMVault.sol/PSMVault.json";
|
|
2
|
+
import PSMVaultV2Artifact from "../artifacts/core/psm/v2/PSMVaultV2.sol/PSMVaultV2.json";
|
|
3
|
+
import PSMVaultV3Artifact from "../artifacts/core/psm/v3/PSMVaultV3.sol/PSMVaultV3.json";
|
|
1
4
|
declare const ABIS: {
|
|
2
5
|
crvusd: ({
|
|
3
6
|
inputs: {
|
|
@@ -5588,4 +5591,6 @@ declare const getABI: (name: keyof typeof ABIS) => any[] | ({
|
|
|
5588
5591
|
type: string;
|
|
5589
5592
|
anonymous?: undefined;
|
|
5590
5593
|
})[];
|
|
5591
|
-
|
|
5594
|
+
/** PSMVault ABI per implementation major version, matched against the `version` of a chain config `psm` entry. */
|
|
5595
|
+
declare const PSM_VAULT_ABIS: Record<number, typeof PSMVaultArtifact.abi | typeof PSMVaultV2Artifact.abi | typeof PSMVaultV3Artifact.abi>;
|
|
5596
|
+
export { getABI, ABIS, PSM_VAULT_ABIS };
|
|
@@ -133,6 +133,7 @@ export declare const getConfigs: () => {
|
|
|
133
133
|
psm: {
|
|
134
134
|
"rpsm-susds": {
|
|
135
135
|
id: string;
|
|
136
|
+
version: string;
|
|
136
137
|
name: string;
|
|
137
138
|
contract: string;
|
|
138
139
|
rateProvider: string;
|
|
@@ -408,6 +409,7 @@ declare const _default: {
|
|
|
408
409
|
psm: {
|
|
409
410
|
"rpsm-susds": {
|
|
410
411
|
id: string;
|
|
412
|
+
version: string;
|
|
411
413
|
name: string;
|
|
412
414
|
contract: string;
|
|
413
415
|
rateProvider: string;
|
package/dist/utils/artifacts.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ABIS = exports.getABI = void 0;
|
|
6
|
+
exports.PSM_VAULT_ABIS = exports.ABIS = exports.getABI = void 0;
|
|
7
7
|
const crvUSDToken_json_1 = __importDefault(require("../artifacts/mocks/core/tokens/crvUSDToken.sol/crvUSDToken.json")); // assert { type: "json" };
|
|
8
8
|
const pmUSD_json_1 = __importDefault(require("../artifacts/mocks/core/tokens/pmUSD.sol/pmUSD.json")); // assert { type: "json" };
|
|
9
9
|
const xPM_json_1 = __importDefault(require("../artifacts/mocks/core/tokens/xPM.sol/xPM.json")); // assert { type: "json" };
|
|
@@ -64,6 +64,8 @@ const AladdinZap_json_1 = __importDefault(require("../artifacts/zap/AladdinZap.s
|
|
|
64
64
|
// Testnet faucet (hand-written ABI, Sepolia only)
|
|
65
65
|
const Faucet_json_1 = __importDefault(require("../artifacts/faucet/Faucet.json"));
|
|
66
66
|
const PSMVault_json_1 = __importDefault(require("../artifacts/core/psm/PSMVault.sol/PSMVault.json"));
|
|
67
|
+
const PSMVaultV2_json_1 = __importDefault(require("../artifacts/core/psm/v2/PSMVaultV2.sol/PSMVaultV2.json"));
|
|
68
|
+
const PSMVaultV3_json_1 = __importDefault(require("../artifacts/core/psm/v3/PSMVaultV3.sol/PSMVaultV3.json"));
|
|
67
69
|
const RateProvider_json_1 = __importDefault(require("../artifacts/core/psm/RateProvider.sol/RateProvider.json"));
|
|
68
70
|
const CRVUSD_ABI = crvUSDToken_json_1.default.abi;
|
|
69
71
|
const PMUSD_ABI = pmUSD_json_1.default.abi;
|
|
@@ -174,3 +176,10 @@ const getABI = (name) => {
|
|
|
174
176
|
return ABIS[name];
|
|
175
177
|
};
|
|
176
178
|
exports.getABI = getABI;
|
|
179
|
+
/** PSMVault ABI per implementation major version, matched against the `version` of a chain config `psm` entry. */
|
|
180
|
+
const PSM_VAULT_ABIS = {
|
|
181
|
+
1: PSMVault_json_1.default.abi,
|
|
182
|
+
2: PSMVaultV2_json_1.default.abi,
|
|
183
|
+
3: PSMVaultV3_json_1.default.abi,
|
|
184
|
+
};
|
|
185
|
+
exports.PSM_VAULT_ABIS = PSM_VAULT_ABIS;
|